babylon.d.ts 2.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. private _moveAssets;
  165. /**
  166. * Removes all the assets contained in the scene and adds them to the container.
  167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  168. */
  169. moveAllFromScene(keepAssets?: KeepAssets): void;
  170. /**
  171. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  172. * @returns the root mesh
  173. */
  174. createRootMesh(): Mesh;
  175. }
  176. }
  177. interface Window {
  178. mozIndexedDB: IDBFactory;
  179. webkitIndexedDB: IDBFactory;
  180. msIndexedDB: IDBFactory;
  181. webkitURL: typeof URL;
  182. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  183. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  184. WebGLRenderingContext: WebGLRenderingContext;
  185. MSGesture: MSGesture;
  186. CANNON: any;
  187. AudioContext: AudioContext;
  188. webkitAudioContext: AudioContext;
  189. PointerEvent: any;
  190. Math: Math;
  191. Uint8Array: Uint8ArrayConstructor;
  192. Float32Array: Float32ArrayConstructor;
  193. mozURL: typeof URL;
  194. msURL: typeof URL;
  195. VRFrameData: any;
  196. DracoDecoderModule: any;
  197. setImmediate(handler: (...args: any[]) => void): number;
  198. }
  199. interface WebGLProgram {
  200. context?: WebGLRenderingContext;
  201. vertexShader?: WebGLShader;
  202. fragmentShader?: WebGLShader;
  203. isParallelCompiled: boolean;
  204. onCompiled?: () => void;
  205. }
  206. interface WebGLRenderingContext {
  207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  209. vertexAttribDivisor(index: number, divisor: number): void;
  210. createVertexArray(): any;
  211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  218. createQuery(): WebGLQuery;
  219. deleteQuery(query: WebGLQuery): void;
  220. beginQuery(target: number, query: WebGLQuery): void;
  221. endQuery(target: number): void;
  222. getQueryParameter(query: WebGLQuery, pname: number): any;
  223. getQuery(target: number, pname: number): any;
  224. MAX_SAMPLES: number;
  225. RGBA8: number;
  226. READ_FRAMEBUFFER: number;
  227. DRAW_FRAMEBUFFER: number;
  228. UNIFORM_BUFFER: number;
  229. HALF_FLOAT_OES: number;
  230. RGBA16F: number;
  231. RGBA32F: number;
  232. R32F: number;
  233. RG32F: number;
  234. RGB32F: number;
  235. R16F: number;
  236. RG16F: number;
  237. RGB16F: number;
  238. RED: number;
  239. RG: number;
  240. R8: number;
  241. RG8: number;
  242. UNSIGNED_INT_24_8: number;
  243. DEPTH24_STENCIL8: number;
  244. drawBuffers(buffers: number[]): void;
  245. readBuffer(src: number): void;
  246. readonly COLOR_ATTACHMENT0: number;
  247. readonly COLOR_ATTACHMENT1: number;
  248. readonly COLOR_ATTACHMENT2: number;
  249. readonly COLOR_ATTACHMENT3: number;
  250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  251. ANY_SAMPLES_PASSED: number;
  252. QUERY_RESULT_AVAILABLE: number;
  253. QUERY_RESULT: number;
  254. }
  255. interface Document {
  256. mozCancelFullScreen(): void;
  257. msCancelFullScreen(): void;
  258. webkitCancelFullScreen(): void;
  259. requestPointerLock(): void;
  260. exitPointerLock(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. readonly webkitIsFullScreen: boolean;
  264. readonly pointerLockElement: Element;
  265. mozPointerLockElement: HTMLElement;
  266. msPointerLockElement: HTMLElement;
  267. webkitPointerLockElement: HTMLElement;
  268. }
  269. interface HTMLCanvasElement {
  270. requestPointerLock(): void;
  271. msRequestPointerLock?(): void;
  272. mozRequestPointerLock?(): void;
  273. webkitRequestPointerLock?(): void;
  274. }
  275. interface CanvasRenderingContext2D {
  276. msImageSmoothingEnabled: boolean;
  277. }
  278. interface WebGLBuffer {
  279. references: number;
  280. capacity: number;
  281. is32Bits: boolean;
  282. }
  283. interface WebGLProgram {
  284. transformFeedback?: WebGLTransformFeedback | null;
  285. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  286. }
  287. interface MouseEvent {
  288. mozMovementX: number;
  289. mozMovementY: number;
  290. webkitMovementX: number;
  291. webkitMovementY: number;
  292. msMovementX: number;
  293. msMovementY: number;
  294. }
  295. interface Navigator {
  296. mozGetVRDevices: (any: any) => any;
  297. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. webkitGetGamepads(): Gamepad[];
  301. msGetGamepads(): Gamepad[];
  302. webkitGamepads(): Gamepad[];
  303. }
  304. interface HTMLVideoElement {
  305. mozSrcObject: any;
  306. }
  307. interface Math {
  308. fround(x: number): number;
  309. imul(a: number, b: number): number;
  310. }
  311. interface EXT_disjoint_timer_query {
  312. QUERY_COUNTER_BITS_EXT: number;
  313. TIME_ELAPSED_EXT: number;
  314. TIMESTAMP_EXT: number;
  315. GPU_DISJOINT_EXT: number;
  316. QUERY_RESULT_EXT: number;
  317. QUERY_RESULT_AVAILABLE_EXT: number;
  318. queryCounterEXT(query: WebGLQuery, target: number): void;
  319. createQueryEXT(): WebGLQuery;
  320. beginQueryEXT(target: number, query: WebGLQuery): void;
  321. endQueryEXT(target: number): void;
  322. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  323. deleteQueryEXT(query: WebGLQuery): void;
  324. }
  325. interface WebGLUniformLocation {
  326. _currentState: any;
  327. }
  328. interface XRDevice {
  329. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  330. }
  331. interface XRSession {
  332. baseLayer: XRWebGLLayer;
  333. requestFrameOfReference(type: string): Promise<void>;
  334. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  335. end(): Promise<void>;
  336. requestAnimationFrame: Function;
  337. addEventListener: Function;
  338. }
  339. interface XRSessionCreationOptions {
  340. outputContext: WebGLRenderingContext;
  341. }
  342. interface XRLayer {
  343. getViewport: Function;
  344. framebufferWidth: number;
  345. framebufferHeight: number;
  346. }
  347. interface XRView {
  348. projectionMatrix: Float32Array;
  349. }
  350. interface XRFrame {
  351. getDevicePose: Function;
  352. views: Array<XRView>;
  353. baseLayer: XRLayer;
  354. }
  355. interface XRFrameOfReference {
  356. }
  357. interface XRWebGLLayer extends XRLayer {
  358. framebuffer: WebGLFramebuffer;
  359. }
  360. declare var XRWebGLLayer: {
  361. prototype: XRWebGLLayer;
  362. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  363. };
  364. declare module BABYLON {
  365. /**
  366. * Defines how a node can be built from a string name.
  367. */
  368. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  369. /**
  370. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  371. */
  372. class Node implements IBehaviorAware<Node> {
  373. private static _NodeConstructors;
  374. /**
  375. * Add a new node constructor
  376. * @param type defines the type name of the node to construct
  377. * @param constructorFunc defines the constructor function
  378. */
  379. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  380. /**
  381. * Returns a node constructor based on type name
  382. * @param type defines the type name
  383. * @param name defines the new node name
  384. * @param scene defines the hosting scene
  385. * @param options defines optional options to transmit to constructors
  386. * @returns the new constructor or null
  387. */
  388. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  389. /**
  390. * Gets or sets the name of the node
  391. */
  392. name: string;
  393. /**
  394. * Gets or sets the id of the node
  395. */
  396. id: string;
  397. /**
  398. * Gets or sets the unique id of the node
  399. */
  400. uniqueId: number;
  401. /**
  402. * Gets or sets a string used to store user defined state for the node
  403. */
  404. state: string;
  405. /**
  406. * Gets or sets an object used to store user defined information for the node
  407. */
  408. metadata: any;
  409. /**
  410. * Gets or sets a boolean used to define if the node must be serialized
  411. */
  412. doNotSerialize: boolean;
  413. /** @hidden */
  414. _isDisposed: boolean;
  415. /**
  416. * Gets a list of Animations associated with the node
  417. */
  418. animations: Animation[];
  419. protected _ranges: {
  420. [name: string]: Nullable<AnimationRange>;
  421. };
  422. /**
  423. * Callback raised when the node is ready to be used
  424. */
  425. onReady: (node: Node) => void;
  426. private _isEnabled;
  427. private _isParentEnabled;
  428. private _isReady;
  429. /** @hidden */
  430. _currentRenderId: number;
  431. private _parentRenderId;
  432. protected _childRenderId: number;
  433. /** @hidden */
  434. _waitingParentId: Nullable<string>;
  435. /** @hidden */
  436. _scene: Scene;
  437. /** @hidden */
  438. _cache: any;
  439. private _parentNode;
  440. private _children;
  441. /** @hidden */
  442. _worldMatrix: Matrix;
  443. /** @hidden */
  444. _worldMatrixDeterminant: number;
  445. /** @hidden */
  446. private _sceneRootNodesIndex;
  447. /**
  448. * Gets a boolean indicating if the node has been disposed
  449. * @returns true if the node was disposed
  450. */
  451. isDisposed(): boolean;
  452. /**
  453. * Gets or sets the parent of the node
  454. */
  455. parent: Nullable<Node>;
  456. private addToSceneRootNodes;
  457. private removeFromSceneRootNodes;
  458. private _animationPropertiesOverride;
  459. /**
  460. * Gets or sets the animation properties override
  461. */
  462. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  463. /**
  464. * Gets a string idenfifying the name of the class
  465. * @returns "Node" string
  466. */
  467. getClassName(): string;
  468. /**
  469. * An event triggered when the mesh is disposed
  470. */
  471. onDisposeObservable: Observable<Node>;
  472. private _onDisposeObserver;
  473. /**
  474. * Sets a callback that will be raised when the node will be disposed
  475. */
  476. onDispose: () => void;
  477. /**
  478. * Creates a new Node
  479. * @param name the name and id to be given to this node
  480. * @param scene the scene this node will be added to
  481. */
  482. constructor(name: string, scene?: Nullable<Scene>);
  483. /**
  484. * Gets the scene of the node
  485. * @returns a scene
  486. */
  487. getScene(): Scene;
  488. /**
  489. * Gets the engine of the node
  490. * @returns a Engine
  491. */
  492. getEngine(): Engine;
  493. private _behaviors;
  494. /**
  495. * Attach a behavior to the node
  496. * @see http://doc.babylonjs.com/features/behaviour
  497. * @param behavior defines the behavior to attach
  498. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  499. * @returns the current Node
  500. */
  501. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  502. /**
  503. * Remove an attached behavior
  504. * @see http://doc.babylonjs.com/features/behaviour
  505. * @param behavior defines the behavior to attach
  506. * @returns the current Node
  507. */
  508. removeBehavior(behavior: Behavior<Node>): Node;
  509. /**
  510. * Gets the list of attached behaviors
  511. * @see http://doc.babylonjs.com/features/behaviour
  512. */
  513. readonly behaviors: Behavior<Node>[];
  514. /**
  515. * Gets an attached behavior by name
  516. * @param name defines the name of the behavior to look for
  517. * @see http://doc.babylonjs.com/features/behaviour
  518. * @returns null if behavior was not found else the requested behavior
  519. */
  520. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  521. /**
  522. * Returns the latest update of the World matrix
  523. * @returns a Matrix
  524. */
  525. getWorldMatrix(): Matrix;
  526. /** @hidden */
  527. _getWorldMatrixDeterminant(): number;
  528. /**
  529. * Returns directly the latest state of the mesh World matrix.
  530. * A Matrix is returned.
  531. */
  532. readonly worldMatrixFromCache: Matrix;
  533. /** @hidden */
  534. _initCache(): void;
  535. /** @hidden */
  536. updateCache(force?: boolean): void;
  537. /** @hidden */
  538. _updateCache(ignoreParentClass?: boolean): void;
  539. /** @hidden */
  540. _isSynchronized(): boolean;
  541. /** @hidden */
  542. _markSyncedWithParent(): void;
  543. /** @hidden */
  544. isSynchronizedWithParent(): boolean;
  545. /** @hidden */
  546. isSynchronized(): boolean;
  547. /**
  548. * Is this node ready to be used/rendered
  549. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  550. * @return true if the node is ready
  551. */
  552. isReady(completeCheck?: boolean): boolean;
  553. /**
  554. * Is this node enabled?
  555. * 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
  556. * @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
  557. * @return whether this node (and its parent) is enabled
  558. */
  559. isEnabled(checkAncestors?: boolean): boolean;
  560. /** @hidden */
  561. protected _syncParentEnabledState(): void;
  562. /**
  563. * Set the enabled state of this node
  564. * @param value defines the new enabled state
  565. */
  566. setEnabled(value: boolean): void;
  567. /**
  568. * Is this node a descendant of the given node?
  569. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  570. * @param ancestor defines the parent node to inspect
  571. * @returns a boolean indicating if this node is a descendant of the given node
  572. */
  573. isDescendantOf(ancestor: Node): boolean;
  574. /** @hidden */
  575. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  576. /**
  577. * Will return all nodes that have this node as ascendant
  578. * @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
  579. * @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
  580. * @return all children nodes of all types
  581. */
  582. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  583. /**
  584. * Get all child-meshes of this node
  585. * @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
  586. * @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
  587. * @returns an array of AbstractMesh
  588. */
  589. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  590. /**
  591. * Get all child-transformNodes of this node
  592. * @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
  593. * @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
  594. * @returns an array of TransformNode
  595. */
  596. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  597. /**
  598. * Get all direct children of this node
  599. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  600. * @returns an array of Node
  601. */
  602. getChildren(predicate?: (node: Node) => boolean): Node[];
  603. /** @hidden */
  604. _setReady(state: boolean): void;
  605. /**
  606. * Get an animation by name
  607. * @param name defines the name of the animation to look for
  608. * @returns null if not found else the requested animation
  609. */
  610. getAnimationByName(name: string): Nullable<Animation>;
  611. /**
  612. * Creates an animation range for this node
  613. * @param name defines the name of the range
  614. * @param from defines the starting key
  615. * @param to defines the end key
  616. */
  617. createAnimationRange(name: string, from: number, to: number): void;
  618. /**
  619. * Delete a specific animation range
  620. * @param name defines the name of the range to delete
  621. * @param deleteFrames defines if animation frames from the range must be deleted as well
  622. */
  623. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  624. /**
  625. * Get an animation range by name
  626. * @param name defines the name of the animation range to look for
  627. * @returns null if not found else the requested animation range
  628. */
  629. getAnimationRange(name: string): Nullable<AnimationRange>;
  630. /**
  631. * Will start the animation sequence
  632. * @param name defines the range frames for animation sequence
  633. * @param loop defines if the animation should loop (false by default)
  634. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  635. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  636. * @returns the object created for this animation. If range does not exist, it will return null
  637. */
  638. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  639. /**
  640. * Serialize animation ranges into a JSON compatible object
  641. * @returns serialization object
  642. */
  643. serializeAnimationRanges(): any;
  644. /**
  645. * Computes the world matrix of the node
  646. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  647. * @returns the world matrix
  648. */
  649. computeWorldMatrix(force?: boolean): Matrix;
  650. /**
  651. * Releases resources associated with this node.
  652. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  653. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  654. */
  655. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  656. /**
  657. * Parse animation range data from a serialization object and store them into a given node
  658. * @param node defines where to store the animation ranges
  659. * @param parsedNode defines the serialization object to read data from
  660. * @param scene defines the hosting scene
  661. */
  662. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  663. }
  664. }
  665. declare module BABYLON {
  666. /**
  667. * Define an interface for all classes that will hold resources
  668. */
  669. interface IDisposable {
  670. /**
  671. * Releases all held resources
  672. */
  673. dispose(): void;
  674. }
  675. /**
  676. * This class is used by the onRenderingGroupObservable
  677. */
  678. class RenderingGroupInfo {
  679. /**
  680. * The Scene that being rendered
  681. */
  682. scene: Scene;
  683. /**
  684. * The camera currently used for the rendering pass
  685. */
  686. camera: Nullable<Camera>;
  687. /**
  688. * The ID of the renderingGroup being processed
  689. */
  690. renderingGroupId: number;
  691. }
  692. /** Interface defining initialization parameters for Scene class */
  693. interface SceneOptions {
  694. /**
  695. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  696. * It will improve performance when the number of geometries becomes important.
  697. */
  698. useGeometryIdsMap?: boolean;
  699. /**
  700. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  701. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  702. */
  703. useMaterialMeshMap?: boolean;
  704. /**
  705. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  706. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  707. */
  708. useClonedMeshhMap?: boolean;
  709. }
  710. /**
  711. * Represents a scene to be rendered by the engine.
  712. * @see http://doc.babylonjs.com/features/scene
  713. */
  714. class Scene extends AbstractScene implements IAnimatable {
  715. private static _uniqueIdCounter;
  716. /** The fog is deactivated */
  717. static readonly FOGMODE_NONE: number;
  718. /** The fog density is following an exponential function */
  719. static readonly FOGMODE_EXP: number;
  720. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  721. static readonly FOGMODE_EXP2: number;
  722. /** The fog density is following a linear function. */
  723. static readonly FOGMODE_LINEAR: number;
  724. /**
  725. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  726. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  727. */
  728. static MinDeltaTime: number;
  729. /**
  730. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  732. */
  733. static MaxDeltaTime: number;
  734. /**
  735. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  736. */
  737. autoClear: boolean;
  738. /**
  739. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  740. */
  741. autoClearDepthAndStencil: boolean;
  742. /**
  743. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  744. */
  745. clearColor: Color4;
  746. /**
  747. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  748. */
  749. ambientColor: Color3;
  750. /** @hidden */
  751. _environmentBRDFTexture: BaseTexture;
  752. /** @hidden */
  753. protected _environmentTexture: BaseTexture;
  754. /**
  755. * Texture used in all pbr material as the reflection texture.
  756. * As in the majority of the scene they are the same (exception for multi room and so on),
  757. * this is easier to reference from here than from all the materials.
  758. */
  759. /**
  760. * Texture used in all pbr material as the reflection texture.
  761. * As in the majority of the scene they are the same (exception for multi room and so on),
  762. * this is easier to set here than in all the materials.
  763. */
  764. environmentTexture: BaseTexture;
  765. /** @hidden */
  766. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  767. /**
  768. * Default image processing configuration used either in the rendering
  769. * Forward main pass or through the imageProcessingPostProcess if present.
  770. * As in the majority of the scene they are the same (exception for multi camera),
  771. * this is easier to reference from here than from all the materials and post process.
  772. *
  773. * No setter as we it is a shared configuration, you can set the values instead.
  774. */
  775. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  776. private _forceWireframe;
  777. /**
  778. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  779. */
  780. forceWireframe: boolean;
  781. private _forcePointsCloud;
  782. /**
  783. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  784. */
  785. forcePointsCloud: boolean;
  786. /**
  787. * Gets or sets the active clipplane 1
  788. */
  789. clipPlane: Nullable<Plane>;
  790. /**
  791. * Gets or sets the active clipplane 2
  792. */
  793. clipPlane2: Nullable<Plane>;
  794. /**
  795. * Gets or sets the active clipplane 3
  796. */
  797. clipPlane3: Nullable<Plane>;
  798. /**
  799. * Gets or sets the active clipplane 4
  800. */
  801. clipPlane4: Nullable<Plane>;
  802. /**
  803. * Gets or sets a boolean indicating if animations are enabled
  804. */
  805. animationsEnabled: boolean;
  806. private _animationPropertiesOverride;
  807. /**
  808. * Gets or sets the animation properties override
  809. */
  810. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  811. /**
  812. * Gets or sets a boolean indicating if a constant deltatime has to be used
  813. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  814. */
  815. useConstantAnimationDeltaTime: boolean;
  816. /**
  817. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  818. * Please note that it requires to run a ray cast through the scene on every frame
  819. */
  820. constantlyUpdateMeshUnderPointer: boolean;
  821. /**
  822. * Defines the HTML cursor to use when hovering over interactive elements
  823. */
  824. hoverCursor: string;
  825. /**
  826. * Defines the HTML default cursor to use (empty by default)
  827. */
  828. defaultCursor: string;
  829. /**
  830. * This is used to call preventDefault() on pointer down
  831. * in order to block unwanted artifacts like system double clicks
  832. */
  833. preventDefaultOnPointerDown: boolean;
  834. /**
  835. * This is used to call preventDefault() on pointer up
  836. * in order to block unwanted artifacts like system double clicks
  837. */
  838. preventDefaultOnPointerUp: boolean;
  839. /**
  840. * Gets or sets user defined metadata
  841. */
  842. metadata: any;
  843. /**
  844. * Gets the name of the plugin used to load this scene (null by default)
  845. */
  846. loadingPluginName: string;
  847. /**
  848. * Use this array to add regular expressions used to disable offline support for specific urls
  849. */
  850. disableOfflineSupportExceptionRules: RegExp[];
  851. /**
  852. * An event triggered when the scene is disposed.
  853. */
  854. onDisposeObservable: Observable<Scene>;
  855. private _onDisposeObserver;
  856. /** Sets a function to be executed when this scene is disposed. */
  857. onDispose: () => void;
  858. /**
  859. * An event triggered before rendering the scene (right after animations and physics)
  860. */
  861. onBeforeRenderObservable: Observable<Scene>;
  862. private _onBeforeRenderObserver;
  863. /** Sets a function to be executed before rendering this scene */
  864. beforeRender: Nullable<() => void>;
  865. /**
  866. * An event triggered after rendering the scene
  867. */
  868. onAfterRenderObservable: Observable<Scene>;
  869. private _onAfterRenderObserver;
  870. /** Sets a function to be executed after rendering this scene */
  871. afterRender: Nullable<() => void>;
  872. /**
  873. * An event triggered before animating the scene
  874. */
  875. onBeforeAnimationsObservable: Observable<Scene>;
  876. /**
  877. * An event triggered after animations processing
  878. */
  879. onAfterAnimationsObservable: Observable<Scene>;
  880. /**
  881. * An event triggered before draw calls are ready to be sent
  882. */
  883. onBeforeDrawPhaseObservable: Observable<Scene>;
  884. /**
  885. * An event triggered after draw calls have been sent
  886. */
  887. onAfterDrawPhaseObservable: Observable<Scene>;
  888. /**
  889. * An event triggered when the scene is ready
  890. */
  891. onReadyObservable: Observable<Scene>;
  892. /**
  893. * An event triggered before rendering a camera
  894. */
  895. onBeforeCameraRenderObservable: Observable<Camera>;
  896. private _onBeforeCameraRenderObserver;
  897. /** Sets a function to be executed before rendering a camera*/
  898. beforeCameraRender: () => void;
  899. /**
  900. * An event triggered after rendering a camera
  901. */
  902. onAfterCameraRenderObservable: Observable<Camera>;
  903. private _onAfterCameraRenderObserver;
  904. /** Sets a function to be executed after rendering a camera*/
  905. afterCameraRender: () => void;
  906. /**
  907. * An event triggered when active meshes evaluation is about to start
  908. */
  909. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  910. /**
  911. * An event triggered when active meshes evaluation is done
  912. */
  913. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  914. /**
  915. * An event triggered when particles rendering is about to start
  916. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  917. */
  918. onBeforeParticlesRenderingObservable: Observable<Scene>;
  919. /**
  920. * An event triggered when particles rendering is done
  921. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  922. */
  923. onAfterParticlesRenderingObservable: Observable<Scene>;
  924. /**
  925. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  926. */
  927. onDataLoadedObservable: Observable<Scene>;
  928. /**
  929. * An event triggered when a camera is created
  930. */
  931. onNewCameraAddedObservable: Observable<Camera>;
  932. /**
  933. * An event triggered when a camera is removed
  934. */
  935. onCameraRemovedObservable: Observable<Camera>;
  936. /**
  937. * An event triggered when a light is created
  938. */
  939. onNewLightAddedObservable: Observable<Light>;
  940. /**
  941. * An event triggered when a light is removed
  942. */
  943. onLightRemovedObservable: Observable<Light>;
  944. /**
  945. * An event triggered when a geometry is created
  946. */
  947. onNewGeometryAddedObservable: Observable<Geometry>;
  948. /**
  949. * An event triggered when a geometry is removed
  950. */
  951. onGeometryRemovedObservable: Observable<Geometry>;
  952. /**
  953. * An event triggered when a transform node is created
  954. */
  955. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  956. /**
  957. * An event triggered when a transform node is removed
  958. */
  959. onTransformNodeRemovedObservable: Observable<TransformNode>;
  960. /**
  961. * An event triggered when a mesh is created
  962. */
  963. onNewMeshAddedObservable: Observable<AbstractMesh>;
  964. /**
  965. * An event triggered when a mesh is removed
  966. */
  967. onMeshRemovedObservable: Observable<AbstractMesh>;
  968. /**
  969. * An event triggered when a material is created
  970. */
  971. onNewMaterialAddedObservable: Observable<Material>;
  972. /**
  973. * An event triggered when a material is removed
  974. */
  975. onMaterialRemovedObservable: Observable<Material>;
  976. /**
  977. * An event triggered when a texture is created
  978. */
  979. onNewTextureAddedObservable: Observable<BaseTexture>;
  980. /**
  981. * An event triggered when a texture is removed
  982. */
  983. onTextureRemovedObservable: Observable<BaseTexture>;
  984. /**
  985. * An event triggered when render targets are about to be rendered
  986. * Can happen multiple times per frame.
  987. */
  988. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  989. /**
  990. * An event triggered when render targets were rendered.
  991. * Can happen multiple times per frame.
  992. */
  993. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  994. /**
  995. * An event triggered before calculating deterministic simulation step
  996. */
  997. onBeforeStepObservable: Observable<Scene>;
  998. /**
  999. * An event triggered after calculating deterministic simulation step
  1000. */
  1001. onAfterStepObservable: Observable<Scene>;
  1002. /**
  1003. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1004. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1005. * 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)
  1006. */
  1007. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1008. /**
  1009. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1010. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1011. * 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)
  1012. */
  1013. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1014. /**
  1015. * This Observable will when a mesh has been imported into the scene.
  1016. */
  1017. onMeshImportedObservable: Observable<AbstractMesh>;
  1018. private _registeredForLateAnimationBindings;
  1019. /**
  1020. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1021. */
  1022. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1023. /**
  1024. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1025. */
  1026. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1027. /**
  1028. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1029. */
  1030. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1031. private _onPointerMove;
  1032. private _onPointerDown;
  1033. private _onPointerUp;
  1034. /** Deprecated. Use onPointerObservable instead */
  1035. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1036. /** Deprecated. Use onPointerObservable instead */
  1037. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1038. /** Deprecated. Use onPointerObservable instead */
  1039. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1040. /** Deprecated. Use onPointerObservable instead */
  1041. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1042. /**
  1043. * 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).
  1044. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1045. */
  1046. onPrePointerObservable: Observable<PointerInfoPre>;
  1047. /**
  1048. * Observable event triggered each time an input event is received from the rendering canvas
  1049. */
  1050. onPointerObservable: Observable<PointerInfo>;
  1051. /**
  1052. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1053. */
  1054. readonly unTranslatedPointer: Vector2;
  1055. /** The distance in pixel that you have to move to prevent some events */
  1056. static DragMovementThreshold: number;
  1057. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1058. static LongPressDelay: number;
  1059. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1060. static DoubleClickDelay: number;
  1061. /** If you need to check double click without raising a single click at first click, enable this flag */
  1062. static ExclusiveDoubleClickMode: boolean;
  1063. private _initClickEvent;
  1064. private _initActionManager;
  1065. private _delayedSimpleClick;
  1066. private _delayedSimpleClickTimeout;
  1067. private _previousDelayedSimpleClickTimeout;
  1068. private _meshPickProceed;
  1069. private _previousButtonPressed;
  1070. private _currentPickResult;
  1071. private _previousPickResult;
  1072. private _totalPointersPressed;
  1073. private _doubleClickOccured;
  1074. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1075. cameraToUseForPointers: Nullable<Camera>;
  1076. private _pointerX;
  1077. private _pointerY;
  1078. private _unTranslatedPointerX;
  1079. private _unTranslatedPointerY;
  1080. private _startingPointerPosition;
  1081. private _previousStartingPointerPosition;
  1082. private _startingPointerTime;
  1083. private _previousStartingPointerTime;
  1084. private _pointerCaptures;
  1085. private _timeAccumulator;
  1086. private _currentStepId;
  1087. private _currentInternalStep;
  1088. /** @hidden */
  1089. _mirroredCameraPosition: Nullable<Vector3>;
  1090. /**
  1091. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1092. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1093. */
  1094. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1095. /**
  1096. * Observable event triggered each time an keyboard event is received from the hosting window
  1097. */
  1098. onKeyboardObservable: Observable<KeyboardInfo>;
  1099. private _onKeyDown;
  1100. private _onKeyUp;
  1101. private _onCanvasFocusObserver;
  1102. private _onCanvasBlurObserver;
  1103. private _useRightHandedSystem;
  1104. /**
  1105. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1106. */
  1107. useRightHandedSystem: boolean;
  1108. /**
  1109. * Sets the step Id used by deterministic lock step
  1110. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1111. * @param newStepId defines the step Id
  1112. */
  1113. setStepId(newStepId: number): void;
  1114. /**
  1115. * Gets the step Id used by deterministic lock step
  1116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1117. * @returns the step Id
  1118. */
  1119. getStepId(): number;
  1120. /**
  1121. * Gets the internal step used by deterministic lock step
  1122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1123. * @returns the internal step
  1124. */
  1125. getInternalStep(): number;
  1126. private _fogEnabled;
  1127. /**
  1128. * Gets or sets a boolean indicating if fog is enabled on this scene
  1129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1130. * (Default is true)
  1131. */
  1132. fogEnabled: boolean;
  1133. private _fogMode;
  1134. /**
  1135. * Gets or sets the fog mode to use
  1136. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1137. * | mode | value |
  1138. * | --- | --- |
  1139. * | FOGMODE_NONE | 0 |
  1140. * | FOGMODE_EXP | 1 |
  1141. * | FOGMODE_EXP2 | 2 |
  1142. * | FOGMODE_LINEAR | 3 |
  1143. */
  1144. fogMode: number;
  1145. /**
  1146. * Gets or sets the fog color to use
  1147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1148. * (Default is Color3(0.2, 0.2, 0.3))
  1149. */
  1150. fogColor: Color3;
  1151. /**
  1152. * Gets or sets the fog density to use
  1153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1154. * (Default is 0.1)
  1155. */
  1156. fogDensity: number;
  1157. /**
  1158. * Gets or sets the fog start distance to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * (Default is 0)
  1161. */
  1162. fogStart: number;
  1163. /**
  1164. * Gets or sets the fog end distance to use
  1165. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1166. * (Default is 1000)
  1167. */
  1168. fogEnd: number;
  1169. private _shadowsEnabled;
  1170. /**
  1171. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1172. */
  1173. shadowsEnabled: boolean;
  1174. private _lightsEnabled;
  1175. /**
  1176. * Gets or sets a boolean indicating if lights are enabled on this scene
  1177. */
  1178. lightsEnabled: boolean;
  1179. /** All of the active cameras added to this scene. */
  1180. activeCameras: Camera[];
  1181. /** The current active camera */
  1182. activeCamera: Nullable<Camera>;
  1183. private _defaultMaterial;
  1184. /** The default material used on meshes when no material is affected */
  1185. /** The default material used on meshes when no material is affected */
  1186. defaultMaterial: Material;
  1187. private _texturesEnabled;
  1188. /**
  1189. * Gets or sets a boolean indicating if textures are enabled on this scene
  1190. */
  1191. texturesEnabled: boolean;
  1192. /**
  1193. * Gets or sets a boolean indicating if particles are enabled on this scene
  1194. */
  1195. particlesEnabled: boolean;
  1196. /**
  1197. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1198. */
  1199. spritesEnabled: boolean;
  1200. private _skeletonsEnabled;
  1201. /**
  1202. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1203. */
  1204. skeletonsEnabled: boolean;
  1205. /**
  1206. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1207. */
  1208. lensFlaresEnabled: boolean;
  1209. /**
  1210. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1212. */
  1213. collisionsEnabled: boolean;
  1214. private _workerCollisions;
  1215. /** @hidden */
  1216. collisionCoordinator: ICollisionCoordinator;
  1217. /**
  1218. * Defines the gravity applied to this scene (used only for collisions)
  1219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1220. */
  1221. gravity: Vector3;
  1222. /**
  1223. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1224. */
  1225. postProcessesEnabled: boolean;
  1226. /**
  1227. * The list of postprocesses added to the scene
  1228. */
  1229. postProcesses: PostProcess[];
  1230. /**
  1231. * Gets the current postprocess manager
  1232. */
  1233. postProcessManager: PostProcessManager;
  1234. /**
  1235. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1236. */
  1237. renderTargetsEnabled: boolean;
  1238. /**
  1239. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1240. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1241. */
  1242. dumpNextRenderTargets: boolean;
  1243. /**
  1244. * The list of user defined render targets added to the scene
  1245. */
  1246. customRenderTargets: RenderTargetTexture[];
  1247. /**
  1248. * Defines if texture loading must be delayed
  1249. * If true, textures will only be loaded when they need to be rendered
  1250. */
  1251. useDelayedTextureLoading: boolean;
  1252. /**
  1253. * Gets the list of meshes imported to the scene through SceneLoader
  1254. */
  1255. importedMeshesFiles: String[];
  1256. /**
  1257. * Gets or sets a boolean indicating if probes are enabled on this scene
  1258. */
  1259. probesEnabled: boolean;
  1260. /**
  1261. * Gets or sets the current offline provider to use to store scene data
  1262. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1263. */
  1264. offlineProvider: IOfflineProvider;
  1265. /**
  1266. * Gets or sets the action manager associated with the scene
  1267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1268. */
  1269. actionManager: ActionManager;
  1270. private _meshesForIntersections;
  1271. /**
  1272. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1273. */
  1274. proceduralTexturesEnabled: boolean;
  1275. private _engine;
  1276. private _totalVertices;
  1277. /** @hidden */
  1278. _activeIndices: PerfCounter;
  1279. /** @hidden */
  1280. _activeParticles: PerfCounter;
  1281. /** @hidden */
  1282. _activeBones: PerfCounter;
  1283. private _animationRatio;
  1284. private _animationTimeLast;
  1285. private _animationTime;
  1286. /**
  1287. * Gets or sets a general scale for animation speed
  1288. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1289. */
  1290. animationTimeScale: number;
  1291. /** @hidden */
  1292. _cachedMaterial: Nullable<Material>;
  1293. /** @hidden */
  1294. _cachedEffect: Nullable<Effect>;
  1295. /** @hidden */
  1296. _cachedVisibility: Nullable<number>;
  1297. private _renderId;
  1298. private _frameId;
  1299. private _executeWhenReadyTimeoutId;
  1300. private _intermediateRendering;
  1301. private _viewUpdateFlag;
  1302. private _projectionUpdateFlag;
  1303. private _alternateViewUpdateFlag;
  1304. private _alternateProjectionUpdateFlag;
  1305. /** @hidden */
  1306. _toBeDisposed: Nullable<IDisposable>[];
  1307. private _activeRequests;
  1308. private _pendingData;
  1309. private _isDisposed;
  1310. /**
  1311. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1312. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1313. */
  1314. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1315. private _activeMeshes;
  1316. private _processedMaterials;
  1317. private _renderTargets;
  1318. /** @hidden */
  1319. _activeParticleSystems: SmartArray<IParticleSystem>;
  1320. private _activeSkeletons;
  1321. private _softwareSkinnedMeshes;
  1322. private _renderingManager;
  1323. /** @hidden */
  1324. _activeAnimatables: Animatable[];
  1325. private _transformMatrix;
  1326. private _sceneUbo;
  1327. private _alternateSceneUbo;
  1328. private _pickWithRayInverseMatrix;
  1329. private _viewMatrix;
  1330. private _projectionMatrix;
  1331. private _alternateViewMatrix;
  1332. private _alternateProjectionMatrix;
  1333. private _alternateTransformMatrix;
  1334. private _useAlternateCameraConfiguration;
  1335. private _alternateRendering;
  1336. private _wheelEventName;
  1337. /** @hidden */
  1338. _forcedViewPosition: Nullable<Vector3>;
  1339. /** @hidden */
  1340. readonly _isAlternateRenderingEnabled: boolean;
  1341. private _frustumPlanes;
  1342. /**
  1343. * Gets the list of frustum planes (built from the active camera)
  1344. */
  1345. readonly frustumPlanes: Plane[];
  1346. /**
  1347. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1348. * This is useful if there are more lights that the maximum simulteanous authorized
  1349. */
  1350. requireLightSorting: boolean;
  1351. /** @hidden */
  1352. readonly useMaterialMeshMap: boolean;
  1353. /** @hidden */
  1354. readonly useClonedMeshhMap: boolean;
  1355. private _pointerOverMesh;
  1356. private _pickedDownMesh;
  1357. private _pickedUpMesh;
  1358. private _externalData;
  1359. private _uid;
  1360. /**
  1361. * @hidden
  1362. * Backing store of defined scene components.
  1363. */
  1364. _components: ISceneComponent[];
  1365. /**
  1366. * @hidden
  1367. * Backing store of defined scene components.
  1368. */
  1369. _serializableComponents: ISceneSerializableComponent[];
  1370. /**
  1371. * List of components to register on the next registration step.
  1372. */
  1373. private _transientComponents;
  1374. /**
  1375. * Registers the transient components if needed.
  1376. */
  1377. private _registerTransientComponents;
  1378. /**
  1379. * @hidden
  1380. * Add a component to the scene.
  1381. * Note that the ccomponent could be registered on th next frame if this is called after
  1382. * the register component stage.
  1383. * @param component Defines the component to add to the scene
  1384. */
  1385. _addComponent(component: ISceneComponent): void;
  1386. /**
  1387. * @hidden
  1388. * Gets a component from the scene.
  1389. * @param name defines the name of the component to retrieve
  1390. * @returns the component or null if not present
  1391. */
  1392. _getComponent(name: string): Nullable<ISceneComponent>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening before camera updates.
  1396. */
  1397. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1398. /**
  1399. * @hidden
  1400. * Defines the actions happening before clear the canvas.
  1401. */
  1402. _beforeClearStage: Stage<SimpleStageAction>;
  1403. /**
  1404. * @hidden
  1405. * Defines the actions when collecting render targets for the frame.
  1406. */
  1407. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1408. /**
  1409. * @hidden
  1410. * Defines the actions happening for one camera in the frame.
  1411. */
  1412. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1413. /**
  1414. * @hidden
  1415. * Defines the actions happening during the per mesh ready checks.
  1416. */
  1417. _isReadyForMeshStage: Stage<MeshStageAction>;
  1418. /**
  1419. * @hidden
  1420. * Defines the actions happening before evaluate active mesh checks.
  1421. */
  1422. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1423. /**
  1424. * @hidden
  1425. * Defines the actions happening during the evaluate sub mesh checks.
  1426. */
  1427. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1428. /**
  1429. * @hidden
  1430. * Defines the actions happening during the active mesh stage.
  1431. */
  1432. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1433. /**
  1434. * @hidden
  1435. * Defines the actions happening during the per camera render target step.
  1436. */
  1437. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1438. /**
  1439. * @hidden
  1440. * Defines the actions happening just before the active camera is drawing.
  1441. */
  1442. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1443. /**
  1444. * @hidden
  1445. * Defines the actions happening just before a rendering group is drawing.
  1446. */
  1447. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1448. /**
  1449. * @hidden
  1450. * Defines the actions happening just before a mesh is drawing.
  1451. */
  1452. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1453. /**
  1454. * @hidden
  1455. * Defines the actions happening just after a mesh has been drawn.
  1456. */
  1457. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1458. /**
  1459. * @hidden
  1460. * Defines the actions happening just after a rendering group has been drawn.
  1461. */
  1462. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1463. /**
  1464. * @hidden
  1465. * Defines the actions happening just after the active camera has been drawn.
  1466. */
  1467. _afterCameraDrawStage: Stage<CameraStageAction>;
  1468. /**
  1469. * @hidden
  1470. * Defines the actions happening just after rendering all cameras and computing intersections.
  1471. */
  1472. _afterRenderStage: Stage<SimpleStageAction>;
  1473. /**
  1474. * @hidden
  1475. * Defines the actions happening when a pointer move event happens.
  1476. */
  1477. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1478. /**
  1479. * @hidden
  1480. * Defines the actions happening when a pointer down event happens.
  1481. */
  1482. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1483. /**
  1484. * @hidden
  1485. * Defines the actions happening when a pointer up event happens.
  1486. */
  1487. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1488. /**
  1489. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1490. */
  1491. private geometriesById;
  1492. /**
  1493. * Creates a new Scene
  1494. * @param engine defines the engine to use to render this scene
  1495. */
  1496. constructor(engine: Engine, options?: SceneOptions);
  1497. private _defaultMeshCandidates;
  1498. /**
  1499. * @hidden
  1500. */
  1501. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1502. private _defaultSubMeshCandidates;
  1503. /**
  1504. * @hidden
  1505. */
  1506. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1507. /**
  1508. * Sets the default candidate providers for the scene.
  1509. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1510. * and getCollidingSubMeshCandidates to their default function
  1511. */
  1512. setDefaultCandidateProviders(): void;
  1513. /**
  1514. * Gets a boolean indicating if collisions are processed on a web worker
  1515. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1516. */
  1517. workerCollisions: boolean;
  1518. /**
  1519. * Gets the mesh that is currently under the pointer
  1520. */
  1521. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1522. /**
  1523. * Gets the current on-screen X position of the pointer
  1524. */
  1525. readonly pointerX: number;
  1526. /**
  1527. * Gets the current on-screen Y position of the pointer
  1528. */
  1529. readonly pointerY: number;
  1530. /**
  1531. * Gets the cached material (ie. the latest rendered one)
  1532. * @returns the cached material
  1533. */
  1534. getCachedMaterial(): Nullable<Material>;
  1535. /**
  1536. * Gets the cached effect (ie. the latest rendered one)
  1537. * @returns the cached effect
  1538. */
  1539. getCachedEffect(): Nullable<Effect>;
  1540. /**
  1541. * Gets the cached visibility state (ie. the latest rendered one)
  1542. * @returns the cached visibility state
  1543. */
  1544. getCachedVisibility(): Nullable<number>;
  1545. /**
  1546. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1547. * @param material defines the current material
  1548. * @param effect defines the current effect
  1549. * @param visibility defines the current visibility state
  1550. * @returns true if one parameter is not cached
  1551. */
  1552. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1553. /**
  1554. * Gets the engine associated with the scene
  1555. * @returns an Engine
  1556. */
  1557. getEngine(): Engine;
  1558. /**
  1559. * Gets the total number of vertices rendered per frame
  1560. * @returns the total number of vertices rendered per frame
  1561. */
  1562. getTotalVertices(): number;
  1563. /**
  1564. * Gets the performance counter for total vertices
  1565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1566. */
  1567. readonly totalVerticesPerfCounter: PerfCounter;
  1568. /**
  1569. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1570. * @returns the total number of active indices rendered per frame
  1571. */
  1572. getActiveIndices(): number;
  1573. /**
  1574. * Gets the performance counter for active indices
  1575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1576. */
  1577. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1578. /**
  1579. * Gets the total number of active particles rendered per frame
  1580. * @returns the total number of active particles rendered per frame
  1581. */
  1582. getActiveParticles(): number;
  1583. /**
  1584. * Gets the performance counter for active particles
  1585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1586. */
  1587. readonly activeParticlesPerfCounter: PerfCounter;
  1588. /**
  1589. * Gets the total number of active bones rendered per frame
  1590. * @returns the total number of active bones rendered per frame
  1591. */
  1592. getActiveBones(): number;
  1593. /**
  1594. * Gets the performance counter for active bones
  1595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1596. */
  1597. readonly activeBonesPerfCounter: PerfCounter;
  1598. /** @hidden */
  1599. getInterFramePerfCounter(): number;
  1600. /** @hidden */
  1601. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1602. /** @hidden */
  1603. getLastFrameDuration(): number;
  1604. /** @hidden */
  1605. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1606. /** @hidden */
  1607. getEvaluateActiveMeshesDuration(): number;
  1608. /** @hidden */
  1609. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1610. /**
  1611. * Gets the array of active meshes
  1612. * @returns an array of AbstractMesh
  1613. */
  1614. getActiveMeshes(): SmartArray<AbstractMesh>;
  1615. /** @hidden */
  1616. getRenderTargetsDuration(): number;
  1617. /** @hidden */
  1618. getRenderDuration(): number;
  1619. /** @hidden */
  1620. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1621. /** @hidden */
  1622. getParticlesDuration(): number;
  1623. /** @hidden */
  1624. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1625. /** @hidden */
  1626. getSpritesDuration(): number;
  1627. /** @hidden */
  1628. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1629. /**
  1630. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1631. * @returns a number
  1632. */
  1633. getAnimationRatio(): number;
  1634. /**
  1635. * Gets an unique Id for the current render phase
  1636. * @returns a number
  1637. */
  1638. getRenderId(): number;
  1639. /**
  1640. * Gets an unique Id for the current frame
  1641. * @returns a number
  1642. */
  1643. getFrameId(): number;
  1644. /** Call this function if you want to manually increment the render Id*/
  1645. incrementRenderId(): void;
  1646. private _updatePointerPosition;
  1647. private _createUbo;
  1648. private _createAlternateUbo;
  1649. private _setRayOnPointerInfo;
  1650. /**
  1651. * Use this method to simulate a pointer move on a mesh
  1652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1655. * @returns the current scene
  1656. */
  1657. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1658. private _processPointerMove;
  1659. private _checkPrePointerObservable;
  1660. /**
  1661. * Use this method to simulate a pointer down on a mesh
  1662. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1663. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1664. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1665. * @returns the current scene
  1666. */
  1667. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1668. private _processPointerDown;
  1669. /**
  1670. * Use this method to simulate a pointer up on a mesh
  1671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1674. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1675. * @returns the current scene
  1676. */
  1677. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1678. private _processPointerUp;
  1679. /**
  1680. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1681. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1682. * @returns true if the pointer was captured
  1683. */
  1684. isPointerCaptured(pointerId?: number): boolean;
  1685. /** @hidden */
  1686. _isPointerSwiping(): boolean;
  1687. /**
  1688. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1689. * @param attachUp defines if you want to attach events to pointerup
  1690. * @param attachDown defines if you want to attach events to pointerdown
  1691. * @param attachMove defines if you want to attach events to pointermove
  1692. */
  1693. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1694. /** Detaches all event handlers*/
  1695. detachControl(): void;
  1696. /**
  1697. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1698. * Delay loaded resources are not taking in account
  1699. * @return true if all required resources are ready
  1700. */
  1701. isReady(): boolean;
  1702. /** Resets all cached information relative to material (including effect and visibility) */
  1703. resetCachedMaterial(): void;
  1704. /**
  1705. * Registers a function to be called before every frame render
  1706. * @param func defines the function to register
  1707. */
  1708. registerBeforeRender(func: () => void): void;
  1709. /**
  1710. * Unregisters a function called before every frame render
  1711. * @param func defines the function to unregister
  1712. */
  1713. unregisterBeforeRender(func: () => void): void;
  1714. /**
  1715. * Registers a function to be called after every frame render
  1716. * @param func defines the function to register
  1717. */
  1718. registerAfterRender(func: () => void): void;
  1719. /**
  1720. * Unregisters a function called after every frame render
  1721. * @param func defines the function to unregister
  1722. */
  1723. unregisterAfterRender(func: () => void): void;
  1724. private _executeOnceBeforeRender;
  1725. /**
  1726. * The provided function will run before render once and will be disposed afterwards.
  1727. * A timeout delay can be provided so that the function will be executed in N ms.
  1728. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1729. * @param func The function to be executed.
  1730. * @param timeout optional delay in ms
  1731. */
  1732. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1733. /** @hidden */
  1734. _addPendingData(data: any): void;
  1735. /** @hidden */
  1736. _removePendingData(data: any): void;
  1737. /**
  1738. * Returns the number of items waiting to be loaded
  1739. * @returns the number of items waiting to be loaded
  1740. */
  1741. getWaitingItemsCount(): number;
  1742. /**
  1743. * Returns a boolean indicating if the scene is still loading data
  1744. */
  1745. readonly isLoading: boolean;
  1746. /**
  1747. * Registers a function to be executed when the scene is ready
  1748. * @param {Function} func - the function to be executed
  1749. */
  1750. executeWhenReady(func: () => void): void;
  1751. /**
  1752. * Returns a promise that resolves when the scene is ready
  1753. * @returns A promise that resolves when the scene is ready
  1754. */
  1755. whenReadyAsync(): Promise<void>;
  1756. /** @hidden */
  1757. _checkIsReady(): void;
  1758. /**
  1759. * Will start the animation sequence of a given target
  1760. * @param target defines the target
  1761. * @param from defines from which frame should animation start
  1762. * @param to defines until which frame should animation run.
  1763. * @param weight defines the weight to apply to the animation (1.0 by default)
  1764. * @param loop defines if the animation loops
  1765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1766. * @param onAnimationEnd defines the function to be executed when the animation ends
  1767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1769. * @returns the animatable object created for this animation
  1770. */
  1771. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1772. /**
  1773. * Will start the animation sequence of a given target
  1774. * @param target defines the target
  1775. * @param from defines from which frame should animation start
  1776. * @param to defines until which frame should animation run.
  1777. * @param loop defines if the animation loops
  1778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1779. * @param onAnimationEnd defines the function to be executed when the animation ends
  1780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1782. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1783. * @returns the animatable object created for this animation
  1784. */
  1785. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1786. /**
  1787. * Begin a new animation on a given node
  1788. * @param target defines the target where the animation will take place
  1789. * @param animations defines the list of animations to start
  1790. * @param from defines the initial value
  1791. * @param to defines the final value
  1792. * @param loop defines if you want animation to loop (off by default)
  1793. * @param speedRatio defines the speed ratio to apply to all animations
  1794. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1795. * @returns the list of created animatables
  1796. */
  1797. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1798. /**
  1799. * Begin a new animation on a given node and its hierarchy
  1800. * @param target defines the root node where the animation will take place
  1801. * @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.
  1802. * @param animations defines the list of animations to start
  1803. * @param from defines the initial value
  1804. * @param to defines the final value
  1805. * @param loop defines if you want animation to loop (off by default)
  1806. * @param speedRatio defines the speed ratio to apply to all animations
  1807. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1808. * @returns the list of animatables created for all nodes
  1809. */
  1810. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1811. /**
  1812. * Gets the animatable associated with a specific target
  1813. * @param target defines the target of the animatable
  1814. * @returns the required animatable if found
  1815. */
  1816. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1817. /**
  1818. * Gets all animatables associated with a given target
  1819. * @param target defines the target to look animatables for
  1820. * @returns an array of Animatables
  1821. */
  1822. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1823. /**
  1824. * Gets all animatable attached to the scene
  1825. */
  1826. readonly animatables: Animatable[];
  1827. /**
  1828. * Will stop the animation of the given target
  1829. * @param target - the target
  1830. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1831. * @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)
  1832. */
  1833. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1834. /**
  1835. * Stops and removes all animations that have been applied to the scene
  1836. */
  1837. stopAllAnimations(): void;
  1838. private _animate;
  1839. /** @hidden */
  1840. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1841. private _processLateAnimationBindingsForMatrices;
  1842. private _processLateAnimationBindingsForQuaternions;
  1843. private _processLateAnimationBindings;
  1844. /** @hidden */
  1845. _switchToAlternateCameraConfiguration(active: boolean): void;
  1846. /**
  1847. * Gets the current view matrix
  1848. * @returns a Matrix
  1849. */
  1850. getViewMatrix(): Matrix;
  1851. /**
  1852. * Gets the current projection matrix
  1853. * @returns a Matrix
  1854. */
  1855. getProjectionMatrix(): Matrix;
  1856. /**
  1857. * Gets the current transform matrix
  1858. * @returns a Matrix made of View * Projection
  1859. */
  1860. getTransformMatrix(): Matrix;
  1861. /**
  1862. * Sets the current transform matrix
  1863. * @param view defines the View matrix to use
  1864. * @param projection defines the Projection matrix to use
  1865. */
  1866. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1867. /** @hidden */
  1868. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1869. /**
  1870. * Gets the uniform buffer used to store scene data
  1871. * @returns a UniformBuffer
  1872. */
  1873. getSceneUniformBuffer(): UniformBuffer;
  1874. /**
  1875. * Gets an unique (relatively to the current scene) Id
  1876. * @returns an unique number for the scene
  1877. */
  1878. getUniqueId(): number;
  1879. /**
  1880. * Add a mesh to the list of scene's meshes
  1881. * @param newMesh defines the mesh to add
  1882. * @param recursive if all child meshes should also be added to the scene
  1883. */
  1884. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1885. /**
  1886. * Remove a mesh for the list of scene's meshes
  1887. * @param toRemove defines the mesh to remove
  1888. * @param recursive if all child meshes should also be removed from the scene
  1889. * @returns the index where the mesh was in the mesh list
  1890. */
  1891. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1892. /**
  1893. * Add a transform node to the list of scene's transform nodes
  1894. * @param newTransformNode defines the transform node to add
  1895. */
  1896. addTransformNode(newTransformNode: TransformNode): void;
  1897. /**
  1898. * Remove a transform node for the list of scene's transform nodes
  1899. * @param toRemove defines the transform node to remove
  1900. * @returns the index where the transform node was in the transform node list
  1901. */
  1902. removeTransformNode(toRemove: TransformNode): number;
  1903. /**
  1904. * Remove a skeleton for the list of scene's skeletons
  1905. * @param toRemove defines the skeleton to remove
  1906. * @returns the index where the skeleton was in the skeleton list
  1907. */
  1908. removeSkeleton(toRemove: Skeleton): number;
  1909. /**
  1910. * Remove a morph target for the list of scene's morph targets
  1911. * @param toRemove defines the morph target to remove
  1912. * @returns the index where the morph target was in the morph target list
  1913. */
  1914. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1915. /**
  1916. * Remove a light for the list of scene's lights
  1917. * @param toRemove defines the light to remove
  1918. * @returns the index where the light was in the light list
  1919. */
  1920. removeLight(toRemove: Light): number;
  1921. /**
  1922. * Remove a camera for the list of scene's cameras
  1923. * @param toRemove defines the camera to remove
  1924. * @returns the index where the camera was in the camera list
  1925. */
  1926. removeCamera(toRemove: Camera): number;
  1927. /**
  1928. * Remove a particle system for the list of scene's particle systems
  1929. * @param toRemove defines the particle system to remove
  1930. * @returns the index where the particle system was in the particle system list
  1931. */
  1932. removeParticleSystem(toRemove: IParticleSystem): number;
  1933. /**
  1934. * Remove a animation for the list of scene's animations
  1935. * @param toRemove defines the animation to remove
  1936. * @returns the index where the animation was in the animation list
  1937. */
  1938. removeAnimation(toRemove: Animation): number;
  1939. /**
  1940. * Removes the given animation group from this scene.
  1941. * @param toRemove The animation group to remove
  1942. * @returns The index of the removed animation group
  1943. */
  1944. removeAnimationGroup(toRemove: AnimationGroup): number;
  1945. /**
  1946. * Removes the given multi-material from this scene.
  1947. * @param toRemove The multi-material to remove
  1948. * @returns The index of the removed multi-material
  1949. */
  1950. removeMultiMaterial(toRemove: MultiMaterial): number;
  1951. /**
  1952. * Removes the given material from this scene.
  1953. * @param toRemove The material to remove
  1954. * @returns The index of the removed material
  1955. */
  1956. removeMaterial(toRemove: Material): number;
  1957. /**
  1958. * Removes the given action manager from this scene.
  1959. * @param toRemove The action manager to remove
  1960. * @returns The index of the removed action manager
  1961. */
  1962. removeActionManager(toRemove: ActionManager): number;
  1963. /**
  1964. * Removes the given texture from this scene.
  1965. * @param toRemove The texture to remove
  1966. * @returns The index of the removed texture
  1967. */
  1968. removeTexture(toRemove: BaseTexture): number;
  1969. /**
  1970. * Adds the given light to this scene
  1971. * @param newLight The light to add
  1972. */
  1973. addLight(newLight: Light): void;
  1974. /**
  1975. * Sorts the list list based on light priorities
  1976. */
  1977. sortLightsByPriority(): void;
  1978. /**
  1979. * Adds the given camera to this scene
  1980. * @param newCamera The camera to add
  1981. */
  1982. addCamera(newCamera: Camera): void;
  1983. /**
  1984. * Adds the given skeleton to this scene
  1985. * @param newSkeleton The skeleton to add
  1986. */
  1987. addSkeleton(newSkeleton: Skeleton): void;
  1988. /**
  1989. * Adds the given particle system to this scene
  1990. * @param newParticleSystem The particle system to add
  1991. */
  1992. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1993. /**
  1994. * Adds the given animation to this scene
  1995. * @param newAnimation The animation to add
  1996. */
  1997. addAnimation(newAnimation: Animation): void;
  1998. /**
  1999. * Adds the given animation group to this scene.
  2000. * @param newAnimationGroup The animation group to add
  2001. */
  2002. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2003. /**
  2004. * Adds the given multi-material to this scene
  2005. * @param newMultiMaterial The multi-material to add
  2006. */
  2007. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2008. /**
  2009. * Adds the given material to this scene
  2010. * @param newMaterial The material to add
  2011. */
  2012. addMaterial(newMaterial: Material): void;
  2013. /**
  2014. * Adds the given morph target to this scene
  2015. * @param newMorphTargetManager The morph target to add
  2016. */
  2017. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2018. /**
  2019. * Adds the given geometry to this scene
  2020. * @param newGeometry The geometry to add
  2021. */
  2022. addGeometry(newGeometry: Geometry): void;
  2023. /**
  2024. * Adds the given action manager to this scene
  2025. * @param newActionManager The action manager to add
  2026. */
  2027. addActionManager(newActionManager: ActionManager): void;
  2028. /**
  2029. * Adds the given texture to this scene.
  2030. * @param newTexture The texture to add
  2031. */
  2032. addTexture(newTexture: BaseTexture): void;
  2033. /**
  2034. * Switch active camera
  2035. * @param newCamera defines the new active camera
  2036. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2037. */
  2038. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2039. /**
  2040. * sets the active camera of the scene using its ID
  2041. * @param id defines the camera's ID
  2042. * @return the new active camera or null if none found.
  2043. */
  2044. setActiveCameraByID(id: string): Nullable<Camera>;
  2045. /**
  2046. * sets the active camera of the scene using its name
  2047. * @param name defines the camera's name
  2048. * @returns the new active camera or null if none found.
  2049. */
  2050. setActiveCameraByName(name: string): Nullable<Camera>;
  2051. /**
  2052. * get an animation group using its name
  2053. * @param name defines the material's name
  2054. * @return the animation group or null if none found.
  2055. */
  2056. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2057. /**
  2058. * get a material using its id
  2059. * @param id defines the material's ID
  2060. * @return the material or null if none found.
  2061. */
  2062. getMaterialByID(id: string): Nullable<Material>;
  2063. /**
  2064. * Gets a material using its name
  2065. * @param name defines the material's name
  2066. * @return the material or null if none found.
  2067. */
  2068. getMaterialByName(name: string): Nullable<Material>;
  2069. /**
  2070. * Gets a camera using its id
  2071. * @param id defines the id to look for
  2072. * @returns the camera or null if not found
  2073. */
  2074. getCameraByID(id: string): Nullable<Camera>;
  2075. /**
  2076. * Gets a camera using its unique id
  2077. * @param uniqueId defines the unique id to look for
  2078. * @returns the camera or null if not found
  2079. */
  2080. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2081. /**
  2082. * Gets a camera using its name
  2083. * @param name defines the camera's name
  2084. * @return the camera or null if none found.
  2085. */
  2086. getCameraByName(name: string): Nullable<Camera>;
  2087. /**
  2088. * Gets a bone using its id
  2089. * @param id defines the bone's id
  2090. * @return the bone or null if not found
  2091. */
  2092. getBoneByID(id: string): Nullable<Bone>;
  2093. /**
  2094. * Gets a bone using its id
  2095. * @param name defines the bone's name
  2096. * @return the bone or null if not found
  2097. */
  2098. getBoneByName(name: string): Nullable<Bone>;
  2099. /**
  2100. * Gets a light node using its name
  2101. * @param name defines the the light's name
  2102. * @return the light or null if none found.
  2103. */
  2104. getLightByName(name: string): Nullable<Light>;
  2105. /**
  2106. * Gets a light node using its id
  2107. * @param id defines the light's id
  2108. * @return the light or null if none found.
  2109. */
  2110. getLightByID(id: string): Nullable<Light>;
  2111. /**
  2112. * Gets a light node using its scene-generated unique ID
  2113. * @param uniqueId defines the light's unique id
  2114. * @return the light or null if none found.
  2115. */
  2116. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2117. /**
  2118. * Gets a particle system by id
  2119. * @param id defines the particle system id
  2120. * @return the corresponding system or null if none found
  2121. */
  2122. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2123. /**
  2124. * Gets a geometry using its ID
  2125. * @param id defines the geometry's id
  2126. * @return the geometry or null if none found.
  2127. */
  2128. getGeometryByID(id: string): Nullable<Geometry>;
  2129. /**
  2130. * Add a new geometry to this scene
  2131. * @param geometry defines the geometry to be added to the scene.
  2132. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2133. * @return a boolean defining if the geometry was added or not
  2134. */
  2135. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2136. /**
  2137. * Removes an existing geometry
  2138. * @param geometry defines the geometry to be removed from the scene
  2139. * @return a boolean defining if the geometry was removed or not
  2140. */
  2141. removeGeometry(geometry: Geometry): boolean;
  2142. /**
  2143. * Gets the list of geometries attached to the scene
  2144. * @returns an array of Geometry
  2145. */
  2146. getGeometries(): Geometry[];
  2147. /**
  2148. * Gets the first added mesh found of a given ID
  2149. * @param id defines the id to search for
  2150. * @return the mesh found or null if not found at all
  2151. */
  2152. getMeshByID(id: string): Nullable<AbstractMesh>;
  2153. /**
  2154. * Gets a list of meshes using their id
  2155. * @param id defines the id to search for
  2156. * @returns a list of meshes
  2157. */
  2158. getMeshesByID(id: string): Array<AbstractMesh>;
  2159. /**
  2160. * Gets the first added transform node found of a given ID
  2161. * @param id defines the id to search for
  2162. * @return the found transform node or null if not found at all.
  2163. */
  2164. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2165. /**
  2166. * Gets a list of transform nodes using their id
  2167. * @param id defines the id to search for
  2168. * @returns a list of transform nodes
  2169. */
  2170. getTransformNodesByID(id: string): Array<TransformNode>;
  2171. /**
  2172. * Gets a mesh with its auto-generated unique id
  2173. * @param uniqueId defines the unique id to search for
  2174. * @return the found mesh or null if not found at all.
  2175. */
  2176. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2177. /**
  2178. * Gets a the last added mesh using a given id
  2179. * @param id defines the id to search for
  2180. * @return the found mesh or null if not found at all.
  2181. */
  2182. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2183. /**
  2184. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2185. * @param id defines the id to search for
  2186. * @return the found node or null if not found at all
  2187. */
  2188. getLastEntryByID(id: string): Nullable<Node>;
  2189. /**
  2190. * Gets a node (Mesh, Camera, Light) using a given id
  2191. * @param id defines the id to search for
  2192. * @return the found node or null if not found at all
  2193. */
  2194. getNodeByID(id: string): Nullable<Node>;
  2195. /**
  2196. * Gets a node (Mesh, Camera, Light) using a given name
  2197. * @param name defines the name to search for
  2198. * @return the found node or null if not found at all.
  2199. */
  2200. getNodeByName(name: string): Nullable<Node>;
  2201. /**
  2202. * Gets a mesh using a given name
  2203. * @param name defines the name to search for
  2204. * @return the found mesh or null if not found at all.
  2205. */
  2206. getMeshByName(name: string): Nullable<AbstractMesh>;
  2207. /**
  2208. * Gets a transform node using a given name
  2209. * @param name defines the name to search for
  2210. * @return the found transform node or null if not found at all.
  2211. */
  2212. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2213. /**
  2214. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2215. * @param id defines the id to search for
  2216. * @return the found skeleton or null if not found at all.
  2217. */
  2218. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2219. /**
  2220. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2221. * @param id defines the id to search for
  2222. * @return the found skeleton or null if not found at all.
  2223. */
  2224. getSkeletonById(id: string): Nullable<Skeleton>;
  2225. /**
  2226. * Gets a skeleton using a given name
  2227. * @param name defines the name to search for
  2228. * @return the found skeleton or null if not found at all.
  2229. */
  2230. getSkeletonByName(name: string): Nullable<Skeleton>;
  2231. /**
  2232. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2233. * @param id defines the id to search for
  2234. * @return the found morph target manager or null if not found at all.
  2235. */
  2236. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2237. /**
  2238. * Gets a boolean indicating if the given mesh is active
  2239. * @param mesh defines the mesh to look for
  2240. * @returns true if the mesh is in the active list
  2241. */
  2242. isActiveMesh(mesh: AbstractMesh): boolean;
  2243. /**
  2244. * Return a unique id as a string which can serve as an identifier for the scene
  2245. */
  2246. readonly uid: string;
  2247. /**
  2248. * Add an externaly attached data from its key.
  2249. * This method call will fail and return false, if such key already exists.
  2250. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2251. * @param key the unique key that identifies the data
  2252. * @param data the data object to associate to the key for this Engine instance
  2253. * @return true if no such key were already present and the data was added successfully, false otherwise
  2254. */
  2255. addExternalData<T>(key: string, data: T): boolean;
  2256. /**
  2257. * Get an externaly attached data from its key
  2258. * @param key the unique key that identifies the data
  2259. * @return the associated data, if present (can be null), or undefined if not present
  2260. */
  2261. getExternalData<T>(key: string): Nullable<T>;
  2262. /**
  2263. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2264. * @param key the unique key that identifies the data
  2265. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2266. * @return the associated data, can be null if the factory returned null.
  2267. */
  2268. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2269. /**
  2270. * Remove an externaly attached data from the Engine instance
  2271. * @param key the unique key that identifies the data
  2272. * @return true if the data was successfully removed, false if it doesn't exist
  2273. */
  2274. removeExternalData(key: string): boolean;
  2275. private _evaluateSubMesh;
  2276. /**
  2277. * Clear the processed materials smart array preventing retention point in material dispose.
  2278. */
  2279. freeProcessedMaterials(): void;
  2280. private _preventFreeActiveMeshesAndRenderingGroups;
  2281. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2282. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2283. * when disposing several meshes in a row or a hierarchy of meshes.
  2284. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2285. */
  2286. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2287. /**
  2288. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2289. */
  2290. freeActiveMeshes(): void;
  2291. /**
  2292. * Clear the info related to rendering groups preventing retention points during dispose.
  2293. */
  2294. freeRenderingGroups(): void;
  2295. /** @hidden */
  2296. _isInIntermediateRendering(): boolean;
  2297. /**
  2298. * Lambda returning the list of potentially active meshes.
  2299. */
  2300. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2301. /**
  2302. * Lambda returning the list of potentially active sub meshes.
  2303. */
  2304. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2305. /**
  2306. * Lambda returning the list of potentially intersecting sub meshes.
  2307. */
  2308. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2309. /**
  2310. * Lambda returning the list of potentially colliding sub meshes.
  2311. */
  2312. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2313. private _activeMeshesFrozen;
  2314. /**
  2315. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2316. * @returns the current scene
  2317. */
  2318. freezeActiveMeshes(): Scene;
  2319. /**
  2320. * Use this function to restart evaluating active meshes on every frame
  2321. * @returns the current scene
  2322. */
  2323. unfreezeActiveMeshes(): Scene;
  2324. private _evaluateActiveMeshes;
  2325. private _activeMesh;
  2326. /**
  2327. * Update the transform matrix to update from the current active camera
  2328. * @param force defines a boolean used to force the update even if cache is up to date
  2329. */
  2330. updateTransformMatrix(force?: boolean): void;
  2331. /**
  2332. * 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)
  2333. * @param alternateCamera defines the camera to use
  2334. */
  2335. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2336. /** @hidden */
  2337. _allowPostProcessClearColor: boolean;
  2338. private _renderForCamera;
  2339. private _processSubCameras;
  2340. private _checkIntersections;
  2341. /** @hidden */
  2342. _advancePhysicsEngineStep(step: number): void;
  2343. /**
  2344. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2345. */
  2346. getDeterministicFrameTime: () => number;
  2347. /**
  2348. * Render the scene
  2349. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2350. */
  2351. render(updateCameras?: boolean): void;
  2352. /**
  2353. * Freeze all materials
  2354. * A frozen material will not be updatable but should be faster to render
  2355. */
  2356. freezeMaterials(): void;
  2357. /**
  2358. * Unfreeze all materials
  2359. * A frozen material will not be updatable but should be faster to render
  2360. */
  2361. unfreezeMaterials(): void;
  2362. /**
  2363. * Releases all held ressources
  2364. */
  2365. dispose(): void;
  2366. /**
  2367. * Gets if the scene is already disposed
  2368. */
  2369. readonly isDisposed: boolean;
  2370. /**
  2371. * Call this function to reduce memory footprint of the scene.
  2372. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2373. */
  2374. clearCachedVertexData(): void;
  2375. /**
  2376. * This function will remove the local cached buffer data from texture.
  2377. * It will save memory but will prevent the texture from being rebuilt
  2378. */
  2379. cleanCachedTextureBuffer(): void;
  2380. /**
  2381. * Get the world extend vectors with an optional filter
  2382. *
  2383. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2384. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2385. */
  2386. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2387. min: Vector3;
  2388. max: Vector3;
  2389. };
  2390. /**
  2391. * Creates a ray that can be used to pick in the scene
  2392. * @param x defines the x coordinate of the origin (on-screen)
  2393. * @param y defines the y coordinate of the origin (on-screen)
  2394. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2395. * @param camera defines the camera to use for the picking
  2396. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2397. * @returns a Ray
  2398. */
  2399. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2400. /**
  2401. * Creates a ray that can be used to pick in the scene
  2402. * @param x defines the x coordinate of the origin (on-screen)
  2403. * @param y defines the y coordinate of the origin (on-screen)
  2404. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2405. * @param result defines the ray where to store the picking ray
  2406. * @param camera defines the camera to use for the picking
  2407. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2408. * @returns the current scene
  2409. */
  2410. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2411. /**
  2412. * Creates a ray that can be used to pick in the scene
  2413. * @param x defines the x coordinate of the origin (on-screen)
  2414. * @param y defines the y coordinate of the origin (on-screen)
  2415. * @param camera defines the camera to use for the picking
  2416. * @returns a Ray
  2417. */
  2418. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2419. /**
  2420. * Creates a ray that can be used to pick in the scene
  2421. * @param x defines the x coordinate of the origin (on-screen)
  2422. * @param y defines the y coordinate of the origin (on-screen)
  2423. * @param result defines the ray where to store the picking ray
  2424. * @param camera defines the camera to use for the picking
  2425. * @returns the current scene
  2426. */
  2427. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2428. private _internalPick;
  2429. private _internalMultiPick;
  2430. private _tempPickingRay;
  2431. /** Launch a ray to try to pick a mesh in the scene
  2432. * @param x position on screen
  2433. * @param y position on screen
  2434. * @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
  2435. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2436. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2437. * @returns a PickingInfo
  2438. */
  2439. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2440. private _cachedRayForTransform;
  2441. /** Use the given ray to pick a mesh in the scene
  2442. * @param ray The ray to use to pick meshes
  2443. * @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
  2444. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2445. * @returns a PickingInfo
  2446. */
  2447. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2448. /**
  2449. * Launch a ray to try to pick a mesh in the scene
  2450. * @param x X position on screen
  2451. * @param y Y position on screen
  2452. * @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
  2453. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2454. * @returns an array of PickingInfo
  2455. */
  2456. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2457. /**
  2458. * Launch a ray to try to pick a mesh in the scene
  2459. * @param ray Ray to use
  2460. * @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
  2461. * @returns an array of PickingInfo
  2462. */
  2463. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2464. /**
  2465. * Force the value of meshUnderPointer
  2466. * @param mesh defines the mesh to use
  2467. */
  2468. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2469. /**
  2470. * Gets the mesh under the pointer
  2471. * @returns a Mesh or null if no mesh is under the pointer
  2472. */
  2473. getPointerOverMesh(): Nullable<AbstractMesh>;
  2474. /** @hidden */
  2475. _rebuildGeometries(): void;
  2476. /** @hidden */
  2477. _rebuildTextures(): void;
  2478. private _getByTags;
  2479. /**
  2480. * Get a list of meshes by tags
  2481. * @param tagsQuery defines the tags query to use
  2482. * @param forEach defines a predicate used to filter results
  2483. * @returns an array of Mesh
  2484. */
  2485. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2486. /**
  2487. * Get a list of cameras by tags
  2488. * @param tagsQuery defines the tags query to use
  2489. * @param forEach defines a predicate used to filter results
  2490. * @returns an array of Camera
  2491. */
  2492. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2493. /**
  2494. * Get a list of lights by tags
  2495. * @param tagsQuery defines the tags query to use
  2496. * @param forEach defines a predicate used to filter results
  2497. * @returns an array of Light
  2498. */
  2499. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2500. /**
  2501. * Get a list of materials by tags
  2502. * @param tagsQuery defines the tags query to use
  2503. * @param forEach defines a predicate used to filter results
  2504. * @returns an array of Material
  2505. */
  2506. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2507. /**
  2508. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2509. * This allowed control for front to back rendering or reversly depending of the special needs.
  2510. *
  2511. * @param renderingGroupId The rendering group id corresponding to its index
  2512. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2513. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2514. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2515. */
  2516. 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;
  2517. /**
  2518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2519. *
  2520. * @param renderingGroupId The rendering group id corresponding to its index
  2521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2522. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2523. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2524. */
  2525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2526. /**
  2527. * Gets the current auto clear configuration for one rendering group of the rendering
  2528. * manager.
  2529. * @param index the rendering group index to get the information for
  2530. * @returns The auto clear setup for the requested rendering group
  2531. */
  2532. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2533. private _blockMaterialDirtyMechanism;
  2534. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2535. blockMaterialDirtyMechanism: boolean;
  2536. /**
  2537. * Will flag all materials as dirty to trigger new shader compilation
  2538. * @param flag defines the flag used to specify which material part must be marked as dirty
  2539. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2540. */
  2541. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2542. /** @hidden */
  2543. _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;
  2544. /** @hidden */
  2545. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2546. }
  2547. }
  2548. declare module BABYLON {
  2549. /**
  2550. * Groups all the scene component constants in one place to ease maintenance.
  2551. * @hidden
  2552. */
  2553. class SceneComponentConstants {
  2554. static readonly NAME_EFFECTLAYER: string;
  2555. static readonly NAME_LAYER: string;
  2556. static readonly NAME_LENSFLARESYSTEM: string;
  2557. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2558. static readonly NAME_PARTICLESYSTEM: string;
  2559. static readonly NAME_GAMEPAD: string;
  2560. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2561. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2562. static readonly NAME_DEPTHRENDERER: string;
  2563. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2564. static readonly NAME_SPRITE: string;
  2565. static readonly NAME_OUTLINERENDERER: string;
  2566. static readonly NAME_PROCEDURALTEXTURE: string;
  2567. static readonly NAME_SHADOWGENERATOR: string;
  2568. static readonly NAME_OCTREE: string;
  2569. static readonly NAME_PHYSICSENGINE: string;
  2570. static readonly NAME_AUDIO: string;
  2571. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2572. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2573. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2574. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2575. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2576. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2577. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2578. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2579. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2580. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2581. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2582. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2583. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2584. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2585. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2586. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2587. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2588. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2589. static readonly STEP_AFTERRENDER_AUDIO: number;
  2590. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2591. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2592. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2593. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2594. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2595. static readonly STEP_POINTERMOVE_SPRITE: number;
  2596. static readonly STEP_POINTERDOWN_SPRITE: number;
  2597. static readonly STEP_POINTERUP_SPRITE: number;
  2598. }
  2599. /**
  2600. * This represents a scene component.
  2601. *
  2602. * This is used to decouple the dependency the scene is having on the different workloads like
  2603. * layers, post processes...
  2604. */
  2605. interface ISceneComponent {
  2606. /**
  2607. * The name of the component. Each component must have a unique name.
  2608. */
  2609. name: string;
  2610. /**
  2611. * The scene the component belongs to.
  2612. */
  2613. scene: Scene;
  2614. /**
  2615. * Register the component to one instance of a scene.
  2616. */
  2617. register(): void;
  2618. /**
  2619. * Rebuilds the elements related to this component in case of
  2620. * context lost for instance.
  2621. */
  2622. rebuild(): void;
  2623. /**
  2624. * Disposes the component and the associated ressources.
  2625. */
  2626. dispose(): void;
  2627. }
  2628. /**
  2629. * This represents a SERIALIZABLE scene component.
  2630. *
  2631. * This extends Scene Component to add Serialization methods on top.
  2632. */
  2633. interface ISceneSerializableComponent extends ISceneComponent {
  2634. /**
  2635. * Adds all the element from the container to the scene
  2636. * @param container the container holding the elements
  2637. */
  2638. addFromContainer(container: AbstractScene): void;
  2639. /**
  2640. * Removes all the elements in the container from the scene
  2641. * @param container contains the elements to remove
  2642. */
  2643. removeFromContainer(container: AbstractScene): void;
  2644. /**
  2645. * Serializes the component data to the specified json object
  2646. * @param serializationObject The object to serialize to
  2647. */
  2648. serialize(serializationObject: any): void;
  2649. }
  2650. /**
  2651. * Strong typing of a Mesh related stage step action
  2652. */
  2653. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2654. /**
  2655. * Strong typing of a Evaluate Sub Mesh related stage step action
  2656. */
  2657. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2658. /**
  2659. * Strong typing of a Active Mesh related stage step action
  2660. */
  2661. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2662. /**
  2663. * Strong typing of a Camera related stage step action
  2664. */
  2665. type CameraStageAction = (camera: Camera) => void;
  2666. /**
  2667. * Strong typing of a RenderingGroup related stage step action
  2668. */
  2669. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2670. /**
  2671. * Strong typing of a Mesh Render related stage step action
  2672. */
  2673. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2674. /**
  2675. * Strong typing of a simple stage step action
  2676. */
  2677. type SimpleStageAction = () => void;
  2678. /**
  2679. * Strong typing of a render target action.
  2680. */
  2681. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2682. /**
  2683. * Strong typing of a pointer move action.
  2684. */
  2685. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2686. /**
  2687. * Strong typing of a pointer up/down action.
  2688. */
  2689. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2690. /**
  2691. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2692. * @hidden
  2693. */
  2694. class Stage<T extends Function> extends Array<{
  2695. index: number;
  2696. component: ISceneComponent;
  2697. action: T;
  2698. }> {
  2699. /**
  2700. * Hide ctor from the rest of the world.
  2701. * @param items The items to add.
  2702. */
  2703. private constructor();
  2704. /**
  2705. * Creates a new Stage.
  2706. * @returns A new instance of a Stage
  2707. */
  2708. static Create<T extends Function>(): Stage<T>;
  2709. /**
  2710. * Registers a step in an ordered way in the targeted stage.
  2711. * @param index Defines the position to register the step in
  2712. * @param component Defines the component attached to the step
  2713. * @param action Defines the action to launch during the step
  2714. */
  2715. registerStep(index: number, component: ISceneComponent, action: T): void;
  2716. /**
  2717. * Clears all the steps from the stage.
  2718. */
  2719. clear(): void;
  2720. }
  2721. }
  2722. declare module BABYLON {
  2723. /** Alias type for value that can be null */
  2724. type Nullable<T> = T | null;
  2725. /**
  2726. * Alias type for number that are floats
  2727. * @ignorenaming
  2728. */
  2729. type float = number;
  2730. /**
  2731. * Alias type for number that are doubles.
  2732. * @ignorenaming
  2733. */
  2734. type double = number;
  2735. /**
  2736. * Alias type for number that are integer
  2737. * @ignorenaming
  2738. */
  2739. type int = number;
  2740. /** Alias type for number array or Float32Array */
  2741. type FloatArray = number[] | Float32Array;
  2742. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2743. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2744. /**
  2745. * Alias for types that can be used by a Buffer or VertexBuffer.
  2746. */
  2747. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2748. }
  2749. declare module BABYLON {
  2750. /**
  2751. * The action to be carried out following a trigger
  2752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2753. */
  2754. class Action {
  2755. /** the trigger, with or without parameters, for the action */
  2756. triggerOptions: any;
  2757. /**
  2758. * Trigger for the action
  2759. */
  2760. trigger: number;
  2761. /**
  2762. * Internal only - manager for action
  2763. * @hidden
  2764. */
  2765. _actionManager: ActionManager;
  2766. private _nextActiveAction;
  2767. private _child;
  2768. private _condition?;
  2769. private _triggerParameter;
  2770. /**
  2771. * An event triggered prior to action being executed.
  2772. */
  2773. onBeforeExecuteObservable: Observable<Action>;
  2774. /**
  2775. * Creates a new Action
  2776. * @param triggerOptions the trigger, with or without parameters, for the action
  2777. * @param condition an optional determinant of action
  2778. */
  2779. constructor(
  2780. /** the trigger, with or without parameters, for the action */
  2781. triggerOptions: any, condition?: Condition);
  2782. /**
  2783. * Internal only
  2784. * @hidden
  2785. */
  2786. _prepare(): void;
  2787. /**
  2788. * Gets the trigger parameters
  2789. * @returns the trigger parameters
  2790. */
  2791. getTriggerParameter(): any;
  2792. /**
  2793. * Internal only - executes current action event
  2794. * @hidden
  2795. */
  2796. _executeCurrent(evt?: ActionEvent): void;
  2797. /**
  2798. * Execute placeholder for child classes
  2799. * @param evt optional action event
  2800. */
  2801. execute(evt?: ActionEvent): void;
  2802. /**
  2803. * Skips to next active action
  2804. */
  2805. skipToNextActiveAction(): void;
  2806. /**
  2807. * Adds action to chain of actions, may be a DoNothingAction
  2808. * @param action defines the next action to execute
  2809. * @returns The action passed in
  2810. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2811. */
  2812. then(action: Action): Action;
  2813. /**
  2814. * Internal only
  2815. * @hidden
  2816. */
  2817. _getProperty(propertyPath: string): string;
  2818. /**
  2819. * Internal only
  2820. * @hidden
  2821. */
  2822. _getEffectiveTarget(target: any, propertyPath: string): any;
  2823. /**
  2824. * Serialize placeholder for child classes
  2825. * @param parent of child
  2826. * @returns the serialized object
  2827. */
  2828. serialize(parent: any): any;
  2829. /**
  2830. * Internal only called by serialize
  2831. * @hidden
  2832. */
  2833. protected _serialize(serializedAction: any, parent?: any): any;
  2834. /**
  2835. * Internal only
  2836. * @hidden
  2837. */
  2838. static _SerializeValueAsString: (value: any) => string;
  2839. /**
  2840. * Internal only
  2841. * @hidden
  2842. */
  2843. static _GetTargetProperty: (target: Scene | Node) => {
  2844. name: string;
  2845. targetType: string;
  2846. value: string;
  2847. };
  2848. }
  2849. }
  2850. declare module BABYLON {
  2851. /**
  2852. * ActionEvent is the event being sent when an action is triggered.
  2853. */
  2854. class ActionEvent {
  2855. /** The mesh or sprite that triggered the action */
  2856. source: any;
  2857. /** The X mouse cursor position at the time of the event */
  2858. pointerX: number;
  2859. /** The Y mouse cursor position at the time of the event */
  2860. pointerY: number;
  2861. /** The mesh that is currently pointed at (can be null) */
  2862. meshUnderPointer: Nullable<AbstractMesh>;
  2863. /** the original (browser) event that triggered the ActionEvent */
  2864. sourceEvent?: any;
  2865. /** additional data for the event */
  2866. additionalData?: any;
  2867. /**
  2868. * Creates a new ActionEvent
  2869. * @param source The mesh or sprite that triggered the action
  2870. * @param pointerX The X mouse cursor position at the time of the event
  2871. * @param pointerY The Y mouse cursor position at the time of the event
  2872. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2873. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2874. * @param additionalData additional data for the event
  2875. */
  2876. constructor(
  2877. /** The mesh or sprite that triggered the action */
  2878. source: any,
  2879. /** The X mouse cursor position at the time of the event */
  2880. pointerX: number,
  2881. /** The Y mouse cursor position at the time of the event */
  2882. pointerY: number,
  2883. /** The mesh that is currently pointed at (can be null) */
  2884. meshUnderPointer: Nullable<AbstractMesh>,
  2885. /** the original (browser) event that triggered the ActionEvent */
  2886. sourceEvent?: any,
  2887. /** additional data for the event */
  2888. additionalData?: any);
  2889. /**
  2890. * Helper function to auto-create an ActionEvent from a source mesh.
  2891. * @param source The source mesh that triggered the event
  2892. * @param evt The original (browser) event
  2893. * @param additionalData additional data for the event
  2894. * @returns the new ActionEvent
  2895. */
  2896. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2897. /**
  2898. * Helper function to auto-create an ActionEvent from a source sprite
  2899. * @param source The source sprite that triggered the event
  2900. * @param scene Scene associated with the sprite
  2901. * @param evt The original (browser) event
  2902. * @param additionalData additional data for the event
  2903. * @returns the new ActionEvent
  2904. */
  2905. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2906. /**
  2907. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2908. * @param scene the scene where the event occurred
  2909. * @param evt The original (browser) event
  2910. * @returns the new ActionEvent
  2911. */
  2912. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2913. /**
  2914. * Helper function to auto-create an ActionEvent from a primitive
  2915. * @param prim defines the target primitive
  2916. * @param pointerPos defines the pointer position
  2917. * @param evt The original (browser) event
  2918. * @param additionalData additional data for the event
  2919. * @returns the new ActionEvent
  2920. */
  2921. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2922. }
  2923. /**
  2924. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2925. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2927. */
  2928. class ActionManager {
  2929. /**
  2930. * Nothing
  2931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2932. */
  2933. static readonly NothingTrigger: number;
  2934. /**
  2935. * On pick
  2936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2937. */
  2938. static readonly OnPickTrigger: number;
  2939. /**
  2940. * On left pick
  2941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2942. */
  2943. static readonly OnLeftPickTrigger: number;
  2944. /**
  2945. * On right pick
  2946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2947. */
  2948. static readonly OnRightPickTrigger: number;
  2949. /**
  2950. * On center pick
  2951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2952. */
  2953. static readonly OnCenterPickTrigger: number;
  2954. /**
  2955. * On pick down
  2956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2957. */
  2958. static readonly OnPickDownTrigger: number;
  2959. /**
  2960. * On double pick
  2961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2962. */
  2963. static readonly OnDoublePickTrigger: number;
  2964. /**
  2965. * On pick up
  2966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2967. */
  2968. static readonly OnPickUpTrigger: number;
  2969. /**
  2970. * On pick out.
  2971. * This trigger will only be raised if you also declared a OnPickDown
  2972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2973. */
  2974. static readonly OnPickOutTrigger: number;
  2975. /**
  2976. * On long press
  2977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2978. */
  2979. static readonly OnLongPressTrigger: number;
  2980. /**
  2981. * On pointer over
  2982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2983. */
  2984. static readonly OnPointerOverTrigger: number;
  2985. /**
  2986. * On pointer out
  2987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2988. */
  2989. static readonly OnPointerOutTrigger: number;
  2990. /**
  2991. * On every frame
  2992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2993. */
  2994. static readonly OnEveryFrameTrigger: number;
  2995. /**
  2996. * On intersection enter
  2997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2998. */
  2999. static readonly OnIntersectionEnterTrigger: number;
  3000. /**
  3001. * On intersection exit
  3002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3003. */
  3004. static readonly OnIntersectionExitTrigger: number;
  3005. /**
  3006. * On key down
  3007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3008. */
  3009. static readonly OnKeyDownTrigger: number;
  3010. /**
  3011. * On key up
  3012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3013. */
  3014. static readonly OnKeyUpTrigger: number;
  3015. /** Gets the list of active triggers */
  3016. static Triggers: {
  3017. [key: string]: number;
  3018. };
  3019. /** Gets the list of actions */
  3020. actions: Action[];
  3021. /** Gets the cursor to use when hovering items */
  3022. hoverCursor: string;
  3023. private _scene;
  3024. /**
  3025. * Creates a new action manager
  3026. * @param scene defines the hosting scene
  3027. */
  3028. constructor(scene: Scene);
  3029. /**
  3030. * Releases all associated resources
  3031. */
  3032. dispose(): void;
  3033. /**
  3034. * Gets hosting scene
  3035. * @returns the hosting scene
  3036. */
  3037. getScene(): Scene;
  3038. /**
  3039. * Does this action manager handles actions of any of the given triggers
  3040. * @param triggers defines the triggers to be tested
  3041. * @return a boolean indicating whether one (or more) of the triggers is handled
  3042. */
  3043. hasSpecificTriggers(triggers: number[]): boolean;
  3044. /**
  3045. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3046. * speed.
  3047. * @param triggerA defines the trigger to be tested
  3048. * @param triggerB defines the trigger to be tested
  3049. * @return a boolean indicating whether one (or more) of the triggers is handled
  3050. */
  3051. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3052. /**
  3053. * Does this action manager handles actions of a given trigger
  3054. * @param trigger defines the trigger to be tested
  3055. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3056. * @return whether the trigger is handled
  3057. */
  3058. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3059. /**
  3060. * Does this action manager has pointer triggers
  3061. */
  3062. readonly hasPointerTriggers: boolean;
  3063. /**
  3064. * Does this action manager has pick triggers
  3065. */
  3066. readonly hasPickTriggers: boolean;
  3067. /**
  3068. * Does exist one action manager with at least one trigger
  3069. **/
  3070. static readonly HasTriggers: boolean;
  3071. /**
  3072. * Does exist one action manager with at least one pick trigger
  3073. **/
  3074. static readonly HasPickTriggers: boolean;
  3075. /**
  3076. * Does exist one action manager that handles actions of a given trigger
  3077. * @param trigger defines the trigger to be tested
  3078. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3079. **/
  3080. static HasSpecificTrigger(trigger: number): boolean;
  3081. /**
  3082. * Registers an action to this action manager
  3083. * @param action defines the action to be registered
  3084. * @return the action amended (prepared) after registration
  3085. */
  3086. registerAction(action: Action): Nullable<Action>;
  3087. /**
  3088. * Unregisters an action to this action manager
  3089. * @param action defines the action to be unregistered
  3090. * @return a boolean indicating whether the action has been unregistered
  3091. */
  3092. unregisterAction(action: Action): Boolean;
  3093. /**
  3094. * Process a specific trigger
  3095. * @param trigger defines the trigger to process
  3096. * @param evt defines the event details to be processed
  3097. */
  3098. processTrigger(trigger: number, evt?: ActionEvent): void;
  3099. /** @hidden */
  3100. _getEffectiveTarget(target: any, propertyPath: string): any;
  3101. /** @hidden */
  3102. _getProperty(propertyPath: string): string;
  3103. /**
  3104. * Serialize this manager to a JSON object
  3105. * @param name defines the property name to store this manager
  3106. * @returns a JSON representation of this manager
  3107. */
  3108. serialize(name: string): any;
  3109. /**
  3110. * Creates a new ActionManager from a JSON data
  3111. * @param parsedActions defines the JSON data to read from
  3112. * @param object defines the hosting mesh
  3113. * @param scene defines the hosting scene
  3114. */
  3115. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3116. /**
  3117. * Get a trigger name by index
  3118. * @param trigger defines the trigger index
  3119. * @returns a trigger name
  3120. */
  3121. static GetTriggerName(trigger: number): string;
  3122. }
  3123. }
  3124. declare module BABYLON {
  3125. /**
  3126. * A Condition applied to an Action
  3127. */
  3128. class Condition {
  3129. /**
  3130. * Internal only - manager for action
  3131. * @hidden
  3132. */
  3133. _actionManager: ActionManager;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. _evaluationId: number;
  3139. /**
  3140. * Internal only
  3141. * @hidden
  3142. */
  3143. _currentResult: boolean;
  3144. /**
  3145. * Creates a new Condition
  3146. * @param actionManager the manager of the action the condition is applied to
  3147. */
  3148. constructor(actionManager: ActionManager);
  3149. /**
  3150. * Check if the current condition is valid
  3151. * @returns a boolean
  3152. */
  3153. isValid(): boolean;
  3154. /**
  3155. * Internal only
  3156. * @hidden
  3157. */
  3158. _getProperty(propertyPath: string): string;
  3159. /**
  3160. * Internal only
  3161. * @hidden
  3162. */
  3163. _getEffectiveTarget(target: any, propertyPath: string): any;
  3164. /**
  3165. * Serialize placeholder for child classes
  3166. * @returns the serialized object
  3167. */
  3168. serialize(): any;
  3169. /**
  3170. * Internal only
  3171. * @hidden
  3172. */
  3173. protected _serialize(serializedCondition: any): any;
  3174. }
  3175. /**
  3176. * Defines specific conditional operators as extensions of Condition
  3177. */
  3178. class ValueCondition extends Condition {
  3179. /** path to specify the property of the target the conditional operator uses */
  3180. propertyPath: string;
  3181. /** the value compared by the conditional operator against the current value of the property */
  3182. value: any;
  3183. /** the conditional operator, default ValueCondition.IsEqual */
  3184. operator: number;
  3185. /**
  3186. * Internal only
  3187. * @hidden
  3188. */
  3189. private static _IsEqual;
  3190. /**
  3191. * Internal only
  3192. * @hidden
  3193. */
  3194. private static _IsDifferent;
  3195. /**
  3196. * Internal only
  3197. * @hidden
  3198. */
  3199. private static _IsGreater;
  3200. /**
  3201. * Internal only
  3202. * @hidden
  3203. */
  3204. private static _IsLesser;
  3205. /**
  3206. * returns the number for IsEqual
  3207. */
  3208. static readonly IsEqual: number;
  3209. /**
  3210. * Returns the number for IsDifferent
  3211. */
  3212. static readonly IsDifferent: number;
  3213. /**
  3214. * Returns the number for IsGreater
  3215. */
  3216. static readonly IsGreater: number;
  3217. /**
  3218. * Returns the number for IsLesser
  3219. */
  3220. static readonly IsLesser: number;
  3221. /**
  3222. * Internal only The action manager for the condition
  3223. * @hidden
  3224. */
  3225. _actionManager: ActionManager;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. private _target;
  3231. /**
  3232. * Internal only
  3233. * @hidden
  3234. */
  3235. private _effectiveTarget;
  3236. /**
  3237. * Internal only
  3238. * @hidden
  3239. */
  3240. private _property;
  3241. /**
  3242. * Creates a new ValueCondition
  3243. * @param actionManager manager for the action the condition applies to
  3244. * @param target for the action
  3245. * @param propertyPath path to specify the property of the target the conditional operator uses
  3246. * @param value the value compared by the conditional operator against the current value of the property
  3247. * @param operator the conditional operator, default ValueCondition.IsEqual
  3248. */
  3249. constructor(actionManager: ActionManager, target: any,
  3250. /** path to specify the property of the target the conditional operator uses */
  3251. propertyPath: string,
  3252. /** the value compared by the conditional operator against the current value of the property */
  3253. value: any,
  3254. /** the conditional operator, default ValueCondition.IsEqual */
  3255. operator?: number);
  3256. /**
  3257. * Compares the given value with the property value for the specified conditional operator
  3258. * @returns the result of the comparison
  3259. */
  3260. isValid(): boolean;
  3261. /**
  3262. * Serialize the ValueCondition into a JSON compatible object
  3263. * @returns serialization object
  3264. */
  3265. serialize(): any;
  3266. /**
  3267. * Gets the name of the conditional operator for the ValueCondition
  3268. * @param operator the conditional operator
  3269. * @returns the name
  3270. */
  3271. static GetOperatorName(operator: number): string;
  3272. }
  3273. /**
  3274. * Defines a predicate condition as an extension of Condition
  3275. */
  3276. class PredicateCondition extends Condition {
  3277. /** defines the predicate function used to validate the condition */
  3278. predicate: () => boolean;
  3279. /**
  3280. * Internal only - manager for action
  3281. * @hidden
  3282. */
  3283. _actionManager: ActionManager;
  3284. /**
  3285. * Creates a new PredicateCondition
  3286. * @param actionManager manager for the action the condition applies to
  3287. * @param predicate defines the predicate function used to validate the condition
  3288. */
  3289. constructor(actionManager: ActionManager,
  3290. /** defines the predicate function used to validate the condition */
  3291. predicate: () => boolean);
  3292. /**
  3293. * @returns the validity of the predicate condition
  3294. */
  3295. isValid(): boolean;
  3296. }
  3297. /**
  3298. * Defines a state condition as an extension of Condition
  3299. */
  3300. class StateCondition extends Condition {
  3301. /** Value to compare with target state */
  3302. value: string;
  3303. /**
  3304. * Internal only - manager for action
  3305. * @hidden
  3306. */
  3307. _actionManager: ActionManager;
  3308. /**
  3309. * Internal only
  3310. * @hidden
  3311. */
  3312. private _target;
  3313. /**
  3314. * Creates a new StateCondition
  3315. * @param actionManager manager for the action the condition applies to
  3316. * @param target of the condition
  3317. * @param value to compare with target state
  3318. */
  3319. constructor(actionManager: ActionManager, target: any,
  3320. /** Value to compare with target state */
  3321. value: string);
  3322. /**
  3323. * Gets a boolean indicating if the current condition is met
  3324. * @returns the validity of the state
  3325. */
  3326. isValid(): boolean;
  3327. /**
  3328. * Serialize the StateCondition into a JSON compatible object
  3329. * @returns serialization object
  3330. */
  3331. serialize(): any;
  3332. }
  3333. }
  3334. declare module BABYLON {
  3335. /**
  3336. * This defines an action responsible to toggle a boolean once triggered.
  3337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3338. */
  3339. class SwitchBooleanAction extends Action {
  3340. /**
  3341. * The path to the boolean property in the target object
  3342. */
  3343. propertyPath: string;
  3344. private _target;
  3345. private _effectiveTarget;
  3346. private _property;
  3347. /**
  3348. * Instantiate the action
  3349. * @param triggerOptions defines the trigger options
  3350. * @param target defines the object containing the boolean
  3351. * @param propertyPath defines the path to the boolean property in the target object
  3352. * @param condition defines the trigger related conditions
  3353. */
  3354. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3355. /** @hidden */
  3356. _prepare(): void;
  3357. /**
  3358. * Execute the action toggle the boolean value.
  3359. */
  3360. execute(): void;
  3361. /**
  3362. * Serializes the actions and its related information.
  3363. * @param parent defines the object to serialize in
  3364. * @returns the serialized object
  3365. */
  3366. serialize(parent: any): any;
  3367. }
  3368. /**
  3369. * This defines an action responsible to set a the state field of the target
  3370. * to a desired value once triggered.
  3371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3372. */
  3373. class SetStateAction extends Action {
  3374. /**
  3375. * The value to store in the state field.
  3376. */
  3377. value: string;
  3378. private _target;
  3379. /**
  3380. * Instantiate the action
  3381. * @param triggerOptions defines the trigger options
  3382. * @param target defines the object containing the state property
  3383. * @param value defines the value to store in the state field
  3384. * @param condition defines the trigger related conditions
  3385. */
  3386. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3387. /**
  3388. * Execute the action and store the value on the target state property.
  3389. */
  3390. execute(): void;
  3391. /**
  3392. * Serializes the actions and its related information.
  3393. * @param parent defines the object to serialize in
  3394. * @returns the serialized object
  3395. */
  3396. serialize(parent: any): any;
  3397. }
  3398. /**
  3399. * This defines an action responsible to set a property of the target
  3400. * to a desired value once triggered.
  3401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3402. */
  3403. class SetValueAction extends Action {
  3404. /**
  3405. * The path of the property to set in the target.
  3406. */
  3407. propertyPath: string;
  3408. /**
  3409. * The value to set in the property
  3410. */
  3411. value: any;
  3412. private _target;
  3413. private _effectiveTarget;
  3414. private _property;
  3415. /**
  3416. * Instantiate the action
  3417. * @param triggerOptions defines the trigger options
  3418. * @param target defines the object containing the property
  3419. * @param propertyPath defines the path of the property to set in the target
  3420. * @param value defines the value to set in the property
  3421. * @param condition defines the trigger related conditions
  3422. */
  3423. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3424. /** @hidden */
  3425. _prepare(): void;
  3426. /**
  3427. * Execute the action and set the targetted property to the desired value.
  3428. */
  3429. execute(): void;
  3430. /**
  3431. * Serializes the actions and its related information.
  3432. * @param parent defines the object to serialize in
  3433. * @returns the serialized object
  3434. */
  3435. serialize(parent: any): any;
  3436. }
  3437. /**
  3438. * This defines an action responsible to increment the target value
  3439. * to a desired value once triggered.
  3440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3441. */
  3442. class IncrementValueAction extends Action {
  3443. /**
  3444. * The path of the property to increment in the target.
  3445. */
  3446. propertyPath: string;
  3447. /**
  3448. * The value we should increment the property by.
  3449. */
  3450. value: any;
  3451. private _target;
  3452. private _effectiveTarget;
  3453. private _property;
  3454. /**
  3455. * Instantiate the action
  3456. * @param triggerOptions defines the trigger options
  3457. * @param target defines the object containing the property
  3458. * @param propertyPath defines the path of the property to increment in the target
  3459. * @param value defines the value value we should increment the property by
  3460. * @param condition defines the trigger related conditions
  3461. */
  3462. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3463. /** @hidden */
  3464. _prepare(): void;
  3465. /**
  3466. * Execute the action and increment the target of the value amount.
  3467. */
  3468. execute(): void;
  3469. /**
  3470. * Serializes the actions and its related information.
  3471. * @param parent defines the object to serialize in
  3472. * @returns the serialized object
  3473. */
  3474. serialize(parent: any): any;
  3475. }
  3476. /**
  3477. * This defines an action responsible to start an animation once triggered.
  3478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3479. */
  3480. class PlayAnimationAction extends Action {
  3481. /**
  3482. * Where the animation should start (animation frame)
  3483. */
  3484. from: number;
  3485. /**
  3486. * Where the animation should stop (animation frame)
  3487. */
  3488. to: number;
  3489. /**
  3490. * Define if the animation should loop or stop after the first play.
  3491. */
  3492. loop?: boolean;
  3493. private _target;
  3494. /**
  3495. * Instantiate the action
  3496. * @param triggerOptions defines the trigger options
  3497. * @param target defines the target animation or animation name
  3498. * @param from defines from where the animation should start (animation frame)
  3499. * @param end defines where the animation should stop (animation frame)
  3500. * @param loop defines if the animation should loop or stop after the first play
  3501. * @param condition defines the trigger related conditions
  3502. */
  3503. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3504. /** @hidden */
  3505. _prepare(): void;
  3506. /**
  3507. * Execute the action and play the animation.
  3508. */
  3509. execute(): void;
  3510. /**
  3511. * Serializes the actions and its related information.
  3512. * @param parent defines the object to serialize in
  3513. * @returns the serialized object
  3514. */
  3515. serialize(parent: any): any;
  3516. }
  3517. /**
  3518. * This defines an action responsible to stop an animation once triggered.
  3519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3520. */
  3521. class StopAnimationAction extends Action {
  3522. private _target;
  3523. /**
  3524. * Instantiate the action
  3525. * @param triggerOptions defines the trigger options
  3526. * @param target defines the target animation or animation name
  3527. * @param condition defines the trigger related conditions
  3528. */
  3529. constructor(triggerOptions: any, target: any, condition?: Condition);
  3530. /** @hidden */
  3531. _prepare(): void;
  3532. /**
  3533. * Execute the action and stop the animation.
  3534. */
  3535. execute(): void;
  3536. /**
  3537. * Serializes the actions and its related information.
  3538. * @param parent defines the object to serialize in
  3539. * @returns the serialized object
  3540. */
  3541. serialize(parent: any): any;
  3542. }
  3543. /**
  3544. * This defines an action responsible that does nothing once triggered.
  3545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3546. */
  3547. class DoNothingAction extends Action {
  3548. /**
  3549. * Instantiate the action
  3550. * @param triggerOptions defines the trigger options
  3551. * @param condition defines the trigger related conditions
  3552. */
  3553. constructor(triggerOptions?: any, condition?: Condition);
  3554. /**
  3555. * Execute the action and do nothing.
  3556. */
  3557. execute(): void;
  3558. /**
  3559. * Serializes the actions and its related information.
  3560. * @param parent defines the object to serialize in
  3561. * @returns the serialized object
  3562. */
  3563. serialize(parent: any): any;
  3564. }
  3565. /**
  3566. * This defines an action responsible to trigger several actions once triggered.
  3567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3568. */
  3569. class CombineAction extends Action {
  3570. /**
  3571. * The list of aggregated animations to run.
  3572. */
  3573. children: Action[];
  3574. /**
  3575. * Instantiate the action
  3576. * @param triggerOptions defines the trigger options
  3577. * @param children defines the list of aggregated animations to run
  3578. * @param condition defines the trigger related conditions
  3579. */
  3580. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3581. /** @hidden */
  3582. _prepare(): void;
  3583. /**
  3584. * Execute the action and executes all the aggregated actions.
  3585. */
  3586. execute(evt: ActionEvent): void;
  3587. /**
  3588. * Serializes the actions and its related information.
  3589. * @param parent defines the object to serialize in
  3590. * @returns the serialized object
  3591. */
  3592. serialize(parent: any): any;
  3593. }
  3594. /**
  3595. * This defines an action responsible to run code (external event) once triggered.
  3596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3597. */
  3598. class ExecuteCodeAction extends Action {
  3599. /**
  3600. * The callback function to run.
  3601. */
  3602. func: (evt: ActionEvent) => void;
  3603. /**
  3604. * Instantiate the action
  3605. * @param triggerOptions defines the trigger options
  3606. * @param func defines the callback function to run
  3607. * @param condition defines the trigger related conditions
  3608. */
  3609. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3610. /**
  3611. * Execute the action and run the attached code.
  3612. */
  3613. execute(evt: ActionEvent): void;
  3614. }
  3615. /**
  3616. * This defines an action responsible to set the parent property of the target once triggered.
  3617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3618. */
  3619. class SetParentAction extends Action {
  3620. private _parent;
  3621. private _target;
  3622. /**
  3623. * Instantiate the action
  3624. * @param triggerOptions defines the trigger options
  3625. * @param target defines the target containing the parent property
  3626. * @param parent defines from where the animation should start (animation frame)
  3627. * @param condition defines the trigger related conditions
  3628. */
  3629. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3630. /** @hidden */
  3631. _prepare(): void;
  3632. /**
  3633. * Execute the action and set the parent property.
  3634. */
  3635. execute(): void;
  3636. /**
  3637. * Serializes the actions and its related information.
  3638. * @param parent defines the object to serialize in
  3639. * @returns the serialized object
  3640. */
  3641. serialize(parent: any): any;
  3642. }
  3643. }
  3644. declare module BABYLON {
  3645. /**
  3646. * This defines an action helpful to play a defined sound on a triggered action.
  3647. */
  3648. class PlaySoundAction extends Action {
  3649. private _sound;
  3650. /**
  3651. * Instantiate the action
  3652. * @param triggerOptions defines the trigger options
  3653. * @param sound defines the sound to play
  3654. * @param condition defines the trigger related conditions
  3655. */
  3656. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3657. /** @hidden */
  3658. _prepare(): void;
  3659. /**
  3660. * Execute the action and play the sound.
  3661. */
  3662. execute(): void;
  3663. /**
  3664. * Serializes the actions and its related information.
  3665. * @param parent defines the object to serialize in
  3666. * @returns the serialized object
  3667. */
  3668. serialize(parent: any): any;
  3669. }
  3670. /**
  3671. * This defines an action helpful to stop a defined sound on a triggered action.
  3672. */
  3673. class StopSoundAction extends Action {
  3674. private _sound;
  3675. /**
  3676. * Instantiate the action
  3677. * @param triggerOptions defines the trigger options
  3678. * @param sound defines the sound to stop
  3679. * @param condition defines the trigger related conditions
  3680. */
  3681. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3682. /** @hidden */
  3683. _prepare(): void;
  3684. /**
  3685. * Execute the action and stop the sound.
  3686. */
  3687. execute(): void;
  3688. /**
  3689. * Serializes the actions and its related information.
  3690. * @param parent defines the object to serialize in
  3691. * @returns the serialized object
  3692. */
  3693. serialize(parent: any): any;
  3694. }
  3695. }
  3696. declare module BABYLON {
  3697. /**
  3698. * This defines an action responsible to change the value of a property
  3699. * by interpolating between its current value and the newly set one once triggered.
  3700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3701. */
  3702. class InterpolateValueAction extends Action {
  3703. /**
  3704. * Defines the path of the property where the value should be interpolated
  3705. */
  3706. propertyPath: string;
  3707. /**
  3708. * Defines the target value at the end of the interpolation.
  3709. */
  3710. value: any;
  3711. /**
  3712. * Defines the time it will take for the property to interpolate to the value.
  3713. */
  3714. duration: number;
  3715. /**
  3716. * Defines if the other scene animations should be stopped when the action has been triggered
  3717. */
  3718. stopOtherAnimations?: boolean;
  3719. /**
  3720. * Defines a callback raised once the interpolation animation has been done.
  3721. */
  3722. onInterpolationDone?: () => void;
  3723. /**
  3724. * Observable triggered once the interpolation animation has been done.
  3725. */
  3726. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3727. private _target;
  3728. private _effectiveTarget;
  3729. private _property;
  3730. /**
  3731. * Instantiate the action
  3732. * @param triggerOptions defines the trigger options
  3733. * @param target defines the object containing the value to interpolate
  3734. * @param propertyPath defines the path to the property in the target object
  3735. * @param value defines the target value at the end of the interpolation
  3736. * @param duration deines the time it will take for the property to interpolate to the value.
  3737. * @param condition defines the trigger related conditions
  3738. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3739. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3740. */
  3741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3742. /** @hidden */
  3743. _prepare(): void;
  3744. /**
  3745. * Execute the action starts the value interpolation.
  3746. */
  3747. execute(): void;
  3748. /**
  3749. * Serializes the actions and its related information.
  3750. * @param parent defines the object to serialize in
  3751. * @returns the serialized object
  3752. */
  3753. serialize(parent: any): any;
  3754. }
  3755. }
  3756. declare module BABYLON {
  3757. /**
  3758. * Class used to store an actual running animation
  3759. */
  3760. class Animatable {
  3761. /** defines the target object */
  3762. target: any;
  3763. /** defines the starting frame number (default is 0) */
  3764. fromFrame: number;
  3765. /** defines the ending frame number (default is 100) */
  3766. toFrame: number;
  3767. /** defines if the animation must loop (default is false) */
  3768. loopAnimation: boolean;
  3769. /** defines a callback to call when animation ends if it is not looping */
  3770. onAnimationEnd?: (() => void) | null | undefined;
  3771. private _localDelayOffset;
  3772. private _pausedDelay;
  3773. private _runtimeAnimations;
  3774. private _paused;
  3775. private _scene;
  3776. private _speedRatio;
  3777. private _weight;
  3778. private _syncRoot;
  3779. /**
  3780. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3781. * This will only apply for non looping animation (default is true)
  3782. */
  3783. disposeOnEnd: boolean;
  3784. /**
  3785. * Gets a boolean indicating if the animation has started
  3786. */
  3787. animationStarted: boolean;
  3788. /**
  3789. * Observer raised when the animation ends
  3790. */
  3791. onAnimationEndObservable: Observable<Animatable>;
  3792. /**
  3793. * Gets the root Animatable used to synchronize and normalize animations
  3794. */
  3795. readonly syncRoot: Animatable;
  3796. /**
  3797. * Gets the current frame of the first RuntimeAnimation
  3798. * Used to synchronize Animatables
  3799. */
  3800. readonly masterFrame: number;
  3801. /**
  3802. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3803. */
  3804. weight: number;
  3805. /**
  3806. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3807. */
  3808. speedRatio: number;
  3809. /**
  3810. * Creates a new Animatable
  3811. * @param scene defines the hosting scene
  3812. * @param target defines the target object
  3813. * @param fromFrame defines the starting frame number (default is 0)
  3814. * @param toFrame defines the ending frame number (default is 100)
  3815. * @param loopAnimation defines if the animation must loop (default is false)
  3816. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3817. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3818. * @param animations defines a group of animation to add to the new Animatable
  3819. */
  3820. constructor(scene: Scene,
  3821. /** defines the target object */
  3822. target: any,
  3823. /** defines the starting frame number (default is 0) */
  3824. fromFrame?: number,
  3825. /** defines the ending frame number (default is 100) */
  3826. toFrame?: number,
  3827. /** defines if the animation must loop (default is false) */
  3828. loopAnimation?: boolean, speedRatio?: number,
  3829. /** defines a callback to call when animation ends if it is not looping */
  3830. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3831. /**
  3832. * Synchronize and normalize current Animatable with a source Animatable
  3833. * This is useful when using animation weights and when animations are not of the same length
  3834. * @param root defines the root Animatable to synchronize with
  3835. * @returns the current Animatable
  3836. */
  3837. syncWith(root: Animatable): Animatable;
  3838. /**
  3839. * Gets the list of runtime animations
  3840. * @returns an array of RuntimeAnimation
  3841. */
  3842. getAnimations(): RuntimeAnimation[];
  3843. /**
  3844. * Adds more animations to the current animatable
  3845. * @param target defines the target of the animations
  3846. * @param animations defines the new animations to add
  3847. */
  3848. appendAnimations(target: any, animations: Animation[]): void;
  3849. /**
  3850. * Gets the source animation for a specific property
  3851. * @param property defines the propertyu to look for
  3852. * @returns null or the source animation for the given property
  3853. */
  3854. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3855. /**
  3856. * Gets the runtime animation for a specific property
  3857. * @param property defines the propertyu to look for
  3858. * @returns null or the runtime animation for the given property
  3859. */
  3860. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3861. /**
  3862. * Resets the animatable to its original state
  3863. */
  3864. reset(): void;
  3865. /**
  3866. * Allows the animatable to blend with current running animations
  3867. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3868. * @param blendingSpeed defines the blending speed to use
  3869. */
  3870. enableBlending(blendingSpeed: number): void;
  3871. /**
  3872. * Disable animation blending
  3873. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3874. */
  3875. disableBlending(): void;
  3876. /**
  3877. * Jump directly to a given frame
  3878. * @param frame defines the frame to jump to
  3879. */
  3880. goToFrame(frame: number): void;
  3881. /**
  3882. * Pause the animation
  3883. */
  3884. pause(): void;
  3885. /**
  3886. * Restart the animation
  3887. */
  3888. restart(): void;
  3889. private _raiseOnAnimationEnd;
  3890. /**
  3891. * Stop and delete the current animation
  3892. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3893. * @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)
  3894. */
  3895. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3896. /**
  3897. * Wait asynchronously for the animation to end
  3898. * @returns a promise which will be fullfilled when the animation ends
  3899. */
  3900. waitAsync(): Promise<Animatable>;
  3901. /** @hidden */
  3902. _animate(delay: number): boolean;
  3903. }
  3904. }
  3905. declare module BABYLON {
  3906. /**
  3907. * Represents the range of an animation
  3908. */
  3909. class AnimationRange {
  3910. /**The name of the animation range**/
  3911. name: string;
  3912. /**The starting frame of the animation */
  3913. from: number;
  3914. /**The ending frame of the animation*/
  3915. to: number;
  3916. /**
  3917. * Initializes the range of an animation
  3918. * @param name The name of the animation range
  3919. * @param from The starting frame of the animation
  3920. * @param to The ending frame of the animation
  3921. */
  3922. constructor(
  3923. /**The name of the animation range**/
  3924. name: string,
  3925. /**The starting frame of the animation */
  3926. from: number,
  3927. /**The ending frame of the animation*/
  3928. to: number);
  3929. /**
  3930. * Makes a copy of the animation range
  3931. * @returns A copy of the animation range
  3932. */
  3933. clone(): AnimationRange;
  3934. }
  3935. /**
  3936. * Composed of a frame, and an action function
  3937. */
  3938. class AnimationEvent {
  3939. /** The frame for which the event is triggered **/
  3940. frame: number;
  3941. /** The event to perform when triggered **/
  3942. action: (currentFrame: number) => void;
  3943. /** Specifies if the event should be triggered only once**/
  3944. onlyOnce?: boolean | undefined;
  3945. /**
  3946. * Specifies if the animation event is done
  3947. */
  3948. isDone: boolean;
  3949. /**
  3950. * Initializes the animation event
  3951. * @param frame The frame for which the event is triggered
  3952. * @param action The event to perform when triggered
  3953. * @param onlyOnce Specifies if the event should be triggered only once
  3954. */
  3955. constructor(
  3956. /** The frame for which the event is triggered **/
  3957. frame: number,
  3958. /** The event to perform when triggered **/
  3959. action: (currentFrame: number) => void,
  3960. /** Specifies if the event should be triggered only once**/
  3961. onlyOnce?: boolean | undefined);
  3962. /** @hidden */
  3963. _clone(): AnimationEvent;
  3964. }
  3965. /**
  3966. * A cursor which tracks a point on a path
  3967. */
  3968. class PathCursor {
  3969. private path;
  3970. /**
  3971. * Stores path cursor callbacks for when an onchange event is triggered
  3972. */
  3973. private _onchange;
  3974. /**
  3975. * The value of the path cursor
  3976. */
  3977. value: number;
  3978. /**
  3979. * The animation array of the path cursor
  3980. */
  3981. animations: Animation[];
  3982. /**
  3983. * Initializes the path cursor
  3984. * @param path The path to track
  3985. */
  3986. constructor(path: Path2);
  3987. /**
  3988. * Gets the cursor point on the path
  3989. * @returns A point on the path cursor at the cursor location
  3990. */
  3991. getPoint(): Vector3;
  3992. /**
  3993. * Moves the cursor ahead by the step amount
  3994. * @param step The amount to move the cursor forward
  3995. * @returns This path cursor
  3996. */
  3997. moveAhead(step?: number): PathCursor;
  3998. /**
  3999. * Moves the cursor behind by the step amount
  4000. * @param step The amount to move the cursor back
  4001. * @returns This path cursor
  4002. */
  4003. moveBack(step?: number): PathCursor;
  4004. /**
  4005. * Moves the cursor by the step amount
  4006. * If the step amount is greater than one, an exception is thrown
  4007. * @param step The amount to move the cursor
  4008. * @returns This path cursor
  4009. */
  4010. move(step: number): PathCursor;
  4011. /**
  4012. * Ensures that the value is limited between zero and one
  4013. * @returns This path cursor
  4014. */
  4015. private ensureLimits;
  4016. /**
  4017. * Runs onchange callbacks on change (used by the animation engine)
  4018. * @returns This path cursor
  4019. */
  4020. private raiseOnChange;
  4021. /**
  4022. * Executes a function on change
  4023. * @param f A path cursor onchange callback
  4024. * @returns This path cursor
  4025. */
  4026. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4027. }
  4028. /**
  4029. * Defines an interface which represents an animation key frame
  4030. */
  4031. interface IAnimationKey {
  4032. /**
  4033. * Frame of the key frame
  4034. */
  4035. frame: number;
  4036. /**
  4037. * Value at the specifies key frame
  4038. */
  4039. value: any;
  4040. /**
  4041. * The input tangent for the cubic hermite spline
  4042. */
  4043. inTangent?: any;
  4044. /**
  4045. * The output tangent for the cubic hermite spline
  4046. */
  4047. outTangent?: any;
  4048. /**
  4049. * The animation interpolation type
  4050. */
  4051. interpolation?: AnimationKeyInterpolation;
  4052. }
  4053. /**
  4054. * Enum for the animation key frame interpolation type
  4055. */
  4056. enum AnimationKeyInterpolation {
  4057. /**
  4058. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4059. */
  4060. STEP = 1
  4061. }
  4062. /**
  4063. * Class used to store any kind of animation
  4064. */
  4065. class Animation {
  4066. /**Name of the animation */
  4067. name: string;
  4068. /**Property to animate */
  4069. targetProperty: string;
  4070. /**The frames per second of the animation */
  4071. framePerSecond: number;
  4072. /**The data type of the animation */
  4073. dataType: number;
  4074. /**The loop mode of the animation */
  4075. loopMode?: number | undefined;
  4076. /**Specifies if blending should be enabled */
  4077. enableBlending?: boolean | undefined;
  4078. /**
  4079. * Use matrix interpolation instead of using direct key value when animating matrices
  4080. */
  4081. static AllowMatricesInterpolation: boolean;
  4082. /**
  4083. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4084. */
  4085. static AllowMatrixDecomposeForInterpolation: boolean;
  4086. /**
  4087. * Stores the key frames of the animation
  4088. */
  4089. private _keys;
  4090. /**
  4091. * Stores the easing function of the animation
  4092. */
  4093. private _easingFunction;
  4094. /**
  4095. * @hidden Internal use only
  4096. */
  4097. _runtimeAnimations: RuntimeAnimation[];
  4098. /**
  4099. * The set of event that will be linked to this animation
  4100. */
  4101. private _events;
  4102. /**
  4103. * Stores an array of target property paths
  4104. */
  4105. targetPropertyPath: string[];
  4106. /**
  4107. * Stores the blending speed of the animation
  4108. */
  4109. blendingSpeed: number;
  4110. /**
  4111. * Stores the animation ranges for the animation
  4112. */
  4113. private _ranges;
  4114. /**
  4115. * @hidden Internal use
  4116. */
  4117. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4118. /**
  4119. * Sets up an animation
  4120. * @param property The property to animate
  4121. * @param animationType The animation type to apply
  4122. * @param framePerSecond The frames per second of the animation
  4123. * @param easingFunction The easing function used in the animation
  4124. * @returns The created animation
  4125. */
  4126. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4127. /**
  4128. * Create and start an animation on a node
  4129. * @param name defines the name of the global animation that will be run on all nodes
  4130. * @param node defines the root node where the animation will take place
  4131. * @param targetProperty defines property to animate
  4132. * @param framePerSecond defines the number of frame per second yo use
  4133. * @param totalFrame defines the number of frames in total
  4134. * @param from defines the initial value
  4135. * @param to defines the final value
  4136. * @param loopMode defines which loop mode you want to use (off by default)
  4137. * @param easingFunction defines the easing function to use (linear by default)
  4138. * @param onAnimationEnd defines the callback to call when animation end
  4139. * @returns the animatable created for this animation
  4140. */
  4141. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4142. /**
  4143. * Create and start an animation on a node and its descendants
  4144. * @param name defines the name of the global animation that will be run on all nodes
  4145. * @param node defines the root node where the animation will take place
  4146. * @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
  4147. * @param targetProperty defines property to animate
  4148. * @param framePerSecond defines the number of frame per second to use
  4149. * @param totalFrame defines the number of frames in total
  4150. * @param from defines the initial value
  4151. * @param to defines the final value
  4152. * @param loopMode defines which loop mode you want to use (off by default)
  4153. * @param easingFunction defines the easing function to use (linear by default)
  4154. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4155. * @returns the list of animatables created for all nodes
  4156. * @example https://www.babylonjs-playground.com/#MH0VLI
  4157. */
  4158. 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[]>;
  4159. /**
  4160. * Creates a new animation, merges it with the existing animations and starts it
  4161. * @param name Name of the animation
  4162. * @param node Node which contains the scene that begins the animations
  4163. * @param targetProperty Specifies which property to animate
  4164. * @param framePerSecond The frames per second of the animation
  4165. * @param totalFrame The total number of frames
  4166. * @param from The frame at the beginning of the animation
  4167. * @param to The frame at the end of the animation
  4168. * @param loopMode Specifies the loop mode of the animation
  4169. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4170. * @param onAnimationEnd Callback to run once the animation is complete
  4171. * @returns Nullable animation
  4172. */
  4173. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4174. /**
  4175. * Transition property of an host to the target Value
  4176. * @param property The property to transition
  4177. * @param targetValue The target Value of the property
  4178. * @param host The object where the property to animate belongs
  4179. * @param scene Scene used to run the animation
  4180. * @param frameRate Framerate (in frame/s) to use
  4181. * @param transition The transition type we want to use
  4182. * @param duration The duration of the animation, in milliseconds
  4183. * @param onAnimationEnd Callback trigger at the end of the animation
  4184. * @returns Nullable animation
  4185. */
  4186. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4187. /**
  4188. * Return the array of runtime animations currently using this animation
  4189. */
  4190. readonly runtimeAnimations: RuntimeAnimation[];
  4191. /**
  4192. * Specifies if any of the runtime animations are currently running
  4193. */
  4194. readonly hasRunningRuntimeAnimations: boolean;
  4195. /**
  4196. * Initializes the animation
  4197. * @param name Name of the animation
  4198. * @param targetProperty Property to animate
  4199. * @param framePerSecond The frames per second of the animation
  4200. * @param dataType The data type of the animation
  4201. * @param loopMode The loop mode of the animation
  4202. * @param enableBlendings Specifies if blending should be enabled
  4203. */
  4204. constructor(
  4205. /**Name of the animation */
  4206. name: string,
  4207. /**Property to animate */
  4208. targetProperty: string,
  4209. /**The frames per second of the animation */
  4210. framePerSecond: number,
  4211. /**The data type of the animation */
  4212. dataType: number,
  4213. /**The loop mode of the animation */
  4214. loopMode?: number | undefined,
  4215. /**Specifies if blending should be enabled */
  4216. enableBlending?: boolean | undefined);
  4217. /**
  4218. * Converts the animation to a string
  4219. * @param fullDetails support for multiple levels of logging within scene loading
  4220. * @returns String form of the animation
  4221. */
  4222. toString(fullDetails?: boolean): string;
  4223. /**
  4224. * Add an event to this animation
  4225. * @param event Event to add
  4226. */
  4227. addEvent(event: AnimationEvent): void;
  4228. /**
  4229. * Remove all events found at the given frame
  4230. * @param frame The frame to remove events from
  4231. */
  4232. removeEvents(frame: number): void;
  4233. /**
  4234. * Retrieves all the events from the animation
  4235. * @returns Events from the animation
  4236. */
  4237. getEvents(): AnimationEvent[];
  4238. /**
  4239. * Creates an animation range
  4240. * @param name Name of the animation range
  4241. * @param from Starting frame of the animation range
  4242. * @param to Ending frame of the animation
  4243. */
  4244. createRange(name: string, from: number, to: number): void;
  4245. /**
  4246. * Deletes an animation range by name
  4247. * @param name Name of the animation range to delete
  4248. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4249. */
  4250. deleteRange(name: string, deleteFrames?: boolean): void;
  4251. /**
  4252. * Gets the animation range by name, or null if not defined
  4253. * @param name Name of the animation range
  4254. * @returns Nullable animation range
  4255. */
  4256. getRange(name: string): Nullable<AnimationRange>;
  4257. /**
  4258. * Gets the key frames from the animation
  4259. * @returns The key frames of the animation
  4260. */
  4261. getKeys(): Array<IAnimationKey>;
  4262. /**
  4263. * Gets the highest frame rate of the animation
  4264. * @returns Highest frame rate of the animation
  4265. */
  4266. getHighestFrame(): number;
  4267. /**
  4268. * Gets the easing function of the animation
  4269. * @returns Easing function of the animation
  4270. */
  4271. getEasingFunction(): IEasingFunction;
  4272. /**
  4273. * Sets the easing function of the animation
  4274. * @param easingFunction A custom mathematical formula for animation
  4275. */
  4276. setEasingFunction(easingFunction: EasingFunction): void;
  4277. /**
  4278. * Interpolates a scalar linearly
  4279. * @param startValue Start value of the animation curve
  4280. * @param endValue End value of the animation curve
  4281. * @param gradient Scalar amount to interpolate
  4282. * @returns Interpolated scalar value
  4283. */
  4284. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4285. /**
  4286. * Interpolates a scalar cubically
  4287. * @param startValue Start value of the animation curve
  4288. * @param outTangent End tangent of the animation
  4289. * @param endValue End value of the animation curve
  4290. * @param inTangent Start tangent of the animation curve
  4291. * @param gradient Scalar amount to interpolate
  4292. * @returns Interpolated scalar value
  4293. */
  4294. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4295. /**
  4296. * Interpolates a quaternion using a spherical linear interpolation
  4297. * @param startValue Start value of the animation curve
  4298. * @param endValue End value of the animation curve
  4299. * @param gradient Scalar amount to interpolate
  4300. * @returns Interpolated quaternion value
  4301. */
  4302. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4303. /**
  4304. * Interpolates a quaternion cubically
  4305. * @param startValue Start value of the animation curve
  4306. * @param outTangent End tangent of the animation curve
  4307. * @param endValue End value of the animation curve
  4308. * @param inTangent Start tangent of the animation curve
  4309. * @param gradient Scalar amount to interpolate
  4310. * @returns Interpolated quaternion value
  4311. */
  4312. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4313. /**
  4314. * Interpolates a Vector3 linearl
  4315. * @param startValue Start value of the animation curve
  4316. * @param endValue End value of the animation curve
  4317. * @param gradient Scalar amount to interpolate
  4318. * @returns Interpolated scalar value
  4319. */
  4320. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4321. /**
  4322. * Interpolates a Vector3 cubically
  4323. * @param startValue Start value of the animation curve
  4324. * @param outTangent End tangent of the animation
  4325. * @param endValue End value of the animation curve
  4326. * @param inTangent Start tangent of the animation curve
  4327. * @param gradient Scalar amount to interpolate
  4328. * @returns InterpolatedVector3 value
  4329. */
  4330. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4331. /**
  4332. * Interpolates a Vector2 linearly
  4333. * @param startValue Start value of the animation curve
  4334. * @param endValue End value of the animation curve
  4335. * @param gradient Scalar amount to interpolate
  4336. * @returns Interpolated Vector2 value
  4337. */
  4338. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4339. /**
  4340. * Interpolates a Vector2 cubically
  4341. * @param startValue Start value of the animation curve
  4342. * @param outTangent End tangent of the animation
  4343. * @param endValue End value of the animation curve
  4344. * @param inTangent Start tangent of the animation curve
  4345. * @param gradient Scalar amount to interpolate
  4346. * @returns Interpolated Vector2 value
  4347. */
  4348. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4349. /**
  4350. * Interpolates a size linearly
  4351. * @param startValue Start value of the animation curve
  4352. * @param endValue End value of the animation curve
  4353. * @param gradient Scalar amount to interpolate
  4354. * @returns Interpolated Size value
  4355. */
  4356. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4357. /**
  4358. * Interpolates a Color3 linearly
  4359. * @param startValue Start value of the animation curve
  4360. * @param endValue End value of the animation curve
  4361. * @param gradient Scalar amount to interpolate
  4362. * @returns Interpolated Color3 value
  4363. */
  4364. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4365. /**
  4366. * @hidden Internal use only
  4367. */
  4368. _getKeyValue(value: any): any;
  4369. /**
  4370. * @hidden Internal use only
  4371. */
  4372. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4373. /**
  4374. * Defines the function to use to interpolate matrices
  4375. * @param startValue defines the start matrix
  4376. * @param endValue defines the end matrix
  4377. * @param gradient defines the gradient between both matrices
  4378. * @param result defines an optional target matrix where to store the interpolation
  4379. * @returns the interpolated matrix
  4380. */
  4381. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4382. /**
  4383. * Makes a copy of the animation
  4384. * @returns Cloned animation
  4385. */
  4386. clone(): Animation;
  4387. /**
  4388. * Sets the key frames of the animation
  4389. * @param values The animation key frames to set
  4390. */
  4391. setKeys(values: Array<IAnimationKey>): void;
  4392. /**
  4393. * Serializes the animation to an object
  4394. * @returns Serialized object
  4395. */
  4396. serialize(): any;
  4397. /**
  4398. * Float animation type
  4399. */
  4400. private static _ANIMATIONTYPE_FLOAT;
  4401. /**
  4402. * Vector3 animation type
  4403. */
  4404. private static _ANIMATIONTYPE_VECTOR3;
  4405. /**
  4406. * Quaternion animation type
  4407. */
  4408. private static _ANIMATIONTYPE_QUATERNION;
  4409. /**
  4410. * Matrix animation type
  4411. */
  4412. private static _ANIMATIONTYPE_MATRIX;
  4413. /**
  4414. * Color3 animation type
  4415. */
  4416. private static _ANIMATIONTYPE_COLOR3;
  4417. /**
  4418. * Vector2 animation type
  4419. */
  4420. private static _ANIMATIONTYPE_VECTOR2;
  4421. /**
  4422. * Size animation type
  4423. */
  4424. private static _ANIMATIONTYPE_SIZE;
  4425. /**
  4426. * Relative Loop Mode
  4427. */
  4428. private static _ANIMATIONLOOPMODE_RELATIVE;
  4429. /**
  4430. * Cycle Loop Mode
  4431. */
  4432. private static _ANIMATIONLOOPMODE_CYCLE;
  4433. /**
  4434. * Constant Loop Mode
  4435. */
  4436. private static _ANIMATIONLOOPMODE_CONSTANT;
  4437. /**
  4438. * Get the float animation type
  4439. */
  4440. static readonly ANIMATIONTYPE_FLOAT: number;
  4441. /**
  4442. * Get the Vector3 animation type
  4443. */
  4444. static readonly ANIMATIONTYPE_VECTOR3: number;
  4445. /**
  4446. * Get the Vector2 animation type
  4447. */
  4448. static readonly ANIMATIONTYPE_VECTOR2: number;
  4449. /**
  4450. * Get the Size animation type
  4451. */
  4452. static readonly ANIMATIONTYPE_SIZE: number;
  4453. /**
  4454. * Get the Quaternion animation type
  4455. */
  4456. static readonly ANIMATIONTYPE_QUATERNION: number;
  4457. /**
  4458. * Get the Matrix animation type
  4459. */
  4460. static readonly ANIMATIONTYPE_MATRIX: number;
  4461. /**
  4462. * Get the Color3 animation type
  4463. */
  4464. static readonly ANIMATIONTYPE_COLOR3: number;
  4465. /**
  4466. * Get the Relative Loop Mode
  4467. */
  4468. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4469. /**
  4470. * Get the Cycle Loop Mode
  4471. */
  4472. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4473. /**
  4474. * Get the Constant Loop Mode
  4475. */
  4476. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4477. /** @hidden */
  4478. static _UniversalLerp(left: any, right: any, amount: number): any;
  4479. /**
  4480. * Parses an animation object and creates an animation
  4481. * @param parsedAnimation Parsed animation object
  4482. * @returns Animation object
  4483. */
  4484. static Parse(parsedAnimation: any): Animation;
  4485. /**
  4486. * Appends the serialized animations from the source animations
  4487. * @param source Source containing the animations
  4488. * @param destination Target to store the animations
  4489. */
  4490. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4491. }
  4492. }
  4493. declare module BABYLON {
  4494. /**
  4495. * This class defines the direct association between an animation and a target
  4496. */
  4497. class TargetedAnimation {
  4498. /**
  4499. * Animation to perform
  4500. */
  4501. animation: Animation;
  4502. /**
  4503. * Target to animate
  4504. */
  4505. target: any;
  4506. }
  4507. /**
  4508. * Use this class to create coordinated animations on multiple targets
  4509. */
  4510. class AnimationGroup implements IDisposable {
  4511. /** The name of the animation group */
  4512. name: string;
  4513. private _scene;
  4514. private _targetedAnimations;
  4515. private _animatables;
  4516. private _from;
  4517. private _to;
  4518. private _isStarted;
  4519. private _speedRatio;
  4520. /**
  4521. * This observable will notify when one animation have ended.
  4522. */
  4523. onAnimationEndObservable: Observable<TargetedAnimation>;
  4524. /**
  4525. * This observable will notify when all animations have ended.
  4526. */
  4527. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4528. /**
  4529. * This observable will notify when all animations have paused.
  4530. */
  4531. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4532. /**
  4533. * Gets the first frame
  4534. */
  4535. readonly from: number;
  4536. /**
  4537. * Gets the last frame
  4538. */
  4539. readonly to: number;
  4540. /**
  4541. * Define if the animations are started
  4542. */
  4543. readonly isStarted: boolean;
  4544. /**
  4545. * Gets or sets the speed ratio to use for all animations
  4546. */
  4547. /**
  4548. * Gets or sets the speed ratio to use for all animations
  4549. */
  4550. speedRatio: number;
  4551. /**
  4552. * Gets the targeted animations for this animation group
  4553. */
  4554. readonly targetedAnimations: Array<TargetedAnimation>;
  4555. /**
  4556. * returning the list of animatables controlled by this animation group.
  4557. */
  4558. readonly animatables: Array<Animatable>;
  4559. /**
  4560. * Instantiates a new Animation Group.
  4561. * This helps managing several animations at once.
  4562. * @see http://doc.babylonjs.com/how_to/group
  4563. * @param name Defines the name of the group
  4564. * @param scene Defines the scene the group belongs to
  4565. */
  4566. constructor(
  4567. /** The name of the animation group */
  4568. name: string, scene?: Nullable<Scene>);
  4569. /**
  4570. * Add an animation (with its target) in the group
  4571. * @param animation defines the animation we want to add
  4572. * @param target defines the target of the animation
  4573. * @returns the TargetedAnimation object
  4574. */
  4575. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4576. /**
  4577. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4578. * It can add constant keys at begin or end
  4579. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4580. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4581. * @returns the animation group
  4582. */
  4583. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4584. /**
  4585. * Start all animations on given targets
  4586. * @param loop defines if animations must loop
  4587. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4588. * @param from defines the from key (optional)
  4589. * @param to defines the to key (optional)
  4590. * @returns the current animation group
  4591. */
  4592. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4593. /**
  4594. * Pause all animations
  4595. * @returns the animation group
  4596. */
  4597. pause(): AnimationGroup;
  4598. /**
  4599. * Play all animations to initial state
  4600. * This function will start() the animations if they were not started or will restart() them if they were paused
  4601. * @param loop defines if animations must loop
  4602. * @returns the animation group
  4603. */
  4604. play(loop?: boolean): AnimationGroup;
  4605. /**
  4606. * Reset all animations to initial state
  4607. * @returns the animation group
  4608. */
  4609. reset(): AnimationGroup;
  4610. /**
  4611. * Restart animations from key 0
  4612. * @returns the animation group
  4613. */
  4614. restart(): AnimationGroup;
  4615. /**
  4616. * Stop all animations
  4617. * @returns the animation group
  4618. */
  4619. stop(): AnimationGroup;
  4620. /**
  4621. * Set animation weight for all animatables
  4622. * @param weight defines the weight to use
  4623. * @return the animationGroup
  4624. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4625. */
  4626. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4627. /**
  4628. * Synchronize and normalize all animatables with a source animatable
  4629. * @param root defines the root animatable to synchronize with
  4630. * @return the animationGroup
  4631. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4632. */
  4633. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4634. /**
  4635. * Goes to a specific frame in this animation group
  4636. * @param frame the frame number to go to
  4637. * @return the animationGroup
  4638. */
  4639. goToFrame(frame: number): AnimationGroup;
  4640. /**
  4641. * Dispose all associated resources
  4642. */
  4643. dispose(): void;
  4644. private _checkAnimationGroupEnded;
  4645. /**
  4646. * Returns a new AnimationGroup object parsed from the source provided.
  4647. * @param parsedAnimationGroup defines the source
  4648. * @param scene defines the scene that will receive the animationGroup
  4649. * @returns a new AnimationGroup
  4650. */
  4651. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4652. /**
  4653. * Returns the string "AnimationGroup"
  4654. * @returns "AnimationGroup"
  4655. */
  4656. getClassName(): string;
  4657. /**
  4658. * Creates a detailled string about the object
  4659. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4660. * @returns a string representing the object
  4661. */
  4662. toString(fullDetails?: boolean): string;
  4663. }
  4664. }
  4665. declare module BABYLON {
  4666. /**
  4667. * Class used to override all child animations of a given target
  4668. */
  4669. class AnimationPropertiesOverride {
  4670. /**
  4671. * Gets or sets a value indicating if animation blending must be used
  4672. */
  4673. enableBlending: boolean;
  4674. /**
  4675. * Gets or sets the blending speed to use when enableBlending is true
  4676. */
  4677. blendingSpeed: number;
  4678. /**
  4679. * Gets or sets the default loop mode to use
  4680. */
  4681. loopMode: number;
  4682. }
  4683. }
  4684. declare module BABYLON {
  4685. /**
  4686. * This represents the main contract an easing function should follow.
  4687. * Easing functions are used throughout the animation system.
  4688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4689. */
  4690. interface IEasingFunction {
  4691. /**
  4692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4693. * of the easing function.
  4694. * The link below provides some of the most common examples of easing functions.
  4695. * @see https://easings.net/
  4696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4697. * @returns the corresponding value on the curve defined by the easing function
  4698. */
  4699. ease(gradient: number): number;
  4700. }
  4701. /**
  4702. * Base class used for every default easing function.
  4703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4704. */
  4705. class EasingFunction implements IEasingFunction {
  4706. /**
  4707. * Interpolation follows the mathematical formula associated with the easing function.
  4708. */
  4709. static readonly EASINGMODE_EASEIN: number;
  4710. /**
  4711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4712. */
  4713. static readonly EASINGMODE_EASEOUT: number;
  4714. /**
  4715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4716. */
  4717. static readonly EASINGMODE_EASEINOUT: number;
  4718. private _easingMode;
  4719. /**
  4720. * Sets the easing mode of the current function.
  4721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4722. */
  4723. setEasingMode(easingMode: number): void;
  4724. /**
  4725. * Gets the current easing mode.
  4726. * @returns the easing mode
  4727. */
  4728. getEasingMode(): number;
  4729. /**
  4730. * @hidden
  4731. */
  4732. easeInCore(gradient: number): number;
  4733. /**
  4734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4735. * of the easing function.
  4736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4737. * @returns the corresponding value on the curve defined by the easing function
  4738. */
  4739. ease(gradient: number): number;
  4740. }
  4741. /**
  4742. * Easing function with a circle shape (see link below).
  4743. * @see https://easings.net/#easeInCirc
  4744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4745. */
  4746. class CircleEase extends EasingFunction implements IEasingFunction {
  4747. /** @hidden */
  4748. easeInCore(gradient: number): number;
  4749. }
  4750. /**
  4751. * Easing function with a ease back shape (see link below).
  4752. * @see https://easings.net/#easeInBack
  4753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4754. */
  4755. class BackEase extends EasingFunction implements IEasingFunction {
  4756. /** Defines the amplitude of the function */
  4757. amplitude: number;
  4758. /**
  4759. * Instantiates a back ease easing
  4760. * @see https://easings.net/#easeInBack
  4761. * @param amplitude Defines the amplitude of the function
  4762. */
  4763. constructor(
  4764. /** Defines the amplitude of the function */
  4765. amplitude?: number);
  4766. /** @hidden */
  4767. easeInCore(gradient: number): number;
  4768. }
  4769. /**
  4770. * Easing function with a bouncing shape (see link below).
  4771. * @see https://easings.net/#easeInBounce
  4772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4773. */
  4774. class BounceEase extends EasingFunction implements IEasingFunction {
  4775. /** Defines the number of bounces */
  4776. bounces: number;
  4777. /** Defines the amplitude of the bounce */
  4778. bounciness: number;
  4779. /**
  4780. * Instantiates a bounce easing
  4781. * @see https://easings.net/#easeInBounce
  4782. * @param bounces Defines the number of bounces
  4783. * @param bounciness Defines the amplitude of the bounce
  4784. */
  4785. constructor(
  4786. /** Defines the number of bounces */
  4787. bounces?: number,
  4788. /** Defines the amplitude of the bounce */
  4789. bounciness?: number);
  4790. /** @hidden */
  4791. easeInCore(gradient: number): number;
  4792. }
  4793. /**
  4794. * Easing function with a power of 3 shape (see link below).
  4795. * @see https://easings.net/#easeInCubic
  4796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4797. */
  4798. class CubicEase extends EasingFunction implements IEasingFunction {
  4799. /** @hidden */
  4800. easeInCore(gradient: number): number;
  4801. }
  4802. /**
  4803. * Easing function with an elastic shape (see link below).
  4804. * @see https://easings.net/#easeInElastic
  4805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4806. */
  4807. class ElasticEase extends EasingFunction implements IEasingFunction {
  4808. /** Defines the number of oscillations*/
  4809. oscillations: number;
  4810. /** Defines the amplitude of the oscillations*/
  4811. springiness: number;
  4812. /**
  4813. * Instantiates an elastic easing function
  4814. * @see https://easings.net/#easeInElastic
  4815. * @param oscillations Defines the number of oscillations
  4816. * @param springiness Defines the amplitude of the oscillations
  4817. */
  4818. constructor(
  4819. /** Defines the number of oscillations*/
  4820. oscillations?: number,
  4821. /** Defines the amplitude of the oscillations*/
  4822. springiness?: number);
  4823. /** @hidden */
  4824. easeInCore(gradient: number): number;
  4825. }
  4826. /**
  4827. * Easing function with an exponential shape (see link below).
  4828. * @see https://easings.net/#easeInExpo
  4829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4830. */
  4831. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4832. /** Defines the exponent of the function */
  4833. exponent: number;
  4834. /**
  4835. * Instantiates an exponential easing function
  4836. * @see https://easings.net/#easeInExpo
  4837. * @param exponent Defines the exponent of the function
  4838. */
  4839. constructor(
  4840. /** Defines the exponent of the function */
  4841. exponent?: number);
  4842. /** @hidden */
  4843. easeInCore(gradient: number): number;
  4844. }
  4845. /**
  4846. * Easing function with a power shape (see link below).
  4847. * @see https://easings.net/#easeInQuad
  4848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4849. */
  4850. class PowerEase extends EasingFunction implements IEasingFunction {
  4851. /** Defines the power of the function */
  4852. power: number;
  4853. /**
  4854. * Instantiates an power base easing function
  4855. * @see https://easings.net/#easeInQuad
  4856. * @param power Defines the power of the function
  4857. */
  4858. constructor(
  4859. /** Defines the power of the function */
  4860. power?: number);
  4861. /** @hidden */
  4862. easeInCore(gradient: number): number;
  4863. }
  4864. /**
  4865. * Easing function with a power of 2 shape (see link below).
  4866. * @see https://easings.net/#easeInQuad
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4870. /** @hidden */
  4871. easeInCore(gradient: number): number;
  4872. }
  4873. /**
  4874. * Easing function with a power of 4 shape (see link below).
  4875. * @see https://easings.net/#easeInQuart
  4876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4877. */
  4878. class QuarticEase extends EasingFunction implements IEasingFunction {
  4879. /** @hidden */
  4880. easeInCore(gradient: number): number;
  4881. }
  4882. /**
  4883. * Easing function with a power of 5 shape (see link below).
  4884. * @see https://easings.net/#easeInQuint
  4885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4886. */
  4887. class QuinticEase extends EasingFunction implements IEasingFunction {
  4888. /** @hidden */
  4889. easeInCore(gradient: number): number;
  4890. }
  4891. /**
  4892. * Easing function with a sin shape (see link below).
  4893. * @see https://easings.net/#easeInSine
  4894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4895. */
  4896. class SineEase extends EasingFunction implements IEasingFunction {
  4897. /** @hidden */
  4898. easeInCore(gradient: number): number;
  4899. }
  4900. /**
  4901. * Easing function with a bezier shape (see link below).
  4902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4904. */
  4905. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4906. /** Defines the x component of the start tangent in the bezier curve */
  4907. x1: number;
  4908. /** Defines the y component of the start tangent in the bezier curve */
  4909. y1: number;
  4910. /** Defines the x component of the end tangent in the bezier curve */
  4911. x2: number;
  4912. /** Defines the y component of the end tangent in the bezier curve */
  4913. y2: number;
  4914. /**
  4915. * Instantiates a bezier function
  4916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4917. * @param x1 Defines the x component of the start tangent in the bezier curve
  4918. * @param y1 Defines the y component of the start tangent in the bezier curve
  4919. * @param x2 Defines the x component of the end tangent in the bezier curve
  4920. * @param y2 Defines the y component of the end tangent in the bezier curve
  4921. */
  4922. constructor(
  4923. /** Defines the x component of the start tangent in the bezier curve */
  4924. x1?: number,
  4925. /** Defines the y component of the start tangent in the bezier curve */
  4926. y1?: number,
  4927. /** Defines the x component of the end tangent in the bezier curve */
  4928. x2?: number,
  4929. /** Defines the y component of the end tangent in the bezier curve */
  4930. y2?: number);
  4931. /** @hidden */
  4932. easeInCore(gradient: number): number;
  4933. }
  4934. }
  4935. declare module BABYLON {
  4936. /**
  4937. * Defines a runtime animation
  4938. */
  4939. class RuntimeAnimation {
  4940. private _events;
  4941. /**
  4942. * The current frame of the runtime animation
  4943. */
  4944. private _currentFrame;
  4945. /**
  4946. * The animation used by the runtime animation
  4947. */
  4948. private _animation;
  4949. /**
  4950. * The target of the runtime animation
  4951. */
  4952. private _target;
  4953. /**
  4954. * The initiating animatable
  4955. */
  4956. private _host;
  4957. /**
  4958. * The original value of the runtime animation
  4959. */
  4960. private _originalValue;
  4961. /**
  4962. * The original blend value of the runtime animation
  4963. */
  4964. private _originalBlendValue;
  4965. /**
  4966. * The offsets cache of the runtime animation
  4967. */
  4968. private _offsetsCache;
  4969. /**
  4970. * The high limits cache of the runtime animation
  4971. */
  4972. private _highLimitsCache;
  4973. /**
  4974. * Specifies if the runtime animation has been stopped
  4975. */
  4976. private _stopped;
  4977. /**
  4978. * The blending factor of the runtime animation
  4979. */
  4980. private _blendingFactor;
  4981. /**
  4982. * The BabylonJS scene
  4983. */
  4984. private _scene;
  4985. /**
  4986. * The current value of the runtime animation
  4987. */
  4988. private _currentValue;
  4989. /** @hidden */
  4990. _workValue: any;
  4991. /**
  4992. * The active target of the runtime animation
  4993. */
  4994. private _activeTarget;
  4995. /**
  4996. * The target path of the runtime animation
  4997. */
  4998. private _targetPath;
  4999. /**
  5000. * The weight of the runtime animation
  5001. */
  5002. private _weight;
  5003. /**
  5004. * The ratio offset of the runtime animation
  5005. */
  5006. private _ratioOffset;
  5007. /**
  5008. * The previous delay of the runtime animation
  5009. */
  5010. private _previousDelay;
  5011. /**
  5012. * The previous ratio of the runtime animation
  5013. */
  5014. private _previousRatio;
  5015. /**
  5016. * Gets the current frame of the runtime animation
  5017. */
  5018. readonly currentFrame: number;
  5019. /**
  5020. * Gets the weight of the runtime animation
  5021. */
  5022. readonly weight: number;
  5023. /**
  5024. * Gets the current value of the runtime animation
  5025. */
  5026. readonly currentValue: any;
  5027. /**
  5028. * Gets the target path of the runtime animation
  5029. */
  5030. readonly targetPath: string;
  5031. /**
  5032. * Gets the actual target of the runtime animation
  5033. */
  5034. readonly target: any;
  5035. /**
  5036. * Create a new RuntimeAnimation object
  5037. * @param target defines the target of the animation
  5038. * @param animation defines the source animation object
  5039. * @param scene defines the hosting scene
  5040. * @param host defines the initiating Animatable
  5041. */
  5042. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5043. /**
  5044. * Gets the animation from the runtime animation
  5045. */
  5046. readonly animation: Animation;
  5047. /**
  5048. * Resets the runtime animation to the beginning
  5049. * @param restoreOriginal defines whether to restore the target property to the original value
  5050. */
  5051. reset(restoreOriginal?: boolean): void;
  5052. /**
  5053. * Specifies if the runtime animation is stopped
  5054. * @returns Boolean specifying if the runtime animation is stopped
  5055. */
  5056. isStopped(): boolean;
  5057. /**
  5058. * Disposes of the runtime animation
  5059. */
  5060. dispose(): void;
  5061. /**
  5062. * Interpolates the animation from the current frame
  5063. * @param currentFrame The frame to interpolate the animation to
  5064. * @param repeatCount The number of times that the animation should loop
  5065. * @param loopMode The type of looping mode to use
  5066. * @param offsetValue Animation offset value
  5067. * @param highLimitValue The high limit value
  5068. * @returns The interpolated value
  5069. */
  5070. private _interpolate;
  5071. /**
  5072. * Apply the interpolated value to the target
  5073. * @param currentValue defines the value computed by the animation
  5074. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5075. */
  5076. setValue(currentValue: any, weight?: number): void;
  5077. private _setValue;
  5078. /**
  5079. * Gets the loop pmode of the runtime animation
  5080. * @returns Loop Mode
  5081. */
  5082. private _getCorrectLoopMode;
  5083. /**
  5084. * Move the current animation to a given frame
  5085. * @param frame defines the frame to move to
  5086. */
  5087. goToFrame(frame: number): void;
  5088. /**
  5089. * @hidden Internal use only
  5090. */
  5091. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5092. /**
  5093. * Execute the current animation
  5094. * @param delay defines the delay to add to the current frame
  5095. * @param from defines the lower bound of the animation range
  5096. * @param to defines the upper bound of the animation range
  5097. * @param loop defines if the current animation must loop
  5098. * @param speedRatio defines the current speed ratio
  5099. * @param weight defines the weight of the animation (default is -1 so no weight)
  5100. * @returns a boolean indicating if the animation is running
  5101. */
  5102. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5103. }
  5104. }
  5105. declare module BABYLON {
  5106. /**
  5107. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5109. */
  5110. class Analyser {
  5111. /**
  5112. * Gets or sets the smoothing
  5113. * @ignorenaming
  5114. */
  5115. SMOOTHING: number;
  5116. /**
  5117. * Gets or sets the FFT table size
  5118. * @ignorenaming
  5119. */
  5120. FFT_SIZE: number;
  5121. /**
  5122. * Gets or sets the bar graph amplitude
  5123. * @ignorenaming
  5124. */
  5125. BARGRAPHAMPLITUDE: number;
  5126. /**
  5127. * Gets or sets the position of the debug canvas
  5128. * @ignorenaming
  5129. */
  5130. DEBUGCANVASPOS: {
  5131. x: number;
  5132. y: number;
  5133. };
  5134. /**
  5135. * Gets or sets the debug canvas size
  5136. * @ignorenaming
  5137. */
  5138. DEBUGCANVASSIZE: {
  5139. width: number;
  5140. height: number;
  5141. };
  5142. private _byteFreqs;
  5143. private _byteTime;
  5144. private _floatFreqs;
  5145. private _webAudioAnalyser;
  5146. private _debugCanvas;
  5147. private _debugCanvasContext;
  5148. private _scene;
  5149. private _registerFunc;
  5150. private _audioEngine;
  5151. /**
  5152. * Creates a new analyser
  5153. * @param scene defines hosting scene
  5154. */
  5155. constructor(scene: Scene);
  5156. /**
  5157. * Get the number of data values you will have to play with for the visualization
  5158. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5159. * @returns a number
  5160. */
  5161. getFrequencyBinCount(): number;
  5162. /**
  5163. * Gets the current frequency data as a byte array
  5164. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5165. * @returns a Uint8Array
  5166. */
  5167. getByteFrequencyData(): Uint8Array;
  5168. /**
  5169. * Gets the current waveform as a byte array
  5170. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5171. * @returns a Uint8Array
  5172. */
  5173. getByteTimeDomainData(): Uint8Array;
  5174. /**
  5175. * Gets the current frequency data as a float array
  5176. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5177. * @returns a Float32Array
  5178. */
  5179. getFloatFrequencyData(): Float32Array;
  5180. /**
  5181. * Renders the debug canvas
  5182. */
  5183. drawDebugCanvas(): void;
  5184. /**
  5185. * Stops rendering the debug canvas and removes it
  5186. */
  5187. stopDebugCanvas(): void;
  5188. /**
  5189. * Connects two audio nodes
  5190. * @param inputAudioNode defines first node to connect
  5191. * @param outputAudioNode defines second node to connect
  5192. */
  5193. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5194. /**
  5195. * Releases all associated resources
  5196. */
  5197. dispose(): void;
  5198. }
  5199. }
  5200. declare module BABYLON {
  5201. /**
  5202. * This represents an audio engine and it is responsible
  5203. * to play, synchronize and analyse sounds throughout the application.
  5204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5205. */
  5206. interface IAudioEngine extends IDisposable {
  5207. /**
  5208. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5209. */
  5210. readonly canUseWebAudio: boolean;
  5211. /**
  5212. * Gets the current AudioContext if available.
  5213. */
  5214. readonly audioContext: Nullable<AudioContext>;
  5215. /**
  5216. * The master gain node defines the global audio volume of your audio engine.
  5217. */
  5218. readonly masterGain: GainNode;
  5219. /**
  5220. * Gets whether or not mp3 are supported by your browser.
  5221. */
  5222. readonly isMP3supported: boolean;
  5223. /**
  5224. * Gets whether or not ogg are supported by your browser.
  5225. */
  5226. readonly isOGGsupported: boolean;
  5227. /**
  5228. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5229. * @ignoreNaming
  5230. */
  5231. WarnedWebAudioUnsupported: boolean;
  5232. /**
  5233. * Defines if the audio engine relies on a custom unlocked button.
  5234. * In this case, the embedded button will not be displayed.
  5235. */
  5236. useCustomUnlockedButton: boolean;
  5237. /**
  5238. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5239. */
  5240. readonly unlocked: boolean;
  5241. /**
  5242. * Event raised when audio has been unlocked on the browser.
  5243. */
  5244. onAudioUnlockedObservable: Observable<AudioEngine>;
  5245. /**
  5246. * Event raised when audio has been locked on the browser.
  5247. */
  5248. onAudioLockedObservable: Observable<AudioEngine>;
  5249. /**
  5250. * Flags the audio engine in Locked state.
  5251. * This happens due to new browser policies preventing audio to autoplay.
  5252. */
  5253. lock(): void;
  5254. /**
  5255. * Unlocks the audio engine once a user action has been done on the dom.
  5256. * This is helpful to resume play once browser policies have been satisfied.
  5257. */
  5258. unlock(): void;
  5259. }
  5260. /**
  5261. * This represents the default audio engine used in babylon.
  5262. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5264. */
  5265. class AudioEngine implements IAudioEngine {
  5266. private _audioContext;
  5267. private _audioContextInitialized;
  5268. private _muteButton;
  5269. private _hostElement;
  5270. /**
  5271. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5272. */
  5273. canUseWebAudio: boolean;
  5274. /**
  5275. * The master gain node defines the global audio volume of your audio engine.
  5276. */
  5277. masterGain: GainNode;
  5278. /**
  5279. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5280. * @ignoreNaming
  5281. */
  5282. WarnedWebAudioUnsupported: boolean;
  5283. /**
  5284. * Gets whether or not mp3 are supported by your browser.
  5285. */
  5286. isMP3supported: boolean;
  5287. /**
  5288. * Gets whether or not ogg are supported by your browser.
  5289. */
  5290. isOGGsupported: boolean;
  5291. /**
  5292. * Gets whether audio has been unlocked on the device.
  5293. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5294. * a user interaction has happened.
  5295. */
  5296. unlocked: boolean;
  5297. /**
  5298. * Defines if the audio engine relies on a custom unlocked button.
  5299. * In this case, the embedded button will not be displayed.
  5300. */
  5301. useCustomUnlockedButton: boolean;
  5302. /**
  5303. * Event raised when audio has been unlocked on the browser.
  5304. */
  5305. onAudioUnlockedObservable: Observable<AudioEngine>;
  5306. /**
  5307. * Event raised when audio has been locked on the browser.
  5308. */
  5309. onAudioLockedObservable: Observable<AudioEngine>;
  5310. /**
  5311. * Gets the current AudioContext if available.
  5312. */
  5313. readonly audioContext: Nullable<AudioContext>;
  5314. private _connectedAnalyser;
  5315. /**
  5316. * Instantiates a new audio engine.
  5317. *
  5318. * There should be only one per page as some browsers restrict the number
  5319. * of audio contexts you can create.
  5320. * @param hostElement defines the host element where to display the mute icon if necessary
  5321. */
  5322. constructor(hostElement?: Nullable<HTMLElement>);
  5323. /**
  5324. * Flags the audio engine in Locked state.
  5325. * This happens due to new browser policies preventing audio to autoplay.
  5326. */
  5327. lock(): void;
  5328. /**
  5329. * Unlocks the audio engine once a user action has been done on the dom.
  5330. * This is helpful to resume play once browser policies have been satisfied.
  5331. */
  5332. unlock(): void;
  5333. private _resumeAudioContext;
  5334. private _initializeAudioContext;
  5335. private _tryToRun;
  5336. private _triggerRunningState;
  5337. private _triggerSuspendedState;
  5338. private _displayMuteButton;
  5339. private _moveButtonToTopLeft;
  5340. private _onResize;
  5341. private _hideMuteButton;
  5342. /**
  5343. * Destroy and release the resources associated with the audio ccontext.
  5344. */
  5345. dispose(): void;
  5346. /**
  5347. * Gets the global volume sets on the master gain.
  5348. * @returns the global volume if set or -1 otherwise
  5349. */
  5350. getGlobalVolume(): number;
  5351. /**
  5352. * Sets the global volume of your experience (sets on the master gain).
  5353. * @param newVolume Defines the new global volume of the application
  5354. */
  5355. setGlobalVolume(newVolume: number): void;
  5356. /**
  5357. * Connect the audio engine to an audio analyser allowing some amazing
  5358. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5360. * @param analyser The analyser to connect to the engine
  5361. */
  5362. connectToAnalyser(analyser: Analyser): void;
  5363. }
  5364. }
  5365. declare module BABYLON {
  5366. interface AbstractScene {
  5367. /**
  5368. * The list of sounds used in the scene.
  5369. */
  5370. sounds: Nullable<Array<Sound>>;
  5371. }
  5372. interface Scene {
  5373. /**
  5374. * @hidden
  5375. * Backing field
  5376. */
  5377. _mainSoundTrack: SoundTrack;
  5378. /**
  5379. * The main sound track played by the scene.
  5380. * It cotains your primary collection of sounds.
  5381. */
  5382. mainSoundTrack: SoundTrack;
  5383. /**
  5384. * The list of sound tracks added to the scene
  5385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5386. */
  5387. soundTracks: Nullable<Array<SoundTrack>>;
  5388. /**
  5389. * Gets a sound using a given name
  5390. * @param name defines the name to search for
  5391. * @return the found sound or null if not found at all.
  5392. */
  5393. getSoundByName(name: string): Nullable<Sound>;
  5394. /**
  5395. * Gets or sets if audio support is enabled
  5396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5397. */
  5398. audioEnabled: boolean;
  5399. /**
  5400. * Gets or sets if audio will be output to headphones
  5401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5402. */
  5403. headphone: boolean;
  5404. }
  5405. /**
  5406. * Defines the sound scene component responsible to manage any sounds
  5407. * in a given scene.
  5408. */
  5409. class AudioSceneComponent implements ISceneSerializableComponent {
  5410. /**
  5411. * The component name helpfull to identify the component in the list of scene components.
  5412. */
  5413. readonly name: string;
  5414. /**
  5415. * The scene the component belongs to.
  5416. */
  5417. scene: Scene;
  5418. private _audioEnabled;
  5419. /**
  5420. * Gets whether audio is enabled or not.
  5421. * Please use related enable/disable method to switch state.
  5422. */
  5423. readonly audioEnabled: boolean;
  5424. private _headphone;
  5425. /**
  5426. * Gets whether audio is outputing to headphone or not.
  5427. * Please use the according Switch methods to change output.
  5428. */
  5429. readonly headphone: boolean;
  5430. /**
  5431. * Creates a new instance of the component for the given scene
  5432. * @param scene Defines the scene to register the component in
  5433. */
  5434. constructor(scene: Scene);
  5435. /**
  5436. * Registers the component in a given scene
  5437. */
  5438. register(): void;
  5439. /**
  5440. * Rebuilds the elements related to this component in case of
  5441. * context lost for instance.
  5442. */
  5443. rebuild(): void;
  5444. /**
  5445. * Serializes the component data to the specified json object
  5446. * @param serializationObject The object to serialize to
  5447. */
  5448. serialize(serializationObject: any): void;
  5449. /**
  5450. * Adds all the element from the container to the scene
  5451. * @param container the container holding the elements
  5452. */
  5453. addFromContainer(container: AbstractScene): void;
  5454. /**
  5455. * Removes all the elements in the container from the scene
  5456. * @param container contains the elements to remove
  5457. */
  5458. removeFromContainer(container: AbstractScene): void;
  5459. /**
  5460. * Disposes the component and the associated ressources.
  5461. */
  5462. dispose(): void;
  5463. /**
  5464. * Disables audio in the associated scene.
  5465. */
  5466. disableAudio(): void;
  5467. /**
  5468. * Enables audio in the associated scene.
  5469. */
  5470. enableAudio(): void;
  5471. /**
  5472. * Switch audio to headphone output.
  5473. */
  5474. switchAudioModeForHeadphones(): void;
  5475. /**
  5476. * Switch audio to normal speakers.
  5477. */
  5478. switchAudioModeForNormalSpeakers(): void;
  5479. private _afterRender;
  5480. }
  5481. }
  5482. declare module BABYLON {
  5483. /**
  5484. * Defines a sound that can be played in the application.
  5485. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5487. */
  5488. class Sound {
  5489. /**
  5490. * The name of the sound in the scene.
  5491. */
  5492. name: string;
  5493. /**
  5494. * Does the sound autoplay once loaded.
  5495. */
  5496. autoplay: boolean;
  5497. /**
  5498. * Does the sound loop after it finishes playing once.
  5499. */
  5500. loop: boolean;
  5501. /**
  5502. * Does the sound use a custom attenuation curve to simulate the falloff
  5503. * happening when the source gets further away from the camera.
  5504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5505. */
  5506. useCustomAttenuation: boolean;
  5507. /**
  5508. * The sound track id this sound belongs to.
  5509. */
  5510. soundTrackId: number;
  5511. /**
  5512. * Is this sound currently played.
  5513. */
  5514. isPlaying: boolean;
  5515. /**
  5516. * Is this sound currently paused.
  5517. */
  5518. isPaused: boolean;
  5519. /**
  5520. * Does this sound enables spatial sound.
  5521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5522. */
  5523. spatialSound: boolean;
  5524. /**
  5525. * Define the reference distance the sound should be heard perfectly.
  5526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5527. */
  5528. refDistance: number;
  5529. /**
  5530. * Define the roll off factor of spatial sounds.
  5531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5532. */
  5533. rolloffFactor: number;
  5534. /**
  5535. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5537. */
  5538. maxDistance: number;
  5539. /**
  5540. * Define the distance attenuation model the sound will follow.
  5541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5542. */
  5543. distanceModel: string;
  5544. /**
  5545. * @hidden
  5546. * Back Compat
  5547. **/
  5548. onended: () => any;
  5549. /**
  5550. * Observable event when the current playing sound finishes.
  5551. */
  5552. onEndedObservable: Observable<Sound>;
  5553. private _panningModel;
  5554. private _playbackRate;
  5555. private _streaming;
  5556. private _startTime;
  5557. private _startOffset;
  5558. private _position;
  5559. /** @hidden */
  5560. _positionInEmitterSpace: boolean;
  5561. private _localDirection;
  5562. private _volume;
  5563. private _isReadyToPlay;
  5564. private _isDirectional;
  5565. private _readyToPlayCallback;
  5566. private _audioBuffer;
  5567. private _soundSource;
  5568. private _streamingSource;
  5569. private _soundPanner;
  5570. private _soundGain;
  5571. private _inputAudioNode;
  5572. private _outputAudioNode;
  5573. private _coneInnerAngle;
  5574. private _coneOuterAngle;
  5575. private _coneOuterGain;
  5576. private _scene;
  5577. private _connectedMesh;
  5578. private _customAttenuationFunction;
  5579. private _registerFunc;
  5580. private _isOutputConnected;
  5581. private _htmlAudioElement;
  5582. private _urlType;
  5583. /**
  5584. * Create a sound and attach it to a scene
  5585. * @param name Name of your sound
  5586. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5587. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5588. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5589. */
  5590. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5591. /**
  5592. * Release the sound and its associated resources
  5593. */
  5594. dispose(): void;
  5595. /**
  5596. * Gets if the sounds is ready to be played or not.
  5597. * @returns true if ready, otherwise false
  5598. */
  5599. isReady(): boolean;
  5600. private _soundLoaded;
  5601. /**
  5602. * Sets the data of the sound from an audiobuffer
  5603. * @param audioBuffer The audioBuffer containing the data
  5604. */
  5605. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5606. /**
  5607. * Updates the current sounds options such as maxdistance, loop...
  5608. * @param options A JSON object containing values named as the object properties
  5609. */
  5610. updateOptions(options: any): void;
  5611. private _createSpatialParameters;
  5612. private _updateSpatialParameters;
  5613. /**
  5614. * Switch the panning model to HRTF:
  5615. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5617. */
  5618. switchPanningModelToHRTF(): void;
  5619. /**
  5620. * Switch the panning model to Equal Power:
  5621. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5623. */
  5624. switchPanningModelToEqualPower(): void;
  5625. private _switchPanningModel;
  5626. /**
  5627. * Connect this sound to a sound track audio node like gain...
  5628. * @param soundTrackAudioNode the sound track audio node to connect to
  5629. */
  5630. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5631. /**
  5632. * Transform this sound into a directional source
  5633. * @param coneInnerAngle Size of the inner cone in degree
  5634. * @param coneOuterAngle Size of the outer cone in degree
  5635. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5636. */
  5637. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5638. /**
  5639. * Gets or sets the inner angle for the directional cone.
  5640. */
  5641. /**
  5642. * Gets or sets the inner angle for the directional cone.
  5643. */
  5644. directionalConeInnerAngle: number;
  5645. /**
  5646. * Gets or sets the outer angle for the directional cone.
  5647. */
  5648. /**
  5649. * Gets or sets the outer angle for the directional cone.
  5650. */
  5651. directionalConeOuterAngle: number;
  5652. /**
  5653. * Sets the position of the emitter if spatial sound is enabled
  5654. * @param newPosition Defines the new posisiton
  5655. */
  5656. setPosition(newPosition: Vector3): void;
  5657. /**
  5658. * Sets the local direction of the emitter if spatial sound is enabled
  5659. * @param newLocalDirection Defines the new local direction
  5660. */
  5661. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5662. private _updateDirection;
  5663. /** @hidden */
  5664. updateDistanceFromListener(): void;
  5665. /**
  5666. * Sets a new custom attenuation function for the sound.
  5667. * @param callback Defines the function used for the attenuation
  5668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5669. */
  5670. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5671. /**
  5672. * Play the sound
  5673. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5674. * @param offset (optional) Start the sound setting it at a specific time
  5675. */
  5676. play(time?: number, offset?: number): void;
  5677. private _onended;
  5678. /**
  5679. * Stop the sound
  5680. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5681. */
  5682. stop(time?: number): void;
  5683. /**
  5684. * Put the sound in pause
  5685. */
  5686. pause(): void;
  5687. /**
  5688. * Sets a dedicated volume for this sounds
  5689. * @param newVolume Define the new volume of the sound
  5690. * @param time Define in how long the sound should be at this value
  5691. */
  5692. setVolume(newVolume: number, time?: number): void;
  5693. /**
  5694. * Set the sound play back rate
  5695. * @param newPlaybackRate Define the playback rate the sound should be played at
  5696. */
  5697. setPlaybackRate(newPlaybackRate: number): void;
  5698. /**
  5699. * Gets the volume of the sound.
  5700. * @returns the volume of the sound
  5701. */
  5702. getVolume(): number;
  5703. /**
  5704. * Attach the sound to a dedicated mesh
  5705. * @param meshToConnectTo The mesh to connect the sound with
  5706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5707. */
  5708. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5709. /**
  5710. * Detach the sound from the previously attached mesh
  5711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5712. */
  5713. detachFromMesh(): void;
  5714. private _onRegisterAfterWorldMatrixUpdate;
  5715. /**
  5716. * Clone the current sound in the scene.
  5717. * @returns the new sound clone
  5718. */
  5719. clone(): Nullable<Sound>;
  5720. /**
  5721. * Gets the current underlying audio buffer containing the data
  5722. * @returns the audio buffer
  5723. */
  5724. getAudioBuffer(): Nullable<AudioBuffer>;
  5725. /**
  5726. * Serializes the Sound in a JSON representation
  5727. * @returns the JSON representation of the sound
  5728. */
  5729. serialize(): any;
  5730. /**
  5731. * Parse a JSON representation of a sound to innstantiate in a given scene
  5732. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5733. * @param scene Define the scene the new parsed sound should be created in
  5734. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5735. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5736. * @returns the newly parsed sound
  5737. */
  5738. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5739. }
  5740. }
  5741. declare module BABYLON {
  5742. /**
  5743. * Options allowed during the creation of a sound track.
  5744. */
  5745. interface ISoundTrackOptions {
  5746. /**
  5747. * The volume the sound track should take during creation
  5748. */
  5749. volume?: number;
  5750. /**
  5751. * Define if the sound track is the main sound track of the scene
  5752. */
  5753. mainTrack?: boolean;
  5754. }
  5755. /**
  5756. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5757. * It will be also used in a future release to apply effects on a specific track.
  5758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5759. */
  5760. class SoundTrack {
  5761. /**
  5762. * The unique identifier of the sound track in the scene.
  5763. */
  5764. id: number;
  5765. /**
  5766. * The list of sounds included in the sound track.
  5767. */
  5768. soundCollection: Array<Sound>;
  5769. private _outputAudioNode;
  5770. private _scene;
  5771. private _isMainTrack;
  5772. private _connectedAnalyser;
  5773. private _options;
  5774. private _isInitialized;
  5775. /**
  5776. * Creates a new sound track.
  5777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5778. * @param scene Define the scene the sound track belongs to
  5779. * @param options
  5780. */
  5781. constructor(scene: Scene, options?: ISoundTrackOptions);
  5782. private _initializeSoundTrackAudioGraph;
  5783. /**
  5784. * Release the sound track and its associated resources
  5785. */
  5786. dispose(): void;
  5787. /**
  5788. * Adds a sound to this sound track
  5789. * @param sound define the cound to add
  5790. * @ignoreNaming
  5791. */
  5792. AddSound(sound: Sound): void;
  5793. /**
  5794. * Removes a sound to this sound track
  5795. * @param sound define the cound to remove
  5796. * @ignoreNaming
  5797. */
  5798. RemoveSound(sound: Sound): void;
  5799. /**
  5800. * Set a global volume for the full sound track.
  5801. * @param newVolume Define the new volume of the sound track
  5802. */
  5803. setVolume(newVolume: number): void;
  5804. /**
  5805. * Switch the panning model to HRTF:
  5806. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5808. */
  5809. switchPanningModelToHRTF(): void;
  5810. /**
  5811. * Switch the panning model to Equal Power:
  5812. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5814. */
  5815. switchPanningModelToEqualPower(): void;
  5816. /**
  5817. * Connect the sound track to an audio analyser allowing some amazing
  5818. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5820. * @param analyser The analyser to connect to the engine
  5821. */
  5822. connectToAnalyser(analyser: Analyser): void;
  5823. }
  5824. }
  5825. declare module BABYLON {
  5826. /**
  5827. * Wraps one or more Sound objects and selects one with random weight for playback.
  5828. */
  5829. class WeightedSound {
  5830. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5831. loop: boolean;
  5832. private _coneInnerAngle;
  5833. private _coneOuterAngle;
  5834. private _volume;
  5835. /** A Sound is currently playing. */
  5836. isPlaying: boolean;
  5837. /** A Sound is currently paused. */
  5838. isPaused: boolean;
  5839. private _sounds;
  5840. private _weights;
  5841. private _currentIndex?;
  5842. /**
  5843. * Creates a new WeightedSound from the list of sounds given.
  5844. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5845. * @param sounds Array of Sounds that will be selected from.
  5846. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5847. */
  5848. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5849. /**
  5850. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5851. */
  5852. /**
  5853. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5854. */
  5855. directionalConeInnerAngle: number;
  5856. /**
  5857. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5858. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5859. */
  5860. /**
  5861. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5862. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5863. */
  5864. directionalConeOuterAngle: number;
  5865. /**
  5866. * Playback volume.
  5867. */
  5868. /**
  5869. * Playback volume.
  5870. */
  5871. volume: number;
  5872. private _onended;
  5873. /**
  5874. * Suspend playback
  5875. */
  5876. pause(): void;
  5877. /**
  5878. * Stop playback
  5879. */
  5880. stop(): void;
  5881. /**
  5882. * Start playback.
  5883. * @param startOffset Position the clip head at a specific time in seconds.
  5884. */
  5885. play(startOffset?: number): void;
  5886. }
  5887. }
  5888. declare module BABYLON {
  5889. /**
  5890. * Interface used to define a behavior
  5891. */
  5892. interface Behavior<T> {
  5893. /** gets or sets behavior's name */
  5894. name: string;
  5895. /**
  5896. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5897. */
  5898. init(): void;
  5899. /**
  5900. * Called when the behavior is attached to a target
  5901. * @param target defines the target where the behavior is attached to
  5902. */
  5903. attach(target: T): void;
  5904. /**
  5905. * Called when the behavior is detached from its target
  5906. */
  5907. detach(): void;
  5908. }
  5909. /**
  5910. * Interface implemented by classes supporting behaviors
  5911. */
  5912. interface IBehaviorAware<T> {
  5913. /**
  5914. * Attach a behavior
  5915. * @param behavior defines the behavior to attach
  5916. * @returns the current host
  5917. */
  5918. addBehavior(behavior: Behavior<T>): T;
  5919. /**
  5920. * Remove a behavior from the current object
  5921. * @param behavior defines the behavior to detach
  5922. * @returns the current host
  5923. */
  5924. removeBehavior(behavior: Behavior<T>): T;
  5925. /**
  5926. * Gets a behavior using its name to search
  5927. * @param name defines the name to search
  5928. * @returns the behavior or null if not found
  5929. */
  5930. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Class used to store bone information
  5936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5937. */
  5938. class Bone extends Node {
  5939. /**
  5940. * defines the bone name
  5941. */
  5942. name: string;
  5943. private static _tmpVecs;
  5944. private static _tmpQuat;
  5945. private static _tmpMats;
  5946. /**
  5947. * Gets the list of child bones
  5948. */
  5949. children: Bone[];
  5950. /** Gets the animations associated with this bone */
  5951. animations: Animation[];
  5952. /**
  5953. * Gets or sets bone length
  5954. */
  5955. length: number;
  5956. /**
  5957. * @hidden Internal only
  5958. * Set this value to map this bone to a different index in the transform matrices
  5959. * Set this value to -1 to exclude the bone from the transform matrices
  5960. */
  5961. _index: Nullable<number>;
  5962. private _skeleton;
  5963. private _localMatrix;
  5964. private _restPose;
  5965. private _baseMatrix;
  5966. private _absoluteTransform;
  5967. private _invertedAbsoluteTransform;
  5968. private _parent;
  5969. private _scalingDeterminant;
  5970. private _worldTransform;
  5971. private _localScaling;
  5972. private _localRotation;
  5973. private _localPosition;
  5974. private _needToDecompose;
  5975. private _needToCompose;
  5976. /** @hidden */
  5977. /** @hidden */
  5978. _matrix: Matrix;
  5979. /**
  5980. * Create a new bone
  5981. * @param name defines the bone name
  5982. * @param skeleton defines the parent skeleton
  5983. * @param parentBone defines the parent (can be null if the bone is the root)
  5984. * @param localMatrix defines the local matrix
  5985. * @param restPose defines the rest pose matrix
  5986. * @param baseMatrix defines the base matrix
  5987. * @param index defines index of the bone in the hiearchy
  5988. */
  5989. constructor(
  5990. /**
  5991. * defines the bone name
  5992. */
  5993. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5994. /**
  5995. * Gets the parent skeleton
  5996. * @returns a skeleton
  5997. */
  5998. getSkeleton(): Skeleton;
  5999. /**
  6000. * Gets parent bone
  6001. * @returns a bone or null if the bone is the root of the bone hierarchy
  6002. */
  6003. getParent(): Nullable<Bone>;
  6004. /**
  6005. * Sets the parent bone
  6006. * @param parent defines the parent (can be null if the bone is the root)
  6007. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6008. */
  6009. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6010. /**
  6011. * Gets the local matrix
  6012. * @returns a matrix
  6013. */
  6014. getLocalMatrix(): Matrix;
  6015. /**
  6016. * Gets the base matrix (initial matrix which remains unchanged)
  6017. * @returns a matrix
  6018. */
  6019. getBaseMatrix(): Matrix;
  6020. /**
  6021. * Gets the rest pose matrix
  6022. * @returns a matrix
  6023. */
  6024. getRestPose(): Matrix;
  6025. /**
  6026. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6027. */
  6028. getWorldMatrix(): Matrix;
  6029. /**
  6030. * Sets the local matrix to rest pose matrix
  6031. */
  6032. returnToRest(): void;
  6033. /**
  6034. * Gets the inverse of the absolute transform matrix.
  6035. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6036. * @returns a matrix
  6037. */
  6038. getInvertedAbsoluteTransform(): Matrix;
  6039. /**
  6040. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6041. * @returns a matrix
  6042. */
  6043. getAbsoluteTransform(): Matrix;
  6044. /** Gets or sets current position (in local space) */
  6045. position: Vector3;
  6046. /** Gets or sets current rotation (in local space) */
  6047. rotation: Vector3;
  6048. /** Gets or sets current rotation quaternion (in local space) */
  6049. rotationQuaternion: Quaternion;
  6050. /** Gets or sets current scaling (in local space) */
  6051. scaling: Vector3;
  6052. /**
  6053. * Gets the animation properties override
  6054. */
  6055. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6056. private _decompose;
  6057. private _compose;
  6058. /**
  6059. * Update the base and local matrices
  6060. * @param matrix defines the new base or local matrix
  6061. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6062. * @param updateLocalMatrix defines if the local matrix should be updated
  6063. */
  6064. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6065. /** @hidden */
  6066. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6067. /**
  6068. * Flag the bone as dirty (Forcing it to update everything)
  6069. */
  6070. markAsDirty(): void;
  6071. private _markAsDirtyAndCompose;
  6072. private _markAsDirtyAndDecompose;
  6073. /**
  6074. * Copy an animation range from another bone
  6075. * @param source defines the source bone
  6076. * @param rangeName defines the range name to copy
  6077. * @param frameOffset defines the frame offset
  6078. * @param rescaleAsRequired defines if rescaling must be applied if required
  6079. * @param skelDimensionsRatio defines the scaling ratio
  6080. * @returns true if operation was successful
  6081. */
  6082. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6083. /**
  6084. * Translate the bone in local or world space
  6085. * @param vec The amount to translate the bone
  6086. * @param space The space that the translation is in
  6087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6088. */
  6089. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6090. /**
  6091. * Set the postion of the bone in local or world space
  6092. * @param position The position to set the bone
  6093. * @param space The space that the position is in
  6094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6095. */
  6096. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6097. /**
  6098. * Set the absolute position of the bone (world space)
  6099. * @param position The position to set the bone
  6100. * @param mesh The mesh that this bone is attached to
  6101. */
  6102. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6103. /**
  6104. * Scale the bone on the x, y and z axes (in local space)
  6105. * @param x The amount to scale the bone on the x axis
  6106. * @param y The amount to scale the bone on the y axis
  6107. * @param z The amount to scale the bone on the z axis
  6108. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6109. */
  6110. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6111. /**
  6112. * Set the bone scaling in local space
  6113. * @param scale defines the scaling vector
  6114. */
  6115. setScale(scale: Vector3): void;
  6116. /**
  6117. * Gets the current scaling in local space
  6118. * @returns the current scaling vector
  6119. */
  6120. getScale(): Vector3;
  6121. /**
  6122. * Gets the current scaling in local space and stores it in a target vector
  6123. * @param result defines the target vector
  6124. */
  6125. getScaleToRef(result: Vector3): void;
  6126. /**
  6127. * Set the yaw, pitch, and roll of the bone in local or world space
  6128. * @param yaw The rotation of the bone on the y axis
  6129. * @param pitch The rotation of the bone on the x axis
  6130. * @param roll The rotation of the bone on the z axis
  6131. * @param space The space that the axes of rotation are in
  6132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6133. */
  6134. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6135. /**
  6136. * Add a rotation to the bone on an axis in local or world space
  6137. * @param axis The axis to rotate the bone on
  6138. * @param amount The amount to rotate the bone
  6139. * @param space The space that the axis is in
  6140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6141. */
  6142. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6143. /**
  6144. * Set the rotation of the bone to a particular axis angle in local or world space
  6145. * @param axis The axis to rotate the bone on
  6146. * @param angle The angle that the bone should be rotated to
  6147. * @param space The space that the axis is in
  6148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6149. */
  6150. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6151. /**
  6152. * Set the euler rotation of the bone in local of world space
  6153. * @param rotation The euler rotation that the bone should be set to
  6154. * @param space The space that the rotation is in
  6155. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6156. */
  6157. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6158. /**
  6159. * Set the quaternion rotation of the bone in local of world space
  6160. * @param quat The quaternion rotation that the bone should be set to
  6161. * @param space The space that the rotation is in
  6162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6163. */
  6164. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6165. /**
  6166. * Set the rotation matrix of the bone in local of world space
  6167. * @param rotMat The rotation matrix that the bone should be set to
  6168. * @param space The space that the rotation is in
  6169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6170. */
  6171. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6172. private _rotateWithMatrix;
  6173. private _getNegativeRotationToRef;
  6174. /**
  6175. * Get the position of the bone in local or world space
  6176. * @param space The space that the returned position is in
  6177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6178. * @returns The position of the bone
  6179. */
  6180. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6181. /**
  6182. * Copy the position of the bone to a vector3 in local or world space
  6183. * @param space The space that the returned position is in
  6184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6185. * @param result The vector3 to copy the position to
  6186. */
  6187. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6188. /**
  6189. * Get the absolute position of the bone (world space)
  6190. * @param mesh The mesh that this bone is attached to
  6191. * @returns The absolute position of the bone
  6192. */
  6193. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6194. /**
  6195. * Copy the absolute position of the bone (world space) to the result param
  6196. * @param mesh The mesh that this bone is attached to
  6197. * @param result The vector3 to copy the absolute position to
  6198. */
  6199. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6200. /**
  6201. * Compute the absolute transforms of this bone and its children
  6202. */
  6203. computeAbsoluteTransforms(): void;
  6204. /**
  6205. * Get the world direction from an axis that is in the local space of the bone
  6206. * @param localAxis The local direction that is used to compute the world direction
  6207. * @param mesh The mesh that this bone is attached to
  6208. * @returns The world direction
  6209. */
  6210. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6211. /**
  6212. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6213. * @param localAxis The local direction that is used to compute the world direction
  6214. * @param mesh The mesh that this bone is attached to
  6215. * @param result The vector3 that the world direction will be copied to
  6216. */
  6217. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6218. /**
  6219. * Get the euler rotation of the bone in local or world space
  6220. * @param space The space that the rotation should be in
  6221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6222. * @returns The euler rotation
  6223. */
  6224. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6225. /**
  6226. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6227. * @param space The space that the rotation should be in
  6228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6229. * @param result The vector3 that the rotation should be copied to
  6230. */
  6231. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6232. /**
  6233. * Get the quaternion rotation of the bone in either local or world space
  6234. * @param space The space that the rotation should be in
  6235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6236. * @returns The quaternion rotation
  6237. */
  6238. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6239. /**
  6240. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6241. * @param space The space that the rotation should be in
  6242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6243. * @param result The quaternion that the rotation should be copied to
  6244. */
  6245. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6246. /**
  6247. * Get the rotation matrix of the bone in local or world space
  6248. * @param space The space that the rotation should be in
  6249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6250. * @returns The rotation matrix
  6251. */
  6252. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6253. /**
  6254. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6255. * @param space The space that the rotation should be in
  6256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6257. * @param result The quaternion that the rotation should be copied to
  6258. */
  6259. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6260. /**
  6261. * Get the world position of a point that is in the local space of the bone
  6262. * @param position The local position
  6263. * @param mesh The mesh that this bone is attached to
  6264. * @returns The world position
  6265. */
  6266. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6267. /**
  6268. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6269. * @param position The local position
  6270. * @param mesh The mesh that this bone is attached to
  6271. * @param result The vector3 that the world position should be copied to
  6272. */
  6273. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6274. /**
  6275. * Get the local position of a point that is in world space
  6276. * @param position The world position
  6277. * @param mesh The mesh that this bone is attached to
  6278. * @returns The local position
  6279. */
  6280. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6281. /**
  6282. * Get the local position of a point that is in world space and copy it to the result param
  6283. * @param position The world position
  6284. * @param mesh The mesh that this bone is attached to
  6285. * @param result The vector3 that the local position should be copied to
  6286. */
  6287. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6288. }
  6289. }
  6290. declare module BABYLON {
  6291. /**
  6292. * Class used to apply inverse kinematics to bones
  6293. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6294. */
  6295. class BoneIKController {
  6296. private static _tmpVecs;
  6297. private static _tmpQuat;
  6298. private static _tmpMats;
  6299. /**
  6300. * Gets or sets the target mesh
  6301. */
  6302. targetMesh: AbstractMesh;
  6303. /** Gets or sets the mesh used as pole */
  6304. poleTargetMesh: AbstractMesh;
  6305. /**
  6306. * Gets or sets the bone used as pole
  6307. */
  6308. poleTargetBone: Nullable<Bone>;
  6309. /**
  6310. * Gets or sets the target position
  6311. */
  6312. targetPosition: Vector3;
  6313. /**
  6314. * Gets or sets the pole target position
  6315. */
  6316. poleTargetPosition: Vector3;
  6317. /**
  6318. * Gets or sets the pole target local offset
  6319. */
  6320. poleTargetLocalOffset: Vector3;
  6321. /**
  6322. * Gets or sets the pole angle
  6323. */
  6324. poleAngle: number;
  6325. /**
  6326. * Gets or sets the mesh associated with the controller
  6327. */
  6328. mesh: AbstractMesh;
  6329. /**
  6330. * 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)
  6331. */
  6332. slerpAmount: number;
  6333. private _bone1Quat;
  6334. private _bone1Mat;
  6335. private _bone2Ang;
  6336. private _bone1;
  6337. private _bone2;
  6338. private _bone1Length;
  6339. private _bone2Length;
  6340. private _maxAngle;
  6341. private _maxReach;
  6342. private _rightHandedSystem;
  6343. private _bendAxis;
  6344. private _slerping;
  6345. private _adjustRoll;
  6346. /**
  6347. * Gets or sets maximum allowed angle
  6348. */
  6349. maxAngle: number;
  6350. /**
  6351. * Creates a new BoneIKController
  6352. * @param mesh defines the mesh to control
  6353. * @param bone defines the bone to control
  6354. * @param options defines options to set up the controller
  6355. */
  6356. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6357. targetMesh?: AbstractMesh;
  6358. poleTargetMesh?: AbstractMesh;
  6359. poleTargetBone?: Bone;
  6360. poleTargetLocalOffset?: Vector3;
  6361. poleAngle?: number;
  6362. bendAxis?: Vector3;
  6363. maxAngle?: number;
  6364. slerpAmount?: number;
  6365. });
  6366. private _setMaxAngle;
  6367. /**
  6368. * Force the controller to update the bones
  6369. */
  6370. update(): void;
  6371. }
  6372. }
  6373. declare module BABYLON {
  6374. /**
  6375. * Class used to make a bone look toward a point in space
  6376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6377. */
  6378. class BoneLookController {
  6379. private static _tmpVecs;
  6380. private static _tmpQuat;
  6381. private static _tmpMats;
  6382. /**
  6383. * The target Vector3 that the bone will look at
  6384. */
  6385. target: Vector3;
  6386. /**
  6387. * The mesh that the bone is attached to
  6388. */
  6389. mesh: AbstractMesh;
  6390. /**
  6391. * The bone that will be looking to the target
  6392. */
  6393. bone: Bone;
  6394. /**
  6395. * The up axis of the coordinate system that is used when the bone is rotated
  6396. */
  6397. upAxis: Vector3;
  6398. /**
  6399. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6400. */
  6401. upAxisSpace: Space;
  6402. /**
  6403. * Used to make an adjustment to the yaw of the bone
  6404. */
  6405. adjustYaw: number;
  6406. /**
  6407. * Used to make an adjustment to the pitch of the bone
  6408. */
  6409. adjustPitch: number;
  6410. /**
  6411. * Used to make an adjustment to the roll of the bone
  6412. */
  6413. adjustRoll: number;
  6414. /**
  6415. * 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)
  6416. */
  6417. slerpAmount: number;
  6418. private _minYaw;
  6419. private _maxYaw;
  6420. private _minPitch;
  6421. private _maxPitch;
  6422. private _minYawSin;
  6423. private _minYawCos;
  6424. private _maxYawSin;
  6425. private _maxYawCos;
  6426. private _midYawConstraint;
  6427. private _minPitchTan;
  6428. private _maxPitchTan;
  6429. private _boneQuat;
  6430. private _slerping;
  6431. private _transformYawPitch;
  6432. private _transformYawPitchInv;
  6433. private _firstFrameSkipped;
  6434. private _yawRange;
  6435. private _fowardAxis;
  6436. /**
  6437. * Gets or sets the minimum yaw angle that the bone can look to
  6438. */
  6439. minYaw: number;
  6440. /**
  6441. * Gets or sets the maximum yaw angle that the bone can look to
  6442. */
  6443. maxYaw: number;
  6444. /**
  6445. * Gets or sets the minimum pitch angle that the bone can look to
  6446. */
  6447. minPitch: number;
  6448. /**
  6449. * Gets or sets the maximum pitch angle that the bone can look to
  6450. */
  6451. maxPitch: number;
  6452. /**
  6453. * Create a BoneLookController
  6454. * @param mesh the mesh that the bone belongs to
  6455. * @param bone the bone that will be looking to the target
  6456. * @param target the target Vector3 to look at
  6457. * @param settings optional settings:
  6458. * * maxYaw: the maximum angle the bone will yaw to
  6459. * * minYaw: the minimum angle the bone will yaw to
  6460. * * maxPitch: the maximum angle the bone will pitch to
  6461. * * minPitch: the minimum angle the bone will yaw to
  6462. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6463. * * upAxis: the up axis of the coordinate system
  6464. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6465. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6466. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6467. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6468. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6469. * * adjustRoll: used to make an adjustment to the roll of the bone
  6470. **/
  6471. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6472. maxYaw?: number;
  6473. minYaw?: number;
  6474. maxPitch?: number;
  6475. minPitch?: number;
  6476. slerpAmount?: number;
  6477. upAxis?: Vector3;
  6478. upAxisSpace?: Space;
  6479. yawAxis?: Vector3;
  6480. pitchAxis?: Vector3;
  6481. adjustYaw?: number;
  6482. adjustPitch?: number;
  6483. adjustRoll?: number;
  6484. });
  6485. /**
  6486. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6487. */
  6488. update(): void;
  6489. private _getAngleDiff;
  6490. private _getAngleBetween;
  6491. private _isAngleBetween;
  6492. }
  6493. }
  6494. declare module BABYLON {
  6495. /**
  6496. * Class used to handle skinning animations
  6497. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6498. */
  6499. class Skeleton implements IAnimatable {
  6500. /** defines the skeleton name */
  6501. name: string;
  6502. /** defines the skeleton Id */
  6503. id: string;
  6504. /**
  6505. * Gets the list of child bones
  6506. */
  6507. bones: Bone[];
  6508. /**
  6509. * Gets an estimate of the dimension of the skeleton at rest
  6510. */
  6511. dimensionsAtRest: Vector3;
  6512. /**
  6513. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6514. */
  6515. needInitialSkinMatrix: boolean;
  6516. /**
  6517. * Gets the list of animations attached to this skeleton
  6518. */
  6519. animations: Array<Animation>;
  6520. private _scene;
  6521. private _isDirty;
  6522. private _transformMatrices;
  6523. private _transformMatrixTexture;
  6524. private _meshesWithPoseMatrix;
  6525. private _animatables;
  6526. private _identity;
  6527. private _synchronizedWithMesh;
  6528. private _ranges;
  6529. private _lastAbsoluteTransformsUpdateId;
  6530. private _canUseTextureForBones;
  6531. /**
  6532. * Specifies if the skeleton should be serialized
  6533. */
  6534. doNotSerialize: boolean;
  6535. /**
  6536. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6537. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6538. */
  6539. useTextureToStoreBoneMatrices: boolean;
  6540. private _animationPropertiesOverride;
  6541. /**
  6542. * Gets or sets the animation properties override
  6543. */
  6544. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6545. /**
  6546. * An observable triggered before computing the skeleton's matrices
  6547. */
  6548. onBeforeComputeObservable: Observable<Skeleton>;
  6549. /**
  6550. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6551. */
  6552. readonly isUsingTextureForMatrices: boolean;
  6553. /**
  6554. * Creates a new skeleton
  6555. * @param name defines the skeleton name
  6556. * @param id defines the skeleton Id
  6557. * @param scene defines the hosting scene
  6558. */
  6559. constructor(
  6560. /** defines the skeleton name */
  6561. name: string,
  6562. /** defines the skeleton Id */
  6563. id: string, scene: Scene);
  6564. /**
  6565. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6566. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6567. * @returns a Float32Array containing matrices data
  6568. */
  6569. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6570. /**
  6571. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6572. * @returns a raw texture containing the data
  6573. */
  6574. getTransformMatrixTexture(): Nullable<RawTexture>;
  6575. /**
  6576. * Gets the current hosting scene
  6577. * @returns a scene object
  6578. */
  6579. getScene(): Scene;
  6580. /**
  6581. * Gets a string representing the current skeleton data
  6582. * @param fullDetails defines a boolean indicating if we want a verbose version
  6583. * @returns a string representing the current skeleton data
  6584. */
  6585. toString(fullDetails?: boolean): string;
  6586. /**
  6587. * Get bone's index searching by name
  6588. * @param name defines bone's name to search for
  6589. * @return the indice of the bone. Returns -1 if not found
  6590. */
  6591. getBoneIndexByName(name: string): number;
  6592. /**
  6593. * Creater a new animation range
  6594. * @param name defines the name of the range
  6595. * @param from defines the start key
  6596. * @param to defines the end key
  6597. */
  6598. createAnimationRange(name: string, from: number, to: number): void;
  6599. /**
  6600. * Delete a specific animation range
  6601. * @param name defines the name of the range
  6602. * @param deleteFrames defines if frames must be removed as well
  6603. */
  6604. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6605. /**
  6606. * Gets a specific animation range
  6607. * @param name defines the name of the range to look for
  6608. * @returns the requested animation range or null if not found
  6609. */
  6610. getAnimationRange(name: string): Nullable<AnimationRange>;
  6611. /**
  6612. * Gets the list of all animation ranges defined on this skeleton
  6613. * @returns an array
  6614. */
  6615. getAnimationRanges(): Nullable<AnimationRange>[];
  6616. /**
  6617. * Copy animation range from a source skeleton.
  6618. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6619. * @param source defines the source skeleton
  6620. * @param name defines the name of the range to copy
  6621. * @param rescaleAsRequired defines if rescaling must be applied if required
  6622. * @returns true if operation was successful
  6623. */
  6624. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6625. /**
  6626. * Forces the skeleton to go to rest pose
  6627. */
  6628. returnToRest(): void;
  6629. private _getHighestAnimationFrame;
  6630. /**
  6631. * Begin a specific animation range
  6632. * @param name defines the name of the range to start
  6633. * @param loop defines if looping must be turned on (false by default)
  6634. * @param speedRatio defines the speed ratio to apply (1 by default)
  6635. * @param onAnimationEnd defines a callback which will be called when animation will end
  6636. * @returns a new animatable
  6637. */
  6638. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6639. /** @hidden */
  6640. _markAsDirty(): void;
  6641. /** @hidden */
  6642. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6643. /** @hidden */
  6644. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6645. private _computeTransformMatrices;
  6646. /**
  6647. * Build all resources required to render a skeleton
  6648. */
  6649. prepare(): void;
  6650. /**
  6651. * Gets the list of animatables currently running for this skeleton
  6652. * @returns an array of animatables
  6653. */
  6654. getAnimatables(): IAnimatable[];
  6655. /**
  6656. * Clone the current skeleton
  6657. * @param name defines the name of the new skeleton
  6658. * @param id defines the id of the enw skeleton
  6659. * @returns the new skeleton
  6660. */
  6661. clone(name: string, id: string): Skeleton;
  6662. /**
  6663. * Enable animation blending for this skeleton
  6664. * @param blendingSpeed defines the blending speed to apply
  6665. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6666. */
  6667. enableBlending(blendingSpeed?: number): void;
  6668. /**
  6669. * Releases all resources associated with the current skeleton
  6670. */
  6671. dispose(): void;
  6672. /**
  6673. * Serialize the skeleton in a JSON object
  6674. * @returns a JSON object
  6675. */
  6676. serialize(): any;
  6677. /**
  6678. * Creates a new skeleton from serialized data
  6679. * @param parsedSkeleton defines the serialized data
  6680. * @param scene defines the hosting scene
  6681. * @returns a new skeleton
  6682. */
  6683. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6684. /**
  6685. * Compute all node absolute transforms
  6686. * @param forceUpdate defines if computation must be done even if cache is up to date
  6687. */
  6688. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6689. /**
  6690. * Gets the root pose matrix
  6691. * @returns a matrix
  6692. */
  6693. getPoseMatrix(): Nullable<Matrix>;
  6694. /**
  6695. * Sorts bones per internal index
  6696. */
  6697. sortBones(): void;
  6698. private _sortBones;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /** @hidden */
  6703. class Collider {
  6704. /** Define if a collision was found */
  6705. collisionFound: boolean;
  6706. /**
  6707. * Define last intersection point in local space
  6708. */
  6709. intersectionPoint: Vector3;
  6710. /**
  6711. * Define last collided mesh
  6712. */
  6713. collidedMesh: Nullable<AbstractMesh>;
  6714. private _collisionPoint;
  6715. private _planeIntersectionPoint;
  6716. private _tempVector;
  6717. private _tempVector2;
  6718. private _tempVector3;
  6719. private _tempVector4;
  6720. private _edge;
  6721. private _baseToVertex;
  6722. private _destinationPoint;
  6723. private _slidePlaneNormal;
  6724. private _displacementVector;
  6725. /** @hidden */
  6726. _radius: Vector3;
  6727. /** @hidden */
  6728. _retry: number;
  6729. private _velocity;
  6730. private _basePoint;
  6731. private _epsilon;
  6732. /** @hidden */
  6733. _velocityWorldLength: number;
  6734. /** @hidden */
  6735. _basePointWorld: Vector3;
  6736. private _velocityWorld;
  6737. private _normalizedVelocity;
  6738. /** @hidden */
  6739. _initialVelocity: Vector3;
  6740. /** @hidden */
  6741. _initialPosition: Vector3;
  6742. private _nearestDistance;
  6743. private _collisionMask;
  6744. collisionMask: number;
  6745. /**
  6746. * Gets the plane normal used to compute the sliding response (in local space)
  6747. */
  6748. readonly slidePlaneNormal: Vector3;
  6749. /** @hidden */
  6750. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6751. /** @hidden */
  6752. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6753. /** @hidden */
  6754. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6755. /** @hidden */
  6756. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6757. /** @hidden */
  6758. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6759. /** @hidden */
  6760. _getResponse(pos: Vector3, vel: Vector3): void;
  6761. }
  6762. }
  6763. declare module BABYLON {
  6764. /** @hidden */
  6765. var CollisionWorker: string;
  6766. /** @hidden */
  6767. interface ICollisionCoordinator {
  6768. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6769. init(scene: Scene): void;
  6770. destroy(): void;
  6771. onMeshAdded(mesh: AbstractMesh): void;
  6772. onMeshUpdated(mesh: AbstractMesh): void;
  6773. onMeshRemoved(mesh: AbstractMesh): void;
  6774. onGeometryAdded(geometry: Geometry): void;
  6775. onGeometryUpdated(geometry: Geometry): void;
  6776. onGeometryDeleted(geometry: Geometry): void;
  6777. }
  6778. /** @hidden */
  6779. interface SerializedMesh {
  6780. id: string;
  6781. name: string;
  6782. uniqueId: number;
  6783. geometryId: Nullable<string>;
  6784. sphereCenter: Array<number>;
  6785. sphereRadius: number;
  6786. boxMinimum: Array<number>;
  6787. boxMaximum: Array<number>;
  6788. worldMatrixFromCache: any;
  6789. subMeshes: Array<SerializedSubMesh>;
  6790. checkCollisions: boolean;
  6791. }
  6792. /** @hidden */
  6793. interface SerializedSubMesh {
  6794. position: number;
  6795. verticesStart: number;
  6796. verticesCount: number;
  6797. indexStart: number;
  6798. indexCount: number;
  6799. hasMaterial: boolean;
  6800. sphereCenter: Array<number>;
  6801. sphereRadius: number;
  6802. boxMinimum: Array<number>;
  6803. boxMaximum: Array<number>;
  6804. }
  6805. /**
  6806. * Interface describing the value associated with a geometry.
  6807. * @hidden
  6808. */
  6809. interface SerializedGeometry {
  6810. /**
  6811. * Defines the unique ID of the geometry
  6812. */
  6813. id: string;
  6814. /**
  6815. * Defines the array containing the positions
  6816. */
  6817. positions: Float32Array;
  6818. /**
  6819. * Defines the array containing the indices
  6820. */
  6821. indices: Uint32Array;
  6822. /**
  6823. * Defines the array containing the normals
  6824. */
  6825. normals: Float32Array;
  6826. }
  6827. /** @hidden */
  6828. interface BabylonMessage {
  6829. taskType: WorkerTaskType;
  6830. payload: InitPayload | CollidePayload | UpdatePayload;
  6831. }
  6832. /** @hidden */
  6833. interface SerializedColliderToWorker {
  6834. position: Array<number>;
  6835. velocity: Array<number>;
  6836. radius: Array<number>;
  6837. }
  6838. /** Defines supported task for worker process */
  6839. enum WorkerTaskType {
  6840. /** Initialization */
  6841. INIT = 0,
  6842. /** Update of geometry */
  6843. UPDATE = 1,
  6844. /** Evaluate collision */
  6845. COLLIDE = 2
  6846. }
  6847. /** @hidden */
  6848. interface WorkerReply {
  6849. error: WorkerReplyType;
  6850. taskType: WorkerTaskType;
  6851. payload?: any;
  6852. }
  6853. /** @hidden */
  6854. interface CollisionReplyPayload {
  6855. newPosition: Array<number>;
  6856. collisionId: number;
  6857. collidedMeshUniqueId: number;
  6858. }
  6859. /** @hidden */
  6860. interface InitPayload {
  6861. }
  6862. /** @hidden */
  6863. interface CollidePayload {
  6864. collisionId: number;
  6865. collider: SerializedColliderToWorker;
  6866. maximumRetry: number;
  6867. excludedMeshUniqueId: Nullable<number>;
  6868. }
  6869. /** @hidden */
  6870. interface UpdatePayload {
  6871. updatedMeshes: {
  6872. [n: number]: SerializedMesh;
  6873. };
  6874. updatedGeometries: {
  6875. [s: string]: SerializedGeometry;
  6876. };
  6877. removedMeshes: Array<number>;
  6878. removedGeometries: Array<string>;
  6879. }
  6880. /** Defines kind of replies returned by worker */
  6881. enum WorkerReplyType {
  6882. /** Success */
  6883. SUCCESS = 0,
  6884. /** Unkown error */
  6885. UNKNOWN_ERROR = 1
  6886. }
  6887. /** @hidden */
  6888. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6889. private _scene;
  6890. private _scaledPosition;
  6891. private _scaledVelocity;
  6892. private _collisionsCallbackArray;
  6893. private _init;
  6894. private _runningUpdated;
  6895. private _worker;
  6896. private _addUpdateMeshesList;
  6897. private _addUpdateGeometriesList;
  6898. private _toRemoveMeshesArray;
  6899. private _toRemoveGeometryArray;
  6900. constructor();
  6901. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6902. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6903. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6904. init(scene: Scene): void;
  6905. destroy(): void;
  6906. onMeshAdded(mesh: AbstractMesh): void;
  6907. onMeshUpdated: (transformNode: TransformNode) => void;
  6908. onMeshRemoved(mesh: AbstractMesh): void;
  6909. onGeometryAdded(geometry: Geometry): void;
  6910. onGeometryUpdated: (geometry: Geometry) => void;
  6911. onGeometryDeleted(geometry: Geometry): void;
  6912. private _afterRender;
  6913. private _onMessageFromWorker;
  6914. }
  6915. /** @hidden */
  6916. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6917. private _scene;
  6918. private _scaledPosition;
  6919. private _scaledVelocity;
  6920. private _finalPosition;
  6921. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6922. init(scene: Scene): void;
  6923. destroy(): void;
  6924. onMeshAdded(mesh: AbstractMesh): void;
  6925. onMeshUpdated(mesh: AbstractMesh): void;
  6926. onMeshRemoved(mesh: AbstractMesh): void;
  6927. onGeometryAdded(geometry: Geometry): void;
  6928. onGeometryUpdated(geometry: Geometry): void;
  6929. onGeometryDeleted(geometry: Geometry): void;
  6930. private _collideWithWorld;
  6931. }
  6932. }
  6933. declare function importScripts(...urls: string[]): void;
  6934. declare const safePostMessage: any;
  6935. declare module BABYLON {
  6936. /** @hidden */
  6937. var WorkerIncluded: boolean;
  6938. /** @hidden */
  6939. class CollisionCache {
  6940. private _meshes;
  6941. private _geometries;
  6942. getMeshes(): {
  6943. [n: number]: SerializedMesh;
  6944. };
  6945. getGeometries(): {
  6946. [s: number]: SerializedGeometry;
  6947. };
  6948. getMesh(id: any): SerializedMesh;
  6949. addMesh(mesh: SerializedMesh): void;
  6950. removeMesh(uniqueId: number): void;
  6951. getGeometry(id: string): SerializedGeometry;
  6952. addGeometry(geometry: SerializedGeometry): void;
  6953. removeGeometry(id: string): void;
  6954. }
  6955. /** @hidden */
  6956. class CollideWorker {
  6957. collider: Collider;
  6958. private _collisionCache;
  6959. private finalPosition;
  6960. private collisionsScalingMatrix;
  6961. private collisionTranformationMatrix;
  6962. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6963. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6964. private checkCollision;
  6965. private processCollisionsForSubMeshes;
  6966. private collideForSubMesh;
  6967. private checkSubmeshCollision;
  6968. }
  6969. /** @hidden */
  6970. interface ICollisionDetector {
  6971. onInit(payload: InitPayload): void;
  6972. onUpdate(payload: UpdatePayload): void;
  6973. onCollision(payload: CollidePayload): void;
  6974. }
  6975. /** @hidden */
  6976. class CollisionDetectorTransferable implements ICollisionDetector {
  6977. private _collisionCache;
  6978. onInit(payload: InitPayload): void;
  6979. onUpdate(payload: UpdatePayload): void;
  6980. onCollision(payload: CollidePayload): void;
  6981. }
  6982. }
  6983. declare module BABYLON {
  6984. /**
  6985. * @hidden
  6986. */
  6987. class IntersectionInfo {
  6988. bu: Nullable<number>;
  6989. bv: Nullable<number>;
  6990. distance: number;
  6991. faceId: number;
  6992. subMeshId: number;
  6993. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6994. }
  6995. /**
  6996. * Information about the result of picking within a scene
  6997. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6998. */
  6999. class PickingInfo {
  7000. /**
  7001. * If the pick collided with an object
  7002. */
  7003. hit: boolean;
  7004. /**
  7005. * Distance away where the pick collided
  7006. */
  7007. distance: number;
  7008. /**
  7009. * The location of pick collision
  7010. */
  7011. pickedPoint: Nullable<Vector3>;
  7012. /**
  7013. * The mesh corresponding the the pick collision
  7014. */
  7015. pickedMesh: Nullable<AbstractMesh>;
  7016. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7017. bu: number;
  7018. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7019. bv: number;
  7020. /** The id of the face on the mesh that was picked */
  7021. faceId: number;
  7022. /** Id of the the submesh that was picked */
  7023. subMeshId: number;
  7024. /** If a sprite was picked, this will be the sprite the pick collided with */
  7025. pickedSprite: Nullable<Sprite>;
  7026. /**
  7027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7028. */
  7029. originMesh: Nullable<AbstractMesh>;
  7030. /**
  7031. * The ray that was used to perform the picking.
  7032. */
  7033. ray: Nullable<Ray>;
  7034. /**
  7035. * Gets the normal correspodning to the face the pick collided with
  7036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7038. * @returns The normal correspodning to the face the pick collided with
  7039. */
  7040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7041. /**
  7042. * Gets the texture coordinates of where the pick occured
  7043. * @returns the vector containing the coordnates of the texture
  7044. */
  7045. getTextureCoordinates(): Nullable<Vector2>;
  7046. }
  7047. }
  7048. declare module BABYLON {
  7049. /**
  7050. * Class used to store bounding box information
  7051. */
  7052. class BoundingBox implements ICullable {
  7053. /**
  7054. * Gets the 8 vectors representing the bounding box in local space
  7055. */
  7056. readonly vectors: Vector3[];
  7057. /**
  7058. * Gets the center of the bounding box in local space
  7059. */
  7060. readonly center: Vector3;
  7061. /**
  7062. * Gets the center of the bounding box in world space
  7063. */
  7064. readonly centerWorld: Vector3;
  7065. /**
  7066. * Gets the extend size in local space
  7067. */
  7068. readonly extendSize: Vector3;
  7069. /**
  7070. * Gets the extend size in world space
  7071. */
  7072. readonly extendSizeWorld: Vector3;
  7073. /**
  7074. * Gets the OBB (object bounding box) directions
  7075. */
  7076. readonly directions: Vector3[];
  7077. /**
  7078. * Gets the 8 vectors representing the bounding box in world space
  7079. */
  7080. readonly vectorsWorld: Vector3[];
  7081. /**
  7082. * Gets the minimum vector in world space
  7083. */
  7084. readonly minimumWorld: Vector3;
  7085. /**
  7086. * Gets the maximum vector in world space
  7087. */
  7088. readonly maximumWorld: Vector3;
  7089. /**
  7090. * Gets the minimum vector in local space
  7091. */
  7092. readonly minimum: Vector3;
  7093. /**
  7094. * Gets the maximum vector in local space
  7095. */
  7096. readonly maximum: Vector3;
  7097. private _worldMatrix;
  7098. private static readonly TmpVector3;
  7099. /**
  7100. * @hidden
  7101. */
  7102. _tag: number;
  7103. /**
  7104. * Creates a new bounding box
  7105. * @param min defines the minimum vector (in local space)
  7106. * @param max defines the maximum vector (in local space)
  7107. * @param worldMatrix defines the new world matrix
  7108. */
  7109. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  7110. /**
  7111. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7112. * @param min defines the new minimum vector (in local space)
  7113. * @param max defines the new maximum vector (in local space)
  7114. * @param worldMatrix defines the new world matrix
  7115. */
  7116. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  7117. /**
  7118. * Scale the current bounding box by applying a scale factor
  7119. * @param factor defines the scale factor to apply
  7120. * @returns the current bounding box
  7121. */
  7122. scale(factor: number): BoundingBox;
  7123. /**
  7124. * Gets the world matrix of the bounding box
  7125. * @returns a matrix
  7126. */
  7127. getWorldMatrix(): Readonly<Matrix>;
  7128. /** @hidden */
  7129. _update(world: Readonly<Matrix>): void;
  7130. /**
  7131. * Tests if the bounding box is intersecting the frustum planes
  7132. * @param frustumPlanes defines the frustum planes to test
  7133. * @returns true if there is an intersection
  7134. */
  7135. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7136. /**
  7137. * Tests if the bounding box is entirely inside the frustum planes
  7138. * @param frustumPlanes defines the frustum planes to test
  7139. * @returns true if there is an inclusion
  7140. */
  7141. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7142. /**
  7143. * Tests if a point is inside the bounding box
  7144. * @param point defines the point to test
  7145. * @returns true if the point is inside the bounding box
  7146. */
  7147. intersectsPoint(point: Readonly<Vector3>): boolean;
  7148. /**
  7149. * Tests if the bounding box intersects with a bounding sphere
  7150. * @param sphere defines the sphere to test
  7151. * @returns true if there is an intersection
  7152. */
  7153. intersectsSphere(sphere: Readonly<BoundingSphere>): boolean;
  7154. /**
  7155. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7156. * @param min defines the min vector to use
  7157. * @param max defines the max vector to use
  7158. * @returns true if there is an intersection
  7159. */
  7160. intersectsMinMax(min: Readonly<Vector3>, max: Readonly<Vector3>): boolean;
  7161. /**
  7162. * Tests if two bounding boxes are intersections
  7163. * @param box0 defines the first box to test
  7164. * @param box1 defines the second box to test
  7165. * @returns true if there is an intersection
  7166. */
  7167. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  7168. /**
  7169. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7170. * @param minPoint defines the minimum vector of the bounding box
  7171. * @param maxPoint defines the maximum vector of the bounding box
  7172. * @param sphereCenter defines the sphere center
  7173. * @param sphereRadius defines the sphere radius
  7174. * @returns true if there is an intersection
  7175. */
  7176. static IntersectsSphere(minPoint: Readonly<Vector3>, maxPoint: Readonly<Vector3>, sphereCenter: Readonly<Vector3>, sphereRadius: number): boolean;
  7177. /**
  7178. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7179. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7180. * @param frustumPlanes defines the frustum planes to test
  7181. * @return true if there is an inclusion
  7182. */
  7183. static IsCompletelyInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  7184. /**
  7185. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7186. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7187. * @param frustumPlanes defines the frustum planes to test
  7188. * @return true if there is an intersection
  7189. */
  7190. static IsInFrustum(boundingVectors: Array<Readonly<Vector3>>, frustumPlanes: Array<Readonly<Plane>>): boolean;
  7191. }
  7192. }
  7193. declare module BABYLON {
  7194. /**
  7195. * Interface for cullable objects
  7196. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7197. */
  7198. interface ICullable {
  7199. /**
  7200. * Checks if the object or part of the object is in the frustum
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isInFrustum(frustumPlanes: Plane[]): boolean;
  7205. /**
  7206. * Checks if a cullable object (mesh...) is in the camera frustum
  7207. * Unlike isInFrustum this cheks the full bounding box
  7208. * @param frustumPlanes Camera near/planes
  7209. * @returns true if the object is in frustum otherwise false
  7210. */
  7211. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7212. }
  7213. /**
  7214. * Info for a bounding data of a mesh
  7215. */
  7216. class BoundingInfo implements ICullable {
  7217. /**
  7218. * Bounding box for the mesh
  7219. */
  7220. readonly boundingBox: BoundingBox;
  7221. /**
  7222. * Bounding sphere for the mesh
  7223. */
  7224. readonly boundingSphere: BoundingSphere;
  7225. private _isLocked;
  7226. private static readonly TmpVector3;
  7227. /**
  7228. * Constructs bounding info
  7229. * @param minimum min vector of the bounding box/sphere
  7230. * @param maximum max vector of the bounding box/sphere
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. constructor(minimum: Readonly<Vector3>, maximum: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  7234. /**
  7235. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7236. * @param min defines the new minimum vector (in local space)
  7237. * @param max defines the new maximum vector (in local space)
  7238. * @param worldMatrix defines the new world matrix
  7239. */
  7240. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  7241. /**
  7242. * min vector of the bounding box/sphere
  7243. */
  7244. readonly minimum: Vector3;
  7245. /**
  7246. * max vector of the bounding box/sphere
  7247. */
  7248. readonly maximum: Vector3;
  7249. /**
  7250. * If the info is locked and won't be updated to avoid perf overhead
  7251. */
  7252. isLocked: boolean;
  7253. /**
  7254. * Updates the bounding sphere and box
  7255. * @param world world matrix to be used to update
  7256. */
  7257. update(world: Readonly<Matrix>): void;
  7258. /**
  7259. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7260. * @param center New center of the bounding info
  7261. * @param extend New extend of the bounding info
  7262. * @returns the current bounding info
  7263. */
  7264. centerOn(center: Readonly<Vector3>, extend: Readonly<Vector3>): BoundingInfo;
  7265. /**
  7266. * Scale the current bounding info by applying a scale factor
  7267. * @param factor defines the scale factor to apply
  7268. * @returns the current bounding info
  7269. */
  7270. scale(factor: number): BoundingInfo;
  7271. /**
  7272. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7273. * @param frustumPlanes defines the frustum to test
  7274. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7275. * @returns true if the bounding info is in the frustum planes
  7276. */
  7277. isInFrustum(frustumPlanes: Array<Readonly<Plane>>, strategy?: number): boolean;
  7278. /**
  7279. * Gets the world distance between the min and max points of the bounding box
  7280. */
  7281. readonly diagonalLength: number;
  7282. /**
  7283. * Checks if a cullable object (mesh...) is in the camera frustum
  7284. * Unlike isInFrustum this cheks the full bounding box
  7285. * @param frustumPlanes Camera near/planes
  7286. * @returns true if the object is in frustum otherwise false
  7287. */
  7288. isCompletelyInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7289. /** @hidden */
  7290. _checkCollision(collider: Collider): boolean;
  7291. /**
  7292. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param point the point to check intersection with
  7295. * @returns if the point intersects
  7296. */
  7297. intersectsPoint(point: Readonly<Vector3>): boolean;
  7298. /**
  7299. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7300. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7301. * @param boundingInfo the bounding info to check intersection with
  7302. * @param precise if the intersection should be done using OBB
  7303. * @returns if the bounding info intersects
  7304. */
  7305. intersects(boundingInfo: Readonly<BoundingInfo>, precise: boolean): boolean;
  7306. }
  7307. }
  7308. declare module BABYLON {
  7309. /**
  7310. * Class used to store bounding sphere information
  7311. */
  7312. class BoundingSphere {
  7313. /**
  7314. * Gets the center of the bounding sphere in local space
  7315. */
  7316. readonly center: Vector3;
  7317. /**
  7318. * Radius of the bounding sphere in local space
  7319. */
  7320. radius: number;
  7321. /**
  7322. * Gets the center of the bounding sphere in world space
  7323. */
  7324. readonly centerWorld: Vector3;
  7325. /**
  7326. * Radius of the bounding sphere in world space
  7327. */
  7328. radiusWorld: number;
  7329. /**
  7330. * Gets the minimum vector in local space
  7331. */
  7332. readonly minimum: Vector3;
  7333. /**
  7334. * Gets the maximum vector in local space
  7335. */
  7336. readonly maximum: Vector3;
  7337. private _worldMatrix;
  7338. private static readonly TmpVector3;
  7339. /**
  7340. * Creates a new bounding sphere
  7341. * @param min defines the minimum vector (in local space)
  7342. * @param max defines the maximum vector (in local space)
  7343. * @param worldMatrix defines the new world matrix
  7344. */
  7345. constructor(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>);
  7346. /**
  7347. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7348. * @param min defines the new minimum vector (in local space)
  7349. * @param max defines the new maximum vector (in local space)
  7350. * @param worldMatrix defines the new world matrix
  7351. */
  7352. reConstruct(min: Readonly<Vector3>, max: Readonly<Vector3>, worldMatrix?: Readonly<Matrix>): void;
  7353. /**
  7354. * Scale the current bounding sphere by applying a scale factor
  7355. * @param factor defines the scale factor to apply
  7356. * @returns the current bounding box
  7357. */
  7358. scale(factor: number): BoundingSphere;
  7359. /**
  7360. * Gets the world matrix of the bounding box
  7361. * @returns a matrix
  7362. */
  7363. getWorldMatrix(): Readonly<Matrix>;
  7364. /** @hidden */
  7365. _update(worldMatrix: Readonly<Matrix>): void;
  7366. /**
  7367. * Tests if the bounding sphere is intersecting the frustum planes
  7368. * @param frustumPlanes defines the frustum planes to test
  7369. * @returns true if there is an intersection
  7370. */
  7371. isInFrustum(frustumPlanes: Array<Readonly<Plane>>): boolean;
  7372. /**
  7373. * Tests if a point is inside the bounding sphere
  7374. * @param point defines the point to test
  7375. * @returns true if the point is inside the bounding sphere
  7376. */
  7377. intersectsPoint(point: Readonly<Vector3>): boolean;
  7378. /**
  7379. * Checks if two sphere intersct
  7380. * @param sphere0 sphere 0
  7381. * @param sphere1 sphere 1
  7382. * @returns true if the speres intersect
  7383. */
  7384. static Intersects(sphere0: Readonly<BoundingSphere>, sphere1: Readonly<BoundingSphere>): boolean;
  7385. }
  7386. }
  7387. declare module BABYLON {
  7388. /**
  7389. * Class representing a ray with position and direction
  7390. */
  7391. class Ray {
  7392. /** origin point */
  7393. origin: Vector3;
  7394. /** direction */
  7395. direction: Vector3;
  7396. /** length of the ray */
  7397. length: number;
  7398. private static readonly _edge1;
  7399. private static readonly _edge2;
  7400. private static readonly _pvec;
  7401. private static readonly _tvec;
  7402. private static readonly _qvec;
  7403. private static readonly _min;
  7404. private static readonly _max;
  7405. private _tmpRay;
  7406. /**
  7407. * Creates a new ray
  7408. * @param origin origin point
  7409. * @param direction direction
  7410. * @param length length of the ray
  7411. */
  7412. constructor(
  7413. /** origin point */
  7414. origin: Vector3,
  7415. /** direction */
  7416. direction: Vector3,
  7417. /** length of the ray */
  7418. length?: number);
  7419. /**
  7420. * Checks if the ray intersects a box
  7421. * @param minimum bound of the box
  7422. * @param maximum bound of the box
  7423. * @param intersectionTreshold extra extend to be added to the box in all direction
  7424. * @returns if the box was hit
  7425. */
  7426. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3, intersectionTreshold?: number): boolean;
  7427. /**
  7428. * Checks if the ray intersects a box
  7429. * @param box the bounding box to check
  7430. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7431. * @returns if the box was hit
  7432. */
  7433. intersectsBox(box: BoundingBox, intersectionTreshold?: number): boolean;
  7434. /**
  7435. * If the ray hits a sphere
  7436. * @param sphere the bounding sphere to check
  7437. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7438. * @returns true if it hits the sphere
  7439. */
  7440. intersectsSphere(sphere: BoundingSphere, intersectionTreshold?: number): boolean;
  7441. /**
  7442. * If the ray hits a triange
  7443. * @param vertex0 triangle vertex
  7444. * @param vertex1 triangle vertex
  7445. * @param vertex2 triangle vertex
  7446. * @returns intersection information if hit
  7447. */
  7448. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  7449. /**
  7450. * Checks if ray intersects a plane
  7451. * @param plane the plane to check
  7452. * @returns the distance away it was hit
  7453. */
  7454. intersectsPlane(plane: Plane): Nullable<number>;
  7455. /**
  7456. * Checks if ray intersects a mesh
  7457. * @param mesh the mesh to check
  7458. * @param fastCheck if only the bounding box should checked
  7459. * @returns picking info of the intersecton
  7460. */
  7461. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  7462. /**
  7463. * Checks if ray intersects a mesh
  7464. * @param meshes the meshes to check
  7465. * @param fastCheck if only the bounding box should checked
  7466. * @param results array to store result in
  7467. * @returns Array of picking infos
  7468. */
  7469. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7470. private _comparePickingInfo;
  7471. private static smallnum;
  7472. private static rayl;
  7473. /**
  7474. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7475. * @param sega the first point of the segment to test the intersection against
  7476. * @param segb the second point of the segment to test the intersection against
  7477. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7478. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7479. */
  7480. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  7481. /**
  7482. * Update the ray from viewport position
  7483. * @param x position
  7484. * @param y y position
  7485. * @param viewportWidth viewport width
  7486. * @param viewportHeight viewport height
  7487. * @param world world matrix
  7488. * @param view view matrix
  7489. * @param projection projection matrix
  7490. * @returns this ray updated
  7491. */
  7492. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7493. /**
  7494. * Creates a ray with origin and direction of 0,0,0
  7495. * @returns the new ray
  7496. */
  7497. static Zero(): Ray;
  7498. /**
  7499. * Creates a new ray from screen space and viewport
  7500. * @param x position
  7501. * @param y y position
  7502. * @param viewportWidth viewport width
  7503. * @param viewportHeight viewport height
  7504. * @param world world matrix
  7505. * @param view view matrix
  7506. * @param projection projection matrix
  7507. * @returns new ray
  7508. */
  7509. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7510. /**
  7511. * 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
  7512. * transformed to the given world matrix.
  7513. * @param origin The origin point
  7514. * @param end The end point
  7515. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7516. * @returns the new ray
  7517. */
  7518. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Readonly<Matrix>): Ray;
  7519. /**
  7520. * Transforms a ray by a matrix
  7521. * @param ray ray to transform
  7522. * @param matrix matrix to apply
  7523. * @returns the resulting new ray
  7524. */
  7525. static Transform(ray: Ray, matrix: Readonly<Matrix>): Ray;
  7526. /**
  7527. * Transforms a ray by a matrix
  7528. * @param ray ray to transform
  7529. * @param matrix matrix to apply
  7530. * @param result ray to store result in
  7531. */
  7532. static TransformToRef(ray: Ray, matrix: Readonly<Matrix>, result: Ray): void;
  7533. }
  7534. }
  7535. declare module BABYLON {
  7536. /**
  7537. * This represents an orbital type of camera.
  7538. *
  7539. * 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.
  7540. * 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.
  7541. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7542. */
  7543. class ArcRotateCamera extends TargetCamera {
  7544. /**
  7545. * Defines the rotation angle of the camera along the longitudinal axis.
  7546. */
  7547. alpha: number;
  7548. /**
  7549. * Defines the rotation angle of the camera along the latitudinal axis.
  7550. */
  7551. beta: number;
  7552. /**
  7553. * Defines the radius of the camera from it s target point.
  7554. */
  7555. radius: number;
  7556. protected _target: Vector3;
  7557. protected _targetHost: Nullable<AbstractMesh>;
  7558. /**
  7559. * Defines the target point of the camera.
  7560. * The camera looks towards it form the radius distance.
  7561. */
  7562. target: Vector3;
  7563. /**
  7564. * Current inertia value on the longitudinal axis.
  7565. * The bigger this number the longer it will take for the camera to stop.
  7566. */
  7567. inertialAlphaOffset: number;
  7568. /**
  7569. * Current inertia value on the latitudinal axis.
  7570. * The bigger this number the longer it will take for the camera to stop.
  7571. */
  7572. inertialBetaOffset: number;
  7573. /**
  7574. * Current inertia value on the radius axis.
  7575. * The bigger this number the longer it will take for the camera to stop.
  7576. */
  7577. inertialRadiusOffset: number;
  7578. /**
  7579. * Minimum allowed angle on the longitudinal axis.
  7580. * This can help limiting how the Camera is able to move in the scene.
  7581. */
  7582. lowerAlphaLimit: Nullable<number>;
  7583. /**
  7584. * Maximum allowed angle on the longitudinal axis.
  7585. * This can help limiting how the Camera is able to move in the scene.
  7586. */
  7587. upperAlphaLimit: Nullable<number>;
  7588. /**
  7589. * Minimum allowed angle on the latitudinal axis.
  7590. * This can help limiting how the Camera is able to move in the scene.
  7591. */
  7592. lowerBetaLimit: number;
  7593. /**
  7594. * Maximum allowed angle on the latitudinal axis.
  7595. * This can help limiting how the Camera is able to move in the scene.
  7596. */
  7597. upperBetaLimit: number;
  7598. /**
  7599. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7600. * This can help limiting how the Camera is able to move in the scene.
  7601. */
  7602. lowerRadiusLimit: Nullable<number>;
  7603. /**
  7604. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7605. * This can help limiting how the Camera is able to move in the scene.
  7606. */
  7607. upperRadiusLimit: Nullable<number>;
  7608. /**
  7609. * Defines the current inertia value used during panning of the camera along the X axis.
  7610. */
  7611. inertialPanningX: number;
  7612. /**
  7613. * Defines the current inertia value used during panning of the camera along the Y axis.
  7614. */
  7615. inertialPanningY: number;
  7616. /**
  7617. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7618. * Basically if your fingers moves away from more than this distance you will be considered
  7619. * in pinch mode.
  7620. */
  7621. pinchToPanMaxDistance: number;
  7622. /**
  7623. * Defines the maximum distance the camera can pan.
  7624. * This could help keeping the cammera always in your scene.
  7625. */
  7626. panningDistanceLimit: Nullable<number>;
  7627. /**
  7628. * Defines the target of the camera before paning.
  7629. */
  7630. panningOriginTarget: Vector3;
  7631. /**
  7632. * Defines the value of the inertia used during panning.
  7633. * 0 would mean stop inertia and one would mean no decelleration at all.
  7634. */
  7635. panningInertia: number;
  7636. /**
  7637. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7638. */
  7639. angularSensibilityX: number;
  7640. /**
  7641. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7642. */
  7643. angularSensibilityY: number;
  7644. /**
  7645. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7646. */
  7647. pinchPrecision: number;
  7648. /**
  7649. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7650. * It will be used instead of pinchDeltaPrecision if different from 0.
  7651. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7652. */
  7653. pinchDeltaPercentage: number;
  7654. /**
  7655. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7656. */
  7657. panningSensibility: number;
  7658. /**
  7659. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7660. */
  7661. keysUp: number[];
  7662. /**
  7663. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7664. */
  7665. keysDown: number[];
  7666. /**
  7667. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7668. */
  7669. keysLeft: number[];
  7670. /**
  7671. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7672. */
  7673. keysRight: number[];
  7674. /**
  7675. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7676. */
  7677. wheelPrecision: number;
  7678. /**
  7679. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7680. * It will be used instead of pinchDeltaPrecision if different from 0.
  7681. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7682. */
  7683. wheelDeltaPercentage: number;
  7684. /**
  7685. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7686. */
  7687. zoomOnFactor: number;
  7688. /**
  7689. * Defines a screen offset for the camera position.
  7690. */
  7691. targetScreenOffset: Vector2;
  7692. /**
  7693. * Allows the camera to be completely reversed.
  7694. * If false the camera can not arrive upside down.
  7695. */
  7696. allowUpsideDown: boolean;
  7697. /**
  7698. * Define if double tap/click is used to restore the previously saved state of the camera.
  7699. */
  7700. useInputToRestoreState: boolean;
  7701. /** @hidden */
  7702. _viewMatrix: Matrix;
  7703. /** @hidden */
  7704. _useCtrlForPanning: boolean;
  7705. /** @hidden */
  7706. _panningMouseButton: number;
  7707. /**
  7708. * Defines the inpute associated to the camera.
  7709. */
  7710. inputs: ArcRotateCameraInputsManager;
  7711. /** @hidden */
  7712. _reset: () => void;
  7713. /**
  7714. * Defines the allowed panning axis.
  7715. */
  7716. panningAxis: Vector3;
  7717. protected _localDirection: Vector3;
  7718. protected _transformedDirection: Vector3;
  7719. private _bouncingBehavior;
  7720. /**
  7721. * Gets the bouncing behavior of the camera if it has been enabled.
  7722. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7723. */
  7724. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7725. /**
  7726. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7727. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7728. */
  7729. useBouncingBehavior: boolean;
  7730. private _framingBehavior;
  7731. /**
  7732. * Gets the framing behavior of the camera if it has been enabled.
  7733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7734. */
  7735. readonly framingBehavior: Nullable<FramingBehavior>;
  7736. /**
  7737. * Defines if the framing behavior of the camera is enabled on the camera.
  7738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7739. */
  7740. useFramingBehavior: boolean;
  7741. private _autoRotationBehavior;
  7742. /**
  7743. * Gets the auto rotation behavior of the camera if it has been enabled.
  7744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7745. */
  7746. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7747. /**
  7748. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7749. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7750. */
  7751. useAutoRotationBehavior: boolean;
  7752. /**
  7753. * Observable triggered when the mesh target has been changed on the camera.
  7754. */
  7755. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7756. /**
  7757. * Event raised when the camera is colliding with a mesh.
  7758. */
  7759. onCollide: (collidedMesh: AbstractMesh) => void;
  7760. /**
  7761. * Defines whether the camera should check collision with the objects oh the scene.
  7762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7763. */
  7764. checkCollisions: boolean;
  7765. /**
  7766. * Defines the collision radius of the camera.
  7767. * This simulates a sphere around the camera.
  7768. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7769. */
  7770. collisionRadius: Vector3;
  7771. protected _collider: Collider;
  7772. protected _previousPosition: Vector3;
  7773. protected _collisionVelocity: Vector3;
  7774. protected _newPosition: Vector3;
  7775. protected _previousAlpha: number;
  7776. protected _previousBeta: number;
  7777. protected _previousRadius: number;
  7778. protected _collisionTriggered: boolean;
  7779. protected _targetBoundingCenter: Nullable<Vector3>;
  7780. private _computationVector;
  7781. /**
  7782. * Instantiates a new ArcRotateCamera in a given scene
  7783. * @param name Defines the name of the camera
  7784. * @param alpha Defines the camera rotation along the logitudinal axis
  7785. * @param beta Defines the camera rotation along the latitudinal axis
  7786. * @param radius Defines the camera distance from its target
  7787. * @param target Defines the camera target
  7788. * @param scene Defines the scene the camera belongs to
  7789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7790. */
  7791. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7792. /** @hidden */
  7793. _initCache(): void;
  7794. /** @hidden */
  7795. _updateCache(ignoreParentClass?: boolean): void;
  7796. protected _getTargetPosition(): Vector3;
  7797. private _storedAlpha;
  7798. private _storedBeta;
  7799. private _storedRadius;
  7800. private _storedTarget;
  7801. /**
  7802. * Stores the current state of the camera (alpha, beta, radius and target)
  7803. * @returns the camera itself
  7804. */
  7805. storeState(): Camera;
  7806. /**
  7807. * @hidden
  7808. * Restored camera state. You must call storeState() first
  7809. */
  7810. _restoreStateValues(): boolean;
  7811. /** @hidden */
  7812. _isSynchronizedViewMatrix(): boolean;
  7813. /**
  7814. * Attached controls to the current camera.
  7815. * @param element Defines the element the controls should be listened from
  7816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7817. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7818. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7819. */
  7820. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7821. /**
  7822. * Detach the current controls from the camera.
  7823. * The camera will stop reacting to inputs.
  7824. * @param element Defines the element to stop listening the inputs from
  7825. */
  7826. detachControl(element: HTMLElement): void;
  7827. /** @hidden */
  7828. _checkInputs(): void;
  7829. protected _checkLimits(): void;
  7830. /**
  7831. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7832. */
  7833. rebuildAnglesAndRadius(): void;
  7834. /**
  7835. * Use a position to define the current camera related information like aplha, beta and radius
  7836. * @param position Defines the position to set the camera at
  7837. */
  7838. setPosition(position: Vector3): void;
  7839. /**
  7840. * Defines the target the camera should look at.
  7841. * This will automatically adapt alpha beta and radius to fit within the new target.
  7842. * @param target Defines the new target as a Vector or a mesh
  7843. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7844. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7845. */
  7846. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7847. /** @hidden */
  7848. _getViewMatrix(): Matrix;
  7849. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7850. /**
  7851. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7852. * @param meshes Defines the mesh to zoom on
  7853. * @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)
  7854. */
  7855. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7856. /**
  7857. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7858. * The target will be changed but the radius
  7859. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7860. * @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)
  7861. */
  7862. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7863. min: Vector3;
  7864. max: Vector3;
  7865. distance: number;
  7866. }, doNotUpdateMaxZ?: boolean): void;
  7867. /**
  7868. * @override
  7869. * Override Camera.createRigCamera
  7870. */
  7871. createRigCamera(name: string, cameraIndex: number): Camera;
  7872. /**
  7873. * @hidden
  7874. * @override
  7875. * Override Camera._updateRigCameras
  7876. */
  7877. _updateRigCameras(): void;
  7878. /**
  7879. * Destroy the camera and release the current resources hold by it.
  7880. */
  7881. dispose(): void;
  7882. /**
  7883. * Gets the current object class name.
  7884. * @return the class name
  7885. */
  7886. getClassName(): string;
  7887. }
  7888. }
  7889. declare module BABYLON {
  7890. /**
  7891. * Default Inputs manager for the ArcRotateCamera.
  7892. * It groups all the default supported inputs for ease of use.
  7893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7894. */
  7895. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7896. /**
  7897. * Instantiates a new ArcRotateCameraInputsManager.
  7898. * @param camera Defines the camera the inputs belong to
  7899. */
  7900. constructor(camera: ArcRotateCamera);
  7901. /**
  7902. * Add mouse wheel input support to the input manager.
  7903. * @returns the current input manager
  7904. */
  7905. addMouseWheel(): ArcRotateCameraInputsManager;
  7906. /**
  7907. * Add pointers input support to the input manager.
  7908. * @returns the current input manager
  7909. */
  7910. addPointers(): ArcRotateCameraInputsManager;
  7911. /**
  7912. * Add keyboard input support to the input manager.
  7913. * @returns the current input manager
  7914. */
  7915. addKeyboard(): ArcRotateCameraInputsManager;
  7916. /**
  7917. * Add orientation input support to the input manager.
  7918. * @returns the current input manager
  7919. */
  7920. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7921. }
  7922. }
  7923. declare module BABYLON {
  7924. /**
  7925. * This is the base class of all the camera used in the application.
  7926. * @see http://doc.babylonjs.com/features/cameras
  7927. */
  7928. class Camera extends Node {
  7929. /**
  7930. * This is the default projection mode used by the cameras.
  7931. * It helps recreating a feeling of perspective and better appreciate depth.
  7932. * This is the best way to simulate real life cameras.
  7933. */
  7934. static readonly PERSPECTIVE_CAMERA: number;
  7935. /**
  7936. * This helps creating camera with an orthographic mode.
  7937. * 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.
  7938. */
  7939. static readonly ORTHOGRAPHIC_CAMERA: number;
  7940. /**
  7941. * This is the default FOV mode for perspective cameras.
  7942. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7943. */
  7944. static readonly FOVMODE_VERTICAL_FIXED: number;
  7945. /**
  7946. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7947. */
  7948. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7949. /**
  7950. * This specifies ther is no need for a camera rig.
  7951. * Basically only one eye is rendered corresponding to the camera.
  7952. */
  7953. static readonly RIG_MODE_NONE: number;
  7954. /**
  7955. * Simulates a camera Rig with one blue eye and one red eye.
  7956. * This can be use with 3d blue and red glasses.
  7957. */
  7958. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7959. /**
  7960. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7961. */
  7962. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7963. /**
  7964. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7965. */
  7966. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7967. /**
  7968. * Defines that both eyes of the camera will be rendered over under each other.
  7969. */
  7970. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7971. /**
  7972. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7973. */
  7974. static readonly RIG_MODE_VR: number;
  7975. /**
  7976. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7977. */
  7978. static readonly RIG_MODE_WEBVR: number;
  7979. /**
  7980. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7981. */
  7982. static readonly RIG_MODE_CUSTOM: number;
  7983. /**
  7984. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7985. */
  7986. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7987. /**
  7988. * @hidden
  7989. * Might be removed once multiview will be a thing
  7990. */
  7991. static UseAlternateWebVRRendering: boolean;
  7992. /**
  7993. * Define the input manager associated with the camera.
  7994. */
  7995. inputs: CameraInputsManager<Camera>;
  7996. /**
  7997. * Define the current local position of the camera in the scene
  7998. */
  7999. position: Vector3;
  8000. /**
  8001. * The vector the camera should consider as up.
  8002. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8003. */
  8004. upVector: Vector3;
  8005. /**
  8006. * Define the current limit on the left side for an orthographic camera
  8007. * In scene unit
  8008. */
  8009. orthoLeft: Nullable<number>;
  8010. /**
  8011. * Define the current limit on the right side for an orthographic camera
  8012. * In scene unit
  8013. */
  8014. orthoRight: Nullable<number>;
  8015. /**
  8016. * Define the current limit on the bottom side for an orthographic camera
  8017. * In scene unit
  8018. */
  8019. orthoBottom: Nullable<number>;
  8020. /**
  8021. * Define the current limit on the top side for an orthographic camera
  8022. * In scene unit
  8023. */
  8024. orthoTop: Nullable<number>;
  8025. /**
  8026. * Field Of View is set in Radians. (default is 0.8)
  8027. */
  8028. fov: number;
  8029. /**
  8030. * Define the minimum distance the camera can see from.
  8031. * This is important to note that the depth buffer are not infinite and the closer it starts
  8032. * the more your scene might encounter depth fighting issue.
  8033. */
  8034. minZ: number;
  8035. /**
  8036. * Define the maximum distance the camera can see to.
  8037. * This is important to note that the depth buffer are not infinite and the further it end
  8038. * the more your scene might encounter depth fighting issue.
  8039. */
  8040. maxZ: number;
  8041. /**
  8042. * Define the default inertia of the camera.
  8043. * This helps giving a smooth feeling to the camera movement.
  8044. */
  8045. inertia: number;
  8046. /**
  8047. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8048. */
  8049. mode: number;
  8050. /**
  8051. * Define wether the camera is intermediate.
  8052. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  8053. */
  8054. isIntermediate: boolean;
  8055. /**
  8056. * Define the viewport of the camera.
  8057. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8058. */
  8059. viewport: Viewport;
  8060. /**
  8061. * Restricts the camera to viewing objects with the same layerMask.
  8062. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8063. */
  8064. layerMask: number;
  8065. /**
  8066. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8067. */
  8068. fovMode: number;
  8069. /**
  8070. * Rig mode of the camera.
  8071. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8072. * This is normally controlled byt the camera themselves as internal use.
  8073. */
  8074. cameraRigMode: number;
  8075. /**
  8076. * Defines the distance between both "eyes" in case of a RIG
  8077. */
  8078. interaxialDistance: number;
  8079. /**
  8080. * Defines if stereoscopic rendering is done side by side or over under.
  8081. */
  8082. isStereoscopicSideBySide: boolean;
  8083. /**
  8084. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  8085. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8086. * else in the scene.
  8087. */
  8088. customRenderTargets: RenderTargetTexture[];
  8089. /**
  8090. * When set, the camera will render to this render target instead of the default canvas
  8091. */
  8092. outputRenderTarget: Nullable<RenderTargetTexture>;
  8093. /**
  8094. * Observable triggered when the camera view matrix has changed.
  8095. */
  8096. onViewMatrixChangedObservable: Observable<Camera>;
  8097. /**
  8098. * Observable triggered when the camera Projection matrix has changed.
  8099. */
  8100. onProjectionMatrixChangedObservable: Observable<Camera>;
  8101. /**
  8102. * Observable triggered when the inputs have been processed.
  8103. */
  8104. onAfterCheckInputsObservable: Observable<Camera>;
  8105. /**
  8106. * Observable triggered when reset has been called and applied to the camera.
  8107. */
  8108. onRestoreStateObservable: Observable<Camera>;
  8109. /** @hidden */
  8110. _cameraRigParams: any;
  8111. /** @hidden */
  8112. _rigCameras: Camera[];
  8113. /** @hidden */
  8114. _rigPostProcess: Nullable<PostProcess>;
  8115. protected _webvrViewMatrix: Matrix;
  8116. /** @hidden */
  8117. _skipRendering: boolean;
  8118. /** @hidden */
  8119. _alternateCamera: Camera;
  8120. /** @hidden */
  8121. _projectionMatrix: Matrix;
  8122. /** @hidden */
  8123. _postProcesses: Nullable<PostProcess>[];
  8124. /** @hidden */
  8125. _activeMeshes: SmartArray<AbstractMesh>;
  8126. protected _globalPosition: Vector3;
  8127. /** hidden */
  8128. _computedViewMatrix: Matrix;
  8129. private _doNotComputeProjectionMatrix;
  8130. private _transformMatrix;
  8131. private _frustumPlanes;
  8132. private _refreshFrustumPlanes;
  8133. private _storedFov;
  8134. private _stateStored;
  8135. /**
  8136. * Instantiates a new camera object.
  8137. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8138. * @see http://doc.babylonjs.com/features/cameras
  8139. * @param name Defines the name of the camera in the scene
  8140. * @param position Defines the position of the camera
  8141. * @param scene Defines the scene the camera belongs too
  8142. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8143. */
  8144. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8145. /**
  8146. * Store current camera state (fov, position, etc..)
  8147. * @returns the camera
  8148. */
  8149. storeState(): Camera;
  8150. /**
  8151. * Restores the camera state values if it has been stored. You must call storeState() first
  8152. */
  8153. protected _restoreStateValues(): boolean;
  8154. /**
  8155. * Restored camera state. You must call storeState() first.
  8156. * @returns true if restored and false otherwise
  8157. */
  8158. restoreState(): boolean;
  8159. /**
  8160. * Gets the class name of the camera.
  8161. * @returns the class name
  8162. */
  8163. getClassName(): string;
  8164. /**
  8165. * Gets a string representation of the camera usefull for debug purpose.
  8166. * @param fullDetails Defines that a more verboe level of logging is required
  8167. * @returns the string representation
  8168. */
  8169. toString(fullDetails?: boolean): string;
  8170. /**
  8171. * Gets the current world space position of the camera.
  8172. */
  8173. readonly globalPosition: Vector3;
  8174. /**
  8175. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8176. * @returns the active meshe list
  8177. */
  8178. getActiveMeshes(): SmartArray<AbstractMesh>;
  8179. /**
  8180. * Check wether a mesh is part of the current active mesh list of the camera
  8181. * @param mesh Defines the mesh to check
  8182. * @returns true if active, false otherwise
  8183. */
  8184. isActiveMesh(mesh: Mesh): boolean;
  8185. /**
  8186. * Is this camera ready to be used/rendered
  8187. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8188. * @return true if the camera is ready
  8189. */
  8190. isReady(completeCheck?: boolean): boolean;
  8191. /** @hidden */
  8192. _initCache(): void;
  8193. /** @hidden */
  8194. _updateCache(ignoreParentClass?: boolean): void;
  8195. /** @hidden */
  8196. _isSynchronized(): boolean;
  8197. /** @hidden */
  8198. _isSynchronizedViewMatrix(): boolean;
  8199. /** @hidden */
  8200. _isSynchronizedProjectionMatrix(): boolean;
  8201. /**
  8202. * Attach the input controls to a specific dom element to get the input from.
  8203. * @param element Defines the element the controls should be listened from
  8204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8205. */
  8206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8207. /**
  8208. * Detach the current controls from the specified dom element.
  8209. * @param element Defines the element to stop listening the inputs from
  8210. */
  8211. detachControl(element: HTMLElement): void;
  8212. /**
  8213. * Update the camera state according to the different inputs gathered during the frame.
  8214. */
  8215. update(): void;
  8216. /** @hidden */
  8217. _checkInputs(): void;
  8218. /** @hidden */
  8219. readonly rigCameras: Camera[];
  8220. /**
  8221. * Gets the post process used by the rig cameras
  8222. */
  8223. readonly rigPostProcess: Nullable<PostProcess>;
  8224. /**
  8225. * Internal, gets the first post proces.
  8226. * @returns the first post process to be run on this camera.
  8227. */
  8228. _getFirstPostProcess(): Nullable<PostProcess>;
  8229. private _cascadePostProcessesToRigCams;
  8230. /**
  8231. * Attach a post process to the camera.
  8232. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8233. * @param postProcess The post process to attach to the camera
  8234. * @param insertAt The position of the post process in case several of them are in use in the scene
  8235. * @returns the position the post process has been inserted at
  8236. */
  8237. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8238. /**
  8239. * Detach a post process to the camera.
  8240. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8241. * @param postProcess The post process to detach from the camera
  8242. */
  8243. detachPostProcess(postProcess: PostProcess): void;
  8244. /**
  8245. * Gets the current world matrix of the camera
  8246. */
  8247. getWorldMatrix(): Matrix;
  8248. /** @hidden */
  8249. protected _getViewMatrix(): Matrix;
  8250. /**
  8251. * Gets the current view matrix of the camera.
  8252. * @param force forces the camera to recompute the matrix without looking at the cached state
  8253. * @returns the view matrix
  8254. */
  8255. getViewMatrix(force?: boolean): Matrix;
  8256. /**
  8257. * Freeze the projection matrix.
  8258. * It will prevent the cache check of the camera projection compute and can speed up perf
  8259. * if no parameter of the camera are meant to change
  8260. * @param projection Defines manually a projection if necessary
  8261. */
  8262. freezeProjectionMatrix(projection?: Matrix): void;
  8263. /**
  8264. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8265. */
  8266. unfreezeProjectionMatrix(): void;
  8267. /**
  8268. * Gets the current projection matrix of the camera.
  8269. * @param force forces the camera to recompute the matrix without looking at the cached state
  8270. * @returns the projection matrix
  8271. */
  8272. getProjectionMatrix(force?: boolean): Matrix;
  8273. /**
  8274. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8275. * @returns a Matrix
  8276. */
  8277. getTransformationMatrix(): Matrix;
  8278. private _updateFrustumPlanes;
  8279. /**
  8280. * Checks if a cullable object (mesh...) is in the camera frustum
  8281. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8282. * @param target The object to check
  8283. * @returns true if the object is in frustum otherwise false
  8284. */
  8285. isInFrustum(target: ICullable): boolean;
  8286. /**
  8287. * Checks if a cullable object (mesh...) is in the camera frustum
  8288. * Unlike isInFrustum this cheks the full bounding box
  8289. * @param target The object to check
  8290. * @returns true if the object is in frustum otherwise false
  8291. */
  8292. isCompletelyInFrustum(target: ICullable): boolean;
  8293. /**
  8294. * Gets a ray in the forward direction from the camera.
  8295. * @param length Defines the length of the ray to create
  8296. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8297. * @param origin Defines the start point of the ray which defaults to the camera position
  8298. * @returns the forward ray
  8299. */
  8300. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8301. /**
  8302. * Releases resources associated with this node.
  8303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8305. */
  8306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8307. /**
  8308. * Gets the left camera of a rig setup in case of Rigged Camera
  8309. */
  8310. readonly leftCamera: Nullable<FreeCamera>;
  8311. /**
  8312. * Gets the right camera of a rig setup in case of Rigged Camera
  8313. */
  8314. readonly rightCamera: Nullable<FreeCamera>;
  8315. /**
  8316. * Gets the left camera target of a rig setup in case of Rigged Camera
  8317. * @returns the target position
  8318. */
  8319. getLeftTarget(): Nullable<Vector3>;
  8320. /**
  8321. * Gets the right camera target of a rig setup in case of Rigged Camera
  8322. * @returns the target position
  8323. */
  8324. getRightTarget(): Nullable<Vector3>;
  8325. /**
  8326. * @hidden
  8327. */
  8328. setCameraRigMode(mode: number, rigParams: any): void;
  8329. private _getVRProjectionMatrix;
  8330. protected _updateCameraRotationMatrix(): void;
  8331. protected _updateWebVRCameraRotationMatrix(): void;
  8332. /**
  8333. * This function MUST be overwritten by the different WebVR cameras available.
  8334. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8335. */
  8336. protected _getWebVRProjectionMatrix(): Matrix;
  8337. /**
  8338. * This function MUST be overwritten by the different WebVR cameras available.
  8339. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8340. */
  8341. protected _getWebVRViewMatrix(): Matrix;
  8342. /** @hidden */
  8343. setCameraRigParameter(name: string, value: any): void;
  8344. /**
  8345. * needs to be overridden by children so sub has required properties to be copied
  8346. * @hidden
  8347. */
  8348. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8349. /**
  8350. * May need to be overridden by children
  8351. * @hidden
  8352. */
  8353. _updateRigCameras(): void;
  8354. /** @hidden */
  8355. _setupInputs(): void;
  8356. /**
  8357. * Serialiaze the camera setup to a json represention
  8358. * @returns the JSON representation
  8359. */
  8360. serialize(): any;
  8361. /**
  8362. * Clones the current camera.
  8363. * @param name The cloned camera name
  8364. * @returns the cloned camera
  8365. */
  8366. clone(name: string): Camera;
  8367. /**
  8368. * Gets the direction of the camera relative to a given local axis.
  8369. * @param localAxis Defines the reference axis to provide a relative direction.
  8370. * @return the direction
  8371. */
  8372. getDirection(localAxis: Vector3): Vector3;
  8373. /**
  8374. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8375. * @param localAxis Defines the reference axis to provide a relative direction.
  8376. * @param result Defines the vector to store the result in
  8377. */
  8378. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8379. /**
  8380. * Gets a camera constructor for a given camera type
  8381. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8382. * @param name The name of the camera the result will be able to instantiate
  8383. * @param scene The scene the result will construct the camera in
  8384. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8385. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8386. * @returns a factory method to construc the camera
  8387. */
  8388. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8389. /**
  8390. * Compute the world matrix of the camera.
  8391. * @returns the camera workd matrix
  8392. */
  8393. computeWorldMatrix(): Matrix;
  8394. /**
  8395. * Parse a JSON and creates the camera from the parsed information
  8396. * @param parsedCamera The JSON to parse
  8397. * @param scene The scene to instantiate the camera in
  8398. * @returns the newly constructed camera
  8399. */
  8400. static Parse(parsedCamera: any, scene: Scene): Camera;
  8401. }
  8402. }
  8403. declare module BABYLON {
  8404. /**
  8405. * @ignore
  8406. * This is a list of all the different input types that are available in the application.
  8407. * Fo instance: ArcRotateCameraGamepadInput...
  8408. */
  8409. var CameraInputTypes: {};
  8410. /**
  8411. * This is the contract to implement in order to create a new input class.
  8412. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8413. */
  8414. interface ICameraInput<TCamera extends Camera> {
  8415. /**
  8416. * Defines the camera the input is attached to.
  8417. */
  8418. camera: Nullable<TCamera>;
  8419. /**
  8420. * Gets the class name of the current intput.
  8421. * @returns the class name
  8422. */
  8423. getClassName(): string;
  8424. /**
  8425. * Get the friendly name associated with the input class.
  8426. * @returns the input friendly name
  8427. */
  8428. getSimpleName(): string;
  8429. /**
  8430. * Attach the input controls to a specific dom element to get the input from.
  8431. * @param element Defines the element the controls should be listened from
  8432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8433. */
  8434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8435. /**
  8436. * Detach the current controls from the specified dom element.
  8437. * @param element Defines the element to stop listening the inputs from
  8438. */
  8439. detachControl(element: Nullable<HTMLElement>): void;
  8440. /**
  8441. * Update the current camera state depending on the inputs that have been used this frame.
  8442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8443. */
  8444. checkInputs?: () => void;
  8445. }
  8446. /**
  8447. * Represents a map of input types to input instance or input index to input instance.
  8448. */
  8449. interface CameraInputsMap<TCamera extends Camera> {
  8450. /**
  8451. * Accessor to the input by input type.
  8452. */
  8453. [name: string]: ICameraInput<TCamera>;
  8454. /**
  8455. * Accessor to the input by input index.
  8456. */
  8457. [idx: number]: ICameraInput<TCamera>;
  8458. }
  8459. /**
  8460. * This represents the input manager used within a camera.
  8461. * It helps dealing with all the different kind of input attached to a camera.
  8462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8463. */
  8464. class CameraInputsManager<TCamera extends Camera> {
  8465. /**
  8466. * Defines the list of inputs attahed to the camera.
  8467. */
  8468. attached: CameraInputsMap<TCamera>;
  8469. /**
  8470. * Defines the dom element the camera is collecting inputs from.
  8471. * This is null if the controls have not been attached.
  8472. */
  8473. attachedElement: Nullable<HTMLElement>;
  8474. /**
  8475. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8476. */
  8477. noPreventDefault: boolean;
  8478. /**
  8479. * Defined the camera the input manager belongs to.
  8480. */
  8481. camera: TCamera;
  8482. /**
  8483. * Update the current camera state depending on the inputs that have been used this frame.
  8484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8485. */
  8486. checkInputs: () => void;
  8487. /**
  8488. * Instantiate a new Camera Input Manager.
  8489. * @param camera Defines the camera the input manager blongs to
  8490. */
  8491. constructor(camera: TCamera);
  8492. /**
  8493. * Add an input method to a camera
  8494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8495. * @param input camera input method
  8496. */
  8497. add(input: ICameraInput<TCamera>): void;
  8498. /**
  8499. * Remove a specific input method from a camera
  8500. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8501. * @param inputToRemove camera input method
  8502. */
  8503. remove(inputToRemove: ICameraInput<TCamera>): void;
  8504. /**
  8505. * Remove a specific input type from a camera
  8506. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8507. * @param inputType the type of the input to remove
  8508. */
  8509. removeByType(inputType: string): void;
  8510. private _addCheckInputs;
  8511. /**
  8512. * Attach the input controls to the currently attached dom element to listen the events from.
  8513. * @param input Defines the input to attach
  8514. */
  8515. attachInput(input: ICameraInput<TCamera>): void;
  8516. /**
  8517. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8518. * @param element Defines the dom element to collect the events from
  8519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8520. */
  8521. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8522. /**
  8523. * Detach the current manager inputs controls from a specific dom element.
  8524. * @param element Defines the dom element to collect the events from
  8525. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8526. */
  8527. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8528. /**
  8529. * Rebuild the dynamic inputCheck function from the current list of
  8530. * defined inputs in the manager.
  8531. */
  8532. rebuildInputCheck(): void;
  8533. /**
  8534. * Remove all attached input methods from a camera
  8535. */
  8536. clear(): void;
  8537. /**
  8538. * Serialize the current input manager attached to a camera.
  8539. * This ensures than once parsed,
  8540. * the input associated to the camera will be identical to the current ones
  8541. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8542. */
  8543. serialize(serializedCamera: any): void;
  8544. /**
  8545. * Parses an input manager serialized JSON to restore the previous list of inputs
  8546. * and states associated to a camera.
  8547. * @param parsedCamera Defines the JSON to parse
  8548. */
  8549. parse(parsedCamera: any): void;
  8550. }
  8551. }
  8552. declare module BABYLON {
  8553. /**
  8554. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8555. * being tilted forward or back and left or right.
  8556. */
  8557. class DeviceOrientationCamera extends FreeCamera {
  8558. private _initialQuaternion;
  8559. private _quaternionCache;
  8560. /**
  8561. * Creates a new device orientation camera
  8562. * @param name The name of the camera
  8563. * @param position The start position camera
  8564. * @param scene The scene the camera belongs to
  8565. */
  8566. constructor(name: string, position: Vector3, scene: Scene);
  8567. /**
  8568. * Gets the current instance class name ("DeviceOrientationCamera").
  8569. * This helps avoiding instanceof at run time.
  8570. * @returns the class name
  8571. */
  8572. getClassName(): string;
  8573. /**
  8574. * @hidden
  8575. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8576. */
  8577. _checkInputs(): void;
  8578. /**
  8579. * Reset the camera to its default orientation on the specified axis only.
  8580. * @param axis The axis to reset
  8581. */
  8582. resetToCurrentRotation(axis?: Axis): void;
  8583. }
  8584. }
  8585. declare module BABYLON {
  8586. /**
  8587. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8588. * such as in a 3D Space Shooter or a Flight Simulator.
  8589. */
  8590. class FlyCamera extends TargetCamera {
  8591. /**
  8592. * Define the collision ellipsoid of the camera.
  8593. * This is helpful for simulating a camera body, like a player's body.
  8594. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8595. */
  8596. ellipsoid: Vector3;
  8597. /**
  8598. * Define an offset for the position of the ellipsoid around the camera.
  8599. * This can be helpful if the camera is attached away from the player's body center,
  8600. * such as at its head.
  8601. */
  8602. ellipsoidOffset: Vector3;
  8603. /**
  8604. * Enable or disable collisions of the camera with the rest of the scene objects.
  8605. */
  8606. checkCollisions: boolean;
  8607. /**
  8608. * Enable or disable gravity on the camera.
  8609. */
  8610. applyGravity: boolean;
  8611. /**
  8612. * Define the current direction the camera is moving to.
  8613. */
  8614. cameraDirection: Vector3;
  8615. /**
  8616. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8617. * This overrides and empties cameraRotation.
  8618. */
  8619. rotationQuaternion: BABYLON.Quaternion;
  8620. /**
  8621. * Track Roll to maintain the wanted Rolling when looking around.
  8622. */
  8623. _trackRoll: number;
  8624. /**
  8625. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8626. */
  8627. rollCorrect: number;
  8628. /**
  8629. * Mimic a banked turn, Rolling the camera when Yawing.
  8630. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8631. */
  8632. bankedTurn: boolean;
  8633. /**
  8634. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8635. */
  8636. bankedTurnLimit: number;
  8637. /**
  8638. * Value of 0 disables the banked Roll.
  8639. * Value of 1 is equal to the Yaw angle in radians.
  8640. */
  8641. bankedTurnMultiplier: number;
  8642. /**
  8643. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8644. */
  8645. inputs: FlyCameraInputsManager;
  8646. /**
  8647. * Gets the input sensibility for mouse input.
  8648. * Higher values reduce sensitivity.
  8649. */
  8650. /**
  8651. * Sets the input sensibility for a mouse input.
  8652. * Higher values reduce sensitivity.
  8653. */
  8654. angularSensibility: number;
  8655. /**
  8656. * Get the keys for camera movement forward.
  8657. */
  8658. /**
  8659. * Set the keys for camera movement forward.
  8660. */
  8661. keysForward: number[];
  8662. /**
  8663. * Get the keys for camera movement backward.
  8664. */
  8665. keysBackward: number[];
  8666. /**
  8667. * Get the keys for camera movement up.
  8668. */
  8669. /**
  8670. * Set the keys for camera movement up.
  8671. */
  8672. keysUp: number[];
  8673. /**
  8674. * Get the keys for camera movement down.
  8675. */
  8676. /**
  8677. * Set the keys for camera movement down.
  8678. */
  8679. keysDown: number[];
  8680. /**
  8681. * Get the keys for camera movement left.
  8682. */
  8683. /**
  8684. * Set the keys for camera movement left.
  8685. */
  8686. keysLeft: number[];
  8687. /**
  8688. * Set the keys for camera movement right.
  8689. */
  8690. /**
  8691. * Set the keys for camera movement right.
  8692. */
  8693. keysRight: number[];
  8694. /**
  8695. * Event raised when the camera collides with a mesh in the scene.
  8696. */
  8697. onCollide: (collidedMesh: AbstractMesh) => void;
  8698. private _collider;
  8699. private _needMoveForGravity;
  8700. private _oldPosition;
  8701. private _diffPosition;
  8702. private _newPosition;
  8703. /** @hidden */
  8704. _localDirection: Vector3;
  8705. /** @hidden */
  8706. _transformedDirection: Vector3;
  8707. /**
  8708. * Instantiates a FlyCamera.
  8709. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8710. * such as in a 3D Space Shooter or a Flight Simulator.
  8711. * @param name Define the name of the camera in the scene.
  8712. * @param position Define the starting position of the camera in the scene.
  8713. * @param scene Define the scene the camera belongs to.
  8714. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8715. */
  8716. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8717. /**
  8718. * Attach a control to the HTML DOM element.
  8719. * @param element Defines the element that listens to the input events.
  8720. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8721. */
  8722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8723. /**
  8724. * Detach a control from the HTML DOM element.
  8725. * The camera will stop reacting to that input.
  8726. * @param element Defines the element that listens to the input events.
  8727. */
  8728. detachControl(element: HTMLElement): void;
  8729. private _collisionMask;
  8730. /**
  8731. * Get the mask that the camera ignores in collision events.
  8732. */
  8733. /**
  8734. * Set the mask that the camera ignores in collision events.
  8735. */
  8736. collisionMask: number;
  8737. /** @hidden */
  8738. _collideWithWorld(displacement: Vector3): void;
  8739. /** @hidden */
  8740. private _onCollisionPositionChange;
  8741. /** @hidden */
  8742. _checkInputs(): void;
  8743. /** @hidden */
  8744. _decideIfNeedsToMove(): boolean;
  8745. /** @hidden */
  8746. _updatePosition(): void;
  8747. /**
  8748. * Restore the Roll to its target value at the rate specified.
  8749. * @param rate - Higher means slower restoring.
  8750. * @hidden
  8751. */
  8752. restoreRoll(rate: number): void;
  8753. /**
  8754. * Destroy the camera and release the current resources held by it.
  8755. */
  8756. dispose(): void;
  8757. /**
  8758. * Get the current object class name.
  8759. * @returns the class name.
  8760. */
  8761. getClassName(): string;
  8762. }
  8763. }
  8764. declare module BABYLON {
  8765. /**
  8766. * Default Inputs manager for the FlyCamera.
  8767. * It groups all the default supported inputs for ease of use.
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. */
  8770. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8771. /**
  8772. * Instantiates a new FlyCameraInputsManager.
  8773. * @param camera Defines the camera the inputs belong to.
  8774. */
  8775. constructor(camera: FlyCamera);
  8776. /**
  8777. * Add keyboard input support to the input manager.
  8778. * @returns the new FlyCameraKeyboardMoveInput().
  8779. */
  8780. addKeyboard(): FlyCameraInputsManager;
  8781. /**
  8782. * Add mouse input support to the input manager.
  8783. * @param touchEnabled Enable touch screen support.
  8784. * @returns the new FlyCameraMouseInput().
  8785. */
  8786. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8787. }
  8788. }
  8789. declare module BABYLON {
  8790. /**
  8791. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8792. * an arc rotate version arcFollowCamera are available.
  8793. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8794. */
  8795. class FollowCamera extends TargetCamera {
  8796. /**
  8797. * Distance the follow camera should follow an object at
  8798. */
  8799. radius: number;
  8800. /**
  8801. * Define a rotation offset between the camera and the object it follows
  8802. */
  8803. rotationOffset: number;
  8804. /**
  8805. * Define a height offset between the camera and the object it follows.
  8806. * It can help following an object from the top (like a car chaing a plane)
  8807. */
  8808. heightOffset: number;
  8809. /**
  8810. * Define how fast the camera can accelerate to follow it s target.
  8811. */
  8812. cameraAcceleration: number;
  8813. /**
  8814. * Define the speed limit of the camera following an object.
  8815. */
  8816. maxCameraSpeed: number;
  8817. /**
  8818. * Define the target of the camera.
  8819. */
  8820. lockedTarget: Nullable<AbstractMesh>;
  8821. /**
  8822. * Instantiates the follow camera.
  8823. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8824. * @param name Define the name of the camera in the scene
  8825. * @param position Define the position of the camera
  8826. * @param scene Define the scene the camera belong to
  8827. * @param lockedTarget Define the target of the camera
  8828. */
  8829. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8830. private _follow;
  8831. /** @hidden */
  8832. _checkInputs(): void;
  8833. /**
  8834. * Gets the camera class name.
  8835. * @returns the class name
  8836. */
  8837. getClassName(): string;
  8838. }
  8839. /**
  8840. * Arc Rotate version of the follow camera.
  8841. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8842. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8843. */
  8844. class ArcFollowCamera extends TargetCamera {
  8845. /** The longitudinal angle of the camera */
  8846. alpha: number;
  8847. /** The latitudinal angle of the camera */
  8848. beta: number;
  8849. /** The radius of the camera from its target */
  8850. radius: number;
  8851. /** Define the camera target (the messh it should follow) */
  8852. target: Nullable<AbstractMesh>;
  8853. private _cartesianCoordinates;
  8854. /**
  8855. * Instantiates a new ArcFollowCamera
  8856. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8857. * @param name Define the name of the camera
  8858. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8859. * @param beta Define the rotation angle of the camera around the elevation axis
  8860. * @param radius Define the radius of the camera from its target point
  8861. * @param target Define the target of the camera
  8862. * @param scene Define the scene the camera belongs to
  8863. */
  8864. constructor(name: string,
  8865. /** The longitudinal angle of the camera */
  8866. alpha: number,
  8867. /** The latitudinal angle of the camera */
  8868. beta: number,
  8869. /** The radius of the camera from its target */
  8870. radius: number,
  8871. /** Define the camera target (the messh it should follow) */
  8872. target: Nullable<AbstractMesh>, scene: Scene);
  8873. private _follow;
  8874. /** @hidden */
  8875. _checkInputs(): void;
  8876. /**
  8877. * Returns the class name of the object.
  8878. * It is mostly used internally for serialization purposes.
  8879. */
  8880. getClassName(): string;
  8881. }
  8882. }
  8883. declare module BABYLON {
  8884. /**
  8885. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8886. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8888. */
  8889. class FreeCamera extends TargetCamera {
  8890. /**
  8891. * Define the collision ellipsoid of the camera.
  8892. * This is helpful to simulate a camera body like the player body around the camera
  8893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8894. */
  8895. ellipsoid: Vector3;
  8896. /**
  8897. * Define an offset for the position of the ellipsoid around the camera.
  8898. * This can be helpful to determine the center of the body near the gravity center of the body
  8899. * instead of its head.
  8900. */
  8901. ellipsoidOffset: Vector3;
  8902. /**
  8903. * Enable or disable collisions of the camera with the rest of the scene objects.
  8904. */
  8905. checkCollisions: boolean;
  8906. /**
  8907. * Enable or disable gravity on the camera.
  8908. */
  8909. applyGravity: boolean;
  8910. /**
  8911. * Define the input manager associated to the camera.
  8912. */
  8913. inputs: FreeCameraInputsManager;
  8914. /**
  8915. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8916. * Higher values reduce sensitivity.
  8917. */
  8918. /**
  8919. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8920. * Higher values reduce sensitivity.
  8921. */
  8922. angularSensibility: number;
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8925. */
  8926. keysUp: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8929. */
  8930. keysDown: number[];
  8931. /**
  8932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8933. */
  8934. keysLeft: number[];
  8935. /**
  8936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8937. */
  8938. keysRight: number[];
  8939. /**
  8940. * Event raised when the camera collide with a mesh in the scene.
  8941. */
  8942. onCollide: (collidedMesh: AbstractMesh) => void;
  8943. private _collider;
  8944. private _needMoveForGravity;
  8945. private _oldPosition;
  8946. private _diffPosition;
  8947. private _newPosition;
  8948. /** @hidden */
  8949. _localDirection: Vector3;
  8950. /** @hidden */
  8951. _transformedDirection: Vector3;
  8952. /**
  8953. * Instantiates a Free Camera.
  8954. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8955. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8957. * @param name Define the name of the camera in the scene
  8958. * @param position Define the start position of the camera in the scene
  8959. * @param scene Define the scene the camera belongs to
  8960. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8961. */
  8962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8963. /**
  8964. * Attached controls to the current camera.
  8965. * @param element Defines the element the controls should be listened from
  8966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8967. */
  8968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8969. /**
  8970. * Detach the current controls from the camera.
  8971. * The camera will stop reacting to inputs.
  8972. * @param element Defines the element to stop listening the inputs from
  8973. */
  8974. detachControl(element: HTMLElement): void;
  8975. private _collisionMask;
  8976. /**
  8977. * Define a collision mask to limit the list of object the camera can collide with
  8978. */
  8979. collisionMask: number;
  8980. /** @hidden */
  8981. _collideWithWorld(displacement: Vector3): void;
  8982. private _onCollisionPositionChange;
  8983. /** @hidden */
  8984. _checkInputs(): void;
  8985. /** @hidden */
  8986. _decideIfNeedsToMove(): boolean;
  8987. /** @hidden */
  8988. _updatePosition(): void;
  8989. /**
  8990. * Destroy the camera and release the current resources hold by it.
  8991. */
  8992. dispose(): void;
  8993. /**
  8994. * Gets the current object class name.
  8995. * @return the class name
  8996. */
  8997. getClassName(): string;
  8998. }
  8999. }
  9000. declare module BABYLON {
  9001. /**
  9002. * Default Inputs manager for the FreeCamera.
  9003. * It groups all the default supported inputs for ease of use.
  9004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9005. */
  9006. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9007. /**
  9008. * Instantiates a new FreeCameraInputsManager.
  9009. * @param camera Defines the camera the inputs belong to
  9010. */
  9011. constructor(camera: FreeCamera);
  9012. /**
  9013. * Add keyboard input support to the input manager.
  9014. * @returns the current input manager
  9015. */
  9016. addKeyboard(): FreeCameraInputsManager;
  9017. /**
  9018. * Add mouse input support to the input manager.
  9019. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9020. * @returns the current input manager
  9021. */
  9022. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9023. /**
  9024. * Add orientation input support to the input manager.
  9025. * @returns the current input manager
  9026. */
  9027. addDeviceOrientation(): FreeCameraInputsManager;
  9028. /**
  9029. * Add touch input support to the input manager.
  9030. * @returns the current input manager
  9031. */
  9032. addTouch(): FreeCameraInputsManager;
  9033. /**
  9034. * Add virtual joystick input support to the input manager.
  9035. * @returns the current input manager
  9036. */
  9037. addVirtualJoystick(): FreeCameraInputsManager;
  9038. }
  9039. }
  9040. declare module BABYLON {
  9041. /**
  9042. * This represents a FPS type of camera. This is only here for back compat purpose.
  9043. * Please use the UniversalCamera instead as both are identical.
  9044. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9045. */
  9046. class GamepadCamera extends UniversalCamera {
  9047. /**
  9048. * Instantiates a new Gamepad Camera
  9049. * This represents a FPS type of camera. This is only here for back compat purpose.
  9050. * Please use the UniversalCamera instead as both are identical.
  9051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9052. * @param name Define the name of the camera in the scene
  9053. * @param position Define the start position of the camera in the scene
  9054. * @param scene Define the scene the camera belongs to
  9055. */
  9056. constructor(name: string, position: Vector3, scene: Scene);
  9057. /**
  9058. * Gets the current object class name.
  9059. * @return the class name
  9060. */
  9061. getClassName(): string;
  9062. }
  9063. }
  9064. declare module BABYLON {
  9065. /**
  9066. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9067. * This is the base of the follow, arc rotate cameras and Free camera
  9068. * @see http://doc.babylonjs.com/features/cameras
  9069. */
  9070. class TargetCamera extends Camera {
  9071. /**
  9072. * Define the current direction the camera is moving to
  9073. */
  9074. cameraDirection: Vector3;
  9075. /**
  9076. * Define the current rotation the camera is rotating to
  9077. */
  9078. cameraRotation: Vector2;
  9079. /**
  9080. * Define the current rotation of the camera
  9081. */
  9082. rotation: Vector3;
  9083. /**
  9084. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9085. */
  9086. rotationQuaternion: Quaternion;
  9087. /**
  9088. * Define the current speed of the camera
  9089. */
  9090. speed: number;
  9091. /**
  9092. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9093. * around all axis.
  9094. */
  9095. noRotationConstraint: boolean;
  9096. /**
  9097. * Define the current target of the camera as an object or a position.
  9098. */
  9099. lockedTarget: any;
  9100. /** @hidden */
  9101. _currentTarget: Vector3;
  9102. /** @hidden */
  9103. _viewMatrix: Matrix;
  9104. /** @hidden */
  9105. _camMatrix: Matrix;
  9106. /** @hidden */
  9107. _cameraTransformMatrix: Matrix;
  9108. /** @hidden */
  9109. _cameraRotationMatrix: Matrix;
  9110. private _rigCamTransformMatrix;
  9111. /** @hidden */
  9112. _referencePoint: Vector3;
  9113. /** @hidden */
  9114. _transformedReferencePoint: Vector3;
  9115. protected _globalCurrentTarget: Vector3;
  9116. protected _globalCurrentUpVector: Vector3;
  9117. /** @hidden */
  9118. _reset: () => void;
  9119. private _defaultUp;
  9120. /**
  9121. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9122. * This is the base of the follow, arc rotate cameras and Free camera
  9123. * @see http://doc.babylonjs.com/features/cameras
  9124. * @param name Defines the name of the camera in the scene
  9125. * @param position Defines the start position of the camera in the scene
  9126. * @param scene Defines the scene the camera belongs to
  9127. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9128. */
  9129. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9130. /**
  9131. * Gets the position in front of the camera at a given distance.
  9132. * @param distance The distance from the camera we want the position to be
  9133. * @returns the position
  9134. */
  9135. getFrontPosition(distance: number): Vector3;
  9136. /** @hidden */
  9137. _getLockedTargetPosition(): Nullable<Vector3>;
  9138. private _storedPosition;
  9139. private _storedRotation;
  9140. private _storedRotationQuaternion;
  9141. /**
  9142. * Store current camera state of the camera (fov, position, rotation, etc..)
  9143. * @returns the camera
  9144. */
  9145. storeState(): Camera;
  9146. /**
  9147. * Restored camera state. You must call storeState() first
  9148. * @returns whether it was successful or not
  9149. * @hidden
  9150. */
  9151. _restoreStateValues(): boolean;
  9152. /** @hidden */
  9153. _initCache(): void;
  9154. /** @hidden */
  9155. _updateCache(ignoreParentClass?: boolean): void;
  9156. /** @hidden */
  9157. _isSynchronizedViewMatrix(): boolean;
  9158. /** @hidden */
  9159. _computeLocalCameraSpeed(): number;
  9160. /** @hidden */
  9161. setTarget(target: Vector3): void;
  9162. /**
  9163. * Return the current target position of the camera. This value is expressed in local space.
  9164. * @returns the target position
  9165. */
  9166. getTarget(): Vector3;
  9167. /** @hidden */
  9168. _decideIfNeedsToMove(): boolean;
  9169. /** @hidden */
  9170. _updatePosition(): void;
  9171. /** @hidden */
  9172. _checkInputs(): void;
  9173. protected _updateCameraRotationMatrix(): void;
  9174. /**
  9175. * 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)
  9176. * @returns the current camera
  9177. */
  9178. private _rotateUpVectorWithCameraRotationMatrix;
  9179. private _cachedRotationZ;
  9180. private _cachedQuaternionRotationZ;
  9181. /** @hidden */
  9182. _getViewMatrix(): Matrix;
  9183. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9184. /**
  9185. * @hidden
  9186. */
  9187. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9188. /**
  9189. * @hidden
  9190. */
  9191. _updateRigCameras(): void;
  9192. private _getRigCamPosition;
  9193. /**
  9194. * Gets the current object class name.
  9195. * @return the class name
  9196. */
  9197. getClassName(): string;
  9198. }
  9199. }
  9200. declare module BABYLON {
  9201. /**
  9202. * This represents a FPS type of camera controlled by touch.
  9203. * This is like a universal camera minus the Gamepad controls.
  9204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9205. */
  9206. class TouchCamera extends FreeCamera {
  9207. /**
  9208. * Defines the touch sensibility for rotation.
  9209. * The higher the faster.
  9210. */
  9211. touchAngularSensibility: number;
  9212. /**
  9213. * Defines the touch sensibility for move.
  9214. * The higher the faster.
  9215. */
  9216. touchMoveSensibility: number;
  9217. /**
  9218. * Instantiates a new touch camera.
  9219. * This represents a FPS type of camera controlled by touch.
  9220. * This is like a universal camera minus the Gamepad controls.
  9221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9222. * @param name Define the name of the camera in the scene
  9223. * @param position Define the start position of the camera in the scene
  9224. * @param scene Define the scene the camera belongs to
  9225. */
  9226. constructor(name: string, position: Vector3, scene: Scene);
  9227. /**
  9228. * Gets the current object class name.
  9229. * @return the class name
  9230. */
  9231. getClassName(): string;
  9232. /** @hidden */
  9233. _setupInputs(): void;
  9234. }
  9235. }
  9236. declare module BABYLON {
  9237. /**
  9238. * 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,
  9239. * which still works and will still be found in many Playgrounds.
  9240. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9241. */
  9242. class UniversalCamera extends TouchCamera {
  9243. /**
  9244. * Defines the gamepad rotation sensiblity.
  9245. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9246. */
  9247. gamepadAngularSensibility: number;
  9248. /**
  9249. * Defines the gamepad move sensiblity.
  9250. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9251. */
  9252. gamepadMoveSensibility: number;
  9253. /**
  9254. * 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,
  9255. * which still works and will still be found in many Playgrounds.
  9256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9257. * @param name Define the name of the camera in the scene
  9258. * @param position Define the start position of the camera in the scene
  9259. * @param scene Define the scene the camera belongs to
  9260. */
  9261. constructor(name: string, position: Vector3, scene: Scene);
  9262. /**
  9263. * Gets the current object class name.
  9264. * @return the class name
  9265. */
  9266. getClassName(): string;
  9267. }
  9268. }
  9269. declare module BABYLON {
  9270. /**
  9271. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  9272. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9273. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9274. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9275. */
  9276. class VirtualJoysticksCamera extends FreeCamera {
  9277. /**
  9278. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  9279. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9280. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9281. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9282. * @param name Define the name of the camera in the scene
  9283. * @param position Define the start position of the camera in the scene
  9284. * @param scene Define the scene the camera belongs to
  9285. */
  9286. constructor(name: string, position: Vector3, scene: Scene);
  9287. /**
  9288. * Gets the current object class name.
  9289. * @return the class name
  9290. */
  9291. getClassName(): string;
  9292. }
  9293. }
  9294. interface VRDisplay extends EventTarget {
  9295. /**
  9296. * Dictionary of capabilities describing the VRDisplay.
  9297. */
  9298. readonly capabilities: VRDisplayCapabilities;
  9299. /**
  9300. * z-depth defining the far plane of the eye view frustum
  9301. * enables mapping of values in the render target depth
  9302. * attachment to scene coordinates. Initially set to 10000.0.
  9303. */
  9304. depthFar: number;
  9305. /**
  9306. * z-depth defining the near plane of the eye view frustum
  9307. * enables mapping of values in the render target depth
  9308. * attachment to scene coordinates. Initially set to 0.01.
  9309. */
  9310. depthNear: number;
  9311. /**
  9312. * An identifier for this distinct VRDisplay. Used as an
  9313. * association point in the Gamepad API.
  9314. */
  9315. readonly displayId: number;
  9316. /**
  9317. * A display name, a user-readable name identifying it.
  9318. */
  9319. readonly displayName: string;
  9320. readonly isConnected: boolean;
  9321. readonly isPresenting: boolean;
  9322. /**
  9323. * If this VRDisplay supports room-scale experiences, the optional
  9324. * stage attribute contains details on the room-scale parameters.
  9325. */
  9326. readonly stageParameters: VRStageParameters | null;
  9327. /**
  9328. * Passing the value returned by `requestAnimationFrame` to
  9329. * `cancelAnimationFrame` will unregister the callback.
  9330. * @param handle Define the hanle of the request to cancel
  9331. */
  9332. cancelAnimationFrame(handle: number): void;
  9333. /**
  9334. * Stops presenting to the VRDisplay.
  9335. * @returns a promise to know when it stopped
  9336. */
  9337. exitPresent(): Promise<void>;
  9338. /**
  9339. * Return the current VREyeParameters for the given eye.
  9340. * @param whichEye Define the eye we want the parameter for
  9341. * @returns the eye parameters
  9342. */
  9343. getEyeParameters(whichEye: string): VREyeParameters;
  9344. /**
  9345. * Populates the passed VRFrameData with the information required to render
  9346. * the current frame.
  9347. * @param frameData Define the data structure to populate
  9348. * @returns true if ok otherwise false
  9349. */
  9350. getFrameData(frameData: VRFrameData): boolean;
  9351. /**
  9352. * Get the layers currently being presented.
  9353. * @returns the list of VR layers
  9354. */
  9355. getLayers(): VRLayer[];
  9356. /**
  9357. * Return a VRPose containing the future predicted pose of the VRDisplay
  9358. * when the current frame will be presented. The value returned will not
  9359. * change until JavaScript has returned control to the browser.
  9360. *
  9361. * The VRPose will contain the position, orientation, velocity,
  9362. * and acceleration of each of these properties.
  9363. * @returns the pose object
  9364. */
  9365. getPose(): VRPose;
  9366. /**
  9367. * Return the current instantaneous pose of the VRDisplay, with no
  9368. * prediction applied.
  9369. * @returns the current instantaneous pose
  9370. */
  9371. getImmediatePose(): VRPose;
  9372. /**
  9373. * The callback passed to `requestAnimationFrame` will be called
  9374. * any time a new frame should be rendered. When the VRDisplay is
  9375. * presenting the callback will be called at the native refresh
  9376. * rate of the HMD. When not presenting this function acts
  9377. * identically to how window.requestAnimationFrame acts. Content should
  9378. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9379. * asynchronously from other displays and at differing refresh rates.
  9380. * @param callback Define the eaction to run next frame
  9381. * @returns the request handle it
  9382. */
  9383. requestAnimationFrame(callback: FrameRequestCallback): number;
  9384. /**
  9385. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9386. * Repeat calls while already presenting will update the VRLayers being displayed.
  9387. * @param layers Define the list of layer to present
  9388. * @returns a promise to know when the request has been fulfilled
  9389. */
  9390. requestPresent(layers: VRLayer[]): Promise<void>;
  9391. /**
  9392. * Reset the pose for this display, treating its current position and
  9393. * orientation as the "origin/zero" values. VRPose.position,
  9394. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9395. * updated when calling resetPose(). This should be called in only
  9396. * sitting-space experiences.
  9397. */
  9398. resetPose(): void;
  9399. /**
  9400. * The VRLayer provided to the VRDisplay will be captured and presented
  9401. * in the HMD. Calling this function has the same effect on the source
  9402. * canvas as any other operation that uses its source image, and canvases
  9403. * created without preserveDrawingBuffer set to true will be cleared.
  9404. * @param pose Define the pose to submit
  9405. */
  9406. submitFrame(pose?: VRPose): void;
  9407. }
  9408. declare var VRDisplay: {
  9409. prototype: VRDisplay;
  9410. new (): VRDisplay;
  9411. };
  9412. interface VRLayer {
  9413. leftBounds?: number[] | Float32Array | null;
  9414. rightBounds?: number[] | Float32Array | null;
  9415. source?: HTMLCanvasElement | null;
  9416. }
  9417. interface VRDisplayCapabilities {
  9418. readonly canPresent: boolean;
  9419. readonly hasExternalDisplay: boolean;
  9420. readonly hasOrientation: boolean;
  9421. readonly hasPosition: boolean;
  9422. readonly maxLayers: number;
  9423. }
  9424. interface VREyeParameters {
  9425. /** @deprecated */
  9426. readonly fieldOfView: VRFieldOfView;
  9427. readonly offset: Float32Array;
  9428. readonly renderHeight: number;
  9429. readonly renderWidth: number;
  9430. }
  9431. interface VRFieldOfView {
  9432. readonly downDegrees: number;
  9433. readonly leftDegrees: number;
  9434. readonly rightDegrees: number;
  9435. readonly upDegrees: number;
  9436. }
  9437. interface VRFrameData {
  9438. readonly leftProjectionMatrix: Float32Array;
  9439. readonly leftViewMatrix: Float32Array;
  9440. readonly pose: VRPose;
  9441. readonly rightProjectionMatrix: Float32Array;
  9442. readonly rightViewMatrix: Float32Array;
  9443. readonly timestamp: number;
  9444. }
  9445. interface VRPose {
  9446. readonly angularAcceleration: Float32Array | null;
  9447. readonly angularVelocity: Float32Array | null;
  9448. readonly linearAcceleration: Float32Array | null;
  9449. readonly linearVelocity: Float32Array | null;
  9450. readonly orientation: Float32Array | null;
  9451. readonly position: Float32Array | null;
  9452. readonly timestamp: number;
  9453. }
  9454. interface VRStageParameters {
  9455. sittingToStandingTransform?: Float32Array;
  9456. sizeX?: number;
  9457. sizeY?: number;
  9458. }
  9459. interface Navigator {
  9460. getVRDisplays(): Promise<VRDisplay[]>;
  9461. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9462. }
  9463. interface Window {
  9464. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9465. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9466. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9467. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9468. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9469. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9470. }
  9471. interface Gamepad {
  9472. readonly displayId: number;
  9473. }
  9474. /**
  9475. * Module Debug contains the (visual) components to debug a scene correctly
  9476. */
  9477. declare module BABYLON.Debug {
  9478. /**
  9479. * The Axes viewer will show 3 axes in a specific point in space
  9480. */
  9481. class AxesViewer {
  9482. private _xline;
  9483. private _yline;
  9484. private _zline;
  9485. private _xmesh;
  9486. private _ymesh;
  9487. private _zmesh;
  9488. /**
  9489. * Gets the hosting scene
  9490. */
  9491. scene: Nullable<Scene>;
  9492. /**
  9493. * Gets or sets a number used to scale line length
  9494. */
  9495. scaleLines: number;
  9496. /**
  9497. * Creates a new AxesViewer
  9498. * @param scene defines the hosting scene
  9499. * @param scaleLines defines a number used to scale line length (1 by default)
  9500. */
  9501. constructor(scene: Scene, scaleLines?: number);
  9502. /**
  9503. * Force the viewer to update
  9504. * @param position defines the position of the viewer
  9505. * @param xaxis defines the x axis of the viewer
  9506. * @param yaxis defines the y axis of the viewer
  9507. * @param zaxis defines the z axis of the viewer
  9508. */
  9509. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9510. /** Releases resources */
  9511. dispose(): void;
  9512. }
  9513. }
  9514. declare module BABYLON.Debug {
  9515. /**
  9516. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9517. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9518. */
  9519. class BoneAxesViewer extends AxesViewer {
  9520. /**
  9521. * Gets or sets the target mesh where to display the axes viewer
  9522. */
  9523. mesh: Nullable<Mesh>;
  9524. /**
  9525. * Gets or sets the target bone where to display the axes viewer
  9526. */
  9527. bone: Nullable<Bone>;
  9528. /** Gets current position */
  9529. pos: Vector3;
  9530. /** Gets direction of X axis */
  9531. xaxis: Vector3;
  9532. /** Gets direction of Y axis */
  9533. yaxis: Vector3;
  9534. /** Gets direction of Z axis */
  9535. zaxis: Vector3;
  9536. /**
  9537. * Creates a new BoneAxesViewer
  9538. * @param scene defines the hosting scene
  9539. * @param bone defines the target bone
  9540. * @param mesh defines the target mesh
  9541. * @param scaleLines defines a scaling factor for line length (1 by default)
  9542. */
  9543. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9544. /**
  9545. * Force the viewer to update
  9546. */
  9547. update(): void;
  9548. /** Releases resources */
  9549. dispose(): void;
  9550. }
  9551. }
  9552. declare module BABYLON {
  9553. interface Scene {
  9554. /**
  9555. * @hidden
  9556. * Backing field
  9557. */
  9558. _debugLayer: DebugLayer;
  9559. /**
  9560. * Gets the debug layer (aka Inspector) associated with the scene
  9561. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9562. */
  9563. debugLayer: DebugLayer;
  9564. }
  9565. /**
  9566. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9567. * what is happening in your scene
  9568. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9569. */
  9570. class DebugLayer {
  9571. /**
  9572. * Define the url to get the inspector script from.
  9573. * By default it uses the babylonjs CDN.
  9574. * @ignoreNaming
  9575. */
  9576. static InspectorURL: string;
  9577. private _scene;
  9578. private _inspector;
  9579. private BJSINSPECTOR;
  9580. /**
  9581. * Observable triggered when a property is changed through the inspector.
  9582. */
  9583. onPropertyChangedObservable: Observable<{
  9584. object: any;
  9585. property: string;
  9586. value: any;
  9587. initialValue: any;
  9588. }>;
  9589. /**
  9590. * Instantiates a new debug layer.
  9591. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9592. * what is happening in your scene
  9593. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9594. * @param scene Defines the scene to inspect
  9595. */
  9596. constructor(scene: Scene);
  9597. /** Creates the inspector window. */
  9598. private _createInspector;
  9599. /**
  9600. * Get if the inspector is visible or not.
  9601. * @returns true if visible otherwise, false
  9602. */
  9603. isVisible(): boolean;
  9604. /**
  9605. * Hide the inspector and close its window.
  9606. */
  9607. hide(): void;
  9608. /**
  9609. *
  9610. * Launch the debugLayer.
  9611. *
  9612. * initialTab:
  9613. * | Value | Tab Name |
  9614. * | --- | --- |
  9615. * | 0 | Scene |
  9616. * | 1 | Console |
  9617. * | 2 | Stats |
  9618. * | 3 | Textures |
  9619. * | 4 | Mesh |
  9620. * | 5 | Light |
  9621. * | 6 | Material |
  9622. * | 7 | GLTF |
  9623. * | 8 | GUI |
  9624. * | 9 | Physics |
  9625. * | 10 | Camera |
  9626. * | 11 | Audio |
  9627. *
  9628. * @param config Define the configuration of the inspector
  9629. */
  9630. show(config?: {
  9631. popup?: boolean;
  9632. initialTab?: number | string;
  9633. parentElement?: HTMLElement;
  9634. newColors?: {
  9635. backgroundColor?: string;
  9636. backgroundColorLighter?: string;
  9637. backgroundColorLighter2?: string;
  9638. backgroundColorLighter3?: string;
  9639. color?: string;
  9640. colorTop?: string;
  9641. colorBot?: string;
  9642. };
  9643. }): void;
  9644. /**
  9645. * Gets the active tab
  9646. * @return the index of the active tab or -1 if the inspector is hidden
  9647. */
  9648. getActiveTab(): number;
  9649. }
  9650. }
  9651. declare module BABYLON.Debug {
  9652. /**
  9653. * Used to show the physics impostor around the specific mesh
  9654. */
  9655. class PhysicsViewer {
  9656. /** @hidden */
  9657. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9658. /** @hidden */
  9659. protected _meshes: Array<Nullable<AbstractMesh>>;
  9660. /** @hidden */
  9661. protected _scene: Nullable<Scene>;
  9662. /** @hidden */
  9663. protected _numMeshes: number;
  9664. /** @hidden */
  9665. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9666. private _renderFunction;
  9667. private _debugBoxMesh;
  9668. private _debugSphereMesh;
  9669. private _debugMaterial;
  9670. /**
  9671. * Creates a new PhysicsViewer
  9672. * @param scene defines the hosting scene
  9673. */
  9674. constructor(scene: Scene);
  9675. /** @hidden */
  9676. protected _updateDebugMeshes(): void;
  9677. /**
  9678. * Renders a specified physic impostor
  9679. * @param impostor defines the impostor to render
  9680. */
  9681. showImpostor(impostor: PhysicsImpostor): void;
  9682. /**
  9683. * Hides a specified physic impostor
  9684. * @param impostor defines the impostor to hide
  9685. */
  9686. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9687. private _getDebugMaterial;
  9688. private _getDebugBoxMesh;
  9689. private _getDebugSphereMesh;
  9690. private _getDebugMesh;
  9691. /** Releases all resources */
  9692. dispose(): void;
  9693. }
  9694. }
  9695. declare module BABYLON {
  9696. /**
  9697. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9698. * in order to better appreciate the issue one might have.
  9699. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9700. */
  9701. class RayHelper {
  9702. /**
  9703. * Defines the ray we are currently tryin to visualize.
  9704. */
  9705. ray: Nullable<Ray>;
  9706. private _renderPoints;
  9707. private _renderLine;
  9708. private _renderFunction;
  9709. private _scene;
  9710. private _updateToMeshFunction;
  9711. private _attachedToMesh;
  9712. private _meshSpaceDirection;
  9713. private _meshSpaceOrigin;
  9714. /**
  9715. * Helper function to create a colored helper in a scene in one line.
  9716. * @param ray Defines the ray we are currently tryin to visualize
  9717. * @param scene Defines the scene the ray is used in
  9718. * @param color Defines the color we want to see the ray in
  9719. * @returns The newly created ray helper.
  9720. */
  9721. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9722. /**
  9723. * Instantiate a new ray helper.
  9724. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9725. * in order to better appreciate the issue one might have.
  9726. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9727. * @param ray Defines the ray we are currently tryin to visualize
  9728. */
  9729. constructor(ray: Ray);
  9730. /**
  9731. * Shows the ray we are willing to debug.
  9732. * @param scene Defines the scene the ray needs to be rendered in
  9733. * @param color Defines the color the ray needs to be rendered in
  9734. */
  9735. show(scene: Scene, color?: Color3): void;
  9736. /**
  9737. * Hides the ray we are debugging.
  9738. */
  9739. hide(): void;
  9740. private _render;
  9741. /**
  9742. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9743. * @param mesh Defines the mesh we want the helper attached to
  9744. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9745. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9746. * @param length Defines the length of the ray
  9747. */
  9748. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9749. /**
  9750. * Detach the ray helper from the mesh it has previously been attached to.
  9751. */
  9752. detachFromMesh(): void;
  9753. private _updateToMesh;
  9754. /**
  9755. * Dispose the helper and release its associated resources.
  9756. */
  9757. dispose(): void;
  9758. }
  9759. }
  9760. declare module BABYLON.Debug {
  9761. /**
  9762. * Class used to render a debug view of a given skeleton
  9763. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9764. */
  9765. class SkeletonViewer {
  9766. /** defines the skeleton to render */
  9767. skeleton: Skeleton;
  9768. /** defines the mesh attached to the skeleton */
  9769. mesh: AbstractMesh;
  9770. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9771. autoUpdateBonesMatrices: boolean;
  9772. /** defines the rendering group id to use with the viewer */
  9773. renderingGroupId: number;
  9774. /** Gets or sets the color used to render the skeleton */
  9775. color: Color3;
  9776. private _scene;
  9777. private _debugLines;
  9778. private _debugMesh;
  9779. private _isEnabled;
  9780. private _renderFunction;
  9781. /**
  9782. * Creates a new SkeletonViewer
  9783. * @param skeleton defines the skeleton to render
  9784. * @param mesh defines the mesh attached to the skeleton
  9785. * @param scene defines the hosting scene
  9786. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9787. * @param renderingGroupId defines the rendering group id to use with the viewer
  9788. */
  9789. constructor(
  9790. /** defines the skeleton to render */
  9791. skeleton: Skeleton,
  9792. /** defines the mesh attached to the skeleton */
  9793. mesh: AbstractMesh, scene: Scene,
  9794. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9795. autoUpdateBonesMatrices?: boolean,
  9796. /** defines the rendering group id to use with the viewer */
  9797. renderingGroupId?: number);
  9798. /** Gets or sets a boolean indicating if the viewer is enabled */
  9799. isEnabled: boolean;
  9800. private _getBonePosition;
  9801. private _getLinesForBonesWithLength;
  9802. private _getLinesForBonesNoLength;
  9803. /** Update the viewer to sync with current skeleton state */
  9804. update(): void;
  9805. /** Release associated resources */
  9806. dispose(): void;
  9807. }
  9808. }
  9809. declare module BABYLON {
  9810. /**
  9811. * Interface for attribute information associated with buffer instanciation
  9812. */
  9813. class InstancingAttributeInfo {
  9814. /**
  9815. * Index/offset of the attribute in the vertex shader
  9816. */
  9817. index: number;
  9818. /**
  9819. * size of the attribute, 1, 2, 3 or 4
  9820. */
  9821. attributeSize: number;
  9822. /**
  9823. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9824. * default is FLOAT
  9825. */
  9826. attribyteType: number;
  9827. /**
  9828. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9829. */
  9830. normalized: boolean;
  9831. /**
  9832. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9833. */
  9834. offset: number;
  9835. /**
  9836. * Name of the GLSL attribute, for debugging purpose only
  9837. */
  9838. attributeName: string;
  9839. }
  9840. /**
  9841. * Define options used to create a render target texture
  9842. */
  9843. class RenderTargetCreationOptions {
  9844. /**
  9845. * Specifies is mipmaps must be generated
  9846. */
  9847. generateMipMaps?: boolean;
  9848. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9849. generateDepthBuffer?: boolean;
  9850. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9851. generateStencilBuffer?: boolean;
  9852. /** Defines texture type (int by default) */
  9853. type?: number;
  9854. /** Defines sampling mode (trilinear by default) */
  9855. samplingMode?: number;
  9856. /** Defines format (RGBA by default) */
  9857. format?: number;
  9858. }
  9859. /**
  9860. * Define options used to create a depth texture
  9861. */
  9862. class DepthTextureCreationOptions {
  9863. /** Specifies whether or not a stencil should be allocated in the texture */
  9864. generateStencil?: boolean;
  9865. /** Specifies whether or not bilinear filtering is enable on the texture */
  9866. bilinearFiltering?: boolean;
  9867. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9868. comparisonFunction?: number;
  9869. /** Specifies if the created texture is a cube texture */
  9870. isCube?: boolean;
  9871. }
  9872. /**
  9873. * Class used to describe the capabilities of the engine relatively to the current browser
  9874. */
  9875. class EngineCapabilities {
  9876. /** Maximum textures units per fragment shader */
  9877. maxTexturesImageUnits: number;
  9878. /** Maximum texture units per vertex shader */
  9879. maxVertexTextureImageUnits: number;
  9880. /** Maximum textures units in the entire pipeline */
  9881. maxCombinedTexturesImageUnits: number;
  9882. /** Maximum texture size */
  9883. maxTextureSize: number;
  9884. /** Maximum cube texture size */
  9885. maxCubemapTextureSize: number;
  9886. /** Maximum render texture size */
  9887. maxRenderTextureSize: number;
  9888. /** Maximum number of vertex attributes */
  9889. maxVertexAttribs: number;
  9890. /** Maximum number of varyings */
  9891. maxVaryingVectors: number;
  9892. /** Maximum number of uniforms per vertex shader */
  9893. maxVertexUniformVectors: number;
  9894. /** Maximum number of uniforms per fragment shader */
  9895. maxFragmentUniformVectors: number;
  9896. /** Defines if standard derivates (dx/dy) are supported */
  9897. standardDerivatives: boolean;
  9898. /** Defines if s3tc texture compression is supported */
  9899. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9900. /** Defines if pvrtc texture compression is supported */
  9901. pvrtc: any;
  9902. /** Defines if etc1 texture compression is supported */
  9903. etc1: any;
  9904. /** Defines if etc2 texture compression is supported */
  9905. etc2: any;
  9906. /** Defines if astc texture compression is supported */
  9907. astc: any;
  9908. /** Defines if float textures are supported */
  9909. textureFloat: boolean;
  9910. /** Defines if vertex array objects are supported */
  9911. vertexArrayObject: boolean;
  9912. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9913. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9914. /** Gets the maximum level of anisotropy supported */
  9915. maxAnisotropy: number;
  9916. /** Defines if instancing is supported */
  9917. instancedArrays: boolean;
  9918. /** Defines if 32 bits indices are supported */
  9919. uintIndices: boolean;
  9920. /** Defines if high precision shaders are supported */
  9921. highPrecisionShaderSupported: boolean;
  9922. /** Defines if depth reading in the fragment shader is supported */
  9923. fragmentDepthSupported: boolean;
  9924. /** Defines if float texture linear filtering is supported*/
  9925. textureFloatLinearFiltering: boolean;
  9926. /** Defines if rendering to float textures is supported */
  9927. textureFloatRender: boolean;
  9928. /** Defines if half float textures are supported*/
  9929. textureHalfFloat: boolean;
  9930. /** Defines if half float texture linear filtering is supported*/
  9931. textureHalfFloatLinearFiltering: boolean;
  9932. /** Defines if rendering to half float textures is supported */
  9933. textureHalfFloatRender: boolean;
  9934. /** Defines if textureLOD shader command is supported */
  9935. textureLOD: boolean;
  9936. /** Defines if draw buffers extension is supported */
  9937. drawBuffersExtension: boolean;
  9938. /** Defines if depth textures are supported */
  9939. depthTextureExtension: boolean;
  9940. /** Defines if float color buffer are supported */
  9941. colorBufferFloat: boolean;
  9942. /** Gets disjoint timer query extension (null if not supported) */
  9943. timerQuery: EXT_disjoint_timer_query;
  9944. /** Defines if timestamp can be used with timer query */
  9945. canUseTimestampForTimerQuery: boolean;
  9946. /** Function used to let the system compiles shaders in background */
  9947. parallelShaderCompile: {
  9948. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9949. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9950. COMPLETION_STATUS_KHR: number;
  9951. };
  9952. }
  9953. /** Interface defining initialization parameters for Engine class */
  9954. interface EngineOptions extends WebGLContextAttributes {
  9955. /**
  9956. * Defines if the engine should no exceed a specified device ratio
  9957. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9958. */
  9959. limitDeviceRatio?: number;
  9960. /**
  9961. * Defines if webvr should be enabled automatically
  9962. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9963. */
  9964. autoEnableWebVR?: boolean;
  9965. /**
  9966. * Defines if webgl2 should be turned off even if supported
  9967. * @see http://doc.babylonjs.com/features/webgl2
  9968. */
  9969. disableWebGL2Support?: boolean;
  9970. /**
  9971. * Defines if webaudio should be initialized as well
  9972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9973. */
  9974. audioEngine?: boolean;
  9975. /**
  9976. * Defines if animations should run using a deterministic lock step
  9977. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9978. */
  9979. deterministicLockstep?: boolean;
  9980. /** Defines the maximum steps to use with deterministic lock step mode */
  9981. lockstepMaxSteps?: number;
  9982. /**
  9983. * Defines that engine should ignore context lost events
  9984. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9985. */
  9986. doNotHandleContextLost?: boolean;
  9987. }
  9988. /**
  9989. * Defines the interface used by display changed events
  9990. */
  9991. interface IDisplayChangedEventArgs {
  9992. /** Gets the vrDisplay object (if any) */
  9993. vrDisplay: Nullable<any>;
  9994. /** Gets a boolean indicating if webVR is supported */
  9995. vrSupported: boolean;
  9996. }
  9997. /**
  9998. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9999. */
  10000. class Engine {
  10001. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10002. static ExceptionList: ({
  10003. key: string;
  10004. capture: string;
  10005. captureConstraint: number;
  10006. targets: string[];
  10007. } | {
  10008. key: string;
  10009. capture: null;
  10010. captureConstraint: null;
  10011. targets: string[];
  10012. })[];
  10013. /** Gets the list of created engines */
  10014. static Instances: Engine[];
  10015. /**
  10016. * Gets the latest created engine
  10017. */
  10018. static readonly LastCreatedEngine: Nullable<Engine>;
  10019. /**
  10020. * Gets the latest created scene
  10021. */
  10022. static readonly LastCreatedScene: Nullable<Scene>;
  10023. /**
  10024. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10025. * @param flag defines which part of the materials must be marked as dirty
  10026. * @param predicate defines a predicate used to filter which materials should be affected
  10027. */
  10028. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10029. /**
  10030. * Hidden
  10031. */
  10032. static _TextureLoaders: IInternalTextureLoader[];
  10033. /** Defines that alpha blending is disabled */
  10034. static readonly ALPHA_DISABLE: number;
  10035. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10036. static readonly ALPHA_ADD: number;
  10037. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10038. static readonly ALPHA_COMBINE: number;
  10039. /** Defines that alpha blending to DEST - SRC * DEST */
  10040. static readonly ALPHA_SUBTRACT: number;
  10041. /** Defines that alpha blending to SRC * DEST */
  10042. static readonly ALPHA_MULTIPLY: number;
  10043. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10044. static readonly ALPHA_MAXIMIZED: number;
  10045. /** Defines that alpha blending to SRC + DEST */
  10046. static readonly ALPHA_ONEONE: number;
  10047. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10048. static readonly ALPHA_PREMULTIPLIED: number;
  10049. /**
  10050. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10051. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10052. */
  10053. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10054. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10055. static readonly ALPHA_INTERPOLATE: number;
  10056. /**
  10057. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10058. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10059. */
  10060. static readonly ALPHA_SCREENMODE: number;
  10061. /** Defines that the ressource is not delayed*/
  10062. static readonly DELAYLOADSTATE_NONE: number;
  10063. /** Defines that the ressource was successfully delay loaded */
  10064. static readonly DELAYLOADSTATE_LOADED: number;
  10065. /** Defines that the ressource is currently delay loading */
  10066. static readonly DELAYLOADSTATE_LOADING: number;
  10067. /** Defines that the ressource is delayed and has not started loading */
  10068. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10069. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10070. static readonly NEVER: number;
  10071. /** 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 */
  10072. static readonly ALWAYS: number;
  10073. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10074. static readonly LESS: number;
  10075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10076. static readonly EQUAL: number;
  10077. /** 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 */
  10078. static readonly LEQUAL: number;
  10079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10080. static readonly GREATER: number;
  10081. /** 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 */
  10082. static readonly GEQUAL: number;
  10083. /** 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 */
  10084. static readonly NOTEQUAL: number;
  10085. /** Passed to stencilOperation to specify that stencil value must be kept */
  10086. static readonly KEEP: number;
  10087. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10088. static readonly REPLACE: number;
  10089. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10090. static readonly INCR: number;
  10091. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10092. static readonly DECR: number;
  10093. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10094. static readonly INVERT: number;
  10095. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10096. static readonly INCR_WRAP: number;
  10097. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10098. static readonly DECR_WRAP: number;
  10099. /** Texture is not repeating outside of 0..1 UVs */
  10100. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10101. /** Texture is repeating outside of 0..1 UVs */
  10102. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10103. /** Texture is repeating and mirrored */
  10104. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10105. /** ALPHA */
  10106. static readonly TEXTUREFORMAT_ALPHA: number;
  10107. /** LUMINANCE */
  10108. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10109. /** LUMINANCE_ALPHA */
  10110. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10111. /** RGB */
  10112. static readonly TEXTUREFORMAT_RGB: number;
  10113. /** RGBA */
  10114. static readonly TEXTUREFORMAT_RGBA: number;
  10115. /** RED */
  10116. static readonly TEXTUREFORMAT_RED: number;
  10117. /** RED (2nd reference) */
  10118. static readonly TEXTUREFORMAT_R: number;
  10119. /** RG */
  10120. static readonly TEXTUREFORMAT_RG: number;
  10121. /** RED_INTEGER */
  10122. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10123. /** RED_INTEGER (2nd reference) */
  10124. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10125. /** RG_INTEGER */
  10126. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10127. /** RGB_INTEGER */
  10128. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10129. /** RGBA_INTEGER */
  10130. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10131. /** UNSIGNED_BYTE */
  10132. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10133. /** UNSIGNED_BYTE (2nd reference) */
  10134. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10135. /** FLOAT */
  10136. static readonly TEXTURETYPE_FLOAT: number;
  10137. /** HALF_FLOAT */
  10138. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10139. /** BYTE */
  10140. static readonly TEXTURETYPE_BYTE: number;
  10141. /** SHORT */
  10142. static readonly TEXTURETYPE_SHORT: number;
  10143. /** UNSIGNED_SHORT */
  10144. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10145. /** INT */
  10146. static readonly TEXTURETYPE_INT: number;
  10147. /** UNSIGNED_INT */
  10148. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10149. /** UNSIGNED_SHORT_4_4_4_4 */
  10150. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10151. /** UNSIGNED_SHORT_5_5_5_1 */
  10152. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10153. /** UNSIGNED_SHORT_5_6_5 */
  10154. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10155. /** UNSIGNED_INT_2_10_10_10_REV */
  10156. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10157. /** UNSIGNED_INT_24_8 */
  10158. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10159. /** UNSIGNED_INT_10F_11F_11F_REV */
  10160. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10161. /** UNSIGNED_INT_5_9_9_9_REV */
  10162. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10163. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10164. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10165. /** nearest is mag = nearest and min = nearest and mip = linear */
  10166. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10167. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10168. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10169. /** Trilinear is mag = linear and min = linear and mip = linear */
  10170. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10171. /** nearest is mag = nearest and min = nearest and mip = linear */
  10172. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10173. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10174. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10175. /** Trilinear is mag = linear and min = linear and mip = linear */
  10176. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10177. /** mag = nearest and min = nearest and mip = nearest */
  10178. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10179. /** mag = nearest and min = linear and mip = nearest */
  10180. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10181. /** mag = nearest and min = linear and mip = linear */
  10182. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10183. /** mag = nearest and min = linear and mip = none */
  10184. static readonly TEXTURE_NEAREST_LINEAR: number;
  10185. /** mag = nearest and min = nearest and mip = none */
  10186. static readonly TEXTURE_NEAREST_NEAREST: number;
  10187. /** mag = linear and min = nearest and mip = nearest */
  10188. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10189. /** mag = linear and min = nearest and mip = linear */
  10190. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10191. /** mag = linear and min = linear and mip = none */
  10192. static readonly TEXTURE_LINEAR_LINEAR: number;
  10193. /** mag = linear and min = nearest and mip = none */
  10194. static readonly TEXTURE_LINEAR_NEAREST: number;
  10195. /** Explicit coordinates mode */
  10196. static readonly TEXTURE_EXPLICIT_MODE: number;
  10197. /** Spherical coordinates mode */
  10198. static readonly TEXTURE_SPHERICAL_MODE: number;
  10199. /** Planar coordinates mode */
  10200. static readonly TEXTURE_PLANAR_MODE: number;
  10201. /** Cubic coordinates mode */
  10202. static readonly TEXTURE_CUBIC_MODE: number;
  10203. /** Projection coordinates mode */
  10204. static readonly TEXTURE_PROJECTION_MODE: number;
  10205. /** Skybox coordinates mode */
  10206. static readonly TEXTURE_SKYBOX_MODE: number;
  10207. /** Inverse Cubic coordinates mode */
  10208. static readonly TEXTURE_INVCUBIC_MODE: number;
  10209. /** Equirectangular coordinates mode */
  10210. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10211. /** Equirectangular Fixed coordinates mode */
  10212. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10213. /** Equirectangular Fixed Mirrored coordinates mode */
  10214. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10215. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10216. static readonly SCALEMODE_FLOOR: number;
  10217. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10218. static readonly SCALEMODE_NEAREST: number;
  10219. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10220. static readonly SCALEMODE_CEILING: number;
  10221. /**
  10222. * Returns the current version of the framework
  10223. */
  10224. static readonly Version: string;
  10225. /**
  10226. * Returns a string describing the current engine
  10227. */
  10228. readonly description: string;
  10229. /**
  10230. * Gets or sets the epsilon value used by collision engine
  10231. */
  10232. static CollisionsEpsilon: number;
  10233. /**
  10234. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10235. */
  10236. static CodeRepository: string;
  10237. /**
  10238. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10239. */
  10240. static ShadersRepository: string;
  10241. /**
  10242. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10243. */
  10244. forcePOTTextures: boolean;
  10245. /**
  10246. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10247. */
  10248. isFullscreen: boolean;
  10249. /**
  10250. * Gets a boolean indicating if the pointer is currently locked
  10251. */
  10252. isPointerLock: boolean;
  10253. /**
  10254. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10255. */
  10256. cullBackFaces: boolean;
  10257. /**
  10258. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10259. */
  10260. renderEvenInBackground: boolean;
  10261. /**
  10262. * Gets or sets a boolean indicating that cache can be kept between frames
  10263. */
  10264. preventCacheWipeBetweenFrames: boolean;
  10265. /**
  10266. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10267. **/
  10268. enableOfflineSupport: boolean;
  10269. /**
  10270. * 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)
  10271. **/
  10272. disableManifestCheck: boolean;
  10273. /**
  10274. * Gets the list of created scenes
  10275. */
  10276. scenes: Scene[];
  10277. /**
  10278. * Gets the list of created postprocesses
  10279. */
  10280. postProcesses: PostProcess[];
  10281. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10282. validateShaderPrograms: boolean;
  10283. /**
  10284. * Observable event triggered each time the rendering canvas is resized
  10285. */
  10286. onResizeObservable: Observable<Engine>;
  10287. /**
  10288. * Observable event triggered each time the canvas loses focus
  10289. */
  10290. onCanvasBlurObservable: Observable<Engine>;
  10291. /**
  10292. * Observable event triggered each time the canvas gains focus
  10293. */
  10294. onCanvasFocusObservable: Observable<Engine>;
  10295. /**
  10296. * Observable event triggered each time the canvas receives pointerout event
  10297. */
  10298. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10299. /**
  10300. * Observable event triggered before each texture is initialized
  10301. */
  10302. onBeforeTextureInitObservable: Observable<Texture>;
  10303. private _vrDisplay;
  10304. private _vrSupported;
  10305. private _oldSize;
  10306. private _oldHardwareScaleFactor;
  10307. private _vrExclusivePointerMode;
  10308. private _webVRInitPromise;
  10309. /**
  10310. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10311. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10312. */
  10313. readonly isInVRExclusivePointerMode: boolean;
  10314. /**
  10315. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10316. */
  10317. disableUniformBuffers: boolean;
  10318. /** @hidden */
  10319. _uniformBuffers: UniformBuffer[];
  10320. /**
  10321. * Gets a boolean indicating that the engine supports uniform buffers
  10322. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10323. */
  10324. readonly supportsUniformBuffers: boolean;
  10325. /**
  10326. * Observable raised when the engine begins a new frame
  10327. */
  10328. onBeginFrameObservable: Observable<Engine>;
  10329. /**
  10330. * If set, will be used to request the next animation frame for the render loop
  10331. */
  10332. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10333. /**
  10334. * Observable raised when the engine ends the current frame
  10335. */
  10336. onEndFrameObservable: Observable<Engine>;
  10337. /**
  10338. * Observable raised when the engine is about to compile a shader
  10339. */
  10340. onBeforeShaderCompilationObservable: Observable<Engine>;
  10341. /**
  10342. * Observable raised when the engine has jsut compiled a shader
  10343. */
  10344. onAfterShaderCompilationObservable: Observable<Engine>;
  10345. /** @hidden */
  10346. _gl: WebGLRenderingContext;
  10347. private _renderingCanvas;
  10348. private _windowIsBackground;
  10349. private _webGLVersion;
  10350. /**
  10351. * Gets a boolean indicating that only power of 2 textures are supported
  10352. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10353. */
  10354. readonly needPOTTextures: boolean;
  10355. /** @hidden */
  10356. _badOS: boolean;
  10357. /** @hidden */
  10358. _badDesktopOS: boolean;
  10359. /**
  10360. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10361. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10362. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10363. */
  10364. disableTextureBindingOptimization: boolean;
  10365. /**
  10366. * Gets the audio engine
  10367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10368. * @ignorenaming
  10369. */
  10370. static audioEngine: IAudioEngine;
  10371. /**
  10372. * Default AudioEngine factory responsible of creating the Audio Engine.
  10373. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10374. */
  10375. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10376. /**
  10377. * Default offline support factory responsible of creating a tool used to store data locally.
  10378. * By default, this will create a Database object if the workload has been embedded.
  10379. */
  10380. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10381. private _onFocus;
  10382. private _onBlur;
  10383. private _onCanvasPointerOut;
  10384. private _onCanvasBlur;
  10385. private _onCanvasFocus;
  10386. private _onFullscreenChange;
  10387. private _onPointerLockChange;
  10388. private _onVRDisplayPointerRestricted;
  10389. private _onVRDisplayPointerUnrestricted;
  10390. private _onVrDisplayConnect;
  10391. private _onVrDisplayDisconnect;
  10392. private _onVrDisplayPresentChange;
  10393. /**
  10394. * Observable signaled when VR display mode changes
  10395. */
  10396. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10397. /**
  10398. * Observable signaled when VR request present is complete
  10399. */
  10400. onVRRequestPresentComplete: Observable<boolean>;
  10401. /**
  10402. * Observable signaled when VR request present starts
  10403. */
  10404. onVRRequestPresentStart: Observable<Engine>;
  10405. private _hardwareScalingLevel;
  10406. /** @hidden */
  10407. protected _caps: EngineCapabilities;
  10408. private _pointerLockRequested;
  10409. private _isStencilEnable;
  10410. private _colorWrite;
  10411. private _loadingScreen;
  10412. /** @hidden */
  10413. _drawCalls: PerfCounter;
  10414. /** @hidden */
  10415. _textureCollisions: PerfCounter;
  10416. private _glVersion;
  10417. private _glRenderer;
  10418. private _glVendor;
  10419. private _videoTextureSupported;
  10420. private _renderingQueueLaunched;
  10421. private _activeRenderLoops;
  10422. private _deterministicLockstep;
  10423. private _lockstepMaxSteps;
  10424. /**
  10425. * Observable signaled when a context lost event is raised
  10426. */
  10427. onContextLostObservable: Observable<Engine>;
  10428. /**
  10429. * Observable signaled when a context restored event is raised
  10430. */
  10431. onContextRestoredObservable: Observable<Engine>;
  10432. private _onContextLost;
  10433. private _onContextRestored;
  10434. private _contextWasLost;
  10435. private _doNotHandleContextLost;
  10436. /**
  10437. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10439. */
  10440. doNotHandleContextLost: boolean;
  10441. private _performanceMonitor;
  10442. private _fps;
  10443. private _deltaTime;
  10444. /**
  10445. * Turn this value on if you want to pause FPS computation when in background
  10446. */
  10447. disablePerformanceMonitorInBackground: boolean;
  10448. /**
  10449. * Gets the performance monitor attached to this engine
  10450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10451. */
  10452. readonly performanceMonitor: PerformanceMonitor;
  10453. /** @hidden */
  10454. protected _depthCullingState: _DepthCullingState;
  10455. /** @hidden */
  10456. protected _stencilState: _StencilState;
  10457. /** @hidden */
  10458. protected _alphaState: _AlphaState;
  10459. /** @hidden */
  10460. protected _alphaMode: number;
  10461. protected _internalTexturesCache: InternalTexture[];
  10462. /** @hidden */
  10463. protected _activeChannel: number;
  10464. private _currentTextureChannel;
  10465. /** @hidden */
  10466. protected _boundTexturesCache: {
  10467. [key: string]: Nullable<InternalTexture>;
  10468. };
  10469. /** @hidden */
  10470. protected _currentEffect: Nullable<Effect>;
  10471. /** @hidden */
  10472. protected _currentProgram: Nullable<WebGLProgram>;
  10473. private _compiledEffects;
  10474. private _vertexAttribArraysEnabled;
  10475. /** @hidden */
  10476. protected _cachedViewport: Nullable<Viewport>;
  10477. private _cachedVertexArrayObject;
  10478. /** @hidden */
  10479. protected _cachedVertexBuffers: any;
  10480. /** @hidden */
  10481. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10482. /** @hidden */
  10483. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10484. /** @hidden */
  10485. protected _currentRenderTarget: Nullable<InternalTexture>;
  10486. private _uintIndicesCurrentlySet;
  10487. private _currentBoundBuffer;
  10488. /** @hidden */
  10489. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10490. private _currentBufferPointers;
  10491. private _currentInstanceLocations;
  10492. private _currentInstanceBuffers;
  10493. private _textureUnits;
  10494. private _firstBoundInternalTextureTracker;
  10495. private _lastBoundInternalTextureTracker;
  10496. private _workingCanvas;
  10497. private _workingContext;
  10498. private _rescalePostProcess;
  10499. private _dummyFramebuffer;
  10500. private _externalData;
  10501. private _bindedRenderFunction;
  10502. private _vaoRecordInProgress;
  10503. private _mustWipeVertexAttributes;
  10504. private _emptyTexture;
  10505. private _emptyCubeTexture;
  10506. private _emptyTexture3D;
  10507. /** @hidden */
  10508. _frameHandler: number;
  10509. private _nextFreeTextureSlots;
  10510. private _maxSimultaneousTextures;
  10511. private _activeRequests;
  10512. private _texturesSupported;
  10513. private _textureFormatInUse;
  10514. /**
  10515. * Gets the list of texture formats supported
  10516. */
  10517. readonly texturesSupported: Array<string>;
  10518. /**
  10519. * Gets the list of texture formats in use
  10520. */
  10521. readonly textureFormatInUse: Nullable<string>;
  10522. /**
  10523. * Gets the current viewport
  10524. */
  10525. readonly currentViewport: Nullable<Viewport>;
  10526. /**
  10527. * Gets the default empty texture
  10528. */
  10529. readonly emptyTexture: InternalTexture;
  10530. /**
  10531. * Gets the default empty 3D texture
  10532. */
  10533. readonly emptyTexture3D: InternalTexture;
  10534. /**
  10535. * Gets the default empty cube texture
  10536. */
  10537. readonly emptyCubeTexture: InternalTexture;
  10538. /**
  10539. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10540. */
  10541. readonly premultipliedAlpha: boolean;
  10542. /**
  10543. * Creates a new engine
  10544. * @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
  10545. * @param antialias defines enable antialiasing (default: false)
  10546. * @param options defines further options to be sent to the getContext() function
  10547. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10548. */
  10549. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10550. private _rebuildInternalTextures;
  10551. private _rebuildEffects;
  10552. /**
  10553. * Gets a boolean indicating if all created effects are ready
  10554. * @returns true if all effects are ready
  10555. */
  10556. areAllEffectsReady(): boolean;
  10557. private _rebuildBuffers;
  10558. private _initGLContext;
  10559. /**
  10560. * Gets version of the current webGL context
  10561. */
  10562. readonly webGLVersion: number;
  10563. /**
  10564. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10565. */
  10566. readonly isStencilEnable: boolean;
  10567. private _prepareWorkingCanvas;
  10568. /**
  10569. * Reset the texture cache to empty state
  10570. */
  10571. resetTextureCache(): void;
  10572. /**
  10573. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10575. * @returns true if engine is in deterministic lock step mode
  10576. */
  10577. isDeterministicLockStep(): boolean;
  10578. /**
  10579. * Gets the max steps when engine is running in deterministic lock step
  10580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10581. * @returns the max steps
  10582. */
  10583. getLockstepMaxSteps(): number;
  10584. /**
  10585. * Gets an object containing information about the current webGL context
  10586. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10587. */
  10588. getGlInfo(): {
  10589. vendor: string;
  10590. renderer: string;
  10591. version: string;
  10592. };
  10593. /**
  10594. * Gets current aspect ratio
  10595. * @param camera defines the camera to use to get the aspect ratio
  10596. * @param useScreen defines if screen size must be used (or the current render target if any)
  10597. * @returns a number defining the aspect ratio
  10598. */
  10599. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10600. /**
  10601. * Gets current screen aspect ratio
  10602. * @returns a number defining the aspect ratio
  10603. */
  10604. getScreenAspectRatio(): number;
  10605. /**
  10606. * Gets the current render width
  10607. * @param useScreen defines if screen size must be used (or the current render target if any)
  10608. * @returns a number defining the current render width
  10609. */
  10610. getRenderWidth(useScreen?: boolean): number;
  10611. /**
  10612. * Gets the current render height
  10613. * @param useScreen defines if screen size must be used (or the current render target if any)
  10614. * @returns a number defining the current render height
  10615. */
  10616. getRenderHeight(useScreen?: boolean): number;
  10617. /**
  10618. * Gets the HTML canvas attached with the current webGL context
  10619. * @returns a HTML canvas
  10620. */
  10621. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10622. /**
  10623. * Gets the client rect of the HTML canvas attached with the current webGL context
  10624. * @returns a client rectanglee
  10625. */
  10626. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10627. /**
  10628. * Defines the hardware scaling level.
  10629. * By default the hardware scaling level is computed from the window device ratio.
  10630. * 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.
  10631. * @param level defines the level to use
  10632. */
  10633. setHardwareScalingLevel(level: number): void;
  10634. /**
  10635. * Gets the current hardware scaling level.
  10636. * By default the hardware scaling level is computed from the window device ratio.
  10637. * 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.
  10638. * @returns a number indicating the current hardware scaling level
  10639. */
  10640. getHardwareScalingLevel(): number;
  10641. /**
  10642. * Gets the list of loaded textures
  10643. * @returns an array containing all loaded textures
  10644. */
  10645. getLoadedTexturesCache(): InternalTexture[];
  10646. /**
  10647. * Gets the object containing all engine capabilities
  10648. * @returns the EngineCapabilities object
  10649. */
  10650. getCaps(): EngineCapabilities;
  10651. /** @hidden */
  10652. readonly drawCalls: number;
  10653. /** @hidden */
  10654. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10655. /**
  10656. * Gets the current depth function
  10657. * @returns a number defining the depth function
  10658. */
  10659. getDepthFunction(): Nullable<number>;
  10660. /**
  10661. * Sets the current depth function
  10662. * @param depthFunc defines the function to use
  10663. */
  10664. setDepthFunction(depthFunc: number): void;
  10665. /**
  10666. * Sets the current depth function to GREATER
  10667. */
  10668. setDepthFunctionToGreater(): void;
  10669. /**
  10670. * Sets the current depth function to GEQUAL
  10671. */
  10672. setDepthFunctionToGreaterOrEqual(): void;
  10673. /**
  10674. * Sets the current depth function to LESS
  10675. */
  10676. setDepthFunctionToLess(): void;
  10677. /**
  10678. * Sets the current depth function to LEQUAL
  10679. */
  10680. setDepthFunctionToLessOrEqual(): void;
  10681. /**
  10682. * Gets a boolean indicating if stencil buffer is enabled
  10683. * @returns the current stencil buffer state
  10684. */
  10685. getStencilBuffer(): boolean;
  10686. /**
  10687. * Enable or disable the stencil buffer
  10688. * @param enable defines if the stencil buffer must be enabled or disabled
  10689. */
  10690. setStencilBuffer(enable: boolean): void;
  10691. /**
  10692. * Gets the current stencil mask
  10693. * @returns a number defining the new stencil mask to use
  10694. */
  10695. getStencilMask(): number;
  10696. /**
  10697. * Sets the current stencil mask
  10698. * @param mask defines the new stencil mask to use
  10699. */
  10700. setStencilMask(mask: number): void;
  10701. /**
  10702. * Gets the current stencil function
  10703. * @returns a number defining the stencil function to use
  10704. */
  10705. getStencilFunction(): number;
  10706. /**
  10707. * Gets the current stencil reference value
  10708. * @returns a number defining the stencil reference value to use
  10709. */
  10710. getStencilFunctionReference(): number;
  10711. /**
  10712. * Gets the current stencil mask
  10713. * @returns a number defining the stencil mask to use
  10714. */
  10715. getStencilFunctionMask(): number;
  10716. /**
  10717. * Sets the current stencil function
  10718. * @param stencilFunc defines the new stencil function to use
  10719. */
  10720. setStencilFunction(stencilFunc: number): void;
  10721. /**
  10722. * Sets the current stencil reference
  10723. * @param reference defines the new stencil reference to use
  10724. */
  10725. setStencilFunctionReference(reference: number): void;
  10726. /**
  10727. * Sets the current stencil mask
  10728. * @param mask defines the new stencil mask to use
  10729. */
  10730. setStencilFunctionMask(mask: number): void;
  10731. /**
  10732. * Gets the current stencil operation when stencil fails
  10733. * @returns a number defining stencil operation to use when stencil fails
  10734. */
  10735. getStencilOperationFail(): number;
  10736. /**
  10737. * Gets the current stencil operation when depth fails
  10738. * @returns a number defining stencil operation to use when depth fails
  10739. */
  10740. getStencilOperationDepthFail(): number;
  10741. /**
  10742. * Gets the current stencil operation when stencil passes
  10743. * @returns a number defining stencil operation to use when stencil passes
  10744. */
  10745. getStencilOperationPass(): number;
  10746. /**
  10747. * Sets the stencil operation to use when stencil fails
  10748. * @param operation defines the stencil operation to use when stencil fails
  10749. */
  10750. setStencilOperationFail(operation: number): void;
  10751. /**
  10752. * Sets the stencil operation to use when depth fails
  10753. * @param operation defines the stencil operation to use when depth fails
  10754. */
  10755. setStencilOperationDepthFail(operation: number): void;
  10756. /**
  10757. * Sets the stencil operation to use when stencil passes
  10758. * @param operation defines the stencil operation to use when stencil passes
  10759. */
  10760. setStencilOperationPass(operation: number): void;
  10761. /**
  10762. * Sets a boolean indicating if the dithering state is enabled or disabled
  10763. * @param value defines the dithering state
  10764. */
  10765. setDitheringState(value: boolean): void;
  10766. /**
  10767. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10768. * @param value defines the rasterizer state
  10769. */
  10770. setRasterizerState(value: boolean): void;
  10771. /**
  10772. * stop executing a render loop function and remove it from the execution array
  10773. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10774. */
  10775. stopRenderLoop(renderFunction?: () => void): void;
  10776. /** @hidden */
  10777. _renderLoop(): void;
  10778. /**
  10779. * Register and execute a render loop. The engine can have more than one render function
  10780. * @param renderFunction defines the function to continuously execute
  10781. */
  10782. runRenderLoop(renderFunction: () => void): void;
  10783. /**
  10784. * Toggle full screen mode
  10785. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10786. */
  10787. switchFullscreen(requestPointerLock: boolean): void;
  10788. /**
  10789. * Clear the current render buffer or the current render target (if any is set up)
  10790. * @param color defines the color to use
  10791. * @param backBuffer defines if the back buffer must be cleared
  10792. * @param depth defines if the depth buffer must be cleared
  10793. * @param stencil defines if the stencil buffer must be cleared
  10794. */
  10795. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10796. /**
  10797. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10798. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10799. * @param y defines the y-coordinate of the corner of the clear rectangle
  10800. * @param width defines the width of the clear rectangle
  10801. * @param height defines the height of the clear rectangle
  10802. * @param clearColor defines the clear color
  10803. */
  10804. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10805. private _viewportCached;
  10806. /** @hidden */
  10807. _viewport(x: number, y: number, width: number, height: number): void;
  10808. /**
  10809. * Set the WebGL's viewport
  10810. * @param viewport defines the viewport element to be used
  10811. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10812. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10813. */
  10814. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10815. /**
  10816. * Directly set the WebGL Viewport
  10817. * @param x defines the x coordinate of the viewport (in screen space)
  10818. * @param y defines the y coordinate of the viewport (in screen space)
  10819. * @param width defines the width of the viewport (in screen space)
  10820. * @param height defines the height of the viewport (in screen space)
  10821. * @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
  10822. */
  10823. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10824. /**
  10825. * Begin a new frame
  10826. */
  10827. beginFrame(): void;
  10828. /**
  10829. * Enf the current frame
  10830. */
  10831. endFrame(): void;
  10832. /**
  10833. * Resize the view according to the canvas' size
  10834. */
  10835. resize(): void;
  10836. /**
  10837. * Force a specific size of the canvas
  10838. * @param width defines the new canvas' width
  10839. * @param height defines the new canvas' height
  10840. */
  10841. setSize(width: number, height: number): void;
  10842. /**
  10843. * Gets a boolean indicating if a webVR device was detected
  10844. * @returns true if a webVR device was detected
  10845. */
  10846. isVRDevicePresent(): boolean;
  10847. /**
  10848. * Gets the current webVR device
  10849. * @returns the current webVR device (or null)
  10850. */
  10851. getVRDevice(): any;
  10852. /**
  10853. * Initializes a webVR display and starts listening to display change events
  10854. * The onVRDisplayChangedObservable will be notified upon these changes
  10855. * @returns The onVRDisplayChangedObservable
  10856. */
  10857. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10858. /**
  10859. * Initializes a webVR display and starts listening to display change events
  10860. * The onVRDisplayChangedObservable will be notified upon these changes
  10861. * @returns A promise containing a VRDisplay and if vr is supported
  10862. */
  10863. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10864. /**
  10865. * Call this function to switch to webVR mode
  10866. * Will do nothing if webVR is not supported or if there is no webVR device
  10867. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10868. */
  10869. enableVR(): void;
  10870. /**
  10871. * Call this function to leave webVR mode
  10872. * Will do nothing if webVR is not supported or if there is no webVR device
  10873. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10874. */
  10875. disableVR(): void;
  10876. private _onVRFullScreenTriggered;
  10877. private _getVRDisplaysAsync;
  10878. /**
  10879. * Binds the frame buffer to the specified texture.
  10880. * @param texture The texture to render to or null for the default canvas
  10881. * @param faceIndex The face of the texture to render to in case of cube texture
  10882. * @param requiredWidth The width of the target to render to
  10883. * @param requiredHeight The height of the target to render to
  10884. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10885. * @param depthStencilTexture The depth stencil texture to use to render
  10886. * @param lodLevel defines le lod level to bind to the frame buffer
  10887. */
  10888. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10889. private bindUnboundFramebuffer;
  10890. /**
  10891. * Unbind the current render target texture from the webGL context
  10892. * @param texture defines the render target texture to unbind
  10893. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10894. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10895. */
  10896. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10897. /**
  10898. * Unbind a list of render target textures from the webGL context
  10899. * This is used only when drawBuffer extension or webGL2 are active
  10900. * @param textures defines the render target textures to unbind
  10901. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10902. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10903. */
  10904. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10905. /**
  10906. * Force the mipmap generation for the given render target texture
  10907. * @param texture defines the render target texture to use
  10908. */
  10909. generateMipMapsForCubemap(texture: InternalTexture): void;
  10910. /**
  10911. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10912. */
  10913. flushFramebuffer(): void;
  10914. /**
  10915. * Unbind the current render target and bind the default framebuffer
  10916. */
  10917. restoreDefaultFramebuffer(): void;
  10918. /**
  10919. * Create an uniform buffer
  10920. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10921. * @param elements defines the content of the uniform buffer
  10922. * @returns the webGL uniform buffer
  10923. */
  10924. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10925. /**
  10926. * Create a dynamic uniform buffer
  10927. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10928. * @param elements defines the content of the uniform buffer
  10929. * @returns the webGL uniform buffer
  10930. */
  10931. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10932. /**
  10933. * Update an existing uniform buffer
  10934. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10935. * @param uniformBuffer defines the target uniform buffer
  10936. * @param elements defines the content to update
  10937. * @param offset defines the offset in the uniform buffer where update should start
  10938. * @param count defines the size of the data to update
  10939. */
  10940. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10941. private _resetVertexBufferBinding;
  10942. /**
  10943. * Creates a vertex buffer
  10944. * @param data the data for the vertex buffer
  10945. * @returns the new WebGL static buffer
  10946. */
  10947. createVertexBuffer(data: DataArray): WebGLBuffer;
  10948. /**
  10949. * Creates a dynamic vertex buffer
  10950. * @param data the data for the dynamic vertex buffer
  10951. * @returns the new WebGL dynamic buffer
  10952. */
  10953. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10954. /**
  10955. * Update a dynamic index buffer
  10956. * @param indexBuffer defines the target index buffer
  10957. * @param indices defines the data to update
  10958. * @param offset defines the offset in the target index buffer where update should start
  10959. */
  10960. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10961. /**
  10962. * Updates a dynamic vertex buffer.
  10963. * @param vertexBuffer the vertex buffer to update
  10964. * @param data the data used to update the vertex buffer
  10965. * @param byteOffset the byte offset of the data
  10966. * @param byteLength the byte length of the data
  10967. */
  10968. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10969. private _resetIndexBufferBinding;
  10970. /**
  10971. * Creates a new index buffer
  10972. * @param indices defines the content of the index buffer
  10973. * @param updatable defines if the index buffer must be updatable
  10974. * @returns a new webGL buffer
  10975. */
  10976. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10977. /**
  10978. * Bind a webGL buffer to the webGL context
  10979. * @param buffer defines the buffer to bind
  10980. */
  10981. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10982. /**
  10983. * Bind an uniform buffer to the current webGL context
  10984. * @param buffer defines the buffer to bind
  10985. */
  10986. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10987. /**
  10988. * Bind a buffer to the current webGL context at a given location
  10989. * @param buffer defines the buffer to bind
  10990. * @param location defines the index where to bind the buffer
  10991. */
  10992. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10993. /**
  10994. * Bind a specific block at a given index in a specific shader program
  10995. * @param shaderProgram defines the shader program
  10996. * @param blockName defines the block name
  10997. * @param index defines the index where to bind the block
  10998. */
  10999. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11000. private bindIndexBuffer;
  11001. private bindBuffer;
  11002. /**
  11003. * update the bound buffer with the given data
  11004. * @param data defines the data to update
  11005. */
  11006. updateArrayBuffer(data: Float32Array): void;
  11007. private _vertexAttribPointer;
  11008. private _bindIndexBufferWithCache;
  11009. private _bindVertexBuffersAttributes;
  11010. /**
  11011. * Records a vertex array object
  11012. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11013. * @param vertexBuffers defines the list of vertex buffers to store
  11014. * @param indexBuffer defines the index buffer to store
  11015. * @param effect defines the effect to store
  11016. * @returns the new vertex array object
  11017. */
  11018. recordVertexArrayObject(vertexBuffers: {
  11019. [key: string]: VertexBuffer;
  11020. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11021. /**
  11022. * Bind a specific vertex array object
  11023. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11024. * @param vertexArrayObject defines the vertex array object to bind
  11025. * @param indexBuffer defines the index buffer to bind
  11026. */
  11027. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11028. /**
  11029. * Bind webGl buffers directly to the webGL context
  11030. * @param vertexBuffer defines the vertex buffer to bind
  11031. * @param indexBuffer defines the index buffer to bind
  11032. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11033. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11034. * @param effect defines the effect associated with the vertex buffer
  11035. */
  11036. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11037. private _unbindVertexArrayObject;
  11038. /**
  11039. * Bind a list of vertex buffers to the webGL context
  11040. * @param vertexBuffers defines the list of vertex buffers to bind
  11041. * @param indexBuffer defines the index buffer to bind
  11042. * @param effect defines the effect associated with the vertex buffers
  11043. */
  11044. bindBuffers(vertexBuffers: {
  11045. [key: string]: Nullable<VertexBuffer>;
  11046. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11047. /**
  11048. * Unbind all instance attributes
  11049. */
  11050. unbindInstanceAttributes(): void;
  11051. /**
  11052. * Release and free the memory of a vertex array object
  11053. * @param vao defines the vertex array object to delete
  11054. */
  11055. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11056. /** @hidden */
  11057. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11058. /**
  11059. * Creates a webGL buffer to use with instanciation
  11060. * @param capacity defines the size of the buffer
  11061. * @returns the webGL buffer
  11062. */
  11063. createInstancesBuffer(capacity: number): WebGLBuffer;
  11064. /**
  11065. * Delete a webGL buffer used with instanciation
  11066. * @param buffer defines the webGL buffer to delete
  11067. */
  11068. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11069. /**
  11070. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11071. * @param instancesBuffer defines the webGL buffer to update and bind
  11072. * @param data defines the data to store in the buffer
  11073. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11074. */
  11075. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11076. /**
  11077. * Apply all cached states (depth, culling, stencil and alpha)
  11078. */
  11079. applyStates(): void;
  11080. /**
  11081. * Send a draw order
  11082. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11083. * @param indexStart defines the starting index
  11084. * @param indexCount defines the number of index to draw
  11085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11086. */
  11087. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11088. /**
  11089. * Draw a list of points
  11090. * @param verticesStart defines the index of first vertex to draw
  11091. * @param verticesCount defines the count of vertices to draw
  11092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11093. */
  11094. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11095. /**
  11096. * Draw a list of unindexed primitives
  11097. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11098. * @param verticesStart defines the index of first vertex to draw
  11099. * @param verticesCount defines the count of vertices to draw
  11100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11101. */
  11102. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11103. /**
  11104. * Draw a list of indexed primitives
  11105. * @param fillMode defines the primitive to use
  11106. * @param indexStart defines the starting index
  11107. * @param indexCount defines the number of index to draw
  11108. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11109. */
  11110. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11111. /**
  11112. * Draw a list of unindexed primitives
  11113. * @param fillMode defines the primitive to use
  11114. * @param verticesStart defines the index of first vertex to draw
  11115. * @param verticesCount defines the count of vertices to draw
  11116. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11117. */
  11118. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11119. private _drawMode;
  11120. /** @hidden */
  11121. _releaseEffect(effect: Effect): void;
  11122. /** @hidden */
  11123. _deleteProgram(program: WebGLProgram): void;
  11124. /**
  11125. * Create a new effect (used to store vertex/fragment shaders)
  11126. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11127. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11128. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11129. * @param samplers defines an array of string used to represent textures
  11130. * @param defines defines the string containing the defines to use to compile the shaders
  11131. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11132. * @param onCompiled defines a function to call when the effect creation is successful
  11133. * @param onError defines a function to call when the effect creation has failed
  11134. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11135. * @returns the new Effect
  11136. */
  11137. 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;
  11138. private _compileShader;
  11139. private _compileRawShader;
  11140. /**
  11141. * Directly creates a webGL program
  11142. * @param vertexCode defines the vertex shader code to use
  11143. * @param fragmentCode defines the fragment shader code to use
  11144. * @param context defines the webGL context to use (if not set, the current one will be used)
  11145. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11146. * @returns the new webGL program
  11147. */
  11148. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11149. /**
  11150. * Creates a webGL program
  11151. * @param vertexCode defines the vertex shader code to use
  11152. * @param fragmentCode defines the fragment shader code to use
  11153. * @param defines defines the string containing the defines to use to compile the shaders
  11154. * @param context defines the webGL context to use (if not set, the current one will be used)
  11155. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11156. * @returns the new webGL program
  11157. */
  11158. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11159. private _createShaderProgram;
  11160. private _finalizeProgram;
  11161. /** @hidden */
  11162. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11163. /** @hidden */
  11164. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11165. /**
  11166. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11167. * @param shaderProgram defines the webGL program to use
  11168. * @param uniformsNames defines the list of uniform names
  11169. * @returns an array of webGL uniform locations
  11170. */
  11171. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11172. /**
  11173. * Gets the lsit of active attributes for a given webGL program
  11174. * @param shaderProgram defines the webGL program to use
  11175. * @param attributesNames defines the list of attribute names to get
  11176. * @returns an array of indices indicating the offset of each attribute
  11177. */
  11178. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11179. /**
  11180. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11181. * @param effect defines the effect to activate
  11182. */
  11183. enableEffect(effect: Nullable<Effect>): void;
  11184. /**
  11185. * Set the value of an uniform to an array of int32
  11186. * @param uniform defines the webGL uniform location where to store the value
  11187. * @param array defines the array of int32 to store
  11188. */
  11189. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11190. /**
  11191. * Set the value of an uniform to an array of int32 (stored as vec2)
  11192. * @param uniform defines the webGL uniform location where to store the value
  11193. * @param array defines the array of int32 to store
  11194. */
  11195. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11196. /**
  11197. * Set the value of an uniform to an array of int32 (stored as vec3)
  11198. * @param uniform defines the webGL uniform location where to store the value
  11199. * @param array defines the array of int32 to store
  11200. */
  11201. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11202. /**
  11203. * Set the value of an uniform to an array of int32 (stored as vec4)
  11204. * @param uniform defines the webGL uniform location where to store the value
  11205. * @param array defines the array of int32 to store
  11206. */
  11207. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11208. /**
  11209. * Set the value of an uniform to an array of float32
  11210. * @param uniform defines the webGL uniform location where to store the value
  11211. * @param array defines the array of float32 to store
  11212. */
  11213. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11214. /**
  11215. * Set the value of an uniform to an array of float32 (stored as vec2)
  11216. * @param uniform defines the webGL uniform location where to store the value
  11217. * @param array defines the array of float32 to store
  11218. */
  11219. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11220. /**
  11221. * Set the value of an uniform to an array of float32 (stored as vec3)
  11222. * @param uniform defines the webGL uniform location where to store the value
  11223. * @param array defines the array of float32 to store
  11224. */
  11225. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11226. /**
  11227. * Set the value of an uniform to an array of float32 (stored as vec4)
  11228. * @param uniform defines the webGL uniform location where to store the value
  11229. * @param array defines the array of float32 to store
  11230. */
  11231. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11232. /**
  11233. * Set the value of an uniform to an array of number
  11234. * @param uniform defines the webGL uniform location where to store the value
  11235. * @param array defines the array of number to store
  11236. */
  11237. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11238. /**
  11239. * Set the value of an uniform to an array of number (stored as vec2)
  11240. * @param uniform defines the webGL uniform location where to store the value
  11241. * @param array defines the array of number to store
  11242. */
  11243. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11244. /**
  11245. * Set the value of an uniform to an array of number (stored as vec3)
  11246. * @param uniform defines the webGL uniform location where to store the value
  11247. * @param array defines the array of number to store
  11248. */
  11249. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11250. /**
  11251. * Set the value of an uniform to an array of number (stored as vec4)
  11252. * @param uniform defines the webGL uniform location where to store the value
  11253. * @param array defines the array of number to store
  11254. */
  11255. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11256. /**
  11257. * Set the value of an uniform to an array of float32 (stored as matrices)
  11258. * @param uniform defines the webGL uniform location where to store the value
  11259. * @param matrices defines the array of float32 to store
  11260. */
  11261. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11262. /**
  11263. * Set the value of an uniform to a matrix
  11264. * @param uniform defines the webGL uniform location where to store the value
  11265. * @param matrix defines the matrix to store
  11266. */
  11267. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11268. /**
  11269. * Set the value of an uniform to a matrix (3x3)
  11270. * @param uniform defines the webGL uniform location where to store the value
  11271. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11272. */
  11273. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11274. /**
  11275. * Set the value of an uniform to a matrix (2x2)
  11276. * @param uniform defines the webGL uniform location where to store the value
  11277. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11278. */
  11279. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11280. /**
  11281. * Set the value of an uniform to a number (int)
  11282. * @param uniform defines the webGL uniform location where to store the value
  11283. * @param value defines the int number to store
  11284. */
  11285. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11286. /**
  11287. * Set the value of an uniform to a number (float)
  11288. * @param uniform defines the webGL uniform location where to store the value
  11289. * @param value defines the float number to store
  11290. */
  11291. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11292. /**
  11293. * Set the value of an uniform to a vec2
  11294. * @param uniform defines the webGL uniform location where to store the value
  11295. * @param x defines the 1st component of the value
  11296. * @param y defines the 2nd component of the value
  11297. */
  11298. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11299. /**
  11300. * Set the value of an uniform to a vec3
  11301. * @param uniform defines the webGL uniform location where to store the value
  11302. * @param x defines the 1st component of the value
  11303. * @param y defines the 2nd component of the value
  11304. * @param z defines the 3rd component of the value
  11305. */
  11306. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11307. /**
  11308. * Set the value of an uniform to a boolean
  11309. * @param uniform defines the webGL uniform location where to store the value
  11310. * @param bool defines the boolean to store
  11311. */
  11312. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11313. /**
  11314. * Set the value of an uniform to a vec4
  11315. * @param uniform defines the webGL uniform location where to store the value
  11316. * @param x defines the 1st component of the value
  11317. * @param y defines the 2nd component of the value
  11318. * @param z defines the 3rd component of the value
  11319. * @param w defines the 4th component of the value
  11320. */
  11321. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11322. /**
  11323. * Set the value of an uniform to a Color3
  11324. * @param uniform defines the webGL uniform location where to store the value
  11325. * @param color3 defines the color to store
  11326. */
  11327. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11328. /**
  11329. * Set the value of an uniform to a Color3 and an alpha value
  11330. * @param uniform defines the webGL uniform location where to store the value
  11331. * @param color3 defines the color to store
  11332. * @param alpha defines the alpha component to store
  11333. */
  11334. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11335. /**
  11336. * Sets a Color4 on a uniform variable
  11337. * @param uniform defines the uniform location
  11338. * @param color4 defines the value to be set
  11339. */
  11340. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11341. /**
  11342. * Set various states to the webGL context
  11343. * @param culling defines backface culling state
  11344. * @param zOffset defines the value to apply to zOffset (0 by default)
  11345. * @param force defines if states must be applied even if cache is up to date
  11346. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11347. */
  11348. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11349. /**
  11350. * Set the z offset to apply to current rendering
  11351. * @param value defines the offset to apply
  11352. */
  11353. setZOffset(value: number): void;
  11354. /**
  11355. * Gets the current value of the zOffset
  11356. * @returns the current zOffset state
  11357. */
  11358. getZOffset(): number;
  11359. /**
  11360. * Enable or disable depth buffering
  11361. * @param enable defines the state to set
  11362. */
  11363. setDepthBuffer(enable: boolean): void;
  11364. /**
  11365. * Gets a boolean indicating if depth writing is enabled
  11366. * @returns the current depth writing state
  11367. */
  11368. getDepthWrite(): boolean;
  11369. /**
  11370. * Enable or disable depth writing
  11371. * @param enable defines the state to set
  11372. */
  11373. setDepthWrite(enable: boolean): void;
  11374. /**
  11375. * Enable or disable color writing
  11376. * @param enable defines the state to set
  11377. */
  11378. setColorWrite(enable: boolean): void;
  11379. /**
  11380. * Gets a boolean indicating if color writing is enabled
  11381. * @returns the current color writing state
  11382. */
  11383. getColorWrite(): boolean;
  11384. /**
  11385. * Sets alpha constants used by some alpha blending modes
  11386. * @param r defines the red component
  11387. * @param g defines the green component
  11388. * @param b defines the blue component
  11389. * @param a defines the alpha component
  11390. */
  11391. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11392. /**
  11393. * Sets the current alpha mode
  11394. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11395. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11397. */
  11398. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11399. /**
  11400. * Gets the current alpha mode
  11401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11402. * @returns the current alpha mode
  11403. */
  11404. getAlphaMode(): number;
  11405. /**
  11406. * Clears the list of texture accessible through engine.
  11407. * This can help preventing texture load conflict due to name collision.
  11408. */
  11409. clearInternalTexturesCache(): void;
  11410. /**
  11411. * Force the entire cache to be cleared
  11412. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11413. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11414. */
  11415. wipeCaches(bruteForce?: boolean): void;
  11416. /**
  11417. * Set the compressed texture format to use, based on the formats you have, and the formats
  11418. * supported by the hardware / browser.
  11419. *
  11420. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11421. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11422. * to API arguments needed to compressed textures. This puts the burden on the container
  11423. * generator to house the arcane code for determining these for current & future formats.
  11424. *
  11425. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11426. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11427. *
  11428. * Note: The result of this call is not taken into account when a texture is base64.
  11429. *
  11430. * @param formatsAvailable defines the list of those format families you have created
  11431. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11432. *
  11433. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11434. * @returns The extension selected.
  11435. */
  11436. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11437. private _getSamplingParameters;
  11438. private _partialLoadImg;
  11439. private _cascadeLoadImgs;
  11440. /** @hidden */
  11441. _createTexture(): WebGLTexture;
  11442. /**
  11443. * Usually called from BABYLON.Texture.ts.
  11444. * Passed information to create a WebGLTexture
  11445. * @param urlArg defines a value which contains one of the following:
  11446. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11447. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11448. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11450. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11451. * @param scene needed for loading to the correct scene
  11452. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11453. * @param onLoad optional callback to be called upon successful completion
  11454. * @param onError optional callback to be called upon failure
  11455. * @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
  11456. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11457. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11458. * @param forcedExtension defines the extension to use to pick the right loader
  11459. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11460. */
  11461. 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;
  11462. private _rescaleTexture;
  11463. /**
  11464. * Update a raw texture
  11465. * @param texture defines the texture to update
  11466. * @param data defines the data to store in the texture
  11467. * @param format defines the format of the data
  11468. * @param invertY defines if data must be stored with Y axis inverted
  11469. * @param compression defines the compression used (null by default)
  11470. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11471. */
  11472. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11473. /**
  11474. * Creates a raw texture
  11475. * @param data defines the data to store in the texture
  11476. * @param width defines the width of the texture
  11477. * @param height defines the height of the texture
  11478. * @param format defines the format of the data
  11479. * @param generateMipMaps defines if the engine should generate the mip levels
  11480. * @param invertY defines if data must be stored with Y axis inverted
  11481. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11482. * @param compression defines the compression used (null by default)
  11483. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11484. * @returns the raw texture inside an InternalTexture
  11485. */
  11486. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11487. private _unpackFlipYCached;
  11488. /**
  11489. * In case you are sharing the context with other applications, it might
  11490. * be interested to not cache the unpack flip y state to ensure a consistent
  11491. * value would be set.
  11492. */
  11493. enableUnpackFlipYCached: boolean;
  11494. /** @hidden */
  11495. _unpackFlipY(value: boolean): void;
  11496. /** @hidden */
  11497. _getUnpackAlignement(): number;
  11498. /**
  11499. * Creates a dynamic texture
  11500. * @param width defines the width of the texture
  11501. * @param height defines the height of the texture
  11502. * @param generateMipMaps defines if the engine should generate the mip levels
  11503. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11504. * @returns the dynamic texture inside an InternalTexture
  11505. */
  11506. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11507. /**
  11508. * Update the sampling mode of a given texture
  11509. * @param samplingMode defines the required sampling mode
  11510. * @param texture defines the texture to update
  11511. */
  11512. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11513. /**
  11514. * Update the content of a dynamic texture
  11515. * @param texture defines the texture to update
  11516. * @param canvas defines the canvas containing the source
  11517. * @param invertY defines if data must be stored with Y axis inverted
  11518. * @param premulAlpha defines if alpha is stored as premultiplied
  11519. * @param format defines the format of the data
  11520. */
  11521. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11522. /**
  11523. * Update a video texture
  11524. * @param texture defines the texture to update
  11525. * @param video defines the video element to use
  11526. * @param invertY defines if data must be stored with Y axis inverted
  11527. */
  11528. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11529. /**
  11530. * Updates a depth texture Comparison Mode and Function.
  11531. * If the comparison Function is equal to 0, the mode will be set to none.
  11532. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11533. * @param texture The texture to set the comparison function for
  11534. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11535. */
  11536. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11537. private _setupDepthStencilTexture;
  11538. /**
  11539. * Creates a depth stencil texture.
  11540. * This is only available in WebGL 2 or with the depth texture extension available.
  11541. * @param size The size of face edge in the texture.
  11542. * @param options The options defining the texture.
  11543. * @returns The texture
  11544. */
  11545. createDepthStencilTexture(size: number | {
  11546. width: number;
  11547. height: number;
  11548. }, options: DepthTextureCreationOptions): InternalTexture;
  11549. /**
  11550. * Creates a depth stencil texture.
  11551. * This is only available in WebGL 2 or with the depth texture extension available.
  11552. * @param size The size of face edge in the texture.
  11553. * @param options The options defining the texture.
  11554. * @returns The texture
  11555. */
  11556. private _createDepthStencilTexture;
  11557. /**
  11558. * Creates a depth stencil cube texture.
  11559. * This is only available in WebGL 2.
  11560. * @param size The size of face edge in the cube texture.
  11561. * @param options The options defining the cube texture.
  11562. * @returns The cube texture
  11563. */
  11564. private _createDepthStencilCubeTexture;
  11565. /**
  11566. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11567. * @param renderTarget The render target to set the frame buffer for
  11568. */
  11569. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11570. /**
  11571. * Creates a new render target texture
  11572. * @param size defines the size of the texture
  11573. * @param options defines the options used to create the texture
  11574. * @returns a new render target texture stored in an InternalTexture
  11575. */
  11576. createRenderTargetTexture(size: number | {
  11577. width: number;
  11578. height: number;
  11579. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11580. /**
  11581. * Create a multi render target texture
  11582. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11583. * @param size defines the size of the texture
  11584. * @param options defines the creation options
  11585. * @returns the cube texture as an InternalTexture
  11586. */
  11587. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11588. private _setupFramebufferDepthAttachments;
  11589. /**
  11590. * Updates the sample count of a render target texture
  11591. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11592. * @param texture defines the texture to update
  11593. * @param samples defines the sample count to set
  11594. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11595. */
  11596. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11597. /**
  11598. * Update the sample count for a given multiple render target texture
  11599. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11600. * @param textures defines the textures to update
  11601. * @param samples defines the sample count to set
  11602. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11603. */
  11604. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11605. /** @hidden */
  11606. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11607. /** @hidden */
  11608. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11609. /** @hidden */
  11610. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11611. /** @hidden */
  11612. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11613. /**
  11614. * Creates a new render target cube texture
  11615. * @param size defines the size of the texture
  11616. * @param options defines the options used to create the texture
  11617. * @returns a new render target cube texture stored in an InternalTexture
  11618. */
  11619. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11620. /**
  11621. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11622. * @param rootUrl defines the url where the file to load is located
  11623. * @param scene defines the current scene
  11624. * @param lodScale defines scale to apply to the mip map selection
  11625. * @param lodOffset defines offset to apply to the mip map selection
  11626. * @param onLoad defines an optional callback raised when the texture is loaded
  11627. * @param onError defines an optional callback raised if there is an issue to load the texture
  11628. * @param format defines the format of the data
  11629. * @param forcedExtension defines the extension to use to pick the right loader
  11630. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11631. * @returns the cube texture as an InternalTexture
  11632. */
  11633. 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;
  11634. /**
  11635. * Creates a cube texture
  11636. * @param rootUrl defines the url where the files to load is located
  11637. * @param scene defines the current scene
  11638. * @param files defines the list of files to load (1 per face)
  11639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11640. * @param onLoad defines an optional callback raised when the texture is loaded
  11641. * @param onError defines an optional callback raised if there is an issue to load the texture
  11642. * @param format defines the format of the data
  11643. * @param forcedExtension defines the extension to use to pick the right loader
  11644. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11645. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11646. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11647. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11648. * @returns the cube texture as an InternalTexture
  11649. */
  11650. 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;
  11651. /**
  11652. * @hidden
  11653. */
  11654. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11655. /**
  11656. * Update a raw cube texture
  11657. * @param texture defines the texture to udpdate
  11658. * @param data defines the data to store
  11659. * @param format defines the data format
  11660. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11661. * @param invertY defines if data must be stored with Y axis inverted
  11662. * @param compression defines the compression used (null by default)
  11663. * @param level defines which level of the texture to update
  11664. */
  11665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11666. /**
  11667. * Creates a new raw cube texture
  11668. * @param data defines the array of data to use to create each face
  11669. * @param size defines the size of the textures
  11670. * @param format defines the format of the data
  11671. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11672. * @param generateMipMaps defines if the engine should generate the mip levels
  11673. * @param invertY defines if data must be stored with Y axis inverted
  11674. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11675. * @param compression defines the compression used (null by default)
  11676. * @returns the cube texture as an InternalTexture
  11677. */
  11678. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11679. /**
  11680. * Creates a new raw cube texture from a specified url
  11681. * @param url defines the url where the data is located
  11682. * @param scene defines the current scene
  11683. * @param size defines the size of the textures
  11684. * @param format defines the format of the data
  11685. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11686. * @param noMipmap defines if the engine should avoid generating the mip levels
  11687. * @param callback defines a callback used to extract texture data from loaded data
  11688. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11689. * @param onLoad defines a callback called when texture is loaded
  11690. * @param onError defines a callback called if there is an error
  11691. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11692. * @param invertY defines if data must be stored with Y axis inverted
  11693. * @returns the cube texture as an InternalTexture
  11694. */
  11695. 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;
  11696. /**
  11697. * Update a raw 3D texture
  11698. * @param texture defines the texture to update
  11699. * @param data defines the data to store
  11700. * @param format defines the data format
  11701. * @param invertY defines if data must be stored with Y axis inverted
  11702. * @param compression defines the used compression (can be null)
  11703. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11704. */
  11705. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11706. /**
  11707. * Creates a new raw 3D texture
  11708. * @param data defines the data used to create the texture
  11709. * @param width defines the width of the texture
  11710. * @param height defines the height of the texture
  11711. * @param depth defines the depth of the texture
  11712. * @param format defines the format of the texture
  11713. * @param generateMipMaps defines if the engine must generate mip levels
  11714. * @param invertY defines if data must be stored with Y axis inverted
  11715. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11716. * @param compression defines the compressed used (can be null)
  11717. * @param textureType defines the compressed used (can be null)
  11718. * @returns a new raw 3D texture (stored in an InternalTexture)
  11719. */
  11720. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11721. private _prepareWebGLTextureContinuation;
  11722. private _prepareWebGLTexture;
  11723. private _convertRGBtoRGBATextureData;
  11724. /** @hidden */
  11725. _releaseFramebufferObjects(texture: InternalTexture): void;
  11726. /** @hidden */
  11727. _releaseTexture(texture: InternalTexture): void;
  11728. private setProgram;
  11729. private _boundUniforms;
  11730. /**
  11731. * Binds an effect to the webGL context
  11732. * @param effect defines the effect to bind
  11733. */
  11734. bindSamplers(effect: Effect): void;
  11735. private _moveBoundTextureOnTop;
  11736. private _getCorrectTextureChannel;
  11737. private _linkTrackers;
  11738. private _removeDesignatedSlot;
  11739. private _activateCurrentTexture;
  11740. /** @hidden */
  11741. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11742. /** @hidden */
  11743. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11744. /**
  11745. * Sets a texture to the webGL context from a postprocess
  11746. * @param channel defines the channel to use
  11747. * @param postProcess defines the source postprocess
  11748. */
  11749. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11750. /**
  11751. * Binds the output of the passed in post process to the texture channel specified
  11752. * @param channel The channel the texture should be bound to
  11753. * @param postProcess The post process which's output should be bound
  11754. */
  11755. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11756. /**
  11757. * Unbind all textures from the webGL context
  11758. */
  11759. unbindAllTextures(): void;
  11760. /**
  11761. * Sets a texture to the according uniform.
  11762. * @param channel The texture channel
  11763. * @param uniform The uniform to set
  11764. * @param texture The texture to apply
  11765. */
  11766. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11767. /**
  11768. * Sets a depth stencil texture from a render target to the according uniform.
  11769. * @param channel The texture channel
  11770. * @param uniform The uniform to set
  11771. * @param texture The render target texture containing the depth stencil texture to apply
  11772. */
  11773. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11774. private _bindSamplerUniformToChannel;
  11775. private _getTextureWrapMode;
  11776. private _setTexture;
  11777. /**
  11778. * Sets an array of texture to the webGL context
  11779. * @param channel defines the channel where the texture array must be set
  11780. * @param uniform defines the associated uniform location
  11781. * @param textures defines the array of textures to bind
  11782. */
  11783. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11784. /** @hidden */
  11785. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11786. private _setTextureParameterFloat;
  11787. private _setTextureParameterInteger;
  11788. /**
  11789. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11790. * @param x defines the x coordinate of the rectangle where pixels must be read
  11791. * @param y defines the y coordinate of the rectangle where pixels must be read
  11792. * @param width defines the width of the rectangle where pixels must be read
  11793. * @param height defines the height of the rectangle where pixels must be read
  11794. * @returns a Uint8Array containing RGBA colors
  11795. */
  11796. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11797. /**
  11798. * Add an externaly attached data from its key.
  11799. * This method call will fail and return false, if such key already exists.
  11800. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11801. * @param key the unique key that identifies the data
  11802. * @param data the data object to associate to the key for this Engine instance
  11803. * @return true if no such key were already present and the data was added successfully, false otherwise
  11804. */
  11805. addExternalData<T>(key: string, data: T): boolean;
  11806. /**
  11807. * Get an externaly attached data from its key
  11808. * @param key the unique key that identifies the data
  11809. * @return the associated data, if present (can be null), or undefined if not present
  11810. */
  11811. getExternalData<T>(key: string): T;
  11812. /**
  11813. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11814. * @param key the unique key that identifies the data
  11815. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11816. * @return the associated data, can be null if the factory returned null.
  11817. */
  11818. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11819. /**
  11820. * Remove an externaly attached data from the Engine instance
  11821. * @param key the unique key that identifies the data
  11822. * @return true if the data was successfully removed, false if it doesn't exist
  11823. */
  11824. removeExternalData(key: string): boolean;
  11825. /**
  11826. * Unbind all vertex attributes from the webGL context
  11827. */
  11828. unbindAllAttributes(): void;
  11829. /**
  11830. * 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
  11831. */
  11832. releaseEffects(): void;
  11833. /**
  11834. * Dispose and release all associated resources
  11835. */
  11836. dispose(): void;
  11837. /**
  11838. * Display the loading screen
  11839. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11840. */
  11841. displayLoadingUI(): void;
  11842. /**
  11843. * Hide the loading screen
  11844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11845. */
  11846. hideLoadingUI(): void;
  11847. /**
  11848. * Gets the current loading screen object
  11849. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11850. */
  11851. /**
  11852. * Sets the current loading screen object
  11853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11854. */
  11855. loadingScreen: ILoadingScreen;
  11856. /**
  11857. * Sets the current loading screen text
  11858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11859. */
  11860. loadingUIText: string;
  11861. /**
  11862. * Sets the current loading screen background color
  11863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11864. */
  11865. loadingUIBackgroundColor: string;
  11866. /**
  11867. * Attach a new callback raised when context lost event is fired
  11868. * @param callback defines the callback to call
  11869. */
  11870. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11871. /**
  11872. * Attach a new callback raised when context restored event is fired
  11873. * @param callback defines the callback to call
  11874. */
  11875. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11876. /**
  11877. * Gets the source code of the vertex shader associated with a specific webGL program
  11878. * @param program defines the program to use
  11879. * @returns a string containing the source code of the vertex shader associated with the program
  11880. */
  11881. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11882. /**
  11883. * Gets the source code of the fragment shader associated with a specific webGL program
  11884. * @param program defines the program to use
  11885. * @returns a string containing the source code of the fragment shader associated with the program
  11886. */
  11887. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11888. /**
  11889. * Get the current error code of the webGL context
  11890. * @returns the error code
  11891. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11892. */
  11893. getError(): number;
  11894. /**
  11895. * Gets the current framerate
  11896. * @returns a number representing the framerate
  11897. */
  11898. getFps(): number;
  11899. /**
  11900. * Gets the time spent between current and previous frame
  11901. * @returns a number representing the delta time in ms
  11902. */
  11903. getDeltaTime(): number;
  11904. private _measureFps;
  11905. /** @hidden */
  11906. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11907. private _canRenderToFloatFramebuffer;
  11908. private _canRenderToHalfFloatFramebuffer;
  11909. private _canRenderToFramebuffer;
  11910. /** @hidden */
  11911. _getWebGLTextureType(type: number): number;
  11912. private _getInternalFormat;
  11913. /** @hidden */
  11914. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11915. /** @hidden */
  11916. _getRGBAMultiSampleBufferFormat(type: number): number;
  11917. /** @hidden */
  11918. _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;
  11919. /** @hidden */
  11920. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11921. private _partialLoadFile;
  11922. private _cascadeLoadFiles;
  11923. /**
  11924. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11925. * @returns true if the engine can be created
  11926. * @ignorenaming
  11927. */
  11928. static isSupported(): boolean;
  11929. }
  11930. }
  11931. declare module BABYLON {
  11932. /**
  11933. * Options to create the null engine
  11934. */
  11935. class NullEngineOptions {
  11936. /**
  11937. * Render width (Default: 512)
  11938. */
  11939. renderWidth: number;
  11940. /**
  11941. * Render height (Default: 256)
  11942. */
  11943. renderHeight: number;
  11944. /**
  11945. * Texture size (Default: 512)
  11946. */
  11947. textureSize: number;
  11948. /**
  11949. * If delta time between frames should be constant
  11950. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11951. */
  11952. deterministicLockstep: boolean;
  11953. /**
  11954. * Maximum about of steps between frames (Default: 4)
  11955. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11956. */
  11957. lockstepMaxSteps: number;
  11958. }
  11959. /**
  11960. * The null engine class provides support for headless version of babylon.js.
  11961. * This can be used in server side scenario or for testing purposes
  11962. */
  11963. class NullEngine extends Engine {
  11964. private _options;
  11965. /**
  11966. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11967. */
  11968. isDeterministicLockStep(): boolean;
  11969. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11970. getLockstepMaxSteps(): number;
  11971. /**
  11972. * Sets hardware scaling, used to save performance if needed
  11973. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11974. */
  11975. getHardwareScalingLevel(): number;
  11976. constructor(options?: NullEngineOptions);
  11977. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11978. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11979. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11980. getRenderWidth(useScreen?: boolean): number;
  11981. getRenderHeight(useScreen?: boolean): number;
  11982. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11983. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11984. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11985. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11986. bindSamplers(effect: Effect): void;
  11987. enableEffect(effect: Effect): void;
  11988. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11989. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11990. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11991. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11992. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11993. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11994. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11995. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11996. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11997. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11998. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11999. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12000. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12001. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12002. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12003. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12004. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12005. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12006. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12007. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12008. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12009. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12010. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12011. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12012. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12013. bindBuffers(vertexBuffers: {
  12014. [key: string]: VertexBuffer;
  12015. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12016. wipeCaches(bruteForce?: boolean): void;
  12017. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12018. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12019. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12020. /** @hidden */
  12021. _createTexture(): WebGLTexture;
  12022. /** @hidden */
  12023. _releaseTexture(texture: InternalTexture): void;
  12024. 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;
  12025. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12026. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12027. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12028. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12029. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12030. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12031. areAllEffectsReady(): boolean;
  12032. /**
  12033. * @hidden
  12034. * Get the current error code of the webGL context
  12035. * @returns the error code
  12036. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12037. */
  12038. getError(): number;
  12039. /** @hidden */
  12040. _getUnpackAlignement(): number;
  12041. /** @hidden */
  12042. _unpackFlipY(value: boolean): void;
  12043. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12044. /**
  12045. * Updates a dynamic vertex buffer.
  12046. * @param vertexBuffer the vertex buffer to update
  12047. * @param data the data used to update the vertex buffer
  12048. * @param byteOffset the byte offset of the data (optional)
  12049. * @param byteLength the byte length of the data (optional)
  12050. */
  12051. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12052. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12053. /** @hidden */
  12054. _bindTexture(channel: number, texture: InternalTexture): void;
  12055. /** @hidden */
  12056. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12057. releaseEffects(): void;
  12058. displayLoadingUI(): void;
  12059. hideLoadingUI(): void;
  12060. /** @hidden */
  12061. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12062. /** @hidden */
  12063. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12064. /** @hidden */
  12065. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12066. /** @hidden */
  12067. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12068. }
  12069. }
  12070. interface WebGLRenderingContext {
  12071. readonly RASTERIZER_DISCARD: number;
  12072. readonly DEPTH_COMPONENT24: number;
  12073. readonly TEXTURE_3D: number;
  12074. readonly TEXTURE_2D_ARRAY: number;
  12075. readonly TEXTURE_COMPARE_FUNC: number;
  12076. readonly TEXTURE_COMPARE_MODE: number;
  12077. readonly COMPARE_REF_TO_TEXTURE: number;
  12078. readonly TEXTURE_WRAP_R: number;
  12079. readonly HALF_FLOAT: number;
  12080. readonly RGB8: number;
  12081. readonly RED_INTEGER: number;
  12082. readonly RG_INTEGER: number;
  12083. readonly RGB_INTEGER: number;
  12084. readonly RGBA_INTEGER: number;
  12085. readonly R8_SNORM: number;
  12086. readonly RG8_SNORM: number;
  12087. readonly RGB8_SNORM: number;
  12088. readonly RGBA8_SNORM: number;
  12089. readonly R8I: number;
  12090. readonly RG8I: number;
  12091. readonly RGB8I: number;
  12092. readonly RGBA8I: number;
  12093. readonly R8UI: number;
  12094. readonly RG8UI: number;
  12095. readonly RGB8UI: number;
  12096. readonly RGBA8UI: number;
  12097. readonly R16I: number;
  12098. readonly RG16I: number;
  12099. readonly RGB16I: number;
  12100. readonly RGBA16I: number;
  12101. readonly R16UI: number;
  12102. readonly RG16UI: number;
  12103. readonly RGB16UI: number;
  12104. readonly RGBA16UI: number;
  12105. readonly R32I: number;
  12106. readonly RG32I: number;
  12107. readonly RGB32I: number;
  12108. readonly RGBA32I: number;
  12109. readonly R32UI: number;
  12110. readonly RG32UI: number;
  12111. readonly RGB32UI: number;
  12112. readonly RGBA32UI: number;
  12113. readonly RGB10_A2UI: number;
  12114. readonly R11F_G11F_B10F: number;
  12115. readonly RGB9_E5: number;
  12116. readonly RGB10_A2: number;
  12117. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12118. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12119. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12120. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12121. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12122. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12123. 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;
  12124. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12125. readonly TRANSFORM_FEEDBACK: number;
  12126. readonly INTERLEAVED_ATTRIBS: number;
  12127. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12128. createTransformFeedback(): WebGLTransformFeedback;
  12129. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12130. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12131. beginTransformFeedback(primitiveMode: number): void;
  12132. endTransformFeedback(): void;
  12133. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12134. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12135. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12136. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12137. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12138. }
  12139. interface ImageBitmap {
  12140. readonly width: number;
  12141. readonly height: number;
  12142. close(): void;
  12143. }
  12144. interface WebGLQuery extends WebGLObject {
  12145. }
  12146. declare var WebGLQuery: {
  12147. prototype: WebGLQuery;
  12148. new (): WebGLQuery;
  12149. };
  12150. interface WebGLSampler extends WebGLObject {
  12151. }
  12152. declare var WebGLSampler: {
  12153. prototype: WebGLSampler;
  12154. new (): WebGLSampler;
  12155. };
  12156. interface WebGLSync extends WebGLObject {
  12157. }
  12158. declare var WebGLSync: {
  12159. prototype: WebGLSync;
  12160. new (): WebGLSync;
  12161. };
  12162. interface WebGLTransformFeedback extends WebGLObject {
  12163. }
  12164. declare var WebGLTransformFeedback: {
  12165. prototype: WebGLTransformFeedback;
  12166. new (): WebGLTransformFeedback;
  12167. };
  12168. interface WebGLVertexArrayObject extends WebGLObject {
  12169. }
  12170. declare var WebGLVertexArrayObject: {
  12171. prototype: WebGLVertexArrayObject;
  12172. new (): WebGLVertexArrayObject;
  12173. };
  12174. declare module BABYLON {
  12175. /**
  12176. * Gather the list of keyboard event types as constants.
  12177. */
  12178. class KeyboardEventTypes {
  12179. /**
  12180. * The keydown event is fired when a key becomes active (pressed).
  12181. */
  12182. static readonly KEYDOWN: number;
  12183. /**
  12184. * The keyup event is fired when a key has been released.
  12185. */
  12186. static readonly KEYUP: number;
  12187. }
  12188. /**
  12189. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12190. */
  12191. class KeyboardInfo {
  12192. /**
  12193. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12194. */
  12195. type: number;
  12196. /**
  12197. * Defines the related dom event
  12198. */
  12199. event: KeyboardEvent;
  12200. /**
  12201. * Instantiates a new keyboard info.
  12202. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12203. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12204. * @param event Defines the related dom event
  12205. */
  12206. constructor(
  12207. /**
  12208. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12209. */
  12210. type: number,
  12211. /**
  12212. * Defines the related dom event
  12213. */
  12214. event: KeyboardEvent);
  12215. }
  12216. /**
  12217. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12218. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12219. */
  12220. class KeyboardInfoPre extends KeyboardInfo {
  12221. /**
  12222. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12223. */
  12224. type: number;
  12225. /**
  12226. * Defines the related dom event
  12227. */
  12228. event: KeyboardEvent;
  12229. /**
  12230. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12231. */
  12232. skipOnPointerObservable: boolean;
  12233. /**
  12234. * Instantiates a new keyboard pre info.
  12235. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12236. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12237. * @param event Defines the related dom event
  12238. */
  12239. constructor(
  12240. /**
  12241. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12242. */
  12243. type: number,
  12244. /**
  12245. * Defines the related dom event
  12246. */
  12247. event: KeyboardEvent);
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. /**
  12252. * Gather the list of pointer event types as constants.
  12253. */
  12254. class PointerEventTypes {
  12255. /**
  12256. * 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.
  12257. */
  12258. static readonly POINTERDOWN: number;
  12259. /**
  12260. * The pointerup event is fired when a pointer is no longer active.
  12261. */
  12262. static readonly POINTERUP: number;
  12263. /**
  12264. * The pointermove event is fired when a pointer changes coordinates.
  12265. */
  12266. static readonly POINTERMOVE: number;
  12267. /**
  12268. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12269. */
  12270. static readonly POINTERWHEEL: number;
  12271. /**
  12272. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12273. */
  12274. static readonly POINTERPICK: number;
  12275. /**
  12276. * The pointertap event is fired when a the object has been touched and released without drag.
  12277. */
  12278. static readonly POINTERTAP: number;
  12279. /**
  12280. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12281. */
  12282. static readonly POINTERDOUBLETAP: number;
  12283. }
  12284. /**
  12285. * Base class of pointer info types.
  12286. */
  12287. class PointerInfoBase {
  12288. /**
  12289. * Defines the type of event (BABYLON.PointerEventTypes)
  12290. */
  12291. type: number;
  12292. /**
  12293. * Defines the related dom event
  12294. */
  12295. event: PointerEvent | MouseWheelEvent;
  12296. /**
  12297. * Instantiates the base class of pointers info.
  12298. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12299. * @param event Defines the related dom event
  12300. */
  12301. constructor(
  12302. /**
  12303. * Defines the type of event (BABYLON.PointerEventTypes)
  12304. */
  12305. type: number,
  12306. /**
  12307. * Defines the related dom event
  12308. */
  12309. event: PointerEvent | MouseWheelEvent);
  12310. }
  12311. /**
  12312. * This class is used to store pointer related info for the onPrePointerObservable event.
  12313. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12314. */
  12315. class PointerInfoPre extends PointerInfoBase {
  12316. /**
  12317. * Ray from a pointer if availible (eg. 6dof controller)
  12318. */
  12319. ray: Nullable<Ray>;
  12320. /**
  12321. * Defines the local position of the pointer on the canvas.
  12322. */
  12323. localPosition: Vector2;
  12324. /**
  12325. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12326. */
  12327. skipOnPointerObservable: boolean;
  12328. /**
  12329. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12330. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12331. * @param event Defines the related dom event
  12332. * @param localX Defines the local x coordinates of the pointer when the event occured
  12333. * @param localY Defines the local y coordinates of the pointer when the event occured
  12334. */
  12335. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12336. }
  12337. /**
  12338. * This type contains all the data related to a pointer event in Babylon.js.
  12339. * 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.
  12340. */
  12341. class PointerInfo extends PointerInfoBase {
  12342. /**
  12343. * Defines the picking info associated to the info (if any)\
  12344. */
  12345. pickInfo: Nullable<PickingInfo>;
  12346. /**
  12347. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12348. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12349. * @param event Defines the related dom event
  12350. * @param pickInfo Defines the picking info associated to the info (if any)\
  12351. */
  12352. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12353. /**
  12354. * Defines the picking info associated to the info (if any)\
  12355. */
  12356. pickInfo: Nullable<PickingInfo>);
  12357. }
  12358. }
  12359. declare module BABYLON {
  12360. /**
  12361. * Represents a gamepad control stick position
  12362. */
  12363. class StickValues {
  12364. /**
  12365. * The x component of the control stick
  12366. */
  12367. x: number;
  12368. /**
  12369. * The y component of the control stick
  12370. */
  12371. y: number;
  12372. /**
  12373. * Initializes the gamepad x and y control stick values
  12374. * @param x The x component of the gamepad control stick value
  12375. * @param y The y component of the gamepad control stick value
  12376. */
  12377. constructor(
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number,
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number);
  12386. }
  12387. /**
  12388. * An interface which manages callbacks for gamepad button changes
  12389. */
  12390. interface GamepadButtonChanges {
  12391. /**
  12392. * Called when a gamepad has been changed
  12393. */
  12394. changed: boolean;
  12395. /**
  12396. * Called when a gamepad press event has been triggered
  12397. */
  12398. pressChanged: boolean;
  12399. /**
  12400. * Called when a touch event has been triggered
  12401. */
  12402. touchChanged: boolean;
  12403. /**
  12404. * Called when a value has changed
  12405. */
  12406. valueChanged: boolean;
  12407. }
  12408. /**
  12409. * Represents a gamepad
  12410. */
  12411. class Gamepad {
  12412. /**
  12413. * The id of the gamepad
  12414. */
  12415. id: string;
  12416. /**
  12417. * The index of the gamepad
  12418. */
  12419. index: number;
  12420. /**
  12421. * The browser gamepad
  12422. */
  12423. browserGamepad: any;
  12424. /**
  12425. * Specifies what type of gamepad this represents
  12426. */
  12427. type: number;
  12428. private _leftStick;
  12429. private _rightStick;
  12430. /** @hidden */
  12431. _isConnected: boolean;
  12432. private _leftStickAxisX;
  12433. private _leftStickAxisY;
  12434. private _rightStickAxisX;
  12435. private _rightStickAxisY;
  12436. /**
  12437. * Triggered when the left control stick has been changed
  12438. */
  12439. private _onleftstickchanged;
  12440. /**
  12441. * Triggered when the right control stick has been changed
  12442. */
  12443. private _onrightstickchanged;
  12444. /**
  12445. * Represents a gamepad controller
  12446. */
  12447. static GAMEPAD: number;
  12448. /**
  12449. * Represents a generic controller
  12450. */
  12451. static GENERIC: number;
  12452. /**
  12453. * Represents an XBox controller
  12454. */
  12455. static XBOX: number;
  12456. /**
  12457. * Represents a pose-enabled controller
  12458. */
  12459. static POSE_ENABLED: number;
  12460. /**
  12461. * Specifies whether the left control stick should be Y-inverted
  12462. */
  12463. protected _invertLeftStickY: boolean;
  12464. /**
  12465. * Specifies if the gamepad has been connected
  12466. */
  12467. readonly isConnected: boolean;
  12468. /**
  12469. * Initializes the gamepad
  12470. * @param id The id of the gamepad
  12471. * @param index The index of the gamepad
  12472. * @param browserGamepad The browser gamepad
  12473. * @param leftStickX The x component of the left joystick
  12474. * @param leftStickY The y component of the left joystick
  12475. * @param rightStickX The x component of the right joystick
  12476. * @param rightStickY The y component of the right joystick
  12477. */
  12478. constructor(
  12479. /**
  12480. * The id of the gamepad
  12481. */
  12482. id: string,
  12483. /**
  12484. * The index of the gamepad
  12485. */
  12486. index: number,
  12487. /**
  12488. * The browser gamepad
  12489. */
  12490. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12491. /**
  12492. * Callback triggered when the left joystick has changed
  12493. * @param callback
  12494. */
  12495. onleftstickchanged(callback: (values: StickValues) => void): void;
  12496. /**
  12497. * Callback triggered when the right joystick has changed
  12498. * @param callback
  12499. */
  12500. onrightstickchanged(callback: (values: StickValues) => void): void;
  12501. /**
  12502. * Gets the left joystick
  12503. */
  12504. /**
  12505. * Sets the left joystick values
  12506. */
  12507. leftStick: StickValues;
  12508. /**
  12509. * Gets the right joystick
  12510. */
  12511. /**
  12512. * Sets the right joystick value
  12513. */
  12514. rightStick: StickValues;
  12515. /**
  12516. * Updates the gamepad joystick positions
  12517. */
  12518. update(): void;
  12519. /**
  12520. * Disposes the gamepad
  12521. */
  12522. dispose(): void;
  12523. }
  12524. /**
  12525. * Represents a generic gamepad
  12526. */
  12527. class GenericPad extends Gamepad {
  12528. private _buttons;
  12529. private _onbuttondown;
  12530. private _onbuttonup;
  12531. /**
  12532. * Observable triggered when a button has been pressed
  12533. */
  12534. onButtonDownObservable: Observable<number>;
  12535. /**
  12536. * Observable triggered when a button has been released
  12537. */
  12538. onButtonUpObservable: Observable<number>;
  12539. /**
  12540. * Callback triggered when a button has been pressed
  12541. * @param callback Called when a button has been pressed
  12542. */
  12543. onbuttondown(callback: (buttonPressed: number) => void): void;
  12544. /**
  12545. * Callback triggered when a button has been released
  12546. * @param callback Called when a button has been released
  12547. */
  12548. onbuttonup(callback: (buttonReleased: number) => void): void;
  12549. /**
  12550. * Initializes the generic gamepad
  12551. * @param id The id of the generic gamepad
  12552. * @param index The index of the generic gamepad
  12553. * @param browserGamepad The browser gamepad
  12554. */
  12555. constructor(id: string, index: number, browserGamepad: any);
  12556. private _setButtonValue;
  12557. /**
  12558. * Updates the generic gamepad
  12559. */
  12560. update(): void;
  12561. /**
  12562. * Disposes the generic gamepad
  12563. */
  12564. dispose(): void;
  12565. }
  12566. }
  12567. declare module BABYLON {
  12568. /**
  12569. * Manager for handling gamepads
  12570. */
  12571. class GamepadManager {
  12572. private _scene?;
  12573. private _babylonGamepads;
  12574. private _oneGamepadConnected;
  12575. /** @hidden */
  12576. _isMonitoring: boolean;
  12577. private _gamepadEventSupported;
  12578. private _gamepadSupport;
  12579. /**
  12580. * observable to be triggered when the gamepad controller has been connected
  12581. */
  12582. onGamepadConnectedObservable: Observable<Gamepad>;
  12583. /**
  12584. * observable to be triggered when the gamepad controller has been disconnected
  12585. */
  12586. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12587. private _onGamepadConnectedEvent;
  12588. private _onGamepadDisconnectedEvent;
  12589. /**
  12590. * Initializes the gamepad manager
  12591. * @param _scene BabylonJS scene
  12592. */
  12593. constructor(_scene?: Scene | undefined);
  12594. /**
  12595. * The gamepads in the game pad manager
  12596. */
  12597. readonly gamepads: Gamepad[];
  12598. /**
  12599. * Get the gamepad controllers based on type
  12600. * @param type The type of gamepad controller
  12601. * @returns Nullable gamepad
  12602. */
  12603. getGamepadByType(type?: number): Nullable<Gamepad>;
  12604. /**
  12605. * Disposes the gamepad manager
  12606. */
  12607. dispose(): void;
  12608. private _addNewGamepad;
  12609. private _startMonitoringGamepads;
  12610. private _stopMonitoringGamepads;
  12611. /** @hidden */
  12612. _checkGamepadsStatus(): void;
  12613. private _updateGamepadObjects;
  12614. }
  12615. }
  12616. declare module BABYLON {
  12617. interface Scene {
  12618. /** @hidden */
  12619. _gamepadManager: Nullable<GamepadManager>;
  12620. /**
  12621. * Gets the gamepad manager associated with the scene
  12622. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12623. */
  12624. gamepadManager: GamepadManager;
  12625. }
  12626. /**
  12627. * Interface representing a free camera inputs manager
  12628. */
  12629. interface FreeCameraInputsManager {
  12630. /**
  12631. * Adds gamepad input support to the FreeCameraInputsManager.
  12632. * @returns the FreeCameraInputsManager
  12633. */
  12634. addGamepad(): FreeCameraInputsManager;
  12635. }
  12636. /**
  12637. * Interface representing an arc rotate camera inputs manager
  12638. */
  12639. interface ArcRotateCameraInputsManager {
  12640. /**
  12641. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12642. * @returns the camera inputs manager
  12643. */
  12644. addGamepad(): ArcRotateCameraInputsManager;
  12645. }
  12646. /**
  12647. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12648. */
  12649. class GamepadSystemSceneComponent implements ISceneComponent {
  12650. /**
  12651. * The component name helpfull to identify the component in the list of scene components.
  12652. */
  12653. readonly name: string;
  12654. /**
  12655. * The scene the component belongs to.
  12656. */
  12657. scene: Scene;
  12658. /**
  12659. * Creates a new instance of the component for the given scene
  12660. * @param scene Defines the scene to register the component in
  12661. */
  12662. constructor(scene: Scene);
  12663. /**
  12664. * Registers the component in a given scene
  12665. */
  12666. register(): void;
  12667. /**
  12668. * Rebuilds the elements related to this component in case of
  12669. * context lost for instance.
  12670. */
  12671. rebuild(): void;
  12672. /**
  12673. * Disposes the component and the associated ressources
  12674. */
  12675. dispose(): void;
  12676. private _beforeCameraUpdate;
  12677. }
  12678. }
  12679. declare module BABYLON {
  12680. /**
  12681. * Defines supported buttons for XBox360 compatible gamepads
  12682. */
  12683. enum Xbox360Button {
  12684. /** A */
  12685. A = 0,
  12686. /** B */
  12687. B = 1,
  12688. /** X */
  12689. X = 2,
  12690. /** Y */
  12691. Y = 3,
  12692. /** Start */
  12693. Start = 4,
  12694. /** Back */
  12695. Back = 5,
  12696. /** Left button */
  12697. LB = 6,
  12698. /** Right button */
  12699. RB = 7,
  12700. /** Left stick */
  12701. LeftStick = 8,
  12702. /** Right stick */
  12703. RightStick = 9
  12704. }
  12705. /** Defines values for XBox360 DPad */
  12706. enum Xbox360Dpad {
  12707. /** Up */
  12708. Up = 0,
  12709. /** Down */
  12710. Down = 1,
  12711. /** Left */
  12712. Left = 2,
  12713. /** Right */
  12714. Right = 3
  12715. }
  12716. /**
  12717. * Defines a XBox360 gamepad
  12718. */
  12719. class Xbox360Pad extends Gamepad {
  12720. private _leftTrigger;
  12721. private _rightTrigger;
  12722. private _onlefttriggerchanged;
  12723. private _onrighttriggerchanged;
  12724. private _onbuttondown;
  12725. private _onbuttonup;
  12726. private _ondpaddown;
  12727. private _ondpadup;
  12728. /** Observable raised when a button is pressed */
  12729. onButtonDownObservable: Observable<Xbox360Button>;
  12730. /** Observable raised when a button is released */
  12731. onButtonUpObservable: Observable<Xbox360Button>;
  12732. /** Observable raised when a pad is pressed */
  12733. onPadDownObservable: Observable<Xbox360Dpad>;
  12734. /** Observable raised when a pad is released */
  12735. onPadUpObservable: Observable<Xbox360Dpad>;
  12736. private _buttonA;
  12737. private _buttonB;
  12738. private _buttonX;
  12739. private _buttonY;
  12740. private _buttonBack;
  12741. private _buttonStart;
  12742. private _buttonLB;
  12743. private _buttonRB;
  12744. private _buttonLeftStick;
  12745. private _buttonRightStick;
  12746. private _dPadUp;
  12747. private _dPadDown;
  12748. private _dPadLeft;
  12749. private _dPadRight;
  12750. private _isXboxOnePad;
  12751. /**
  12752. * Creates a new XBox360 gamepad object
  12753. * @param id defines the id of this gamepad
  12754. * @param index defines its index
  12755. * @param gamepad defines the internal HTML gamepad object
  12756. * @param xboxOne defines if it is a XBox One gamepad
  12757. */
  12758. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12759. /**
  12760. * Defines the callback to call when left trigger is pressed
  12761. * @param callback defines the callback to use
  12762. */
  12763. onlefttriggerchanged(callback: (value: number) => void): void;
  12764. /**
  12765. * Defines the callback to call when right trigger is pressed
  12766. * @param callback defines the callback to use
  12767. */
  12768. onrighttriggerchanged(callback: (value: number) => void): void;
  12769. /**
  12770. * Gets the left trigger value
  12771. */
  12772. /**
  12773. * Sets the left trigger value
  12774. */
  12775. leftTrigger: number;
  12776. /**
  12777. * Gets the right trigger value
  12778. */
  12779. /**
  12780. * Sets the right trigger value
  12781. */
  12782. rightTrigger: number;
  12783. /**
  12784. * Defines the callback to call when a button is pressed
  12785. * @param callback defines the callback to use
  12786. */
  12787. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12788. /**
  12789. * Defines the callback to call when a button is released
  12790. * @param callback defines the callback to use
  12791. */
  12792. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12793. /**
  12794. * Defines the callback to call when a pad is pressed
  12795. * @param callback defines the callback to use
  12796. */
  12797. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12798. /**
  12799. * Defines the callback to call when a pad is released
  12800. * @param callback defines the callback to use
  12801. */
  12802. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12803. private _setButtonValue;
  12804. private _setDPadValue;
  12805. /**
  12806. * Gets the value of the `A` button
  12807. */
  12808. /**
  12809. * Sets the value of the `A` button
  12810. */
  12811. buttonA: number;
  12812. /**
  12813. * Gets the value of the `B` button
  12814. */
  12815. /**
  12816. * Sets the value of the `B` button
  12817. */
  12818. buttonB: number;
  12819. /**
  12820. * Gets the value of the `X` button
  12821. */
  12822. /**
  12823. * Sets the value of the `X` button
  12824. */
  12825. buttonX: number;
  12826. /**
  12827. * Gets the value of the `Y` button
  12828. */
  12829. /**
  12830. * Sets the value of the `Y` button
  12831. */
  12832. buttonY: number;
  12833. /**
  12834. * Gets the value of the `Start` button
  12835. */
  12836. /**
  12837. * Sets the value of the `Start` button
  12838. */
  12839. buttonStart: number;
  12840. /**
  12841. * Gets the value of the `Back` button
  12842. */
  12843. /**
  12844. * Sets the value of the `Back` button
  12845. */
  12846. buttonBack: number;
  12847. /**
  12848. * Gets the value of the `Left` button
  12849. */
  12850. /**
  12851. * Sets the value of the `Left` button
  12852. */
  12853. buttonLB: number;
  12854. /**
  12855. * Gets the value of the `Right` button
  12856. */
  12857. /**
  12858. * Sets the value of the `Right` button
  12859. */
  12860. buttonRB: number;
  12861. /**
  12862. * Gets the value of the Left joystick
  12863. */
  12864. /**
  12865. * Sets the value of the Left joystick
  12866. */
  12867. buttonLeftStick: number;
  12868. /**
  12869. * Gets the value of the Right joystick
  12870. */
  12871. /**
  12872. * Sets the value of the Right joystick
  12873. */
  12874. buttonRightStick: number;
  12875. /**
  12876. * Gets the value of D-pad up
  12877. */
  12878. /**
  12879. * Sets the value of D-pad up
  12880. */
  12881. dPadUp: number;
  12882. /**
  12883. * Gets the value of D-pad down
  12884. */
  12885. /**
  12886. * Sets the value of D-pad down
  12887. */
  12888. dPadDown: number;
  12889. /**
  12890. * Gets the value of D-pad left
  12891. */
  12892. /**
  12893. * Sets the value of D-pad left
  12894. */
  12895. dPadLeft: number;
  12896. /**
  12897. * Gets the value of D-pad right
  12898. */
  12899. /**
  12900. * Sets the value of D-pad right
  12901. */
  12902. dPadRight: number;
  12903. /**
  12904. * Force the gamepad to synchronize with device values
  12905. */
  12906. update(): void;
  12907. /**
  12908. * Disposes the gamepad
  12909. */
  12910. dispose(): void;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * Represents the different options available during the creation of
  12916. * a Environment helper.
  12917. *
  12918. * This can control the default ground, skybox and image processing setup of your scene.
  12919. */
  12920. interface IEnvironmentHelperOptions {
  12921. /**
  12922. * Specifies wether or not to create a ground.
  12923. * True by default.
  12924. */
  12925. createGround: boolean;
  12926. /**
  12927. * Specifies the ground size.
  12928. * 15 by default.
  12929. */
  12930. groundSize: number;
  12931. /**
  12932. * The texture used on the ground for the main color.
  12933. * Comes from the BabylonJS CDN by default.
  12934. *
  12935. * Remarks: Can be either a texture or a url.
  12936. */
  12937. groundTexture: string | BaseTexture;
  12938. /**
  12939. * The color mixed in the ground texture by default.
  12940. * BabylonJS clearColor by default.
  12941. */
  12942. groundColor: Color3;
  12943. /**
  12944. * Specifies the ground opacity.
  12945. * 1 by default.
  12946. */
  12947. groundOpacity: number;
  12948. /**
  12949. * Enables the ground to receive shadows.
  12950. * True by default.
  12951. */
  12952. enableGroundShadow: boolean;
  12953. /**
  12954. * Helps preventing the shadow to be fully black on the ground.
  12955. * 0.5 by default.
  12956. */
  12957. groundShadowLevel: number;
  12958. /**
  12959. * Creates a mirror texture attach to the ground.
  12960. * false by default.
  12961. */
  12962. enableGroundMirror: boolean;
  12963. /**
  12964. * Specifies the ground mirror size ratio.
  12965. * 0.3 by default as the default kernel is 64.
  12966. */
  12967. groundMirrorSizeRatio: number;
  12968. /**
  12969. * Specifies the ground mirror blur kernel size.
  12970. * 64 by default.
  12971. */
  12972. groundMirrorBlurKernel: number;
  12973. /**
  12974. * Specifies the ground mirror visibility amount.
  12975. * 1 by default
  12976. */
  12977. groundMirrorAmount: number;
  12978. /**
  12979. * Specifies the ground mirror reflectance weight.
  12980. * This uses the standard weight of the background material to setup the fresnel effect
  12981. * of the mirror.
  12982. * 1 by default.
  12983. */
  12984. groundMirrorFresnelWeight: number;
  12985. /**
  12986. * Specifies the ground mirror Falloff distance.
  12987. * This can helps reducing the size of the reflection.
  12988. * 0 by Default.
  12989. */
  12990. groundMirrorFallOffDistance: number;
  12991. /**
  12992. * Specifies the ground mirror texture type.
  12993. * Unsigned Int by Default.
  12994. */
  12995. groundMirrorTextureType: number;
  12996. /**
  12997. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  12998. * the shown objects.
  12999. */
  13000. groundYBias: number;
  13001. /**
  13002. * Specifies wether or not to create a skybox.
  13003. * True by default.
  13004. */
  13005. createSkybox: boolean;
  13006. /**
  13007. * Specifies the skybox size.
  13008. * 20 by default.
  13009. */
  13010. skyboxSize: number;
  13011. /**
  13012. * The texture used on the skybox for the main color.
  13013. * Comes from the BabylonJS CDN by default.
  13014. *
  13015. * Remarks: Can be either a texture or a url.
  13016. */
  13017. skyboxTexture: string | BaseTexture;
  13018. /**
  13019. * The color mixed in the skybox texture by default.
  13020. * BabylonJS clearColor by default.
  13021. */
  13022. skyboxColor: Color3;
  13023. /**
  13024. * The background rotation around the Y axis of the scene.
  13025. * This helps aligning the key lights of your scene with the background.
  13026. * 0 by default.
  13027. */
  13028. backgroundYRotation: number;
  13029. /**
  13030. * Compute automatically the size of the elements to best fit with the scene.
  13031. */
  13032. sizeAuto: boolean;
  13033. /**
  13034. * Default position of the rootMesh if autoSize is not true.
  13035. */
  13036. rootPosition: Vector3;
  13037. /**
  13038. * Sets up the image processing in the scene.
  13039. * true by default.
  13040. */
  13041. setupImageProcessing: boolean;
  13042. /**
  13043. * The texture used as your environment texture in the scene.
  13044. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13045. *
  13046. * Remarks: Can be either a texture or a url.
  13047. */
  13048. environmentTexture: string | BaseTexture;
  13049. /**
  13050. * The value of the exposure to apply to the scene.
  13051. * 0.6 by default if setupImageProcessing is true.
  13052. */
  13053. cameraExposure: number;
  13054. /**
  13055. * The value of the contrast to apply to the scene.
  13056. * 1.6 by default if setupImageProcessing is true.
  13057. */
  13058. cameraContrast: number;
  13059. /**
  13060. * Specifies wether or not tonemapping should be enabled in the scene.
  13061. * true by default if setupImageProcessing is true.
  13062. */
  13063. toneMappingEnabled: boolean;
  13064. }
  13065. /**
  13066. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13067. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13068. * It also helps with the default setup of your imageProcessing configuration.
  13069. */
  13070. class EnvironmentHelper {
  13071. /**
  13072. * Default ground texture URL.
  13073. */
  13074. private static _groundTextureCDNUrl;
  13075. /**
  13076. * Default skybox texture URL.
  13077. */
  13078. private static _skyboxTextureCDNUrl;
  13079. /**
  13080. * Default environment texture URL.
  13081. */
  13082. private static _environmentTextureCDNUrl;
  13083. /**
  13084. * Creates the default options for the helper.
  13085. */
  13086. private static _getDefaultOptions;
  13087. private _rootMesh;
  13088. /**
  13089. * Gets the root mesh created by the helper.
  13090. */
  13091. readonly rootMesh: Mesh;
  13092. private _skybox;
  13093. /**
  13094. * Gets the skybox created by the helper.
  13095. */
  13096. readonly skybox: Nullable<Mesh>;
  13097. private _skyboxTexture;
  13098. /**
  13099. * Gets the skybox texture created by the helper.
  13100. */
  13101. readonly skyboxTexture: Nullable<BaseTexture>;
  13102. private _skyboxMaterial;
  13103. /**
  13104. * Gets the skybox material created by the helper.
  13105. */
  13106. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13107. private _ground;
  13108. /**
  13109. * Gets the ground mesh created by the helper.
  13110. */
  13111. readonly ground: Nullable<Mesh>;
  13112. private _groundTexture;
  13113. /**
  13114. * Gets the ground texture created by the helper.
  13115. */
  13116. readonly groundTexture: Nullable<BaseTexture>;
  13117. private _groundMirror;
  13118. /**
  13119. * Gets the ground mirror created by the helper.
  13120. */
  13121. readonly groundMirror: Nullable<MirrorTexture>;
  13122. /**
  13123. * Gets the ground mirror render list to helps pushing the meshes
  13124. * you wish in the ground reflection.
  13125. */
  13126. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13127. private _groundMaterial;
  13128. /**
  13129. * Gets the ground material created by the helper.
  13130. */
  13131. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13132. /**
  13133. * Stores the creation options.
  13134. */
  13135. private readonly _scene;
  13136. private _options;
  13137. /**
  13138. * This observable will be notified with any error during the creation of the environment,
  13139. * mainly texture creation errors.
  13140. */
  13141. onErrorObservable: Observable<{
  13142. message?: string;
  13143. exception?: any;
  13144. }>;
  13145. /**
  13146. * constructor
  13147. * @param options
  13148. * @param scene The scene to add the material to
  13149. */
  13150. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13151. /**
  13152. * Updates the background according to the new options
  13153. * @param options
  13154. */
  13155. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13156. /**
  13157. * Sets the primary color of all the available elements.
  13158. * @param color the main color to affect to the ground and the background
  13159. */
  13160. setMainColor(color: Color3): void;
  13161. /**
  13162. * Setup the image processing according to the specified options.
  13163. */
  13164. private _setupImageProcessing;
  13165. /**
  13166. * Setup the environment texture according to the specified options.
  13167. */
  13168. private _setupEnvironmentTexture;
  13169. /**
  13170. * Setup the background according to the specified options.
  13171. */
  13172. private _setupBackground;
  13173. /**
  13174. * Get the scene sizes according to the setup.
  13175. */
  13176. private _getSceneSize;
  13177. /**
  13178. * Setup the ground according to the specified options.
  13179. */
  13180. private _setupGround;
  13181. /**
  13182. * Setup the ground material according to the specified options.
  13183. */
  13184. private _setupGroundMaterial;
  13185. /**
  13186. * Setup the ground diffuse texture according to the specified options.
  13187. */
  13188. private _setupGroundDiffuseTexture;
  13189. /**
  13190. * Setup the ground mirror texture according to the specified options.
  13191. */
  13192. private _setupGroundMirrorTexture;
  13193. /**
  13194. * Setup the ground to receive the mirror texture.
  13195. */
  13196. private _setupMirrorInGroundMaterial;
  13197. /**
  13198. * Setup the skybox according to the specified options.
  13199. */
  13200. private _setupSkybox;
  13201. /**
  13202. * Setup the skybox material according to the specified options.
  13203. */
  13204. private _setupSkyboxMaterial;
  13205. /**
  13206. * Setup the skybox reflection texture according to the specified options.
  13207. */
  13208. private _setupSkyboxReflectionTexture;
  13209. private _errorHandler;
  13210. /**
  13211. * Dispose all the elements created by the Helper.
  13212. */
  13213. dispose(): void;
  13214. }
  13215. }
  13216. declare module BABYLON {
  13217. /**
  13218. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13219. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13220. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13221. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13222. */
  13223. class PhotoDome extends TransformNode {
  13224. private _useDirectMapping;
  13225. /**
  13226. * The texture being displayed on the sphere
  13227. */
  13228. protected _photoTexture: Texture;
  13229. /**
  13230. * Gets or sets the texture being displayed on the sphere
  13231. */
  13232. photoTexture: Texture;
  13233. /**
  13234. * Observable raised when an error occured while loading the 360 image
  13235. */
  13236. onLoadErrorObservable: Observable<string>;
  13237. /**
  13238. * The skybox material
  13239. */
  13240. protected _material: BackgroundMaterial;
  13241. /**
  13242. * The surface used for the skybox
  13243. */
  13244. protected _mesh: Mesh;
  13245. /**
  13246. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13247. * Also see the options.resolution property.
  13248. */
  13249. fovMultiplier: number;
  13250. /**
  13251. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13252. * @param name Element's name, child elements will append suffixes for their own names.
  13253. * @param urlsOfPhoto defines the url of the photo to display
  13254. * @param options defines an object containing optional or exposed sub element properties
  13255. * @param onError defines a callback called when an error occured while loading the texture
  13256. */
  13257. constructor(name: string, urlOfPhoto: string, options: {
  13258. resolution?: number;
  13259. size?: number;
  13260. useDirectMapping?: boolean;
  13261. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13262. /**
  13263. * Releases resources associated with this node.
  13264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13266. */
  13267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. interface Scene {
  13272. /**
  13273. * Creates a default light for the scene.
  13274. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13275. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13276. */
  13277. createDefaultLight(replace?: boolean): void;
  13278. /**
  13279. * Creates a default camera for the scene.
  13280. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13281. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13282. * @param replace has default false, when true replaces the active camera in the scene
  13283. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13284. */
  13285. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13286. /**
  13287. * Creates a default camera and a default light.
  13288. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13289. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13290. * @param replace has the default false, when true replaces the active camera/light in the scene
  13291. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13292. */
  13293. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13294. /**
  13295. * Creates a new sky box
  13296. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13297. * @param environmentTexture defines the texture to use as environment texture
  13298. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13299. * @param scale defines the overall scale of the skybox
  13300. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13301. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13302. * @returns a new mesh holding the sky box
  13303. */
  13304. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13305. /**
  13306. * Creates a new environment
  13307. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13308. * @param options defines the options you can use to configure the environment
  13309. * @returns the new EnvironmentHelper
  13310. */
  13311. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13312. /**
  13313. * Creates a new VREXperienceHelper
  13314. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13315. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13316. * @returns a new VREXperienceHelper
  13317. */
  13318. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13319. }
  13320. }
  13321. declare module BABYLON {
  13322. /**
  13323. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13324. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13325. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13326. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13327. */
  13328. class VideoDome extends TransformNode {
  13329. private _useDirectMapping;
  13330. /**
  13331. * The video texture being displayed on the sphere
  13332. */
  13333. protected _videoTexture: VideoTexture;
  13334. /**
  13335. * Gets the video texture being displayed on the sphere
  13336. */
  13337. readonly videoTexture: VideoTexture;
  13338. /**
  13339. * The skybox material
  13340. */
  13341. protected _material: BackgroundMaterial;
  13342. /**
  13343. * The surface used for the skybox
  13344. */
  13345. protected _mesh: Mesh;
  13346. /**
  13347. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13348. * Also see the options.resolution property.
  13349. */
  13350. fovMultiplier: number;
  13351. /**
  13352. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13353. * @param name Element's name, child elements will append suffixes for their own names.
  13354. * @param urlsOrVideo defines the url(s) or the video element to use
  13355. * @param options An object containing optional or exposed sub element properties
  13356. */
  13357. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13358. resolution?: number;
  13359. clickToPlay?: boolean;
  13360. autoPlay?: boolean;
  13361. loop?: boolean;
  13362. size?: number;
  13363. poster?: string;
  13364. useDirectMapping?: boolean;
  13365. }, scene: Scene);
  13366. /**
  13367. * Releases resources associated with this node.
  13368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13370. */
  13371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13372. }
  13373. }
  13374. declare module BABYLON {
  13375. /**
  13376. * Single axis drag gizmo
  13377. */
  13378. class AxisDragGizmo extends Gizmo {
  13379. /**
  13380. * Drag behavior responsible for the gizmos dragging interactions
  13381. */
  13382. dragBehavior: PointerDragBehavior;
  13383. private _pointerObserver;
  13384. /**
  13385. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13386. */
  13387. snapDistance: number;
  13388. /**
  13389. * Event that fires each time the gizmo snaps to a new location.
  13390. * * snapDistance is the the change in distance
  13391. */
  13392. onSnapObservable: Observable<{
  13393. snapDistance: number;
  13394. }>;
  13395. /**
  13396. * Creates an AxisDragGizmo
  13397. * @param gizmoLayer The utility layer the gizmo will be added to
  13398. * @param dragAxis The axis which the gizmo will be able to drag on
  13399. * @param color The color of the gizmo
  13400. */
  13401. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13402. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13403. /**
  13404. * Disposes of the gizmo
  13405. */
  13406. dispose(): void;
  13407. }
  13408. }
  13409. declare module BABYLON {
  13410. /**
  13411. * Single axis scale gizmo
  13412. */
  13413. class AxisScaleGizmo extends Gizmo {
  13414. private _coloredMaterial;
  13415. /**
  13416. * Drag behavior responsible for the gizmos dragging interactions
  13417. */
  13418. dragBehavior: PointerDragBehavior;
  13419. private _pointerObserver;
  13420. /**
  13421. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13422. */
  13423. snapDistance: number;
  13424. /**
  13425. * Event that fires each time the gizmo snaps to a new location.
  13426. * * snapDistance is the the change in distance
  13427. */
  13428. onSnapObservable: Observable<{
  13429. snapDistance: number;
  13430. }>;
  13431. /**
  13432. * If the scaling operation should be done on all axis (default: false)
  13433. */
  13434. uniformScaling: boolean;
  13435. /**
  13436. * Creates an AxisScaleGizmo
  13437. * @param gizmoLayer The utility layer the gizmo will be added to
  13438. * @param dragAxis The axis which the gizmo will be able to scale on
  13439. * @param color The color of the gizmo
  13440. */
  13441. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13442. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13443. /**
  13444. * Disposes of the gizmo
  13445. */
  13446. dispose(): void;
  13447. /**
  13448. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13449. * @param mesh The mesh to replace the default mesh of the gizmo
  13450. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13451. */
  13452. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13453. }
  13454. }
  13455. declare module BABYLON {
  13456. /**
  13457. * Bounding box gizmo
  13458. */
  13459. class BoundingBoxGizmo extends Gizmo {
  13460. private _lineBoundingBox;
  13461. private _rotateSpheresParent;
  13462. private _scaleBoxesParent;
  13463. private _boundingDimensions;
  13464. private _renderObserver;
  13465. private _pointerObserver;
  13466. private _scaleDragSpeed;
  13467. private _tmpQuaternion;
  13468. private _tmpVector;
  13469. private _tmpRotationMatrix;
  13470. /**
  13471. * 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)
  13472. */
  13473. ignoreChildren: boolean;
  13474. /**
  13475. * 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)
  13476. */
  13477. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13478. /**
  13479. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13480. */
  13481. rotationSphereSize: number;
  13482. /**
  13483. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13484. */
  13485. scaleBoxSize: number;
  13486. /**
  13487. * 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)
  13488. */
  13489. fixedDragMeshScreenSize: boolean;
  13490. /**
  13491. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13492. */
  13493. fixedDragMeshScreenSizeDistanceFactor: number;
  13494. /**
  13495. * Fired when a rotation sphere or scale box is dragged
  13496. */
  13497. onDragStartObservable: Observable<{}>;
  13498. /**
  13499. * Fired when a scale box is dragged
  13500. */
  13501. onScaleBoxDragObservable: Observable<{}>;
  13502. /**
  13503. * Fired when a scale box drag is ended
  13504. */
  13505. onScaleBoxDragEndObservable: Observable<{}>;
  13506. /**
  13507. * Fired when a rotation sphere is dragged
  13508. */
  13509. onRotationSphereDragObservable: Observable<{}>;
  13510. /**
  13511. * Fired when a rotation sphere drag is ended
  13512. */
  13513. onRotationSphereDragEndObservable: Observable<{}>;
  13514. /**
  13515. * 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)
  13516. */
  13517. scalePivot: Nullable<Vector3>;
  13518. private _anchorMesh;
  13519. private _existingMeshScale;
  13520. private static _PivotCached;
  13521. private static _OldPivotPoint;
  13522. private static _PivotTranslation;
  13523. private static _PivotTmpVector;
  13524. /** @hidden */
  13525. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13526. /** @hidden */
  13527. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13528. /**
  13529. * Creates an BoundingBoxGizmo
  13530. * @param gizmoLayer The utility layer the gizmo will be added to
  13531. * @param color The color of the gizmo
  13532. */
  13533. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13534. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13535. private _selectNode;
  13536. /**
  13537. * Updates the bounding box information for the Gizmo
  13538. */
  13539. updateBoundingBox(): void;
  13540. /**
  13541. * Enables rotation on the specified axis and disables rotation on the others
  13542. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13543. */
  13544. setEnabledRotationAxis(axis: string): void;
  13545. /**
  13546. * Disposes of the gizmo
  13547. */
  13548. dispose(): void;
  13549. /**
  13550. * 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)
  13551. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13552. * @returns the bounding box mesh with the passed in mesh as a child
  13553. */
  13554. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13555. /**
  13556. * CustomMeshes are not supported by this gizmo
  13557. * @param mesh The mesh to replace the default mesh of the gizmo
  13558. */
  13559. setCustomMesh(mesh: Mesh): void;
  13560. }
  13561. }
  13562. declare module BABYLON {
  13563. /**
  13564. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13565. */
  13566. class Gizmo implements IDisposable {
  13567. /** The utility layer the gizmo will be added to */
  13568. gizmoLayer: UtilityLayerRenderer;
  13569. /**
  13570. * The root mesh of the gizmo
  13571. */
  13572. protected _rootMesh: Mesh;
  13573. private _attachedMesh;
  13574. /**
  13575. * Ratio for the scale of the gizmo (Default: 1)
  13576. */
  13577. scaleRatio: number;
  13578. private _tmpMatrix;
  13579. /**
  13580. * If a custom mesh has been set (Default: false)
  13581. */
  13582. protected _customMeshSet: boolean;
  13583. /**
  13584. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13585. * * When set, interactions will be enabled
  13586. */
  13587. attachedMesh: Nullable<AbstractMesh>;
  13588. /**
  13589. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13590. * @param mesh The mesh to replace the default mesh of the gizmo
  13591. */
  13592. setCustomMesh(mesh: Mesh): void;
  13593. /**
  13594. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13595. */
  13596. updateGizmoRotationToMatchAttachedMesh: boolean;
  13597. /**
  13598. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13599. */
  13600. updateGizmoPositionToMatchAttachedMesh: boolean;
  13601. /**
  13602. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13603. */
  13604. protected _updateScale: boolean;
  13605. protected _interactionsEnabled: boolean;
  13606. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13607. private _beforeRenderObserver;
  13608. /**
  13609. * Creates a gizmo
  13610. * @param gizmoLayer The utility layer the gizmo will be added to
  13611. */
  13612. constructor(
  13613. /** The utility layer the gizmo will be added to */
  13614. gizmoLayer?: UtilityLayerRenderer);
  13615. private _tempVector;
  13616. /**
  13617. * @hidden
  13618. * Updates the gizmo to match the attached mesh's position/rotation
  13619. */
  13620. protected _update(): void;
  13621. /**
  13622. * Disposes of the gizmo
  13623. */
  13624. dispose(): void;
  13625. }
  13626. }
  13627. declare module BABYLON {
  13628. /**
  13629. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13630. */
  13631. class GizmoManager implements IDisposable {
  13632. private scene;
  13633. /**
  13634. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13635. */
  13636. gizmos: {
  13637. positionGizmo: Nullable<PositionGizmo>;
  13638. rotationGizmo: Nullable<RotationGizmo>;
  13639. scaleGizmo: Nullable<ScaleGizmo>;
  13640. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13641. };
  13642. private _gizmosEnabled;
  13643. private _pointerObserver;
  13644. private _attachedMesh;
  13645. private _boundingBoxColor;
  13646. private _defaultUtilityLayer;
  13647. private _defaultKeepDepthUtilityLayer;
  13648. /**
  13649. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13650. */
  13651. boundingBoxDragBehavior: SixDofDragBehavior;
  13652. /**
  13653. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13654. */
  13655. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13656. /**
  13657. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13658. */
  13659. usePointerToAttachGizmos: boolean;
  13660. /**
  13661. * Instatiates a gizmo manager
  13662. * @param scene the scene to overlay the gizmos on top of
  13663. */
  13664. constructor(scene: Scene);
  13665. /**
  13666. * Attaches a set of gizmos to the specified mesh
  13667. * @param mesh The mesh the gizmo's should be attached to
  13668. */
  13669. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13670. /**
  13671. * If the position gizmo is enabled
  13672. */
  13673. positionGizmoEnabled: boolean;
  13674. /**
  13675. * If the rotation gizmo is enabled
  13676. */
  13677. rotationGizmoEnabled: boolean;
  13678. /**
  13679. * If the scale gizmo is enabled
  13680. */
  13681. scaleGizmoEnabled: boolean;
  13682. /**
  13683. * If the boundingBox gizmo is enabled
  13684. */
  13685. boundingBoxGizmoEnabled: boolean;
  13686. /**
  13687. * Disposes of the gizmo manager
  13688. */
  13689. dispose(): void;
  13690. }
  13691. }
  13692. declare module BABYLON {
  13693. /**
  13694. * Single plane rotation gizmo
  13695. */
  13696. class PlaneRotationGizmo extends Gizmo {
  13697. /**
  13698. * Drag behavior responsible for the gizmos dragging interactions
  13699. */
  13700. dragBehavior: PointerDragBehavior;
  13701. private _pointerObserver;
  13702. /**
  13703. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13704. */
  13705. snapDistance: number;
  13706. /**
  13707. * Event that fires each time the gizmo snaps to a new location.
  13708. * * snapDistance is the the change in distance
  13709. */
  13710. onSnapObservable: Observable<{
  13711. snapDistance: number;
  13712. }>;
  13713. /**
  13714. * Creates a PlaneRotationGizmo
  13715. * @param gizmoLayer The utility layer the gizmo will be added to
  13716. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13717. * @param color The color of the gizmo
  13718. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13719. */
  13720. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13721. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13722. /**
  13723. * Disposes of the gizmo
  13724. */
  13725. dispose(): void;
  13726. }
  13727. }
  13728. declare module BABYLON {
  13729. /**
  13730. * Gizmo that enables dragging a mesh along 3 axis
  13731. */
  13732. class PositionGizmo extends Gizmo {
  13733. /**
  13734. * Internal gizmo used for interactions on the x axis
  13735. */
  13736. xGizmo: AxisDragGizmo;
  13737. /**
  13738. * Internal gizmo used for interactions on the y axis
  13739. */
  13740. yGizmo: AxisDragGizmo;
  13741. /**
  13742. * Internal gizmo used for interactions on the z axis
  13743. */
  13744. zGizmo: AxisDragGizmo;
  13745. /** Fires an event when any of it's sub gizmos are dragged */
  13746. onDragStartObservable: Observable<{}>;
  13747. /** Fires an event when any of it's sub gizmos are released from dragging */
  13748. onDragEndObservable: Observable<{}>;
  13749. attachedMesh: Nullable<AbstractMesh>;
  13750. /**
  13751. * Creates a PositionGizmo
  13752. * @param gizmoLayer The utility layer the gizmo will be added to
  13753. */
  13754. constructor(gizmoLayer?: UtilityLayerRenderer);
  13755. updateGizmoRotationToMatchAttachedMesh: boolean;
  13756. /**
  13757. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13758. */
  13759. snapDistance: number;
  13760. /**
  13761. * Ratio for the scale of the gizmo (Default: 1)
  13762. */
  13763. scaleRatio: number;
  13764. /**
  13765. * Disposes of the gizmo
  13766. */
  13767. dispose(): void;
  13768. /**
  13769. * CustomMeshes are not supported by this gizmo
  13770. * @param mesh The mesh to replace the default mesh of the gizmo
  13771. */
  13772. setCustomMesh(mesh: Mesh): void;
  13773. }
  13774. }
  13775. declare module BABYLON {
  13776. /**
  13777. * Gizmo that enables rotating a mesh along 3 axis
  13778. */
  13779. class RotationGizmo extends Gizmo {
  13780. /**
  13781. * Internal gizmo used for interactions on the x axis
  13782. */
  13783. xGizmo: PlaneRotationGizmo;
  13784. /**
  13785. * Internal gizmo used for interactions on the y axis
  13786. */
  13787. yGizmo: PlaneRotationGizmo;
  13788. /**
  13789. * Internal gizmo used for interactions on the z axis
  13790. */
  13791. zGizmo: PlaneRotationGizmo;
  13792. /** Fires an event when any of it's sub gizmos are dragged */
  13793. onDragStartObservable: Observable<{}>;
  13794. /** Fires an event when any of it's sub gizmos are released from dragging */
  13795. onDragEndObservable: Observable<{}>;
  13796. attachedMesh: Nullable<AbstractMesh>;
  13797. /**
  13798. * Creates a RotationGizmo
  13799. * @param gizmoLayer The utility layer the gizmo will be added to
  13800. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13801. */
  13802. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13803. updateGizmoRotationToMatchAttachedMesh: boolean;
  13804. /**
  13805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13806. */
  13807. snapDistance: number;
  13808. /**
  13809. * Ratio for the scale of the gizmo (Default: 1)
  13810. */
  13811. scaleRatio: number;
  13812. /**
  13813. * Disposes of the gizmo
  13814. */
  13815. dispose(): void;
  13816. /**
  13817. * CustomMeshes are not supported by this gizmo
  13818. * @param mesh The mesh to replace the default mesh of the gizmo
  13819. */
  13820. setCustomMesh(mesh: Mesh): void;
  13821. }
  13822. }
  13823. declare module BABYLON {
  13824. /**
  13825. * Gizmo that enables scaling a mesh along 3 axis
  13826. */
  13827. class ScaleGizmo extends Gizmo {
  13828. /**
  13829. * Internal gizmo used for interactions on the x axis
  13830. */
  13831. xGizmo: AxisScaleGizmo;
  13832. /**
  13833. * Internal gizmo used for interactions on the y axis
  13834. */
  13835. yGizmo: AxisScaleGizmo;
  13836. /**
  13837. * Internal gizmo used for interactions on the z axis
  13838. */
  13839. zGizmo: AxisScaleGizmo;
  13840. /**
  13841. * Internal gizmo used to scale all axis equally
  13842. */
  13843. uniformScaleGizmo: AxisScaleGizmo;
  13844. /** Fires an event when any of it's sub gizmos are dragged */
  13845. onDragStartObservable: Observable<{}>;
  13846. /** Fires an event when any of it's sub gizmos are released from dragging */
  13847. onDragEndObservable: Observable<{}>;
  13848. attachedMesh: Nullable<AbstractMesh>;
  13849. /**
  13850. * Creates a ScaleGizmo
  13851. * @param gizmoLayer The utility layer the gizmo will be added to
  13852. */
  13853. constructor(gizmoLayer?: UtilityLayerRenderer);
  13854. updateGizmoRotationToMatchAttachedMesh: boolean;
  13855. /**
  13856. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13857. */
  13858. snapDistance: number;
  13859. /**
  13860. * Ratio for the scale of the gizmo (Default: 1)
  13861. */
  13862. scaleRatio: number;
  13863. /**
  13864. * Disposes of the gizmo
  13865. */
  13866. dispose(): void;
  13867. }
  13868. }
  13869. declare module BABYLON {
  13870. /**
  13871. * This class can be used to get instrumentation data from a Babylon engine
  13872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13873. */
  13874. class EngineInstrumentation implements IDisposable {
  13875. /**
  13876. * Define the instrumented engine.
  13877. */
  13878. engine: Engine;
  13879. private _captureGPUFrameTime;
  13880. private _gpuFrameTimeToken;
  13881. private _gpuFrameTime;
  13882. private _captureShaderCompilationTime;
  13883. private _shaderCompilationTime;
  13884. private _onBeginFrameObserver;
  13885. private _onEndFrameObserver;
  13886. private _onBeforeShaderCompilationObserver;
  13887. private _onAfterShaderCompilationObserver;
  13888. /**
  13889. * Gets the perf counter used for GPU frame time
  13890. */
  13891. readonly gpuFrameTimeCounter: PerfCounter;
  13892. /**
  13893. * Gets the GPU frame time capture status
  13894. */
  13895. /**
  13896. * Enable or disable the GPU frame time capture
  13897. */
  13898. captureGPUFrameTime: boolean;
  13899. /**
  13900. * Gets the perf counter used for shader compilation time
  13901. */
  13902. readonly shaderCompilationTimeCounter: PerfCounter;
  13903. /**
  13904. * Gets the shader compilation time capture status
  13905. */
  13906. /**
  13907. * Enable or disable the shader compilation time capture
  13908. */
  13909. captureShaderCompilationTime: boolean;
  13910. /**
  13911. * Instantiates a new engine instrumentation.
  13912. * This class can be used to get instrumentation data from a Babylon engine
  13913. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13914. * @param engine Defines the engine to instrument
  13915. */
  13916. constructor(
  13917. /**
  13918. * Define the instrumented engine.
  13919. */
  13920. engine: Engine);
  13921. /**
  13922. * Dispose and release associated resources.
  13923. */
  13924. dispose(): void;
  13925. }
  13926. }
  13927. declare module BABYLON {
  13928. /**
  13929. * This class can be used to get instrumentation data from a Babylon engine
  13930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13931. */
  13932. class SceneInstrumentation implements IDisposable {
  13933. /**
  13934. * Defines the scene to instrument
  13935. */
  13936. scene: Scene;
  13937. private _captureActiveMeshesEvaluationTime;
  13938. private _activeMeshesEvaluationTime;
  13939. private _captureRenderTargetsRenderTime;
  13940. private _renderTargetsRenderTime;
  13941. private _captureFrameTime;
  13942. private _frameTime;
  13943. private _captureRenderTime;
  13944. private _renderTime;
  13945. private _captureInterFrameTime;
  13946. private _interFrameTime;
  13947. private _captureParticlesRenderTime;
  13948. private _particlesRenderTime;
  13949. private _captureSpritesRenderTime;
  13950. private _spritesRenderTime;
  13951. private _capturePhysicsTime;
  13952. private _physicsTime;
  13953. private _captureAnimationsTime;
  13954. private _animationsTime;
  13955. private _captureCameraRenderTime;
  13956. private _cameraRenderTime;
  13957. private _onBeforeActiveMeshesEvaluationObserver;
  13958. private _onAfterActiveMeshesEvaluationObserver;
  13959. private _onBeforeRenderTargetsRenderObserver;
  13960. private _onAfterRenderTargetsRenderObserver;
  13961. private _onAfterRenderObserver;
  13962. private _onBeforeDrawPhaseObserver;
  13963. private _onAfterDrawPhaseObserver;
  13964. private _onBeforeAnimationsObserver;
  13965. private _onBeforeParticlesRenderingObserver;
  13966. private _onAfterParticlesRenderingObserver;
  13967. private _onBeforeSpritesRenderingObserver;
  13968. private _onAfterSpritesRenderingObserver;
  13969. private _onBeforePhysicsObserver;
  13970. private _onAfterPhysicsObserver;
  13971. private _onAfterAnimationsObserver;
  13972. private _onBeforeCameraRenderObserver;
  13973. private _onAfterCameraRenderObserver;
  13974. /**
  13975. * Gets the perf counter used for active meshes evaluation time
  13976. */
  13977. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13978. /**
  13979. * Gets the active meshes evaluation time capture status
  13980. */
  13981. /**
  13982. * Enable or disable the active meshes evaluation time capture
  13983. */
  13984. captureActiveMeshesEvaluationTime: boolean;
  13985. /**
  13986. * Gets the perf counter used for render targets render time
  13987. */
  13988. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13989. /**
  13990. * Gets the render targets render time capture status
  13991. */
  13992. /**
  13993. * Enable or disable the render targets render time capture
  13994. */
  13995. captureRenderTargetsRenderTime: boolean;
  13996. /**
  13997. * Gets the perf counter used for particles render time
  13998. */
  13999. readonly particlesRenderTimeCounter: PerfCounter;
  14000. /**
  14001. * Gets the particles render time capture status
  14002. */
  14003. /**
  14004. * Enable or disable the particles render time capture
  14005. */
  14006. captureParticlesRenderTime: boolean;
  14007. /**
  14008. * Gets the perf counter used for sprites render time
  14009. */
  14010. readonly spritesRenderTimeCounter: PerfCounter;
  14011. /**
  14012. * Gets the sprites render time capture status
  14013. */
  14014. /**
  14015. * Enable or disable the sprites render time capture
  14016. */
  14017. captureSpritesRenderTime: boolean;
  14018. /**
  14019. * Gets the perf counter used for physics time
  14020. */
  14021. readonly physicsTimeCounter: PerfCounter;
  14022. /**
  14023. * Gets the physics time capture status
  14024. */
  14025. /**
  14026. * Enable or disable the physics time capture
  14027. */
  14028. capturePhysicsTime: boolean;
  14029. /**
  14030. * Gets the perf counter used for animations time
  14031. */
  14032. readonly animationsTimeCounter: PerfCounter;
  14033. /**
  14034. * Gets the animations time capture status
  14035. */
  14036. /**
  14037. * Enable or disable the animations time capture
  14038. */
  14039. captureAnimationsTime: boolean;
  14040. /**
  14041. * Gets the perf counter used for frame time capture
  14042. */
  14043. readonly frameTimeCounter: PerfCounter;
  14044. /**
  14045. * Gets the frame time capture status
  14046. */
  14047. /**
  14048. * Enable or disable the frame time capture
  14049. */
  14050. captureFrameTime: boolean;
  14051. /**
  14052. * Gets the perf counter used for inter-frames time capture
  14053. */
  14054. readonly interFrameTimeCounter: PerfCounter;
  14055. /**
  14056. * Gets the inter-frames time capture status
  14057. */
  14058. /**
  14059. * Enable or disable the inter-frames time capture
  14060. */
  14061. captureInterFrameTime: boolean;
  14062. /**
  14063. * Gets the perf counter used for render time capture
  14064. */
  14065. readonly renderTimeCounter: PerfCounter;
  14066. /**
  14067. * Gets the render time capture status
  14068. */
  14069. /**
  14070. * Enable or disable the render time capture
  14071. */
  14072. captureRenderTime: boolean;
  14073. /**
  14074. * Gets the perf counter used for camera render time capture
  14075. */
  14076. readonly cameraRenderTimeCounter: PerfCounter;
  14077. /**
  14078. * Gets the camera render time capture status
  14079. */
  14080. /**
  14081. * Enable or disable the camera render time capture
  14082. */
  14083. captureCameraRenderTime: boolean;
  14084. /**
  14085. * Gets the perf counter used for draw calls
  14086. */
  14087. readonly drawCallsCounter: PerfCounter;
  14088. /**
  14089. * Gets the perf counter used for texture collisions
  14090. */
  14091. readonly textureCollisionsCounter: PerfCounter;
  14092. /**
  14093. * Instantiates a new scene instrumentation.
  14094. * This class can be used to get instrumentation data from a Babylon engine
  14095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14096. * @param scene Defines the scene to instrument
  14097. */
  14098. constructor(
  14099. /**
  14100. * Defines the scene to instrument
  14101. */
  14102. scene: Scene);
  14103. /**
  14104. * Dispose and release associated resources.
  14105. */
  14106. dispose(): void;
  14107. }
  14108. }
  14109. declare module BABYLON {
  14110. /**
  14111. * @hidden
  14112. **/
  14113. class _TimeToken {
  14114. _startTimeQuery: Nullable<WebGLQuery>;
  14115. _endTimeQuery: Nullable<WebGLQuery>;
  14116. _timeElapsedQuery: Nullable<WebGLQuery>;
  14117. _timeElapsedQueryEnded: boolean;
  14118. }
  14119. }
  14120. declare module BABYLON {
  14121. /**
  14122. * Effect layer options. This helps customizing the behaviour
  14123. * of the effect layer.
  14124. */
  14125. interface IEffectLayerOptions {
  14126. /**
  14127. * Multiplication factor apply to the canvas size to compute the render target size
  14128. * used to generated the objects (the smaller the faster).
  14129. */
  14130. mainTextureRatio: number;
  14131. /**
  14132. * Enforces a fixed size texture to ensure effect stability across devices.
  14133. */
  14134. mainTextureFixedSize?: number;
  14135. /**
  14136. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14137. */
  14138. alphaBlendingMode: number;
  14139. /**
  14140. * The camera attached to the layer.
  14141. */
  14142. camera: Nullable<Camera>;
  14143. /**
  14144. * The rendering group to draw the layer in.
  14145. */
  14146. renderingGroupId: number;
  14147. }
  14148. /**
  14149. * The effect layer Helps adding post process effect blended with the main pass.
  14150. *
  14151. * This can be for instance use to generate glow or higlight effects on the scene.
  14152. *
  14153. * The effect layer class can not be used directly and is intented to inherited from to be
  14154. * customized per effects.
  14155. */
  14156. abstract class EffectLayer {
  14157. private _vertexBuffers;
  14158. private _indexBuffer;
  14159. private _cachedDefines;
  14160. private _effectLayerMapGenerationEffect;
  14161. private _effectLayerOptions;
  14162. private _mergeEffect;
  14163. protected _scene: Scene;
  14164. protected _engine: Engine;
  14165. protected _maxSize: number;
  14166. protected _mainTextureDesiredSize: ISize;
  14167. protected _mainTexture: RenderTargetTexture;
  14168. protected _shouldRender: boolean;
  14169. protected _postProcesses: PostProcess[];
  14170. protected _textures: BaseTexture[];
  14171. protected _emissiveTextureAndColor: {
  14172. texture: Nullable<BaseTexture>;
  14173. color: Color4;
  14174. };
  14175. /**
  14176. * The name of the layer
  14177. */
  14178. name: string;
  14179. /**
  14180. * The clear color of the texture used to generate the glow map.
  14181. */
  14182. neutralColor: Color4;
  14183. /**
  14184. * Specifies wether the highlight layer is enabled or not.
  14185. */
  14186. isEnabled: boolean;
  14187. /**
  14188. * Gets the camera attached to the layer.
  14189. */
  14190. readonly camera: Nullable<Camera>;
  14191. /**
  14192. * Gets the rendering group id the layer should render in.
  14193. */
  14194. readonly renderingGroupId: number;
  14195. /**
  14196. * An event triggered when the effect layer has been disposed.
  14197. */
  14198. onDisposeObservable: Observable<EffectLayer>;
  14199. /**
  14200. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14201. */
  14202. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14203. /**
  14204. * An event triggered when the generated texture is being merged in the scene.
  14205. */
  14206. onBeforeComposeObservable: Observable<EffectLayer>;
  14207. /**
  14208. * An event triggered when the generated texture has been merged in the scene.
  14209. */
  14210. onAfterComposeObservable: Observable<EffectLayer>;
  14211. /**
  14212. * An event triggered when the efffect layer changes its size.
  14213. */
  14214. onSizeChangedObservable: Observable<EffectLayer>;
  14215. /**
  14216. * Instantiates a new effect Layer and references it in the scene.
  14217. * @param name The name of the layer
  14218. * @param scene The scene to use the layer in
  14219. */
  14220. constructor(
  14221. /** The Friendly of the effect in the scene */
  14222. name: string, scene: Scene);
  14223. /**
  14224. * Get the effect name of the layer.
  14225. * @return The effect name
  14226. */
  14227. abstract getEffectName(): string;
  14228. /**
  14229. * Checks for the readiness of the element composing the layer.
  14230. * @param subMesh the mesh to check for
  14231. * @param useInstances specify wether or not to use instances to render the mesh
  14232. * @return true if ready otherwise, false
  14233. */
  14234. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14235. /**
  14236. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14237. * @returns true if the effect requires stencil during the main canvas render pass.
  14238. */
  14239. abstract needStencil(): boolean;
  14240. /**
  14241. * Create the merge effect. This is the shader use to blit the information back
  14242. * to the main canvas at the end of the scene rendering.
  14243. * @returns The effect containing the shader used to merge the effect on the main canvas
  14244. */
  14245. protected abstract _createMergeEffect(): Effect;
  14246. /**
  14247. * Creates the render target textures and post processes used in the effect layer.
  14248. */
  14249. protected abstract _createTextureAndPostProcesses(): void;
  14250. /**
  14251. * Implementation specific of rendering the generating effect on the main canvas.
  14252. * @param effect The effect used to render through
  14253. */
  14254. protected abstract _internalRender(effect: Effect): void;
  14255. /**
  14256. * Sets the required values for both the emissive texture and and the main color.
  14257. */
  14258. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14259. /**
  14260. * Free any resources and references associated to a mesh.
  14261. * Internal use
  14262. * @param mesh The mesh to free.
  14263. */
  14264. abstract _disposeMesh(mesh: Mesh): void;
  14265. /**
  14266. * Serializes this layer (Glow or Highlight for example)
  14267. * @returns a serialized layer object
  14268. */
  14269. abstract serialize?(): any;
  14270. /**
  14271. * Initializes the effect layer with the required options.
  14272. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14273. */
  14274. protected _init(options: Partial<IEffectLayerOptions>): void;
  14275. /**
  14276. * Generates the index buffer of the full screen quad blending to the main canvas.
  14277. */
  14278. private _generateIndexBuffer;
  14279. /**
  14280. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14281. */
  14282. private _genrateVertexBuffer;
  14283. /**
  14284. * Sets the main texture desired size which is the closest power of two
  14285. * of the engine canvas size.
  14286. */
  14287. private _setMainTextureSize;
  14288. /**
  14289. * Creates the main texture for the effect layer.
  14290. */
  14291. protected _createMainTexture(): void;
  14292. /**
  14293. * Checks for the readiness of the element composing the layer.
  14294. * @param subMesh the mesh to check for
  14295. * @param useInstances specify wether or not to use instances to render the mesh
  14296. * @param emissiveTexture the associated emissive texture used to generate the glow
  14297. * @return true if ready otherwise, false
  14298. */
  14299. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14300. /**
  14301. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14302. */
  14303. render(): void;
  14304. /**
  14305. * Determine if a given mesh will be used in the current effect.
  14306. * @param mesh mesh to test
  14307. * @returns true if the mesh will be used
  14308. */
  14309. hasMesh(mesh: AbstractMesh): boolean;
  14310. /**
  14311. * Returns true if the layer contains information to display, otherwise false.
  14312. * @returns true if the glow layer should be rendered
  14313. */
  14314. shouldRender(): boolean;
  14315. /**
  14316. * Returns true if the mesh should render, otherwise false.
  14317. * @param mesh The mesh to render
  14318. * @returns true if it should render otherwise false
  14319. */
  14320. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14321. /**
  14322. * Returns true if the mesh should render, otherwise false.
  14323. * @param mesh The mesh to render
  14324. * @returns true if it should render otherwise false
  14325. */
  14326. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14327. /**
  14328. * Renders the submesh passed in parameter to the generation map.
  14329. */
  14330. protected _renderSubMesh(subMesh: SubMesh): void;
  14331. /**
  14332. * Rebuild the required buffers.
  14333. * @hidden Internal use only.
  14334. */
  14335. _rebuild(): void;
  14336. /**
  14337. * Dispose only the render target textures and post process.
  14338. */
  14339. private _disposeTextureAndPostProcesses;
  14340. /**
  14341. * Dispose the highlight layer and free resources.
  14342. */
  14343. dispose(): void;
  14344. /**
  14345. * Gets the class name of the effect layer
  14346. * @returns the string with the class name of the effect layer
  14347. */
  14348. getClassName(): string;
  14349. /**
  14350. * Creates an effect layer from parsed effect layer data
  14351. * @param parsedEffectLayer defines effect layer data
  14352. * @param scene defines the current scene
  14353. * @param rootUrl defines the root URL containing the effect layer information
  14354. * @returns a parsed effect Layer
  14355. */
  14356. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14357. }
  14358. }
  14359. declare module BABYLON {
  14360. interface AbstractScene {
  14361. /**
  14362. * The list of effect layers (highlights/glow) added to the scene
  14363. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14364. * @see http://doc.babylonjs.com/how_to/glow_layer
  14365. */
  14366. effectLayers: Array<EffectLayer>;
  14367. /**
  14368. * Removes the given effect layer from this scene.
  14369. * @param toRemove defines the effect layer to remove
  14370. * @returns the index of the removed effect layer
  14371. */
  14372. removeEffectLayer(toRemove: EffectLayer): number;
  14373. /**
  14374. * Adds the given effect layer to this scene
  14375. * @param newEffectLayer defines the effect layer to add
  14376. */
  14377. addEffectLayer(newEffectLayer: EffectLayer): void;
  14378. }
  14379. /**
  14380. * Defines the layer scene component responsible to manage any effect layers
  14381. * in a given scene.
  14382. */
  14383. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14384. /**
  14385. * The component name helpfull to identify the component in the list of scene components.
  14386. */
  14387. readonly name: string;
  14388. /**
  14389. * The scene the component belongs to.
  14390. */
  14391. scene: Scene;
  14392. private _engine;
  14393. private _renderEffects;
  14394. private _needStencil;
  14395. private _previousStencilState;
  14396. /**
  14397. * Creates a new instance of the component for the given scene
  14398. * @param scene Defines the scene to register the component in
  14399. */
  14400. constructor(scene: Scene);
  14401. /**
  14402. * Registers the component in a given scene
  14403. */
  14404. register(): void;
  14405. /**
  14406. * Rebuilds the elements related to this component in case of
  14407. * context lost for instance.
  14408. */
  14409. rebuild(): void;
  14410. /**
  14411. * Serializes the component data to the specified json object
  14412. * @param serializationObject The object to serialize to
  14413. */
  14414. serialize(serializationObject: any): void;
  14415. /**
  14416. * Adds all the element from the container to the scene
  14417. * @param container the container holding the elements
  14418. */
  14419. addFromContainer(container: AbstractScene): void;
  14420. /**
  14421. * Removes all the elements in the container from the scene
  14422. * @param container contains the elements to remove
  14423. */
  14424. removeFromContainer(container: AbstractScene): void;
  14425. /**
  14426. * Disposes the component and the associated ressources.
  14427. */
  14428. dispose(): void;
  14429. private _isReadyForMesh;
  14430. private _renderMainTexture;
  14431. private _setStencil;
  14432. private _setStencilBack;
  14433. private _draw;
  14434. private _drawCamera;
  14435. private _drawRenderingGroup;
  14436. }
  14437. }
  14438. declare module BABYLON {
  14439. interface AbstractScene {
  14440. /**
  14441. * Return a the first highlight layer of the scene with a given name.
  14442. * @param name The name of the highlight layer to look for.
  14443. * @return The highlight layer if found otherwise null.
  14444. */
  14445. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14446. }
  14447. /**
  14448. * Glow layer options. This helps customizing the behaviour
  14449. * of the glow layer.
  14450. */
  14451. interface IGlowLayerOptions {
  14452. /**
  14453. * Multiplication factor apply to the canvas size to compute the render target size
  14454. * used to generated the glowing objects (the smaller the faster).
  14455. */
  14456. mainTextureRatio: number;
  14457. /**
  14458. * Enforces a fixed size texture to ensure resize independant blur.
  14459. */
  14460. mainTextureFixedSize?: number;
  14461. /**
  14462. * How big is the kernel of the blur texture.
  14463. */
  14464. blurKernelSize: number;
  14465. /**
  14466. * The camera attached to the layer.
  14467. */
  14468. camera: Nullable<Camera>;
  14469. /**
  14470. * Enable MSAA by chosing the number of samples.
  14471. */
  14472. mainTextureSamples?: number;
  14473. /**
  14474. * The rendering group to draw the layer in.
  14475. */
  14476. renderingGroupId: number;
  14477. }
  14478. /**
  14479. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14480. *
  14481. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14482. * glowy meshes to your scene.
  14483. *
  14484. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14485. */
  14486. class GlowLayer extends EffectLayer {
  14487. /**
  14488. * Effect Name of the layer.
  14489. */
  14490. static readonly EffectName: string;
  14491. /**
  14492. * The default blur kernel size used for the glow.
  14493. */
  14494. static DefaultBlurKernelSize: number;
  14495. /**
  14496. * The default texture size ratio used for the glow.
  14497. */
  14498. static DefaultTextureRatio: number;
  14499. /**
  14500. * Sets the kernel size of the blur.
  14501. */
  14502. /**
  14503. * Gets the kernel size of the blur.
  14504. */
  14505. blurKernelSize: number;
  14506. /**
  14507. * Sets the glow intensity.
  14508. */
  14509. /**
  14510. * Gets the glow intensity.
  14511. */
  14512. intensity: number;
  14513. private _options;
  14514. private _intensity;
  14515. private _horizontalBlurPostprocess1;
  14516. private _verticalBlurPostprocess1;
  14517. private _horizontalBlurPostprocess2;
  14518. private _verticalBlurPostprocess2;
  14519. private _blurTexture1;
  14520. private _blurTexture2;
  14521. private _postProcesses1;
  14522. private _postProcesses2;
  14523. private _includedOnlyMeshes;
  14524. private _excludedMeshes;
  14525. /**
  14526. * Callback used to let the user override the color selection on a per mesh basis
  14527. */
  14528. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14529. /**
  14530. * Callback used to let the user override the texture selection on a per mesh basis
  14531. */
  14532. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14533. /**
  14534. * Instantiates a new glow Layer and references it to the scene.
  14535. * @param name The name of the layer
  14536. * @param scene The scene to use the layer in
  14537. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14538. */
  14539. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14540. /**
  14541. * Get the effect name of the layer.
  14542. * @return The effect name
  14543. */
  14544. getEffectName(): string;
  14545. /**
  14546. * Create the merge effect. This is the shader use to blit the information back
  14547. * to the main canvas at the end of the scene rendering.
  14548. */
  14549. protected _createMergeEffect(): Effect;
  14550. /**
  14551. * Creates the render target textures and post processes used in the glow layer.
  14552. */
  14553. protected _createTextureAndPostProcesses(): void;
  14554. /**
  14555. * Checks for the readiness of the element composing the layer.
  14556. * @param subMesh the mesh to check for
  14557. * @param useInstances specify wether or not to use instances to render the mesh
  14558. * @param emissiveTexture the associated emissive texture used to generate the glow
  14559. * @return true if ready otherwise, false
  14560. */
  14561. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14562. /**
  14563. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14564. */
  14565. needStencil(): boolean;
  14566. /**
  14567. * Implementation specific of rendering the generating effect on the main canvas.
  14568. * @param effect The effect used to render through
  14569. */
  14570. protected _internalRender(effect: Effect): void;
  14571. /**
  14572. * Sets the required values for both the emissive texture and and the main color.
  14573. */
  14574. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14575. /**
  14576. * Returns true if the mesh should render, otherwise false.
  14577. * @param mesh The mesh to render
  14578. * @returns true if it should render otherwise false
  14579. */
  14580. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14581. /**
  14582. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14583. * @param mesh The mesh to exclude from the glow layer
  14584. */
  14585. addExcludedMesh(mesh: Mesh): void;
  14586. /**
  14587. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14588. * @param mesh The mesh to remove
  14589. */
  14590. removeExcludedMesh(mesh: Mesh): void;
  14591. /**
  14592. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14593. * @param mesh The mesh to include in the glow layer
  14594. */
  14595. addIncludedOnlyMesh(mesh: Mesh): void;
  14596. /**
  14597. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14598. * @param mesh The mesh to remove
  14599. */
  14600. removeIncludedOnlyMesh(mesh: Mesh): void;
  14601. /**
  14602. * Determine if a given mesh will be used in the glow layer
  14603. * @param mesh The mesh to test
  14604. * @returns true if the mesh will be highlighted by the current glow layer
  14605. */
  14606. hasMesh(mesh: AbstractMesh): boolean;
  14607. /**
  14608. * Free any resources and references associated to a mesh.
  14609. * Internal use
  14610. * @param mesh The mesh to free.
  14611. * @hidden
  14612. */
  14613. _disposeMesh(mesh: Mesh): void;
  14614. /**
  14615. * Gets the class name of the effect layer
  14616. * @returns the string with the class name of the effect layer
  14617. */
  14618. getClassName(): string;
  14619. /**
  14620. * Serializes this glow layer
  14621. * @returns a serialized glow layer object
  14622. */
  14623. serialize(): any;
  14624. /**
  14625. * Creates a Glow Layer from parsed glow layer data
  14626. * @param parsedGlowLayer defines glow layer data
  14627. * @param scene defines the current scene
  14628. * @param rootUrl defines the root URL containing the glow layer information
  14629. * @returns a parsed Glow Layer
  14630. */
  14631. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14632. }
  14633. }
  14634. declare module BABYLON {
  14635. interface AbstractScene {
  14636. /**
  14637. * Return a the first highlight layer of the scene with a given name.
  14638. * @param name The name of the highlight layer to look for.
  14639. * @return The highlight layer if found otherwise null.
  14640. */
  14641. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14642. }
  14643. /**
  14644. * Highlight layer options. This helps customizing the behaviour
  14645. * of the highlight layer.
  14646. */
  14647. interface IHighlightLayerOptions {
  14648. /**
  14649. * Multiplication factor apply to the canvas size to compute the render target size
  14650. * used to generated the glowing objects (the smaller the faster).
  14651. */
  14652. mainTextureRatio: number;
  14653. /**
  14654. * Enforces a fixed size texture to ensure resize independant blur.
  14655. */
  14656. mainTextureFixedSize?: number;
  14657. /**
  14658. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14659. * of the picture to blur (the smaller the faster).
  14660. */
  14661. blurTextureSizeRatio: number;
  14662. /**
  14663. * How big in texel of the blur texture is the vertical blur.
  14664. */
  14665. blurVerticalSize: number;
  14666. /**
  14667. * How big in texel of the blur texture is the horizontal blur.
  14668. */
  14669. blurHorizontalSize: number;
  14670. /**
  14671. * Alpha blending mode used to apply the blur. Default is combine.
  14672. */
  14673. alphaBlendingMode: number;
  14674. /**
  14675. * The camera attached to the layer.
  14676. */
  14677. camera: Nullable<Camera>;
  14678. /**
  14679. * Should we display highlight as a solid stroke?
  14680. */
  14681. isStroke?: boolean;
  14682. /**
  14683. * The rendering group to draw the layer in.
  14684. */
  14685. renderingGroupId: number;
  14686. }
  14687. /**
  14688. * The highlight layer Helps adding a glow effect around a mesh.
  14689. *
  14690. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14691. * glowy meshes to your scene.
  14692. *
  14693. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14694. */
  14695. class HighlightLayer extends EffectLayer {
  14696. name: string;
  14697. /**
  14698. * Effect Name of the highlight layer.
  14699. */
  14700. static readonly EffectName: string;
  14701. /**
  14702. * The neutral color used during the preparation of the glow effect.
  14703. * This is black by default as the blend operation is a blend operation.
  14704. */
  14705. static NeutralColor: Color4;
  14706. /**
  14707. * Stencil value used for glowing meshes.
  14708. */
  14709. static GlowingMeshStencilReference: number;
  14710. /**
  14711. * Stencil value used for the other meshes in the scene.
  14712. */
  14713. static NormalMeshStencilReference: number;
  14714. /**
  14715. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14716. */
  14717. innerGlow: boolean;
  14718. /**
  14719. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14720. */
  14721. outerGlow: boolean;
  14722. /**
  14723. * Specifies the horizontal size of the blur.
  14724. */
  14725. /**
  14726. * Gets the horizontal size of the blur.
  14727. */
  14728. blurHorizontalSize: number;
  14729. /**
  14730. * Specifies the vertical size of the blur.
  14731. */
  14732. /**
  14733. * Gets the vertical size of the blur.
  14734. */
  14735. blurVerticalSize: number;
  14736. /**
  14737. * An event triggered when the highlight layer is being blurred.
  14738. */
  14739. onBeforeBlurObservable: Observable<HighlightLayer>;
  14740. /**
  14741. * An event triggered when the highlight layer has been blurred.
  14742. */
  14743. onAfterBlurObservable: Observable<HighlightLayer>;
  14744. private _instanceGlowingMeshStencilReference;
  14745. private _options;
  14746. private _downSamplePostprocess;
  14747. private _horizontalBlurPostprocess;
  14748. private _verticalBlurPostprocess;
  14749. private _blurTexture;
  14750. private _meshes;
  14751. private _excludedMeshes;
  14752. /**
  14753. * Instantiates a new highlight Layer and references it to the scene..
  14754. * @param name The name of the layer
  14755. * @param scene The scene to use the layer in
  14756. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14757. */
  14758. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14759. /**
  14760. * Get the effect name of the layer.
  14761. * @return The effect name
  14762. */
  14763. getEffectName(): string;
  14764. /**
  14765. * Create the merge effect. This is the shader use to blit the information back
  14766. * to the main canvas at the end of the scene rendering.
  14767. */
  14768. protected _createMergeEffect(): Effect;
  14769. /**
  14770. * Creates the render target textures and post processes used in the highlight layer.
  14771. */
  14772. protected _createTextureAndPostProcesses(): void;
  14773. /**
  14774. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14775. */
  14776. needStencil(): boolean;
  14777. /**
  14778. * Checks for the readiness of the element composing the layer.
  14779. * @param subMesh the mesh to check for
  14780. * @param useInstances specify wether or not to use instances to render the mesh
  14781. * @param emissiveTexture the associated emissive texture used to generate the glow
  14782. * @return true if ready otherwise, false
  14783. */
  14784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14785. /**
  14786. * Implementation specific of rendering the generating effect on the main canvas.
  14787. * @param effect The effect used to render through
  14788. */
  14789. protected _internalRender(effect: Effect): void;
  14790. /**
  14791. * Returns true if the layer contains information to display, otherwise false.
  14792. */
  14793. shouldRender(): boolean;
  14794. /**
  14795. * Returns true if the mesh should render, otherwise false.
  14796. * @param mesh The mesh to render
  14797. * @returns true if it should render otherwise false
  14798. */
  14799. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14800. /**
  14801. * Sets the required values for both the emissive texture and and the main color.
  14802. */
  14803. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14804. /**
  14805. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14806. * @param mesh The mesh to exclude from the highlight layer
  14807. */
  14808. addExcludedMesh(mesh: Mesh): void;
  14809. /**
  14810. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14811. * @param mesh The mesh to highlight
  14812. */
  14813. removeExcludedMesh(mesh: Mesh): void;
  14814. /**
  14815. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14816. * @param mesh mesh to test
  14817. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14818. */
  14819. hasMesh(mesh: AbstractMesh): boolean;
  14820. /**
  14821. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14822. * @param mesh The mesh to highlight
  14823. * @param color The color of the highlight
  14824. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14825. */
  14826. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14827. /**
  14828. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14829. * @param mesh The mesh to highlight
  14830. */
  14831. removeMesh(mesh: Mesh): void;
  14832. /**
  14833. * Force the stencil to the normal expected value for none glowing parts
  14834. */
  14835. private _defaultStencilReference;
  14836. /**
  14837. * Free any resources and references associated to a mesh.
  14838. * Internal use
  14839. * @param mesh The mesh to free.
  14840. * @hidden
  14841. */
  14842. _disposeMesh(mesh: Mesh): void;
  14843. /**
  14844. * Dispose the highlight layer and free resources.
  14845. */
  14846. dispose(): void;
  14847. /**
  14848. * Gets the class name of the effect layer
  14849. * @returns the string with the class name of the effect layer
  14850. */
  14851. getClassName(): string;
  14852. /**
  14853. * Serializes this Highlight layer
  14854. * @returns a serialized Highlight layer object
  14855. */
  14856. serialize(): any;
  14857. /**
  14858. * Creates a Highlight layer from parsed Highlight layer data
  14859. * @param parsedHightlightLayer defines the Highlight layer data
  14860. * @param scene defines the current scene
  14861. * @param rootUrl defines the root URL containing the Highlight layer information
  14862. * @returns a parsed Highlight layer
  14863. */
  14864. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14865. }
  14866. }
  14867. declare module BABYLON {
  14868. /**
  14869. * This represents a full screen 2d layer.
  14870. * This can be usefull to display a picture in the background of your scene for instance.
  14871. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14872. */
  14873. class Layer {
  14874. /**
  14875. * Define the name of the layer.
  14876. */
  14877. name: string;
  14878. /**
  14879. * Define the texture the layer should display.
  14880. */
  14881. texture: Nullable<Texture>;
  14882. /**
  14883. * Is the layer in background or foreground.
  14884. */
  14885. isBackground: boolean;
  14886. /**
  14887. * Define the color of the layer (instead of texture).
  14888. */
  14889. color: Color4;
  14890. /**
  14891. * Define the scale of the layer in order to zoom in out of the texture.
  14892. */
  14893. scale: Vector2;
  14894. /**
  14895. * Define an offset for the layer in order to shift the texture.
  14896. */
  14897. offset: Vector2;
  14898. /**
  14899. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14900. */
  14901. alphaBlendingMode: number;
  14902. /**
  14903. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14904. * Alpha test will not mix with the background color in case of transparency.
  14905. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14906. */
  14907. alphaTest: boolean;
  14908. /**
  14909. * Define a mask to restrict the layer to only some of the scene cameras.
  14910. */
  14911. layerMask: number;
  14912. private _scene;
  14913. private _vertexBuffers;
  14914. private _indexBuffer;
  14915. private _effect;
  14916. private _alphaTestEffect;
  14917. /**
  14918. * An event triggered when the layer is disposed.
  14919. */
  14920. onDisposeObservable: Observable<Layer>;
  14921. private _onDisposeObserver;
  14922. /**
  14923. * Back compatibility with callback before the onDisposeObservable existed.
  14924. * The set callback will be triggered when the layer has been disposed.
  14925. */
  14926. onDispose: () => void;
  14927. /**
  14928. * An event triggered before rendering the scene
  14929. */
  14930. onBeforeRenderObservable: Observable<Layer>;
  14931. private _onBeforeRenderObserver;
  14932. /**
  14933. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14934. * The set callback will be triggered just before rendering the layer.
  14935. */
  14936. onBeforeRender: () => void;
  14937. /**
  14938. * An event triggered after rendering the scene
  14939. */
  14940. onAfterRenderObservable: Observable<Layer>;
  14941. private _onAfterRenderObserver;
  14942. /**
  14943. * Back compatibility with callback before the onAfterRenderObservable existed.
  14944. * The set callback will be triggered just after rendering the layer.
  14945. */
  14946. onAfterRender: () => void;
  14947. /**
  14948. * Instantiates a new layer.
  14949. * This represents a full screen 2d layer.
  14950. * This can be usefull to display a picture in the background of your scene for instance.
  14951. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14952. * @param name Define the name of the layer in the scene
  14953. * @param imgUrl Define the url of the texture to display in the layer
  14954. * @param scene Define the scene the layer belongs to
  14955. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14956. * @param color Defines a color for the layer
  14957. */
  14958. constructor(
  14959. /**
  14960. * Define the name of the layer.
  14961. */
  14962. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14963. private _createIndexBuffer;
  14964. /** @hidden */
  14965. _rebuild(): void;
  14966. /**
  14967. * Renders the layer in the scene.
  14968. */
  14969. render(): void;
  14970. /**
  14971. * Disposes and releases the associated ressources.
  14972. */
  14973. dispose(): void;
  14974. }
  14975. }
  14976. declare module BABYLON {
  14977. interface AbstractScene {
  14978. /**
  14979. * The list of layers (background and foreground) of the scene
  14980. */
  14981. layers: Array<Layer>;
  14982. }
  14983. /**
  14984. * Defines the layer scene component responsible to manage any layers
  14985. * in a given scene.
  14986. */
  14987. class LayerSceneComponent implements ISceneComponent {
  14988. /**
  14989. * The component name helpfull to identify the component in the list of scene components.
  14990. */
  14991. readonly name: string;
  14992. /**
  14993. * The scene the component belongs to.
  14994. */
  14995. scene: Scene;
  14996. private _engine;
  14997. /**
  14998. * Creates a new instance of the component for the given scene
  14999. * @param scene Defines the scene to register the component in
  15000. */
  15001. constructor(scene: Scene);
  15002. /**
  15003. * Registers the component in a given scene
  15004. */
  15005. register(): void;
  15006. /**
  15007. * Rebuilds the elements related to this component in case of
  15008. * context lost for instance.
  15009. */
  15010. rebuild(): void;
  15011. /**
  15012. * Disposes the component and the associated ressources.
  15013. */
  15014. dispose(): void;
  15015. private _draw;
  15016. private _drawBackground;
  15017. private _drawForeground;
  15018. }
  15019. }
  15020. declare module BABYLON {
  15021. /**
  15022. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15023. * It controls one of the indiviual texture used in the effect.
  15024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15025. */
  15026. class LensFlare {
  15027. /**
  15028. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15029. */
  15030. size: number;
  15031. /**
  15032. * 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.
  15033. */
  15034. position: number;
  15035. /**
  15036. * Define the lens color.
  15037. */
  15038. color: Color3;
  15039. /**
  15040. * Define the lens texture.
  15041. */
  15042. texture: Nullable<Texture>;
  15043. /**
  15044. * Define the alpha mode to render this particular lens.
  15045. */
  15046. alphaMode: number;
  15047. private _system;
  15048. /**
  15049. * Creates a new Lens Flare.
  15050. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15051. * It controls one of the indiviual texture used in the effect.
  15052. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15053. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15054. * @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.
  15055. * @param color Define the lens color
  15056. * @param imgUrl Define the lens texture url
  15057. * @param system Define the `lensFlareSystem` this flare is part of
  15058. * @returns The newly created Lens Flare
  15059. */
  15060. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15061. /**
  15062. * Instantiates a new Lens Flare.
  15063. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15064. * It controls one of the indiviual texture used in the effect.
  15065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15066. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15067. * @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.
  15068. * @param color Define the lens color
  15069. * @param imgUrl Define the lens texture url
  15070. * @param system Define the `lensFlareSystem` this flare is part of
  15071. */
  15072. constructor(
  15073. /**
  15074. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15075. */
  15076. size: number,
  15077. /**
  15078. * 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.
  15079. */
  15080. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15081. /**
  15082. * Dispose and release the lens flare with its associated resources.
  15083. */
  15084. dispose(): void;
  15085. }
  15086. }
  15087. declare module BABYLON {
  15088. /**
  15089. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15090. * It is usually composed of several `BABYLON.lensFlare`.
  15091. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15092. */
  15093. class LensFlareSystem {
  15094. /**
  15095. * Define the name of the lens flare system
  15096. */
  15097. name: string;
  15098. /**
  15099. * List of lens flares used in this system.
  15100. */
  15101. lensFlares: LensFlare[];
  15102. /**
  15103. * Define a limit from the border the lens flare can be visible.
  15104. */
  15105. borderLimit: number;
  15106. /**
  15107. * Define a viewport border we do not want to see the lens flare in.
  15108. */
  15109. viewportBorder: number;
  15110. /**
  15111. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15112. */
  15113. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15114. /**
  15115. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15116. */
  15117. layerMask: number;
  15118. /**
  15119. * Define the id of the lens flare system in the scene.
  15120. * (equal to name by default)
  15121. */
  15122. id: string;
  15123. private _scene;
  15124. private _emitter;
  15125. private _vertexBuffers;
  15126. private _indexBuffer;
  15127. private _effect;
  15128. private _positionX;
  15129. private _positionY;
  15130. private _isEnabled;
  15131. /**
  15132. * Instantiates a lens flare system.
  15133. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15134. * It is usually composed of several `BABYLON.lensFlare`.
  15135. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15136. * @param name Define the name of the lens flare system in the scene
  15137. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15138. * @param scene Define the scene the lens flare system belongs to
  15139. */
  15140. constructor(
  15141. /**
  15142. * Define the name of the lens flare system
  15143. */
  15144. name: string, emitter: any, scene: Scene);
  15145. /**
  15146. * Define if the lens flare system is enabled.
  15147. */
  15148. isEnabled: boolean;
  15149. /**
  15150. * Get the scene the effects belongs to.
  15151. * @returns the scene holding the lens flare system
  15152. */
  15153. getScene(): Scene;
  15154. /**
  15155. * Get the emitter of the lens flare system.
  15156. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15157. * @returns the emitter of the lens flare system
  15158. */
  15159. getEmitter(): any;
  15160. /**
  15161. * Set the emitter of the lens flare system.
  15162. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15163. * @param newEmitter Define the new emitter of the system
  15164. */
  15165. setEmitter(newEmitter: any): void;
  15166. /**
  15167. * Get the lens flare system emitter position.
  15168. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15169. * @returns the position
  15170. */
  15171. getEmitterPosition(): Vector3;
  15172. /**
  15173. * @hidden
  15174. */
  15175. computeEffectivePosition(globalViewport: Viewport): boolean;
  15176. /** @hidden */
  15177. _isVisible(): boolean;
  15178. /**
  15179. * @hidden
  15180. */
  15181. render(): boolean;
  15182. /**
  15183. * Dispose and release the lens flare with its associated resources.
  15184. */
  15185. dispose(): void;
  15186. /**
  15187. * Parse a lens flare system from a JSON repressentation
  15188. * @param parsedLensFlareSystem Define the JSON to parse
  15189. * @param scene Define the scene the parsed system should be instantiated in
  15190. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15191. * @returns the parsed system
  15192. */
  15193. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15194. /**
  15195. * Serialize the current Lens Flare System into a JSON representation.
  15196. * @returns the serialized JSON
  15197. */
  15198. serialize(): any;
  15199. }
  15200. }
  15201. declare module BABYLON {
  15202. interface AbstractScene {
  15203. /**
  15204. * The list of lens flare system added to the scene
  15205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15206. */
  15207. lensFlareSystems: Array<LensFlareSystem>;
  15208. /**
  15209. * Removes the given lens flare system from this scene.
  15210. * @param toRemove The lens flare system to remove
  15211. * @returns The index of the removed lens flare system
  15212. */
  15213. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15214. /**
  15215. * Adds the given lens flare system to this scene
  15216. * @param newLensFlareSystem The lens flare system to add
  15217. */
  15218. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15219. /**
  15220. * Gets a lens flare system using its name
  15221. * @param name defines the name to look for
  15222. * @returns the lens flare system or null if not found
  15223. */
  15224. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15225. /**
  15226. * Gets a lens flare system using its id
  15227. * @param id defines the id to look for
  15228. * @returns the lens flare system or null if not found
  15229. */
  15230. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15231. }
  15232. /**
  15233. * Defines the lens flare scene component responsible to manage any lens flares
  15234. * in a given scene.
  15235. */
  15236. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15237. /**
  15238. * The component name helpfull to identify the component in the list of scene components.
  15239. */
  15240. readonly name: string;
  15241. /**
  15242. * The scene the component belongs to.
  15243. */
  15244. scene: Scene;
  15245. /**
  15246. * Creates a new instance of the component for the given scene
  15247. * @param scene Defines the scene to register the component in
  15248. */
  15249. constructor(scene: Scene);
  15250. /**
  15251. * Registers the component in a given scene
  15252. */
  15253. register(): void;
  15254. /**
  15255. * Rebuilds the elements related to this component in case of
  15256. * context lost for instance.
  15257. */
  15258. rebuild(): void;
  15259. /**
  15260. * Adds all the element from the container to the scene
  15261. * @param container the container holding the elements
  15262. */
  15263. addFromContainer(container: AbstractScene): void;
  15264. /**
  15265. * Removes all the elements in the container from the scene
  15266. * @param container contains the elements to remove
  15267. */
  15268. removeFromContainer(container: AbstractScene): void;
  15269. /**
  15270. * Serializes the component data to the specified json object
  15271. * @param serializationObject The object to serialize to
  15272. */
  15273. serialize(serializationObject: any): void;
  15274. /**
  15275. * Disposes the component and the associated ressources.
  15276. */
  15277. dispose(): void;
  15278. private _draw;
  15279. }
  15280. }
  15281. declare module BABYLON {
  15282. /**
  15283. * A directional light is defined by a direction (what a surprise!).
  15284. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15285. * 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.
  15286. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15287. */
  15288. class DirectionalLight extends ShadowLight {
  15289. private _shadowFrustumSize;
  15290. /**
  15291. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15292. */
  15293. /**
  15294. * Specifies a fix frustum size for the shadow generation.
  15295. */
  15296. shadowFrustumSize: number;
  15297. private _shadowOrthoScale;
  15298. /**
  15299. * Gets the shadow projection scale against the optimal computed one.
  15300. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15301. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15302. */
  15303. /**
  15304. * Sets the shadow projection scale against the optimal computed one.
  15305. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15306. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15307. */
  15308. shadowOrthoScale: number;
  15309. /**
  15310. * Automatically compute the projection matrix to best fit (including all the casters)
  15311. * on each frame.
  15312. */
  15313. autoUpdateExtends: boolean;
  15314. private _orthoLeft;
  15315. private _orthoRight;
  15316. private _orthoTop;
  15317. private _orthoBottom;
  15318. /**
  15319. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15320. * The directional light is emitted from everywhere in the given direction.
  15321. * It can cast shadows.
  15322. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15323. * @param name The friendly name of the light
  15324. * @param direction The direction of the light
  15325. * @param scene The scene the light belongs to
  15326. */
  15327. constructor(name: string, direction: Vector3, scene: Scene);
  15328. /**
  15329. * Returns the string "DirectionalLight".
  15330. * @return The class name
  15331. */
  15332. getClassName(): string;
  15333. /**
  15334. * Returns the integer 1.
  15335. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15336. */
  15337. getTypeID(): number;
  15338. /**
  15339. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15340. * Returns the DirectionalLight Shadow projection matrix.
  15341. */
  15342. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15343. /**
  15344. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15345. * Returns the DirectionalLight Shadow projection matrix.
  15346. */
  15347. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15348. /**
  15349. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15350. * Returns the DirectionalLight Shadow projection matrix.
  15351. */
  15352. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15353. protected _buildUniformLayout(): void;
  15354. /**
  15355. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15356. * @param effect The effect to update
  15357. * @param lightIndex The index of the light in the effect to update
  15358. * @returns The directional light
  15359. */
  15360. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15361. /**
  15362. * Gets the minZ used for shadow according to both the scene and the light.
  15363. *
  15364. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15365. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15366. * @param activeCamera The camera we are returning the min for
  15367. * @returns the depth min z
  15368. */
  15369. getDepthMinZ(activeCamera: Camera): number;
  15370. /**
  15371. * Gets the maxZ used for shadow according to both the scene and the light.
  15372. *
  15373. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15374. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15375. * @param activeCamera The camera we are returning the max for
  15376. * @returns the depth max z
  15377. */
  15378. getDepthMaxZ(activeCamera: Camera): number;
  15379. /**
  15380. * Prepares the list of defines specific to the light type.
  15381. * @param defines the list of defines
  15382. * @param lightIndex defines the index of the light for the effect
  15383. */
  15384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15385. }
  15386. }
  15387. declare module BABYLON {
  15388. /**
  15389. * The HemisphericLight simulates the ambient environment light,
  15390. * so the passed direction is the light reflection direction, not the incoming direction.
  15391. */
  15392. class HemisphericLight extends Light {
  15393. /**
  15394. * The groundColor is the light in the opposite direction to the one specified during creation.
  15395. * 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.
  15396. */
  15397. groundColor: Color3;
  15398. /**
  15399. * The light reflection direction, not the incoming direction.
  15400. */
  15401. direction: Vector3;
  15402. /**
  15403. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15404. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15405. * The HemisphericLight can't cast shadows.
  15406. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15407. * @param name The friendly name of the light
  15408. * @param direction The direction of the light reflection
  15409. * @param scene The scene the light belongs to
  15410. */
  15411. constructor(name: string, direction: Vector3, scene: Scene);
  15412. protected _buildUniformLayout(): void;
  15413. /**
  15414. * Returns the string "HemisphericLight".
  15415. * @return The class name
  15416. */
  15417. getClassName(): string;
  15418. /**
  15419. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15420. * Returns the updated direction.
  15421. * @param target The target the direction should point to
  15422. * @return The computed direction
  15423. */
  15424. setDirectionToTarget(target: Vector3): Vector3;
  15425. /**
  15426. * Returns the shadow generator associated to the light.
  15427. * @returns Always null for hemispheric lights because it does not support shadows.
  15428. */
  15429. getShadowGenerator(): Nullable<IShadowGenerator>;
  15430. /**
  15431. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15432. * @param effect The effect to update
  15433. * @param lightIndex The index of the light in the effect to update
  15434. * @returns The hemispheric light
  15435. */
  15436. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15437. /**
  15438. * Computes the world matrix of the node
  15439. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15440. * @param useWasUpdatedFlag defines a reserved property
  15441. * @returns the world matrix
  15442. */
  15443. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15444. /**
  15445. * Returns the integer 3.
  15446. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15447. */
  15448. getTypeID(): number;
  15449. /**
  15450. * Prepares the list of defines specific to the light type.
  15451. * @param defines the list of defines
  15452. * @param lightIndex defines the index of the light for the effect
  15453. */
  15454. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15460. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15461. * 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.
  15462. */
  15463. abstract class Light extends Node {
  15464. /**
  15465. * Falloff Default: light is falling off following the material specification:
  15466. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15467. */
  15468. static readonly FALLOFF_DEFAULT: number;
  15469. /**
  15470. * Falloff Physical: light is falling off following the inverse squared distance law.
  15471. */
  15472. static readonly FALLOFF_PHYSICAL: number;
  15473. /**
  15474. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15475. * to enhance interoperability with other engines.
  15476. */
  15477. static readonly FALLOFF_GLTF: number;
  15478. /**
  15479. * Falloff Standard: light is falling off like in the standard material
  15480. * to enhance interoperability with other materials.
  15481. */
  15482. static readonly FALLOFF_STANDARD: number;
  15483. /**
  15484. * If every light affecting the material is in this lightmapMode,
  15485. * material.lightmapTexture adds or multiplies
  15486. * (depends on material.useLightmapAsShadowmap)
  15487. * after every other light calculations.
  15488. */
  15489. static readonly LIGHTMAP_DEFAULT: number;
  15490. /**
  15491. * material.lightmapTexture as only diffuse lighting from this light
  15492. * adds only specular lighting from this light
  15493. * adds dynamic shadows
  15494. */
  15495. static readonly LIGHTMAP_SPECULAR: number;
  15496. /**
  15497. * material.lightmapTexture as only lighting
  15498. * no light calculation from this light
  15499. * only adds dynamic shadows from this light
  15500. */
  15501. static readonly LIGHTMAP_SHADOWSONLY: number;
  15502. /**
  15503. * Each light type uses the default quantity according to its type:
  15504. * point/spot lights use luminous intensity
  15505. * directional lights use illuminance
  15506. */
  15507. static readonly INTENSITYMODE_AUTOMATIC: number;
  15508. /**
  15509. * lumen (lm)
  15510. */
  15511. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15512. /**
  15513. * candela (lm/sr)
  15514. */
  15515. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15516. /**
  15517. * lux (lm/m^2)
  15518. */
  15519. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15520. /**
  15521. * nit (cd/m^2)
  15522. */
  15523. static readonly INTENSITYMODE_LUMINANCE: number;
  15524. /**
  15525. * Light type const id of the point light.
  15526. */
  15527. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15528. /**
  15529. * Light type const id of the directional light.
  15530. */
  15531. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15532. /**
  15533. * Light type const id of the spot light.
  15534. */
  15535. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15536. /**
  15537. * Light type const id of the hemispheric light.
  15538. */
  15539. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15540. /**
  15541. * Diffuse gives the basic color to an object.
  15542. */
  15543. diffuse: Color3;
  15544. /**
  15545. * Specular produces a highlight color on an object.
  15546. * Note: This is note affecting PBR materials.
  15547. */
  15548. specular: Color3;
  15549. /**
  15550. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15551. * falling off base on range or angle.
  15552. * This can be set to any values in Light.FALLOFF_x.
  15553. *
  15554. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15555. * other types of materials.
  15556. */
  15557. falloffType: number;
  15558. /**
  15559. * Strength of the light.
  15560. * Note: By default it is define in the framework own unit.
  15561. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15562. */
  15563. intensity: number;
  15564. private _range;
  15565. protected _inverseSquaredRange: number;
  15566. /**
  15567. * Defines how far from the source the light is impacting in scene units.
  15568. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15569. */
  15570. /**
  15571. * Defines how far from the source the light is impacting in scene units.
  15572. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15573. */
  15574. range: number;
  15575. /**
  15576. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15577. * of light.
  15578. */
  15579. private _photometricScale;
  15580. private _intensityMode;
  15581. /**
  15582. * Gets the photometric scale used to interpret the intensity.
  15583. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15584. */
  15585. /**
  15586. * Sets the photometric scale used to interpret the intensity.
  15587. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15588. */
  15589. intensityMode: number;
  15590. private _radius;
  15591. /**
  15592. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15593. */
  15594. /**
  15595. * sets the light radius used by PBR Materials to simulate soft area lights.
  15596. */
  15597. radius: number;
  15598. private _renderPriority;
  15599. /**
  15600. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15601. * exceeding the number allowed of the materials.
  15602. */
  15603. renderPriority: number;
  15604. private _shadowEnabled;
  15605. /**
  15606. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15607. * the current shadow generator.
  15608. */
  15609. /**
  15610. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15611. * the current shadow generator.
  15612. */
  15613. shadowEnabled: boolean;
  15614. private _includedOnlyMeshes;
  15615. /**
  15616. * Gets the only meshes impacted by this light.
  15617. */
  15618. /**
  15619. * Sets the only meshes impacted by this light.
  15620. */
  15621. includedOnlyMeshes: AbstractMesh[];
  15622. private _excludedMeshes;
  15623. /**
  15624. * Gets the meshes not impacted by this light.
  15625. */
  15626. /**
  15627. * Sets the meshes not impacted by this light.
  15628. */
  15629. excludedMeshes: AbstractMesh[];
  15630. private _excludeWithLayerMask;
  15631. /**
  15632. * Gets the layer id use to find what meshes are not impacted by the light.
  15633. * Inactive if 0
  15634. */
  15635. /**
  15636. * Sets the layer id use to find what meshes are not impacted by the light.
  15637. * Inactive if 0
  15638. */
  15639. excludeWithLayerMask: number;
  15640. private _includeOnlyWithLayerMask;
  15641. /**
  15642. * Gets the layer id use to find what meshes are impacted by the light.
  15643. * Inactive if 0
  15644. */
  15645. /**
  15646. * Sets the layer id use to find what meshes are impacted by the light.
  15647. * Inactive if 0
  15648. */
  15649. includeOnlyWithLayerMask: number;
  15650. private _lightmapMode;
  15651. /**
  15652. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15653. */
  15654. /**
  15655. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15656. */
  15657. lightmapMode: number;
  15658. /**
  15659. * Shadow generator associted to the light.
  15660. * @hidden Internal use only.
  15661. */
  15662. _shadowGenerator: Nullable<IShadowGenerator>;
  15663. /**
  15664. * @hidden Internal use only.
  15665. */
  15666. _excludedMeshesIds: string[];
  15667. /**
  15668. * @hidden Internal use only.
  15669. */
  15670. _includedOnlyMeshesIds: string[];
  15671. /**
  15672. * The current light unifom buffer.
  15673. * @hidden Internal use only.
  15674. */
  15675. _uniformBuffer: UniformBuffer;
  15676. /**
  15677. * Creates a Light object in the scene.
  15678. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15679. * @param name The firendly name of the light
  15680. * @param scene The scene the light belongs too
  15681. */
  15682. constructor(name: string, scene: Scene);
  15683. protected abstract _buildUniformLayout(): void;
  15684. /**
  15685. * Sets the passed Effect "effect" with the Light information.
  15686. * @param effect The effect to update
  15687. * @param lightIndex The index of the light in the effect to update
  15688. * @returns The light
  15689. */
  15690. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15691. /**
  15692. * Returns the string "Light".
  15693. * @returns the class name
  15694. */
  15695. getClassName(): string;
  15696. /**
  15697. * Converts the light information to a readable string for debug purpose.
  15698. * @param fullDetails Supports for multiple levels of logging within scene loading
  15699. * @returns the human readable light info
  15700. */
  15701. toString(fullDetails?: boolean): string;
  15702. /** @hidden */
  15703. protected _syncParentEnabledState(): void;
  15704. /**
  15705. * Set the enabled state of this node.
  15706. * @param value - the new enabled state
  15707. */
  15708. setEnabled(value: boolean): void;
  15709. /**
  15710. * Returns the Light associated shadow generator if any.
  15711. * @return the associated shadow generator.
  15712. */
  15713. getShadowGenerator(): Nullable<IShadowGenerator>;
  15714. /**
  15715. * Returns a Vector3, the absolute light position in the World.
  15716. * @returns the world space position of the light
  15717. */
  15718. getAbsolutePosition(): Vector3;
  15719. /**
  15720. * Specifies if the light will affect the passed mesh.
  15721. * @param mesh The mesh to test against the light
  15722. * @return true the mesh is affected otherwise, false.
  15723. */
  15724. canAffectMesh(mesh: AbstractMesh): boolean;
  15725. /**
  15726. * Sort function to order lights for rendering.
  15727. * @param a First Light object to compare to second.
  15728. * @param b Second Light object to compare first.
  15729. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15730. */
  15731. static CompareLightsPriority(a: Light, b: Light): number;
  15732. /**
  15733. * Releases resources associated with this node.
  15734. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15735. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15736. */
  15737. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15738. /**
  15739. * Returns the light type ID (integer).
  15740. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15741. */
  15742. getTypeID(): number;
  15743. /**
  15744. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15745. * @returns the scaled intensity in intensity mode unit
  15746. */
  15747. getScaledIntensity(): number;
  15748. /**
  15749. * Returns a new Light object, named "name", from the current one.
  15750. * @param name The name of the cloned light
  15751. * @returns the new created light
  15752. */
  15753. clone(name: string): Nullable<Light>;
  15754. /**
  15755. * Serializes the current light into a Serialization object.
  15756. * @returns the serialized object.
  15757. */
  15758. serialize(): any;
  15759. /**
  15760. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15761. * This new light is named "name" and added to the passed scene.
  15762. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15763. * @param name The friendly name of the light
  15764. * @param scene The scene the new light will belong to
  15765. * @returns the constructor function
  15766. */
  15767. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15768. /**
  15769. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15770. * @param parsedLight The JSON representation of the light
  15771. * @param scene The scene to create the parsed light in
  15772. * @returns the created light after parsing
  15773. */
  15774. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15775. private _hookArrayForExcluded;
  15776. private _hookArrayForIncludedOnly;
  15777. private _resyncMeshes;
  15778. /**
  15779. * Forces the meshes to update their light related information in their rendering used effects
  15780. * @hidden Internal Use Only
  15781. */
  15782. _markMeshesAsLightDirty(): void;
  15783. /**
  15784. * Recomputes the cached photometric scale if needed.
  15785. */
  15786. private _computePhotometricScale;
  15787. /**
  15788. * Returns the Photometric Scale according to the light type and intensity mode.
  15789. */
  15790. private _getPhotometricScale;
  15791. /**
  15792. * Reorder the light in the scene according to their defined priority.
  15793. * @hidden Internal Use Only
  15794. */
  15795. _reorderLightsInScene(): void;
  15796. /**
  15797. * Prepares the list of defines specific to the light type.
  15798. * @param defines the list of defines
  15799. * @param lightIndex defines the index of the light for the effect
  15800. */
  15801. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15802. }
  15803. }
  15804. declare module BABYLON {
  15805. /**
  15806. * A point light is a light defined by an unique point in world space.
  15807. * The light is emitted in every direction from this point.
  15808. * A good example of a point light is a standard light bulb.
  15809. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15810. */
  15811. class PointLight extends ShadowLight {
  15812. private _shadowAngle;
  15813. /**
  15814. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15815. * This specifies what angle the shadow will use to be created.
  15816. *
  15817. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15818. */
  15819. /**
  15820. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15821. * This specifies what angle the shadow will use to be created.
  15822. *
  15823. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15824. */
  15825. shadowAngle: number;
  15826. /**
  15827. * Gets the direction if it has been set.
  15828. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15829. */
  15830. /**
  15831. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15832. */
  15833. direction: Vector3;
  15834. /**
  15835. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15836. * A PointLight emits the light in every direction.
  15837. * It can cast shadows.
  15838. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15839. * ```javascript
  15840. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15841. * ```
  15842. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15843. * @param name The light friendly name
  15844. * @param position The position of the point light in the scene
  15845. * @param scene The scene the lights belongs to
  15846. */
  15847. constructor(name: string, position: Vector3, scene: Scene);
  15848. /**
  15849. * Returns the string "PointLight"
  15850. * @returns the class name
  15851. */
  15852. getClassName(): string;
  15853. /**
  15854. * Returns the integer 0.
  15855. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15856. */
  15857. getTypeID(): number;
  15858. /**
  15859. * Specifies wether or not the shadowmap should be a cube texture.
  15860. * @returns true if the shadowmap needs to be a cube texture.
  15861. */
  15862. needCube(): boolean;
  15863. /**
  15864. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15865. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15866. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15867. */
  15868. getShadowDirection(faceIndex?: number): Vector3;
  15869. /**
  15870. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15871. * - fov = PI / 2
  15872. * - aspect ratio : 1.0
  15873. * - z-near and far equal to the active camera minZ and maxZ.
  15874. * Returns the PointLight.
  15875. */
  15876. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15877. protected _buildUniformLayout(): void;
  15878. /**
  15879. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15880. * @param effect The effect to update
  15881. * @param lightIndex The index of the light in the effect to update
  15882. * @returns The point light
  15883. */
  15884. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15885. /**
  15886. * Prepares the list of defines specific to the light type.
  15887. * @param defines the list of defines
  15888. * @param lightIndex defines the index of the light for the effect
  15889. */
  15890. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15891. }
  15892. }
  15893. declare module BABYLON {
  15894. /**
  15895. * Interface describing all the common properties and methods a shadow light needs to implement.
  15896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15897. * as well as binding the different shadow properties to the effects.
  15898. */
  15899. interface IShadowLight extends Light {
  15900. /**
  15901. * The light id in the scene (used in scene.findLighById for instance)
  15902. */
  15903. id: string;
  15904. /**
  15905. * The position the shdow will be casted from.
  15906. */
  15907. position: Vector3;
  15908. /**
  15909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15910. */
  15911. direction: Vector3;
  15912. /**
  15913. * The transformed position. Position of the light in world space taking parenting in account.
  15914. */
  15915. transformedPosition: Vector3;
  15916. /**
  15917. * The transformed direction. Direction of the light in world space taking parenting in account.
  15918. */
  15919. transformedDirection: Vector3;
  15920. /**
  15921. * The friendly name of the light in the scene.
  15922. */
  15923. name: string;
  15924. /**
  15925. * Defines the shadow projection clipping minimum z value.
  15926. */
  15927. shadowMinZ: number;
  15928. /**
  15929. * Defines the shadow projection clipping maximum z value.
  15930. */
  15931. shadowMaxZ: number;
  15932. /**
  15933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15935. */
  15936. computeTransformedInformation(): boolean;
  15937. /**
  15938. * Gets the scene the light belongs to.
  15939. * @returns The scene
  15940. */
  15941. getScene(): Scene;
  15942. /**
  15943. * Callback defining a custom Projection Matrix Builder.
  15944. * This can be used to override the default projection matrix computation.
  15945. */
  15946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15947. /**
  15948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15949. * @param matrix The materix to updated with the projection information
  15950. * @param viewMatrix The transform matrix of the light
  15951. * @param renderList The list of mesh to render in the map
  15952. * @returns The current light
  15953. */
  15954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15955. /**
  15956. * Gets the current depth scale used in ESM.
  15957. * @returns The scale
  15958. */
  15959. getDepthScale(): number;
  15960. /**
  15961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15962. * @returns true if a cube texture needs to be use
  15963. */
  15964. needCube(): boolean;
  15965. /**
  15966. * Detects if the projection matrix requires to be recomputed this frame.
  15967. * @returns true if it requires to be recomputed otherwise, false.
  15968. */
  15969. needProjectionMatrixCompute(): boolean;
  15970. /**
  15971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15972. */
  15973. forceProjectionMatrixCompute(): void;
  15974. /**
  15975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15978. */
  15979. getShadowDirection(faceIndex?: number): Vector3;
  15980. /**
  15981. * Gets the minZ used for shadow according to both the scene and the light.
  15982. * @param activeCamera The camera we are returning the min for
  15983. * @returns the depth min z
  15984. */
  15985. getDepthMinZ(activeCamera: Camera): number;
  15986. /**
  15987. * Gets the maxZ used for shadow according to both the scene and the light.
  15988. * @param activeCamera The camera we are returning the max for
  15989. * @returns the depth max z
  15990. */
  15991. getDepthMaxZ(activeCamera: Camera): number;
  15992. }
  15993. /**
  15994. * Base implementation IShadowLight
  15995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15996. */
  15997. abstract class ShadowLight extends Light implements IShadowLight {
  15998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15999. protected _position: Vector3;
  16000. protected _setPosition(value: Vector3): void;
  16001. /**
  16002. * Sets the position the shadow will be casted from. Also use as the light position for both
  16003. * point and spot lights.
  16004. */
  16005. /**
  16006. * Sets the position the shadow will be casted from. Also use as the light position for both
  16007. * point and spot lights.
  16008. */
  16009. position: Vector3;
  16010. protected _direction: Vector3;
  16011. protected _setDirection(value: Vector3): void;
  16012. /**
  16013. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16014. * Also use as the light direction on spot and directional lights.
  16015. */
  16016. /**
  16017. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16018. * Also use as the light direction on spot and directional lights.
  16019. */
  16020. direction: Vector3;
  16021. private _shadowMinZ;
  16022. /**
  16023. * Gets the shadow projection clipping minimum z value.
  16024. */
  16025. /**
  16026. * Sets the shadow projection clipping minimum z value.
  16027. */
  16028. shadowMinZ: number;
  16029. private _shadowMaxZ;
  16030. /**
  16031. * Sets the shadow projection clipping maximum z value.
  16032. */
  16033. /**
  16034. * Gets the shadow projection clipping maximum z value.
  16035. */
  16036. shadowMaxZ: number;
  16037. /**
  16038. * Callback defining a custom Projection Matrix Builder.
  16039. * This can be used to override the default projection matrix computation.
  16040. */
  16041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16042. /**
  16043. * The transformed position. Position of the light in world space taking parenting in account.
  16044. */
  16045. transformedPosition: Vector3;
  16046. /**
  16047. * The transformed direction. Direction of the light in world space taking parenting in account.
  16048. */
  16049. transformedDirection: Vector3;
  16050. private _needProjectionMatrixCompute;
  16051. /**
  16052. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16053. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16054. */
  16055. computeTransformedInformation(): boolean;
  16056. /**
  16057. * Return the depth scale used for the shadow map.
  16058. * @returns the depth scale.
  16059. */
  16060. getDepthScale(): number;
  16061. /**
  16062. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16063. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16064. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16065. */
  16066. getShadowDirection(faceIndex?: number): Vector3;
  16067. /**
  16068. * Returns the ShadowLight absolute position in the World.
  16069. * @returns the position vector in world space
  16070. */
  16071. getAbsolutePosition(): Vector3;
  16072. /**
  16073. * Sets the ShadowLight direction toward the passed target.
  16074. * @param target The point tot target in local space
  16075. * @returns the updated ShadowLight direction
  16076. */
  16077. setDirectionToTarget(target: Vector3): Vector3;
  16078. /**
  16079. * Returns the light rotation in euler definition.
  16080. * @returns the x y z rotation in local space.
  16081. */
  16082. getRotation(): Vector3;
  16083. /**
  16084. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16085. * @returns true if a cube texture needs to be use
  16086. */
  16087. needCube(): boolean;
  16088. /**
  16089. * Detects if the projection matrix requires to be recomputed this frame.
  16090. * @returns true if it requires to be recomputed otherwise, false.
  16091. */
  16092. needProjectionMatrixCompute(): boolean;
  16093. /**
  16094. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16095. */
  16096. forceProjectionMatrixCompute(): void;
  16097. /** @hidden */
  16098. _initCache(): void;
  16099. /** @hidden */
  16100. _isSynchronized(): boolean;
  16101. /**
  16102. * Computes the world matrix of the node
  16103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16104. * @returns the world matrix
  16105. */
  16106. computeWorldMatrix(force?: boolean): Matrix;
  16107. /**
  16108. * Gets the minZ used for shadow according to both the scene and the light.
  16109. * @param activeCamera The camera we are returning the min for
  16110. * @returns the depth min z
  16111. */
  16112. getDepthMinZ(activeCamera: Camera): number;
  16113. /**
  16114. * Gets the maxZ used for shadow according to both the scene and the light.
  16115. * @param activeCamera The camera we are returning the max for
  16116. * @returns the depth max z
  16117. */
  16118. getDepthMaxZ(activeCamera: Camera): number;
  16119. /**
  16120. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16121. * @param matrix The materix to updated with the projection information
  16122. * @param viewMatrix The transform matrix of the light
  16123. * @param renderList The list of mesh to render in the map
  16124. * @returns The current light
  16125. */
  16126. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16127. }
  16128. }
  16129. declare module BABYLON {
  16130. /**
  16131. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16132. * These values define a cone of light starting from the position, emitting toward the direction.
  16133. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16134. * and the exponent defines the speed of the decay of the light with distance (reach).
  16135. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16136. */
  16137. class SpotLight extends ShadowLight {
  16138. private _angle;
  16139. private _innerAngle;
  16140. private _cosHalfAngle;
  16141. private _lightAngleScale;
  16142. private _lightAngleOffset;
  16143. /**
  16144. * Gets the cone angle of the spot light in Radians.
  16145. */
  16146. /**
  16147. * Sets the cone angle of the spot light in Radians.
  16148. */
  16149. angle: number;
  16150. /**
  16151. * Only used in gltf falloff mode, this defines the angle where
  16152. * the directional falloff will start before cutting at angle which could be seen
  16153. * as outer angle.
  16154. */
  16155. /**
  16156. * Only used in gltf falloff mode, this defines the angle where
  16157. * the directional falloff will start before cutting at angle which could be seen
  16158. * as outer angle.
  16159. */
  16160. innerAngle: number;
  16161. private _shadowAngleScale;
  16162. /**
  16163. * Allows scaling the angle of the light for shadow generation only.
  16164. */
  16165. /**
  16166. * Allows scaling the angle of the light for shadow generation only.
  16167. */
  16168. shadowAngleScale: number;
  16169. /**
  16170. * The light decay speed with the distance from the emission spot.
  16171. */
  16172. exponent: number;
  16173. private _projectionTextureMatrix;
  16174. /**
  16175. * Allows reading the projecton texture
  16176. */
  16177. readonly projectionTextureMatrix: Matrix;
  16178. protected _projectionTextureLightNear: number;
  16179. /**
  16180. * Gets the near clip of the Spotlight for texture projection.
  16181. */
  16182. /**
  16183. * Sets the near clip of the Spotlight for texture projection.
  16184. */
  16185. projectionTextureLightNear: number;
  16186. protected _projectionTextureLightFar: number;
  16187. /**
  16188. * Gets the far clip of the Spotlight for texture projection.
  16189. */
  16190. /**
  16191. * Sets the far clip of the Spotlight for texture projection.
  16192. */
  16193. projectionTextureLightFar: number;
  16194. protected _projectionTextureUpDirection: Vector3;
  16195. /**
  16196. * Gets the Up vector of the Spotlight for texture projection.
  16197. */
  16198. /**
  16199. * Sets the Up vector of the Spotlight for texture projection.
  16200. */
  16201. projectionTextureUpDirection: Vector3;
  16202. private _projectionTexture;
  16203. /**
  16204. * Gets the projection texture of the light.
  16205. */
  16206. /**
  16207. * Sets the projection texture of the light.
  16208. */
  16209. projectionTexture: Nullable<BaseTexture>;
  16210. private _projectionTextureViewLightDirty;
  16211. private _projectionTextureProjectionLightDirty;
  16212. private _projectionTextureDirty;
  16213. private _projectionTextureViewTargetVector;
  16214. private _projectionTextureViewLightMatrix;
  16215. private _projectionTextureProjectionLightMatrix;
  16216. private _projectionTextureScalingMatrix;
  16217. /**
  16218. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16219. * It can cast shadows.
  16220. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16221. * @param name The light friendly name
  16222. * @param position The position of the spot light in the scene
  16223. * @param direction The direction of the light in the scene
  16224. * @param angle The cone angle of the light in Radians
  16225. * @param exponent The light decay speed with the distance from the emission spot
  16226. * @param scene The scene the lights belongs to
  16227. */
  16228. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16229. /**
  16230. * Returns the string "SpotLight".
  16231. * @returns the class name
  16232. */
  16233. getClassName(): string;
  16234. /**
  16235. * Returns the integer 2.
  16236. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16237. */
  16238. getTypeID(): number;
  16239. /**
  16240. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16241. */
  16242. protected _setDirection(value: Vector3): void;
  16243. /**
  16244. * Overrides the position setter to recompute the projection texture view light Matrix.
  16245. */
  16246. protected _setPosition(value: Vector3): void;
  16247. /**
  16248. * 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.
  16249. * Returns the SpotLight.
  16250. */
  16251. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16252. protected _computeProjectionTextureViewLightMatrix(): void;
  16253. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16254. /**
  16255. * Main function for light texture projection matrix computing.
  16256. */
  16257. protected _computeProjectionTextureMatrix(): void;
  16258. protected _buildUniformLayout(): void;
  16259. private _computeAngleValues;
  16260. /**
  16261. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16262. * @param effect The effect to update
  16263. * @param lightIndex The index of the light in the effect to update
  16264. * @returns The spot light
  16265. */
  16266. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16267. /**
  16268. * Disposes the light and the associated resources.
  16269. */
  16270. dispose(): void;
  16271. /**
  16272. * Prepares the list of defines specific to the light type.
  16273. * @param defines the list of defines
  16274. * @param lightIndex defines the index of the light for the effect
  16275. */
  16276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16277. }
  16278. }
  16279. declare module BABYLON {
  16280. /**
  16281. * Interface used to present a loading screen while loading a scene
  16282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16283. */
  16284. interface ILoadingScreen {
  16285. /**
  16286. * Function called to display the loading screen
  16287. */
  16288. displayLoadingUI: () => void;
  16289. /**
  16290. * Function called to hide the loading screen
  16291. */
  16292. hideLoadingUI: () => void;
  16293. /**
  16294. * Gets or sets the color to use for the background
  16295. */
  16296. loadingUIBackgroundColor: string;
  16297. /**
  16298. * Gets or sets the text to display while loading
  16299. */
  16300. loadingUIText: string;
  16301. }
  16302. /**
  16303. * Class used for the default loading screen
  16304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16305. */
  16306. class DefaultLoadingScreen implements ILoadingScreen {
  16307. private _renderingCanvas;
  16308. private _loadingText;
  16309. private _loadingDivBackgroundColor;
  16310. private _loadingDiv;
  16311. private _loadingTextDiv;
  16312. /**
  16313. * Creates a new default loading screen
  16314. * @param _renderingCanvas defines the canvas used to render the scene
  16315. * @param _loadingText defines the default text to display
  16316. * @param _loadingDivBackgroundColor defines the default background color
  16317. */
  16318. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16319. /**
  16320. * Function called to display the loading screen
  16321. */
  16322. displayLoadingUI(): void;
  16323. /**
  16324. * Function called to hide the loading screen
  16325. */
  16326. hideLoadingUI(): void;
  16327. /**
  16328. * Gets or sets the text to display while loading
  16329. */
  16330. loadingUIText: string;
  16331. /**
  16332. * Gets or sets the color to use for the background
  16333. */
  16334. loadingUIBackgroundColor: string;
  16335. private _resizeLoadingUI;
  16336. }
  16337. }
  16338. declare module BABYLON {
  16339. /**
  16340. * Class used to represent data loading progression
  16341. */
  16342. class SceneLoaderProgressEvent {
  16343. /** defines if data length to load can be evaluated */
  16344. readonly lengthComputable: boolean;
  16345. /** defines the loaded data length */
  16346. readonly loaded: number;
  16347. /** defines the data length to load */
  16348. readonly total: number;
  16349. /**
  16350. * Create a new progress event
  16351. * @param lengthComputable defines if data length to load can be evaluated
  16352. * @param loaded defines the loaded data length
  16353. * @param total defines the data length to load
  16354. */
  16355. constructor(
  16356. /** defines if data length to load can be evaluated */
  16357. lengthComputable: boolean,
  16358. /** defines the loaded data length */
  16359. loaded: number,
  16360. /** defines the data length to load */
  16361. total: number);
  16362. /**
  16363. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16364. * @param event defines the source event
  16365. * @returns a new SceneLoaderProgressEvent
  16366. */
  16367. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16368. }
  16369. /**
  16370. * Interface used by SceneLoader plugins to define supported file extensions
  16371. */
  16372. interface ISceneLoaderPluginExtensions {
  16373. /**
  16374. * Defines the list of supported extensions
  16375. */
  16376. [extension: string]: {
  16377. isBinary: boolean;
  16378. };
  16379. }
  16380. /**
  16381. * Interface used by SceneLoader plugin factory
  16382. */
  16383. interface ISceneLoaderPluginFactory {
  16384. /**
  16385. * Defines the name of the factory
  16386. */
  16387. name: string;
  16388. /**
  16389. * Function called to create a new plugin
  16390. * @return the new plugin
  16391. */
  16392. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16393. /**
  16394. * Boolean indicating if the plugin can direct load specific data
  16395. */
  16396. canDirectLoad?: (data: string) => boolean;
  16397. }
  16398. /**
  16399. * Interface used to define a SceneLoader plugin
  16400. */
  16401. interface ISceneLoaderPlugin {
  16402. /**
  16403. * The friendly name of this plugin.
  16404. */
  16405. name: string;
  16406. /**
  16407. * The file extensions supported by this plugin.
  16408. */
  16409. extensions: string | ISceneLoaderPluginExtensions;
  16410. /**
  16411. * Import meshes into a scene.
  16412. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16413. * @param scene The scene to import into
  16414. * @param data The data to import
  16415. * @param rootUrl The root url for scene and resources
  16416. * @param meshes The meshes array to import into
  16417. * @param particleSystems The particle systems array to import into
  16418. * @param skeletons The skeletons array to import into
  16419. * @param onError The callback when import fails
  16420. * @returns True if successful or false otherwise
  16421. */
  16422. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16423. /**
  16424. * Load into a scene.
  16425. * @param scene The scene to load into
  16426. * @param data The data to import
  16427. * @param rootUrl The root url for scene and resources
  16428. * @param onError The callback when import fails
  16429. * @returns true if successful or false otherwise
  16430. */
  16431. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  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 onError The callback when import fails
  16446. * @returns The loaded asset container
  16447. */
  16448. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16449. }
  16450. /**
  16451. * Interface used to define an async SceneLoader plugin
  16452. */
  16453. interface ISceneLoaderPluginAsync {
  16454. /**
  16455. * The friendly name of this plugin.
  16456. */
  16457. name: string;
  16458. /**
  16459. * The file extensions supported by this plugin.
  16460. */
  16461. extensions: string | ISceneLoaderPluginExtensions;
  16462. /**
  16463. * Import meshes into a scene.
  16464. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16465. * @param scene The scene to import into
  16466. * @param data The data to import
  16467. * @param rootUrl The root url for scene and resources
  16468. * @param onProgress The callback when the load progresses
  16469. * @param fileName Defines the name of the file to load
  16470. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16471. */
  16472. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16473. meshes: AbstractMesh[];
  16474. particleSystems: IParticleSystem[];
  16475. skeletons: Skeleton[];
  16476. animationGroups: AnimationGroup[];
  16477. }>;
  16478. /**
  16479. * Load into a scene.
  16480. * @param scene The scene to load into
  16481. * @param data The data to import
  16482. * @param rootUrl The root url for scene and resources
  16483. * @param onProgress The callback when the load progresses
  16484. * @param fileName Defines the name of the file to load
  16485. * @returns Nothing
  16486. */
  16487. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16488. /**
  16489. * The callback that returns true if the data can be directly loaded.
  16490. */
  16491. canDirectLoad?: (data: string) => boolean;
  16492. /**
  16493. * The callback that allows custom handling of the root url based on the response url.
  16494. */
  16495. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16496. /**
  16497. * Load into an asset container.
  16498. * @param scene The scene to load into
  16499. * @param data The data to import
  16500. * @param rootUrl The root url for scene and resources
  16501. * @param onProgress The callback when the load progresses
  16502. * @param fileName Defines the name of the file to load
  16503. * @returns The loaded asset container
  16504. */
  16505. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16506. }
  16507. /**
  16508. * Class used to load scene from various file formats using registered plugins
  16509. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16510. */
  16511. class SceneLoader {
  16512. private static _ForceFullSceneLoadingForIncremental;
  16513. private static _ShowLoadingScreen;
  16514. private static _CleanBoneMatrixWeights;
  16515. /**
  16516. * No logging while loading
  16517. */
  16518. static readonly NO_LOGGING: number;
  16519. /**
  16520. * Minimal logging while loading
  16521. */
  16522. static readonly MINIMAL_LOGGING: number;
  16523. /**
  16524. * Summary logging while loading
  16525. */
  16526. static readonly SUMMARY_LOGGING: number;
  16527. /**
  16528. * Detailled logging while loading
  16529. */
  16530. static readonly DETAILED_LOGGING: number;
  16531. private static _loggingLevel;
  16532. /**
  16533. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16534. */
  16535. static ForceFullSceneLoadingForIncremental: boolean;
  16536. /**
  16537. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16538. */
  16539. static ShowLoadingScreen: boolean;
  16540. /**
  16541. * Defines the current logging level (while loading the scene)
  16542. * @ignorenaming
  16543. */
  16544. static loggingLevel: number;
  16545. /**
  16546. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16547. */
  16548. static CleanBoneMatrixWeights: boolean;
  16549. /**
  16550. * Event raised when a plugin is used to load a scene
  16551. */
  16552. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16553. private static _registeredPlugins;
  16554. private static _getDefaultPlugin;
  16555. private static _getPluginForExtension;
  16556. private static _getPluginForDirectLoad;
  16557. private static _getPluginForFilename;
  16558. private static _getDirectLoad;
  16559. private static _loadData;
  16560. private static _getFileInfo;
  16561. /**
  16562. * Gets a plugin that can load the given extension
  16563. * @param extension defines the extension to load
  16564. * @returns a plugin or null if none works
  16565. */
  16566. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16567. /**
  16568. * Gets a boolean indicating that the given extension can be loaded
  16569. * @param extension defines the extension to load
  16570. * @returns true if the extension is supported
  16571. */
  16572. static IsPluginForExtensionAvailable(extension: string): boolean;
  16573. /**
  16574. * Adds a new plugin to the list of registered plugins
  16575. * @param plugin defines the plugin to add
  16576. */
  16577. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16578. /**
  16579. * Import meshes into a scene
  16580. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16581. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16582. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16583. * @param scene the instance of BABYLON.Scene to append to
  16584. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16585. * @param onProgress a callback with a progress event for each file being loaded
  16586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16587. * @param pluginExtension the extension used to determine the plugin
  16588. * @returns The loaded plugin
  16589. */
  16590. 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>;
  16591. /**
  16592. * Import meshes into a scene
  16593. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16594. * @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)
  16595. * @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)
  16596. * @param scene the instance of BABYLON.Scene to append to
  16597. * @param onProgress a callback with a progress event for each file being loaded
  16598. * @param pluginExtension the extension used to determine the plugin
  16599. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16600. */
  16601. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16602. meshes: AbstractMesh[];
  16603. particleSystems: IParticleSystem[];
  16604. skeletons: Skeleton[];
  16605. animationGroups: AnimationGroup[];
  16606. }>;
  16607. /**
  16608. * Load a scene
  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 engine is the instance of BABYLON.Engine to use to create the scene
  16612. * @param onSuccess a callback with the scene when import succeeds
  16613. * @param onProgress a callback with a progress event for each file being loaded
  16614. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16615. * @param pluginExtension the extension used to determine the plugin
  16616. * @returns The loaded plugin
  16617. */
  16618. 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>;
  16619. /**
  16620. * Load a scene
  16621. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16622. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16623. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16624. * @param onProgress a callback with a progress event for each file being loaded
  16625. * @param pluginExtension the extension used to determine the plugin
  16626. * @returns The loaded scene
  16627. */
  16628. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16629. /**
  16630. * Append a scene
  16631. * @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)
  16632. * @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)
  16633. * @param scene is the instance of BABYLON.Scene to append to
  16634. * @param onSuccess a callback with the scene when import succeeds
  16635. * @param onProgress a callback with a progress event for each file being loaded
  16636. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16637. * @param pluginExtension the extension used to determine the plugin
  16638. * @returns The loaded plugin
  16639. */
  16640. 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>;
  16641. /**
  16642. * Append a scene
  16643. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16644. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16645. * @param scene is the instance of BABYLON.Scene to append to
  16646. * @param onProgress a callback with a progress event for each file being loaded
  16647. * @param pluginExtension the extension used to determine the plugin
  16648. * @returns The given scene
  16649. */
  16650. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16651. /**
  16652. * Load a scene into an asset container
  16653. * @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)
  16654. * @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)
  16655. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16656. * @param onSuccess a callback with the scene when import succeeds
  16657. * @param onProgress a callback with a progress event for each file being loaded
  16658. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16659. * @param pluginExtension the extension used to determine the plugin
  16660. * @returns The loaded plugin
  16661. */
  16662. 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>;
  16663. /**
  16664. * Load a scene into an asset container
  16665. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16666. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16667. * @param scene is the instance of BABYLON.Scene to append to
  16668. * @param onProgress a callback with a progress event for each file being loaded
  16669. * @param pluginExtension the extension used to determine the plugin
  16670. * @returns The loaded asset container
  16671. */
  16672. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16673. }
  16674. }
  16675. declare module BABYLON {
  16676. /**
  16677. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16678. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16679. * 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;
  16680. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16681. */
  16682. class ColorCurves {
  16683. private _dirty;
  16684. private _tempColor;
  16685. private _globalCurve;
  16686. private _highlightsCurve;
  16687. private _midtonesCurve;
  16688. private _shadowsCurve;
  16689. private _positiveCurve;
  16690. private _negativeCurve;
  16691. private _globalHue;
  16692. private _globalDensity;
  16693. private _globalSaturation;
  16694. private _globalExposure;
  16695. /**
  16696. * Gets the global Hue value.
  16697. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  16698. */
  16699. /**
  16700. * Sets the global Hue value.
  16701. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  16702. */
  16703. globalHue: number;
  16704. /**
  16705. * Gets the global Density value.
  16706. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  16707. * Values less than zero provide a filter of opposite hue.
  16708. */
  16709. /**
  16710. * Sets the global Density value.
  16711. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  16712. * Values less than zero provide a filter of opposite hue.
  16713. */
  16714. globalDensity: number;
  16715. /**
  16716. * Gets the global Saturation value.
  16717. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16718. */
  16719. /**
  16720. * Sets the global Saturation value.
  16721. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16722. */
  16723. globalSaturation: number;
  16724. /**
  16725. * Gets the global Exposure value.
  16726. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16727. */
  16728. /**
  16729. * Sets the global Exposure value.
  16730. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16731. */
  16732. globalExposure: number;
  16733. private _highlightsHue;
  16734. private _highlightsDensity;
  16735. private _highlightsSaturation;
  16736. private _highlightsExposure;
  16737. /**
  16738. * Gets the highlights Hue value.
  16739. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  16740. */
  16741. /**
  16742. * Sets the highlights Hue value.
  16743. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  16744. */
  16745. highlightsHue: number;
  16746. /**
  16747. * Gets the highlights Density value.
  16748. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  16749. * Values less than zero provide a filter of opposite hue.
  16750. */
  16751. /**
  16752. * Sets the highlights Density value.
  16753. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  16754. * Values less than zero provide a filter of opposite hue.
  16755. */
  16756. highlightsDensity: number;
  16757. /**
  16758. * Gets the highlights Saturation value.
  16759. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16760. */
  16761. /**
  16762. * Sets the highlights Saturation value.
  16763. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16764. */
  16765. highlightsSaturation: number;
  16766. /**
  16767. * Gets the highlights Exposure value.
  16768. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16769. */
  16770. /**
  16771. * Sets the highlights Exposure value.
  16772. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  16773. */
  16774. highlightsExposure: number;
  16775. private _midtonesHue;
  16776. private _midtonesDensity;
  16777. private _midtonesSaturation;
  16778. private _midtonesExposure;
  16779. /**
  16780. * Gets the midtones Hue value.
  16781. * 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).
  16782. */
  16783. /**
  16784. * Sets the midtones Hue value.
  16785. * 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).
  16786. */
  16787. midtonesHue: number;
  16788. /**
  16789. * Gets the midtones Density value.
  16790. * 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.
  16791. * Values less than zero provide a filter of opposite hue.
  16792. */
  16793. /**
  16794. * Sets the midtones Density value.
  16795. * 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.
  16796. * Values less than zero provide a filter of opposite hue.
  16797. */
  16798. midtonesDensity: number;
  16799. /**
  16800. * Gets the midtones Saturation value.
  16801. * 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.
  16802. */
  16803. /**
  16804. * Sets the midtones Saturation value.
  16805. * 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.
  16806. */
  16807. midtonesSaturation: number;
  16808. /**
  16809. * Gets the midtones Exposure value.
  16810. * 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.
  16811. */
  16812. /**
  16813. * Sets the midtones Exposure value.
  16814. * 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.
  16815. */
  16816. midtonesExposure: number;
  16817. private _shadowsHue;
  16818. private _shadowsDensity;
  16819. private _shadowsSaturation;
  16820. private _shadowsExposure;
  16821. /**
  16822. * Gets the shadows Hue value.
  16823. * 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).
  16824. */
  16825. /**
  16826. * Sets the shadows Hue value.
  16827. * 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).
  16828. */
  16829. shadowsHue: number;
  16830. /**
  16831. * Gets the shadows Density value.
  16832. * 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.
  16833. * Values less than zero provide a filter of opposite hue.
  16834. */
  16835. /**
  16836. * Sets the shadows Density value.
  16837. * 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.
  16838. * Values less than zero provide a filter of opposite hue.
  16839. */
  16840. shadowsDensity: number;
  16841. /**
  16842. * Gets the shadows Saturation value.
  16843. * 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.
  16844. */
  16845. /**
  16846. * Sets the shadows Saturation value.
  16847. * 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.
  16848. */
  16849. shadowsSaturation: number;
  16850. /**
  16851. * Gets the shadows Exposure value.
  16852. * 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.
  16853. */
  16854. /**
  16855. * Sets the shadows Exposure value.
  16856. * 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.
  16857. */
  16858. shadowsExposure: number;
  16859. /**
  16860. * Returns the class name
  16861. * @returns The class name
  16862. */
  16863. getClassName(): string;
  16864. /**
  16865. * Binds the color curves to the shader.
  16866. * @param colorCurves The color curve to bind
  16867. * @param effect The effect to bind to
  16868. * @param positiveUniform The positive uniform shader parameter
  16869. * @param neutralUniform The neutral uniform shader parameter
  16870. * @param negativeUniform The negative uniform shader parameter
  16871. */
  16872. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16873. /**
  16874. * Prepare the list of uniforms associated with the ColorCurves effects.
  16875. * @param uniformsList The list of uniforms used in the effect
  16876. */
  16877. static PrepareUniforms(uniformsList: string[]): void;
  16878. /**
  16879. * Returns color grading data based on a hue, density, saturation and exposure value.
  16880. * @param filterHue The hue of the color filter.
  16881. * @param filterDensity The density of the color filter.
  16882. * @param saturation The saturation.
  16883. * @param exposure The exposure.
  16884. * @param result The result data container.
  16885. */
  16886. private getColorGradingDataToRef;
  16887. /**
  16888. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16889. * @param value The input slider value in range [-100,100].
  16890. * @returns Adjusted value.
  16891. */
  16892. private static applyColorGradingSliderNonlinear;
  16893. /**
  16894. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16895. * @param hue The hue (H) input.
  16896. * @param saturation The saturation (S) input.
  16897. * @param brightness The brightness (B) input.
  16898. * @result An RGBA color represented as Vector4.
  16899. */
  16900. private static fromHSBToRef;
  16901. /**
  16902. * Returns a value clamped between min and max
  16903. * @param value The value to clamp
  16904. * @param min The minimum of value
  16905. * @param max The maximum of value
  16906. * @returns The clamped value.
  16907. */
  16908. private static clamp;
  16909. /**
  16910. * Clones the current color curve instance.
  16911. * @return The cloned curves
  16912. */
  16913. clone(): ColorCurves;
  16914. /**
  16915. * Serializes the current color curve instance to a json representation.
  16916. * @return a JSON representation
  16917. */
  16918. serialize(): any;
  16919. /**
  16920. * Parses the color curve from a json representation.
  16921. * @param source the JSON source to parse
  16922. * @return The parsed curves
  16923. */
  16924. static Parse(source: any): ColorCurves;
  16925. }
  16926. }
  16927. declare module BABYLON {
  16928. /**
  16929. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16930. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16931. */
  16932. class EffectFallbacks {
  16933. private _defines;
  16934. private _currentRank;
  16935. private _maxRank;
  16936. private _mesh;
  16937. /**
  16938. * Removes the fallback from the bound mesh.
  16939. */
  16940. unBindMesh(): void;
  16941. /**
  16942. * Adds a fallback on the specified property.
  16943. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16944. * @param define The name of the define in the shader
  16945. */
  16946. addFallback(rank: number, define: string): void;
  16947. /**
  16948. * Sets the mesh to use CPU skinning when needing to fallback.
  16949. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16950. * @param mesh The mesh to use the fallbacks.
  16951. */
  16952. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16953. /**
  16954. * Checks to see if more fallbacks are still availible.
  16955. */
  16956. readonly isMoreFallbacks: boolean;
  16957. /**
  16958. * Removes the defines that shoould be removed when falling back.
  16959. * @param currentDefines defines the current define statements for the shader.
  16960. * @param effect defines the current effect we try to compile
  16961. * @returns The resulting defines with defines of the current rank removed.
  16962. */
  16963. reduce(currentDefines: string, effect: Effect): string;
  16964. }
  16965. /**
  16966. * Options to be used when creating an effect.
  16967. */
  16968. class EffectCreationOptions {
  16969. /**
  16970. * Atrributes that will be used in the shader.
  16971. */
  16972. attributes: string[];
  16973. /**
  16974. * Uniform varible names that will be set in the shader.
  16975. */
  16976. uniformsNames: string[];
  16977. /**
  16978. * Uniform buffer varible names that will be set in the shader.
  16979. */
  16980. uniformBuffersNames: string[];
  16981. /**
  16982. * Sampler texture variable names that will be set in the shader.
  16983. */
  16984. samplers: string[];
  16985. /**
  16986. * Define statements that will be set in the shader.
  16987. */
  16988. defines: any;
  16989. /**
  16990. * Possible fallbacks for this effect to improve performance when needed.
  16991. */
  16992. fallbacks: Nullable<EffectFallbacks>;
  16993. /**
  16994. * Callback that will be called when the shader is compiled.
  16995. */
  16996. onCompiled: Nullable<(effect: Effect) => void>;
  16997. /**
  16998. * Callback that will be called if an error occurs during shader compilation.
  16999. */
  17000. onError: Nullable<(effect: Effect, errors: string) => void>;
  17001. /**
  17002. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17003. */
  17004. indexParameters: any;
  17005. /**
  17006. * Max number of lights that can be used in the shader.
  17007. */
  17008. maxSimultaneousLights: number;
  17009. /**
  17010. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17011. */
  17012. transformFeedbackVaryings: Nullable<string[]>;
  17013. }
  17014. /**
  17015. * Effect containing vertex and fragment shader that can be executed on an object.
  17016. */
  17017. class Effect {
  17018. /**
  17019. * Name of the effect.
  17020. */
  17021. name: any;
  17022. /**
  17023. * String container all the define statements that should be set on the shader.
  17024. */
  17025. defines: string;
  17026. /**
  17027. * Callback that will be called when the shader is compiled.
  17028. */
  17029. onCompiled: Nullable<(effect: Effect) => void>;
  17030. /**
  17031. * Callback that will be called if an error occurs during shader compilation.
  17032. */
  17033. onError: Nullable<(effect: Effect, errors: string) => void>;
  17034. /**
  17035. * Callback that will be called when effect is bound.
  17036. */
  17037. onBind: Nullable<(effect: Effect) => void>;
  17038. /**
  17039. * Unique ID of the effect.
  17040. */
  17041. uniqueId: number;
  17042. /**
  17043. * Observable that will be called when the shader is compiled.
  17044. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17045. */
  17046. onCompileObservable: Observable<Effect>;
  17047. /**
  17048. * Observable that will be called if an error occurs during shader compilation.
  17049. */
  17050. onErrorObservable: Observable<Effect>;
  17051. /** @hidden */
  17052. _onBindObservable: Nullable<Observable<Effect>>;
  17053. /**
  17054. * Observable that will be called when effect is bound.
  17055. */
  17056. readonly onBindObservable: Observable<Effect>;
  17057. /** @hidden */
  17058. _bonesComputationForcedToCPU: boolean;
  17059. private static _uniqueIdSeed;
  17060. private _engine;
  17061. private _uniformBuffersNames;
  17062. private _uniformsNames;
  17063. private _samplers;
  17064. private _isReady;
  17065. private _compilationError;
  17066. private _attributesNames;
  17067. private _attributes;
  17068. private _uniforms;
  17069. /**
  17070. * Key for the effect.
  17071. * @hidden
  17072. */
  17073. _key: string;
  17074. private _indexParameters;
  17075. private _fallbacks;
  17076. private _vertexSourceCode;
  17077. private _fragmentSourceCode;
  17078. private _vertexSourceCodeOverride;
  17079. private _fragmentSourceCodeOverride;
  17080. private _transformFeedbackVaryings;
  17081. /**
  17082. * Compiled shader to webGL program.
  17083. * @hidden
  17084. */
  17085. _program: WebGLProgram;
  17086. private _valueCache;
  17087. private static _baseCache;
  17088. /**
  17089. * Instantiates an effect.
  17090. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17091. * @param baseName Name of the effect.
  17092. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17093. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17094. * @param samplers List of sampler variables that will be passed to the shader.
  17095. * @param engine Engine to be used to render the effect
  17096. * @param defines Define statements to be added to the shader.
  17097. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17098. * @param onCompiled Callback that will be called when the shader is compiled.
  17099. * @param onError Callback that will be called if an error occurs during shader compilation.
  17100. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17101. */
  17102. 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);
  17103. /**
  17104. * Unique key for this effect
  17105. */
  17106. readonly key: string;
  17107. /**
  17108. * If the effect has been compiled and prepared.
  17109. * @returns if the effect is compiled and prepared.
  17110. */
  17111. isReady(): boolean;
  17112. /**
  17113. * The engine the effect was initialized with.
  17114. * @returns the engine.
  17115. */
  17116. getEngine(): Engine;
  17117. /**
  17118. * The compiled webGL program for the effect
  17119. * @returns the webGL program.
  17120. */
  17121. getProgram(): WebGLProgram;
  17122. /**
  17123. * The set of names of attribute variables for the shader.
  17124. * @returns An array of attribute names.
  17125. */
  17126. getAttributesNames(): string[];
  17127. /**
  17128. * Returns the attribute at the given index.
  17129. * @param index The index of the attribute.
  17130. * @returns The location of the attribute.
  17131. */
  17132. getAttributeLocation(index: number): number;
  17133. /**
  17134. * Returns the attribute based on the name of the variable.
  17135. * @param name of the attribute to look up.
  17136. * @returns the attribute location.
  17137. */
  17138. getAttributeLocationByName(name: string): number;
  17139. /**
  17140. * The number of attributes.
  17141. * @returns the numnber of attributes.
  17142. */
  17143. getAttributesCount(): number;
  17144. /**
  17145. * Gets the index of a uniform variable.
  17146. * @param uniformName of the uniform to look up.
  17147. * @returns the index.
  17148. */
  17149. getUniformIndex(uniformName: string): number;
  17150. /**
  17151. * Returns the attribute based on the name of the variable.
  17152. * @param uniformName of the uniform to look up.
  17153. * @returns the location of the uniform.
  17154. */
  17155. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17156. /**
  17157. * Returns an array of sampler variable names
  17158. * @returns The array of sampler variable neames.
  17159. */
  17160. getSamplers(): string[];
  17161. /**
  17162. * The error from the last compilation.
  17163. * @returns the error string.
  17164. */
  17165. getCompilationError(): string;
  17166. /**
  17167. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17168. * @param func The callback to be used.
  17169. */
  17170. executeWhenCompiled(func: (effect: Effect) => void): void;
  17171. private _checkIsReady;
  17172. /** @hidden */
  17173. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17174. /** @hidden */
  17175. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17176. /** @hidden */
  17177. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17178. private _processShaderConversion;
  17179. private _processIncludes;
  17180. private _processPrecision;
  17181. /**
  17182. * Recompiles the webGL program
  17183. * @param vertexSourceCode The source code for the vertex shader.
  17184. * @param fragmentSourceCode The source code for the fragment shader.
  17185. * @param onCompiled Callback called when completed.
  17186. * @param onError Callback called on error.
  17187. * @hidden
  17188. */
  17189. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17190. /**
  17191. * Gets the uniform locations of the the specified variable names
  17192. * @param names THe names of the variables to lookup.
  17193. * @returns Array of locations in the same order as variable names.
  17194. */
  17195. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17196. /**
  17197. * Prepares the effect
  17198. * @hidden
  17199. */
  17200. _prepareEffect(): void;
  17201. /**
  17202. * Checks if the effect is supported. (Must be called after compilation)
  17203. */
  17204. readonly isSupported: boolean;
  17205. /**
  17206. * Binds a texture to the engine to be used as output of the shader.
  17207. * @param channel Name of the output variable.
  17208. * @param texture Texture to bind.
  17209. * @hidden
  17210. */
  17211. _bindTexture(channel: string, texture: InternalTexture): void;
  17212. /**
  17213. * Sets a texture on the engine to be used in the shader.
  17214. * @param channel Name of the sampler variable.
  17215. * @param texture Texture to set.
  17216. */
  17217. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17218. /**
  17219. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17220. * @param channel Name of the sampler variable.
  17221. * @param texture Texture to set.
  17222. */
  17223. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17224. /**
  17225. * Sets an array of textures on the engine to be used in the shader.
  17226. * @param channel Name of the variable.
  17227. * @param textures Textures to set.
  17228. */
  17229. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17230. /**
  17231. * 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)
  17232. * @param channel Name of the sampler variable.
  17233. * @param postProcess Post process to get the input texture from.
  17234. */
  17235. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17236. /**
  17237. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17238. * 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)
  17239. * @param channel Name of the sampler variable.
  17240. * @param postProcess Post process to get the output texture from.
  17241. */
  17242. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17243. /** @hidden */
  17244. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17245. /** @hidden */
  17246. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17247. /** @hidden */
  17248. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17249. /** @hidden */
  17250. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17251. /**
  17252. * Binds a buffer to a uniform.
  17253. * @param buffer Buffer to bind.
  17254. * @param name Name of the uniform variable to bind to.
  17255. */
  17256. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17257. /**
  17258. * Binds block to a uniform.
  17259. * @param blockName Name of the block to bind.
  17260. * @param index Index to bind.
  17261. */
  17262. bindUniformBlock(blockName: string, index: number): void;
  17263. /**
  17264. * Sets an interger value on a uniform variable.
  17265. * @param uniformName Name of the variable.
  17266. * @param value Value to be set.
  17267. * @returns this effect.
  17268. */
  17269. setInt(uniformName: string, value: number): Effect;
  17270. /**
  17271. * Sets an int 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. setIntArray(uniformName: string, array: Int32Array): Effect;
  17277. /**
  17278. * 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)
  17279. * @param uniformName Name of the variable.
  17280. * @param array array to be set.
  17281. * @returns this effect.
  17282. */
  17283. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17284. /**
  17285. * 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)
  17286. * @param uniformName Name of the variable.
  17287. * @param array array to be set.
  17288. * @returns this effect.
  17289. */
  17290. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17291. /**
  17292. * 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)
  17293. * @param uniformName Name of the variable.
  17294. * @param array array to be set.
  17295. * @returns this effect.
  17296. */
  17297. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17298. /**
  17299. * Sets an float array on a uniform variable.
  17300. * @param uniformName Name of the variable.
  17301. * @param array array to be set.
  17302. * @returns this effect.
  17303. */
  17304. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17305. /**
  17306. * 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)
  17307. * @param uniformName Name of the variable.
  17308. * @param array array to be set.
  17309. * @returns this effect.
  17310. */
  17311. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17312. /**
  17313. * 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)
  17314. * @param uniformName Name of the variable.
  17315. * @param array array to be set.
  17316. * @returns this effect.
  17317. */
  17318. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17319. /**
  17320. * 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)
  17321. * @param uniformName Name of the variable.
  17322. * @param array array to be set.
  17323. * @returns this effect.
  17324. */
  17325. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17326. /**
  17327. * Sets an array on a uniform variable.
  17328. * @param uniformName Name of the variable.
  17329. * @param array array to be set.
  17330. * @returns this effect.
  17331. */
  17332. setArray(uniformName: string, array: number[]): Effect;
  17333. /**
  17334. * 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)
  17335. * @param uniformName Name of the variable.
  17336. * @param array array to be set.
  17337. * @returns this effect.
  17338. */
  17339. setArray2(uniformName: string, array: number[]): Effect;
  17340. /**
  17341. * 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)
  17342. * @param uniformName Name of the variable.
  17343. * @param array array to be set.
  17344. * @returns this effect.
  17345. */
  17346. setArray3(uniformName: string, array: number[]): Effect;
  17347. /**
  17348. * 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)
  17349. * @param uniformName Name of the variable.
  17350. * @param array array to be set.
  17351. * @returns this effect.
  17352. */
  17353. setArray4(uniformName: string, array: number[]): Effect;
  17354. /**
  17355. * Sets matrices on a uniform variable.
  17356. * @param uniformName Name of the variable.
  17357. * @param matrices matrices to be set.
  17358. * @returns this effect.
  17359. */
  17360. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17361. /**
  17362. * Sets matrix on a uniform variable.
  17363. * @param uniformName Name of the variable.
  17364. * @param matrix matrix to be set.
  17365. * @returns this effect.
  17366. */
  17367. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17368. /**
  17369. * 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)
  17370. * @param uniformName Name of the variable.
  17371. * @param matrix matrix to be set.
  17372. * @returns this effect.
  17373. */
  17374. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17375. /**
  17376. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17377. * @param uniformName Name of the variable.
  17378. * @param matrix matrix to be set.
  17379. * @returns this effect.
  17380. */
  17381. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17382. /**
  17383. * Sets a float on a uniform variable.
  17384. * @param uniformName Name of the variable.
  17385. * @param value value to be set.
  17386. * @returns this effect.
  17387. */
  17388. setFloat(uniformName: string, value: number): Effect;
  17389. /**
  17390. * Sets a boolean on a uniform variable.
  17391. * @param uniformName Name of the variable.
  17392. * @param bool value to be set.
  17393. * @returns this effect.
  17394. */
  17395. setBool(uniformName: string, bool: boolean): Effect;
  17396. /**
  17397. * Sets a Vector2 on a uniform variable.
  17398. * @param uniformName Name of the variable.
  17399. * @param vector2 vector2 to be set.
  17400. * @returns this effect.
  17401. */
  17402. setVector2(uniformName: string, vector2: Vector2): Effect;
  17403. /**
  17404. * Sets a float2 on a uniform variable.
  17405. * @param uniformName Name of the variable.
  17406. * @param x First float in float2.
  17407. * @param y Second float in float2.
  17408. * @returns this effect.
  17409. */
  17410. setFloat2(uniformName: string, x: number, y: number): Effect;
  17411. /**
  17412. * Sets a Vector3 on a uniform variable.
  17413. * @param uniformName Name of the variable.
  17414. * @param vector3 Value to be set.
  17415. * @returns this effect.
  17416. */
  17417. setVector3(uniformName: string, vector3: Vector3): Effect;
  17418. /**
  17419. * Sets a float3 on a uniform variable.
  17420. * @param uniformName Name of the variable.
  17421. * @param x First float in float3.
  17422. * @param y Second float in float3.
  17423. * @param z Third float in float3.
  17424. * @returns this effect.
  17425. */
  17426. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17427. /**
  17428. * Sets a Vector4 on a uniform variable.
  17429. * @param uniformName Name of the variable.
  17430. * @param vector4 Value to be set.
  17431. * @returns this effect.
  17432. */
  17433. setVector4(uniformName: string, vector4: Vector4): Effect;
  17434. /**
  17435. * Sets a float4 on a uniform variable.
  17436. * @param uniformName Name of the variable.
  17437. * @param x First float in float4.
  17438. * @param y Second float in float4.
  17439. * @param z Third float in float4.
  17440. * @param w Fourth float in float4.
  17441. * @returns this effect.
  17442. */
  17443. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17444. /**
  17445. * Sets a Color3 on a uniform variable.
  17446. * @param uniformName Name of the variable.
  17447. * @param color3 Value to be set.
  17448. * @returns this effect.
  17449. */
  17450. setColor3(uniformName: string, color3: Color3): Effect;
  17451. /**
  17452. * Sets a Color4 on a uniform variable.
  17453. * @param uniformName Name of the variable.
  17454. * @param color3 Value to be set.
  17455. * @param alpha Alpha value to be set.
  17456. * @returns this effect.
  17457. */
  17458. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17459. /**
  17460. * Sets a Color4 on a uniform variable
  17461. * @param uniformName defines the name of the variable
  17462. * @param color4 defines the value to be set
  17463. * @returns this effect.
  17464. */
  17465. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17466. /**
  17467. * This function will add a new shader to the shader store
  17468. * @param name the name of the shader
  17469. * @param pixelShader optional pixel shader content
  17470. * @param vertexShader optional vertex shader content
  17471. */
  17472. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17473. /**
  17474. * Store of each shader (The can be looked up using effect.key)
  17475. */
  17476. static ShadersStore: {
  17477. [key: string]: string;
  17478. };
  17479. /**
  17480. * Store of each included file for a shader (The can be looked up using effect.key)
  17481. */
  17482. static IncludesShadersStore: {
  17483. [key: string]: string;
  17484. };
  17485. /**
  17486. * Resets the cache of effects.
  17487. */
  17488. static ResetCache(): void;
  17489. }
  17490. }
  17491. declare module BABYLON {
  17492. /**
  17493. * This represents all the required information to add a fresnel effect on a material:
  17494. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17495. */
  17496. class FresnelParameters {
  17497. private _isEnabled;
  17498. /**
  17499. * Define if the fresnel effect is enable or not.
  17500. */
  17501. isEnabled: boolean;
  17502. /**
  17503. * Define the color used on edges (grazing angle)
  17504. */
  17505. leftColor: Color3;
  17506. /**
  17507. * Define the color used on center
  17508. */
  17509. rightColor: Color3;
  17510. /**
  17511. * Define bias applied to computed fresnel term
  17512. */
  17513. bias: number;
  17514. /**
  17515. * Defined the power exponent applied to fresnel term
  17516. */
  17517. power: number;
  17518. /**
  17519. * Clones the current fresnel and its valuues
  17520. * @returns a clone fresnel configuration
  17521. */
  17522. clone(): FresnelParameters;
  17523. /**
  17524. * Serializes the current fresnel parameters to a JSON representation.
  17525. * @return the JSON serialization
  17526. */
  17527. serialize(): any;
  17528. /**
  17529. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17530. * @param parsedFresnelParameters Define the JSON representation
  17531. * @returns the parsed parameters
  17532. */
  17533. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17534. }
  17535. }
  17536. declare module BABYLON {
  17537. /**
  17538. * Interface to follow in your material defines to integrate easily the
  17539. * Image proccessing functions.
  17540. * @hidden
  17541. */
  17542. interface IImageProcessingConfigurationDefines {
  17543. IMAGEPROCESSING: boolean;
  17544. VIGNETTE: boolean;
  17545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17546. VIGNETTEBLENDMODEOPAQUE: boolean;
  17547. TONEMAPPING: boolean;
  17548. TONEMAPPING_ACES: boolean;
  17549. CONTRAST: boolean;
  17550. EXPOSURE: boolean;
  17551. COLORCURVES: boolean;
  17552. COLORGRADING: boolean;
  17553. COLORGRADING3D: boolean;
  17554. SAMPLER3DGREENDEPTH: boolean;
  17555. SAMPLER3DBGRMAP: boolean;
  17556. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17557. }
  17558. /**
  17559. * @hidden
  17560. */
  17561. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17562. IMAGEPROCESSING: boolean;
  17563. VIGNETTE: boolean;
  17564. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17565. VIGNETTEBLENDMODEOPAQUE: boolean;
  17566. TONEMAPPING: boolean;
  17567. TONEMAPPING_ACES: boolean;
  17568. CONTRAST: boolean;
  17569. COLORCURVES: boolean;
  17570. COLORGRADING: boolean;
  17571. COLORGRADING3D: boolean;
  17572. SAMPLER3DGREENDEPTH: boolean;
  17573. SAMPLER3DBGRMAP: boolean;
  17574. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17575. EXPOSURE: boolean;
  17576. constructor();
  17577. }
  17578. /**
  17579. * This groups together the common properties used for image processing either in direct forward pass
  17580. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17581. * or not.
  17582. */
  17583. class ImageProcessingConfiguration {
  17584. /**
  17585. * Default tone mapping applied in BabylonJS.
  17586. */
  17587. static readonly TONEMAPPING_STANDARD: number;
  17588. /**
  17589. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17590. * to other engines rendering to increase portability.
  17591. */
  17592. static readonly TONEMAPPING_ACES: number;
  17593. /**
  17594. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17595. */
  17596. colorCurves: Nullable<ColorCurves>;
  17597. private _colorCurvesEnabled;
  17598. /**
  17599. * Gets wether the color curves effect is enabled.
  17600. */
  17601. /**
  17602. * Sets wether the color curves effect is enabled.
  17603. */
  17604. colorCurvesEnabled: boolean;
  17605. private _colorGradingTexture;
  17606. /**
  17607. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17608. */
  17609. /**
  17610. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17611. */
  17612. colorGradingTexture: Nullable<BaseTexture>;
  17613. private _colorGradingEnabled;
  17614. /**
  17615. * Gets wether the color grading effect is enabled.
  17616. */
  17617. /**
  17618. * Sets wether the color grading effect is enabled.
  17619. */
  17620. colorGradingEnabled: boolean;
  17621. private _colorGradingWithGreenDepth;
  17622. /**
  17623. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17624. */
  17625. /**
  17626. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17627. */
  17628. colorGradingWithGreenDepth: boolean;
  17629. private _colorGradingBGR;
  17630. /**
  17631. * Gets wether the color grading texture contains BGR values.
  17632. */
  17633. /**
  17634. * Sets wether the color grading texture contains BGR values.
  17635. */
  17636. colorGradingBGR: boolean;
  17637. /** @hidden */
  17638. _exposure: number;
  17639. /**
  17640. * Gets the Exposure used in the effect.
  17641. */
  17642. /**
  17643. * Sets the Exposure used in the effect.
  17644. */
  17645. exposure: number;
  17646. private _toneMappingEnabled;
  17647. /**
  17648. * Gets wether the tone mapping effect is enabled.
  17649. */
  17650. /**
  17651. * Sets wether the tone mapping effect is enabled.
  17652. */
  17653. toneMappingEnabled: boolean;
  17654. private _toneMappingType;
  17655. /**
  17656. * Gets the type of tone mapping effect.
  17657. */
  17658. /**
  17659. * Sets the type of tone mapping effect used in BabylonJS.
  17660. */
  17661. toneMappingType: number;
  17662. protected _contrast: number;
  17663. /**
  17664. * Gets the contrast used in the effect.
  17665. */
  17666. /**
  17667. * Sets the contrast used in the effect.
  17668. */
  17669. contrast: number;
  17670. /**
  17671. * Vignette stretch size.
  17672. */
  17673. vignetteStretch: number;
  17674. /**
  17675. * Vignette centre X Offset.
  17676. */
  17677. vignetteCentreX: number;
  17678. /**
  17679. * Vignette centre Y Offset.
  17680. */
  17681. vignetteCentreY: number;
  17682. /**
  17683. * Vignette weight or intensity of the vignette effect.
  17684. */
  17685. vignetteWeight: number;
  17686. /**
  17687. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17688. * if vignetteEnabled is set to true.
  17689. */
  17690. vignetteColor: Color4;
  17691. /**
  17692. * Camera field of view used by the Vignette effect.
  17693. */
  17694. vignetteCameraFov: number;
  17695. private _vignetteBlendMode;
  17696. /**
  17697. * Gets the vignette blend mode allowing different kind of effect.
  17698. */
  17699. /**
  17700. * Sets the vignette blend mode allowing different kind of effect.
  17701. */
  17702. vignetteBlendMode: number;
  17703. private _vignetteEnabled;
  17704. /**
  17705. * Gets wether the vignette effect is enabled.
  17706. */
  17707. /**
  17708. * Sets wether the vignette effect is enabled.
  17709. */
  17710. vignetteEnabled: boolean;
  17711. private _applyByPostProcess;
  17712. /**
  17713. * Gets wether the image processing is applied through a post process or not.
  17714. */
  17715. /**
  17716. * Sets wether the image processing is applied through a post process or not.
  17717. */
  17718. applyByPostProcess: boolean;
  17719. private _isEnabled;
  17720. /**
  17721. * Gets wether the image processing is enabled or not.
  17722. */
  17723. /**
  17724. * Sets wether the image processing is enabled or not.
  17725. */
  17726. isEnabled: boolean;
  17727. /**
  17728. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17729. */
  17730. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17731. /**
  17732. * Method called each time the image processing information changes requires to recompile the effect.
  17733. */
  17734. protected _updateParameters(): void;
  17735. /**
  17736. * Gets the current class name.
  17737. * @return "ImageProcessingConfiguration"
  17738. */
  17739. getClassName(): string;
  17740. /**
  17741. * Prepare the list of uniforms associated with the Image Processing effects.
  17742. * @param uniforms The list of uniforms used in the effect
  17743. * @param defines the list of defines currently in use
  17744. */
  17745. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17746. /**
  17747. * Prepare the list of samplers associated with the Image Processing effects.
  17748. * @param samplersList The list of uniforms used in the effect
  17749. * @param defines the list of defines currently in use
  17750. */
  17751. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17752. /**
  17753. * Prepare the list of defines associated to the shader.
  17754. * @param defines the list of defines to complete
  17755. * @param forPostProcess Define if we are currently in post process mode or not
  17756. */
  17757. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17758. /**
  17759. * Returns true if all the image processing information are ready.
  17760. * @returns True if ready, otherwise, false
  17761. */
  17762. isReady(): boolean;
  17763. /**
  17764. * Binds the image processing to the shader.
  17765. * @param effect The effect to bind to
  17766. * @param aspectRatio Define the current aspect ratio of the effect
  17767. */
  17768. bind(effect: Effect, aspectRatio?: number): void;
  17769. /**
  17770. * Clones the current image processing instance.
  17771. * @return The cloned image processing
  17772. */
  17773. clone(): ImageProcessingConfiguration;
  17774. /**
  17775. * Serializes the current image processing instance to a json representation.
  17776. * @return a JSON representation
  17777. */
  17778. serialize(): any;
  17779. /**
  17780. * Parses the image processing from a json representation.
  17781. * @param source the JSON source to parse
  17782. * @return The parsed image processing
  17783. */
  17784. static Parse(source: any): ImageProcessingConfiguration;
  17785. private static _VIGNETTEMODE_MULTIPLY;
  17786. private static _VIGNETTEMODE_OPAQUE;
  17787. /**
  17788. * Used to apply the vignette as a mix with the pixel color.
  17789. */
  17790. static readonly VIGNETTEMODE_MULTIPLY: number;
  17791. /**
  17792. * Used to apply the vignette as a replacement of the pixel color.
  17793. */
  17794. static readonly VIGNETTEMODE_OPAQUE: number;
  17795. }
  17796. }
  17797. declare module BABYLON {
  17798. /**
  17799. * Manages the defines for the Material
  17800. */
  17801. class MaterialDefines {
  17802. private _keys;
  17803. private _isDirty;
  17804. /** @hidden */
  17805. _renderId: number;
  17806. /** @hidden */
  17807. _areLightsDirty: boolean;
  17808. /** @hidden */
  17809. _areAttributesDirty: boolean;
  17810. /** @hidden */
  17811. _areTexturesDirty: boolean;
  17812. /** @hidden */
  17813. _areFresnelDirty: boolean;
  17814. /** @hidden */
  17815. _areMiscDirty: boolean;
  17816. /** @hidden */
  17817. _areImageProcessingDirty: boolean;
  17818. /** @hidden */
  17819. _normals: boolean;
  17820. /** @hidden */
  17821. _uvs: boolean;
  17822. /** @hidden */
  17823. _needNormals: boolean;
  17824. /** @hidden */
  17825. _needUVs: boolean;
  17826. /**
  17827. * Specifies if the material needs to be re-calculated
  17828. */
  17829. readonly isDirty: boolean;
  17830. /**
  17831. * Marks the material to indicate that it has been re-calculated
  17832. */
  17833. markAsProcessed(): void;
  17834. /**
  17835. * Marks the material to indicate that it needs to be re-calculated
  17836. */
  17837. markAsUnprocessed(): void;
  17838. /**
  17839. * Marks the material to indicate all of its defines need to be re-calculated
  17840. */
  17841. markAllAsDirty(): void;
  17842. /**
  17843. * Marks the material to indicate that image processing needs to be re-calculated
  17844. */
  17845. markAsImageProcessingDirty(): void;
  17846. /**
  17847. * Marks the material to indicate the lights need to be re-calculated
  17848. */
  17849. markAsLightDirty(): void;
  17850. /**
  17851. * Marks the attribute state as changed
  17852. */
  17853. markAsAttributesDirty(): void;
  17854. /**
  17855. * Marks the texture state as changed
  17856. */
  17857. markAsTexturesDirty(): void;
  17858. /**
  17859. * Marks the fresnel state as changed
  17860. */
  17861. markAsFresnelDirty(): void;
  17862. /**
  17863. * Marks the misc state as changed
  17864. */
  17865. markAsMiscDirty(): void;
  17866. /**
  17867. * Rebuilds the material defines
  17868. */
  17869. rebuild(): void;
  17870. /**
  17871. * Specifies if two material defines are equal
  17872. * @param other - A material define instance to compare to
  17873. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17874. */
  17875. isEqual(other: MaterialDefines): boolean;
  17876. /**
  17877. * Clones this instance's defines to another instance
  17878. * @param other - material defines to clone values to
  17879. */
  17880. cloneTo(other: MaterialDefines): void;
  17881. /**
  17882. * Resets the material define values
  17883. */
  17884. reset(): void;
  17885. /**
  17886. * Converts the material define values to a string
  17887. * @returns - String of material define information
  17888. */
  17889. toString(): string;
  17890. }
  17891. /**
  17892. * Base class for the main features of a material in Babylon.js
  17893. */
  17894. class Material implements IAnimatable {
  17895. private static _TriangleFillMode;
  17896. private static _WireFrameFillMode;
  17897. private static _PointFillMode;
  17898. private static _PointListDrawMode;
  17899. private static _LineListDrawMode;
  17900. private static _LineLoopDrawMode;
  17901. private static _LineStripDrawMode;
  17902. private static _TriangleStripDrawMode;
  17903. private static _TriangleFanDrawMode;
  17904. /**
  17905. * Returns the triangle fill mode
  17906. */
  17907. static readonly TriangleFillMode: number;
  17908. /**
  17909. * Returns the wireframe mode
  17910. */
  17911. static readonly WireFrameFillMode: number;
  17912. /**
  17913. * Returns the point fill mode
  17914. */
  17915. static readonly PointFillMode: number;
  17916. /**
  17917. * Returns the point list draw mode
  17918. */
  17919. static readonly PointListDrawMode: number;
  17920. /**
  17921. * Returns the line list draw mode
  17922. */
  17923. static readonly LineListDrawMode: number;
  17924. /**
  17925. * Returns the line loop draw mode
  17926. */
  17927. static readonly LineLoopDrawMode: number;
  17928. /**
  17929. * Returns the line strip draw mode
  17930. */
  17931. static readonly LineStripDrawMode: number;
  17932. /**
  17933. * Returns the triangle strip draw mode
  17934. */
  17935. static readonly TriangleStripDrawMode: number;
  17936. /**
  17937. * Returns the triangle fan draw mode
  17938. */
  17939. static readonly TriangleFanDrawMode: number;
  17940. /**
  17941. * Stores the clock-wise side orientation
  17942. */
  17943. private static _ClockWiseSideOrientation;
  17944. /**
  17945. * Stores the counter clock-wise side orientation
  17946. */
  17947. private static _CounterClockWiseSideOrientation;
  17948. /**
  17949. * Returns the clock-wise side orientation
  17950. */
  17951. static readonly ClockWiseSideOrientation: number;
  17952. /**
  17953. * Returns the counter clock-wise side orientation
  17954. */
  17955. static readonly CounterClockWiseSideOrientation: number;
  17956. /**
  17957. * The dirty texture flag value
  17958. */
  17959. static readonly TextureDirtyFlag: number;
  17960. /**
  17961. * The dirty light flag value
  17962. */
  17963. static readonly LightDirtyFlag: number;
  17964. /**
  17965. * The dirty fresnel flag value
  17966. */
  17967. static readonly FresnelDirtyFlag: number;
  17968. /**
  17969. * The dirty attribute flag value
  17970. */
  17971. static readonly AttributesDirtyFlag: number;
  17972. /**
  17973. * The dirty misc flag value
  17974. */
  17975. static readonly MiscDirtyFlag: number;
  17976. /**
  17977. * The all dirty flag value
  17978. */
  17979. static readonly AllDirtyFlag: number;
  17980. /**
  17981. * The ID of the material
  17982. */
  17983. id: string;
  17984. /**
  17985. * Gets or sets the unique id of the material
  17986. */
  17987. uniqueId: number;
  17988. /**
  17989. * The name of the material
  17990. */
  17991. name: string;
  17992. /**
  17993. * Specifies if the ready state should be checked on each call
  17994. */
  17995. checkReadyOnEveryCall: boolean;
  17996. /**
  17997. * Specifies if the ready state should be checked once
  17998. */
  17999. checkReadyOnlyOnce: boolean;
  18000. /**
  18001. * The state of the material
  18002. */
  18003. state: string;
  18004. /**
  18005. * The alpha value of the material
  18006. */
  18007. protected _alpha: number;
  18008. /**
  18009. * Sets the alpha value of the material
  18010. */
  18011. /**
  18012. * Gets the alpha value of the material
  18013. */
  18014. alpha: number;
  18015. /**
  18016. * Specifies if back face culling is enabled
  18017. */
  18018. protected _backFaceCulling: boolean;
  18019. /**
  18020. * Sets the back-face culling state
  18021. */
  18022. /**
  18023. * Gets the back-face culling state
  18024. */
  18025. backFaceCulling: boolean;
  18026. /**
  18027. * Stores the value for side orientation
  18028. */
  18029. sideOrientation: number;
  18030. /**
  18031. * Callback triggered when the material is compiled
  18032. */
  18033. onCompiled: (effect: Effect) => void;
  18034. /**
  18035. * Callback triggered when an error occurs
  18036. */
  18037. onError: (effect: Effect, errors: string) => void;
  18038. /**
  18039. * Callback triggered to get the render target textures
  18040. */
  18041. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18042. /**
  18043. * Gets a boolean indicating that current material needs to register RTT
  18044. */
  18045. readonly hasRenderTargetTextures: boolean;
  18046. /**
  18047. * Specifies if the material should be serialized
  18048. */
  18049. doNotSerialize: boolean;
  18050. /**
  18051. * @hidden
  18052. */
  18053. _storeEffectOnSubMeshes: boolean;
  18054. /**
  18055. * Stores the animations for the material
  18056. */
  18057. animations: Array<Animation>;
  18058. /**
  18059. * An event triggered when the material is disposed
  18060. */
  18061. onDisposeObservable: Observable<Material>;
  18062. /**
  18063. * An observer which watches for dispose events
  18064. */
  18065. private _onDisposeObserver;
  18066. private _onUnBindObservable;
  18067. /**
  18068. * Called during a dispose event
  18069. */
  18070. onDispose: () => void;
  18071. private _onBindObservable;
  18072. /**
  18073. * An event triggered when the material is bound
  18074. */
  18075. readonly onBindObservable: Observable<AbstractMesh>;
  18076. /**
  18077. * An observer which watches for bind events
  18078. */
  18079. private _onBindObserver;
  18080. /**
  18081. * Called during a bind event
  18082. */
  18083. onBind: (Mesh: AbstractMesh) => void;
  18084. /**
  18085. * An event triggered when the material is unbound
  18086. */
  18087. readonly onUnBindObservable: Observable<Material>;
  18088. /**
  18089. * Stores the value of the alpha mode
  18090. */
  18091. private _alphaMode;
  18092. /**
  18093. * Sets the value of the alpha mode.
  18094. *
  18095. * | Value | Type | Description |
  18096. * | --- | --- | --- |
  18097. * | 0 | ALPHA_DISABLE | |
  18098. * | 1 | ALPHA_ADD | |
  18099. * | 2 | ALPHA_COMBINE | |
  18100. * | 3 | ALPHA_SUBTRACT | |
  18101. * | 4 | ALPHA_MULTIPLY | |
  18102. * | 5 | ALPHA_MAXIMIZED | |
  18103. * | 6 | ALPHA_ONEONE | |
  18104. * | 7 | ALPHA_PREMULTIPLIED | |
  18105. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18106. * | 9 | ALPHA_INTERPOLATE | |
  18107. * | 10 | ALPHA_SCREENMODE | |
  18108. *
  18109. */
  18110. /**
  18111. * Gets the value of the alpha mode
  18112. */
  18113. alphaMode: number;
  18114. /**
  18115. * Stores the state of the need depth pre-pass value
  18116. */
  18117. private _needDepthPrePass;
  18118. /**
  18119. * Sets the need depth pre-pass value
  18120. */
  18121. /**
  18122. * Gets the depth pre-pass value
  18123. */
  18124. needDepthPrePass: boolean;
  18125. /**
  18126. * Specifies if depth writing should be disabled
  18127. */
  18128. disableDepthWrite: boolean;
  18129. /**
  18130. * Specifies if depth writing should be forced
  18131. */
  18132. forceDepthWrite: boolean;
  18133. /**
  18134. * Specifies if there should be a separate pass for culling
  18135. */
  18136. separateCullingPass: boolean;
  18137. /**
  18138. * Stores the state specifing if fog should be enabled
  18139. */
  18140. private _fogEnabled;
  18141. /**
  18142. * Sets the state for enabling fog
  18143. */
  18144. /**
  18145. * Gets the value of the fog enabled state
  18146. */
  18147. fogEnabled: boolean;
  18148. /**
  18149. * Stores the size of points
  18150. */
  18151. pointSize: number;
  18152. /**
  18153. * Stores the z offset value
  18154. */
  18155. zOffset: number;
  18156. /**
  18157. * Gets a value specifying if wireframe mode is enabled
  18158. */
  18159. /**
  18160. * Sets the state of wireframe mode
  18161. */
  18162. wireframe: boolean;
  18163. /**
  18164. * Gets the value specifying if point clouds are enabled
  18165. */
  18166. /**
  18167. * Sets the state of point cloud mode
  18168. */
  18169. pointsCloud: boolean;
  18170. /**
  18171. * Gets the material fill mode
  18172. */
  18173. /**
  18174. * Sets the material fill mode
  18175. */
  18176. fillMode: number;
  18177. /**
  18178. * @hidden
  18179. * Stores the effects for the material
  18180. */
  18181. _effect: Nullable<Effect>;
  18182. /**
  18183. * @hidden
  18184. * Specifies if the material was previously ready
  18185. */
  18186. _wasPreviouslyReady: boolean;
  18187. /**
  18188. * Specifies if uniform buffers should be used
  18189. */
  18190. private _useUBO;
  18191. /**
  18192. * Stores a reference to the scene
  18193. */
  18194. private _scene;
  18195. /**
  18196. * Stores the fill mode state
  18197. */
  18198. private _fillMode;
  18199. /**
  18200. * Specifies if the depth write state should be cached
  18201. */
  18202. private _cachedDepthWriteState;
  18203. /**
  18204. * Stores the uniform buffer
  18205. */
  18206. protected _uniformBuffer: UniformBuffer;
  18207. /** @hidden */
  18208. _indexInSceneMaterialArray: number;
  18209. /** @hidden */
  18210. meshMap: Nullable<{
  18211. [id: string]: AbstractMesh | undefined;
  18212. }>;
  18213. /**
  18214. * Creates a material instance
  18215. * @param name defines the name of the material
  18216. * @param scene defines the scene to reference
  18217. * @param doNotAdd specifies if the material should be added to the scene
  18218. */
  18219. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18220. /**
  18221. * Returns a string representation of the current material
  18222. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18223. * @returns a string with material information
  18224. */
  18225. toString(fullDetails?: boolean): string;
  18226. /**
  18227. * Gets the class name of the material
  18228. * @returns a string with the class name of the material
  18229. */
  18230. getClassName(): string;
  18231. /**
  18232. * Specifies if updates for the material been locked
  18233. */
  18234. readonly isFrozen: boolean;
  18235. /**
  18236. * Locks updates for the material
  18237. */
  18238. freeze(): void;
  18239. /**
  18240. * Unlocks updates for the material
  18241. */
  18242. unfreeze(): void;
  18243. /**
  18244. * Specifies if the material is ready to be used
  18245. * @param mesh defines the mesh to check
  18246. * @param useInstances specifies if instances should be used
  18247. * @returns a boolean indicating if the material is ready to be used
  18248. */
  18249. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18250. /**
  18251. * Specifies that the submesh is ready to be used
  18252. * @param mesh defines the mesh to check
  18253. * @param subMesh defines which submesh to check
  18254. * @param useInstances specifies that instances should be used
  18255. * @returns a boolean indicating that the submesh is ready or not
  18256. */
  18257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18258. /**
  18259. * Returns the material effect
  18260. * @returns the effect associated with the material
  18261. */
  18262. getEffect(): Nullable<Effect>;
  18263. /**
  18264. * Returns the current scene
  18265. * @returns a Scene
  18266. */
  18267. getScene(): Scene;
  18268. /**
  18269. * Specifies if the material will require alpha blending
  18270. * @returns a boolean specifying if alpha blending is needed
  18271. */
  18272. needAlphaBlending(): boolean;
  18273. /**
  18274. * Specifies if the mesh will require alpha blending
  18275. * @param mesh defines the mesh to check
  18276. * @returns a boolean specifying if alpha blending is needed for the mesh
  18277. */
  18278. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18279. /**
  18280. * Specifies if this material should be rendered in alpha test mode
  18281. * @returns a boolean specifying if an alpha test is needed.
  18282. */
  18283. needAlphaTesting(): boolean;
  18284. /**
  18285. * Gets the texture used for the alpha test
  18286. * @returns the texture to use for alpha testing
  18287. */
  18288. getAlphaTestTexture(): Nullable<BaseTexture>;
  18289. /**
  18290. * Marks the material to indicate that it needs to be re-calculated
  18291. */
  18292. markDirty(): void;
  18293. /** @hidden */
  18294. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18295. /**
  18296. * Binds the material to the mesh
  18297. * @param world defines the world transformation matrix
  18298. * @param mesh defines the mesh to bind the material to
  18299. */
  18300. bind(world: Matrix, mesh?: Mesh): void;
  18301. /**
  18302. * Binds the submesh to the material
  18303. * @param world defines the world transformation matrix
  18304. * @param mesh defines the mesh containing the submesh
  18305. * @param subMesh defines the submesh to bind the material to
  18306. */
  18307. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18308. /**
  18309. * Binds the world matrix to the material
  18310. * @param world defines the world transformation matrix
  18311. */
  18312. bindOnlyWorldMatrix(world: Matrix): void;
  18313. /**
  18314. * Binds the scene's uniform buffer to the effect.
  18315. * @param effect defines the effect to bind to the scene uniform buffer
  18316. * @param sceneUbo defines the uniform buffer storing scene data
  18317. */
  18318. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18319. /**
  18320. * Binds the view matrix to the effect
  18321. * @param effect defines the effect to bind the view matrix to
  18322. */
  18323. bindView(effect: Effect): void;
  18324. /**
  18325. * Binds the view projection matrix to the effect
  18326. * @param effect defines the effect to bind the view projection matrix to
  18327. */
  18328. bindViewProjection(effect: Effect): void;
  18329. /**
  18330. * Specifies if material alpha testing should be turned on for the mesh
  18331. * @param mesh defines the mesh to check
  18332. */
  18333. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18334. /**
  18335. * Processes to execute after binding the material to a mesh
  18336. * @param mesh defines the rendered mesh
  18337. */
  18338. protected _afterBind(mesh?: Mesh): void;
  18339. /**
  18340. * Unbinds the material from the mesh
  18341. */
  18342. unbind(): void;
  18343. /**
  18344. * Gets the active textures from the material
  18345. * @returns an array of textures
  18346. */
  18347. getActiveTextures(): BaseTexture[];
  18348. /**
  18349. * Specifies if the material uses a texture
  18350. * @param texture defines the texture to check against the material
  18351. * @returns a boolean specifying if the material uses the texture
  18352. */
  18353. hasTexture(texture: BaseTexture): boolean;
  18354. /**
  18355. * Makes a duplicate of the material, and gives it a new name
  18356. * @param name defines the new name for the duplicated material
  18357. * @returns the cloned material
  18358. */
  18359. clone(name: string): Nullable<Material>;
  18360. /**
  18361. * Gets the meshes bound to the material
  18362. * @returns an array of meshes bound to the material
  18363. */
  18364. getBindedMeshes(): AbstractMesh[];
  18365. /**
  18366. * Force shader compilation
  18367. * @param mesh defines the mesh associated with this material
  18368. * @param onCompiled defines a function to execute once the material is compiled
  18369. * @param options defines the options to configure the compilation
  18370. */
  18371. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18372. clipPlane: boolean;
  18373. }>): void;
  18374. /**
  18375. * Force shader compilation
  18376. * @param mesh defines the mesh that will use this material
  18377. * @param options defines additional options for compiling the shaders
  18378. * @returns a promise that resolves when the compilation completes
  18379. */
  18380. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18381. clipPlane: boolean;
  18382. }>): Promise<void>;
  18383. /**
  18384. * Marks a define in the material to indicate that it needs to be re-computed
  18385. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18386. */
  18387. markAsDirty(flag: number): void;
  18388. /**
  18389. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18390. * @param func defines a function which checks material defines against the submeshes
  18391. */
  18392. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18393. /**
  18394. * Indicates that image processing needs to be re-calculated for all submeshes
  18395. */
  18396. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18397. /**
  18398. * Indicates that textures need to be re-calculated for all submeshes
  18399. */
  18400. protected _markAllSubMeshesAsTexturesDirty(): void;
  18401. /**
  18402. * Indicates that fresnel needs to be re-calculated for all submeshes
  18403. */
  18404. protected _markAllSubMeshesAsFresnelDirty(): void;
  18405. /**
  18406. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18407. */
  18408. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18409. /**
  18410. * Indicates that lights need to be re-calculated for all submeshes
  18411. */
  18412. protected _markAllSubMeshesAsLightsDirty(): void;
  18413. /**
  18414. * Indicates that attributes need to be re-calculated for all submeshes
  18415. */
  18416. protected _markAllSubMeshesAsAttributesDirty(): void;
  18417. /**
  18418. * Indicates that misc needs to be re-calculated for all submeshes
  18419. */
  18420. protected _markAllSubMeshesAsMiscDirty(): void;
  18421. /**
  18422. * Indicates that textures and misc need to be re-calculated for all submeshes
  18423. */
  18424. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18425. /**
  18426. * Disposes the material
  18427. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18428. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18429. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18430. */
  18431. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18432. /** @hidden */
  18433. private releaseVertexArrayObject;
  18434. /**
  18435. * Serializes this material
  18436. * @returns the serialized material object
  18437. */
  18438. serialize(): any;
  18439. /**
  18440. * Creates a MultiMaterial from parsed MultiMaterial data.
  18441. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18442. * @param scene defines the hosting scene
  18443. * @returns a new MultiMaterial
  18444. */
  18445. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18446. /**
  18447. * Creates a material from parsed material data
  18448. * @param parsedMaterial defines parsed material data
  18449. * @param scene defines the hosting scene
  18450. * @param rootUrl defines the root URL to use to load textures
  18451. * @returns a new material
  18452. */
  18453. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18454. }
  18455. }
  18456. declare module BABYLON {
  18457. /**
  18458. * "Static Class" containing the most commonly used helper while dealing with material for
  18459. * rendering purpose.
  18460. *
  18461. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18462. *
  18463. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18464. */
  18465. class MaterialHelper {
  18466. /**
  18467. * Bind the current view position to an effect.
  18468. * @param effect The effect to be bound
  18469. * @param scene The scene the eyes position is used from
  18470. */
  18471. static BindEyePosition(effect: Effect, scene: Scene): void;
  18472. /**
  18473. * Helps preparing the defines values about the UVs in used in the effect.
  18474. * UVs are shared as much as we can accross channels in the shaders.
  18475. * @param texture The texture we are preparing the UVs for
  18476. * @param defines The defines to update
  18477. * @param key The channel key "diffuse", "specular"... used in the shader
  18478. */
  18479. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18480. /**
  18481. * Binds a texture matrix value to its corrsponding uniform
  18482. * @param texture The texture to bind the matrix for
  18483. * @param uniformBuffer The uniform buffer receivin the data
  18484. * @param key The channel key "diffuse", "specular"... used in the shader
  18485. */
  18486. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18487. /**
  18488. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18489. * @param mesh defines the current mesh
  18490. * @param scene defines the current scene
  18491. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18492. * @param pointsCloud defines if point cloud rendering has to be turned on
  18493. * @param fogEnabled defines if fog has to be turned on
  18494. * @param alphaTest defines if alpha testing has to be turned on
  18495. * @param defines defines the current list of defines
  18496. */
  18497. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18498. /**
  18499. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18500. * @param scene defines the current scene
  18501. * @param engine defines the current engine
  18502. * @param defines specifies the list of active defines
  18503. * @param useInstances defines if instances have to be turned on
  18504. * @param useClipPlane defines if clip plane have to be turned on
  18505. */
  18506. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18507. /**
  18508. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18509. * @param mesh The mesh containing the geometry data we will draw
  18510. * @param defines The defines to update
  18511. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18512. * @param useBones Precise whether bones should be used or not (override mesh info)
  18513. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18514. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18515. * @returns false if defines are considered not dirty and have not been checked
  18516. */
  18517. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18518. /**
  18519. * Prepares the defines related to the light information passed in parameter
  18520. * @param scene The scene we are intending to draw
  18521. * @param mesh The mesh the effect is compiling for
  18522. * @param defines The defines to update
  18523. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18524. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18525. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18526. * @returns true if normals will be required for the rest of the effect
  18527. */
  18528. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18529. /**
  18530. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18531. * that won t be acctive due to defines being turned off.
  18532. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18533. * @param samplersList The samplers list
  18534. * @param defines The defines helping in the list generation
  18535. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18536. */
  18537. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18538. /**
  18539. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18540. * @param defines The defines to update while falling back
  18541. * @param fallbacks The authorized effect fallbacks
  18542. * @param maxSimultaneousLights The maximum number of lights allowed
  18543. * @param rank the current rank of the Effect
  18544. * @returns The newly affected rank
  18545. */
  18546. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18547. /**
  18548. * Prepares the list of attributes required for morph targets according to the effect defines.
  18549. * @param attribs The current list of supported attribs
  18550. * @param mesh The mesh to prepare the morph targets attributes for
  18551. * @param defines The current Defines of the effect
  18552. */
  18553. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18554. /**
  18555. * Prepares the list of attributes required for bones according to the effect defines.
  18556. * @param attribs The current list of supported attribs
  18557. * @param mesh The mesh to prepare the bones attributes for
  18558. * @param defines The current Defines of the effect
  18559. * @param fallbacks The current efffect fallback strategy
  18560. */
  18561. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18562. /**
  18563. * Prepares the list of attributes required for instances according to the effect defines.
  18564. * @param attribs The current list of supported attribs
  18565. * @param defines The current Defines of the effect
  18566. */
  18567. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18568. /**
  18569. * Binds the light shadow information to the effect for the given mesh.
  18570. * @param light The light containing the generator
  18571. * @param scene The scene the lights belongs to
  18572. * @param mesh The mesh we are binding the information to render
  18573. * @param lightIndex The light index in the effect used to render the mesh
  18574. * @param effect The effect we are binding the data to
  18575. */
  18576. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18577. /**
  18578. * Binds the light information to the effect.
  18579. * @param light The light containing the generator
  18580. * @param effect The effect we are binding the data to
  18581. * @param lightIndex The light index in the effect used to render
  18582. */
  18583. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18584. /**
  18585. * Binds the lights information from the scene to the effect for the given mesh.
  18586. * @param scene The scene the lights belongs to
  18587. * @param mesh The mesh we are binding the information to render
  18588. * @param effect The effect we are binding the data to
  18589. * @param defines The generated defines for the effect
  18590. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18591. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18592. */
  18593. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18594. private static _tempFogColor;
  18595. /**
  18596. * Binds the fog information from the scene to the effect for the given mesh.
  18597. * @param scene The scene the lights belongs to
  18598. * @param mesh The mesh we are binding the information to render
  18599. * @param effect The effect we are binding the data to
  18600. * @param linearSpace Defines if the fog effect is applied in linear space
  18601. */
  18602. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18603. /**
  18604. * Binds the bones information from the mesh to the effect.
  18605. * @param mesh The mesh we are binding the information to render
  18606. * @param effect The effect we are binding the data to
  18607. */
  18608. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18609. /**
  18610. * Binds the morph targets information from the mesh to the effect.
  18611. * @param abstractMesh The mesh we are binding the information to render
  18612. * @param effect The effect we are binding the data to
  18613. */
  18614. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18615. /**
  18616. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18617. * @param defines The generated defines used in the effect
  18618. * @param effect The effect we are binding the data to
  18619. * @param scene The scene we are willing to render with logarithmic scale for
  18620. */
  18621. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18622. /**
  18623. * Binds the clip plane information from the scene to the effect.
  18624. * @param scene The scene the clip plane information are extracted from
  18625. * @param effect The effect we are binding the data to
  18626. */
  18627. static BindClipPlane(effect: Effect, scene: Scene): void;
  18628. }
  18629. }
  18630. declare module BABYLON {
  18631. /**
  18632. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18633. * separate meshes. This can be use to improve performances.
  18634. * @see http://doc.babylonjs.com/how_to/multi_materials
  18635. */
  18636. class MultiMaterial extends Material {
  18637. private _subMaterials;
  18638. /**
  18639. * Gets or Sets the list of Materials used within the multi material.
  18640. * They need to be ordered according to the submeshes order in the associated mesh
  18641. */
  18642. subMaterials: Nullable<Material>[];
  18643. /**
  18644. * Instantiates a new Multi Material
  18645. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18646. * separate meshes. This can be use to improve performances.
  18647. * @see http://doc.babylonjs.com/how_to/multi_materials
  18648. * @param name Define the name in the scene
  18649. * @param scene Define the scene the material belongs to
  18650. */
  18651. constructor(name: string, scene: Scene);
  18652. private _hookArray;
  18653. /**
  18654. * Get one of the submaterial by its index in the submaterials array
  18655. * @param index The index to look the sub material at
  18656. * @returns The Material if the index has been defined
  18657. */
  18658. getSubMaterial(index: number): Nullable<Material>;
  18659. /**
  18660. * Get the list of active textures for the whole sub materials list.
  18661. * @returns All the textures that will be used during the rendering
  18662. */
  18663. getActiveTextures(): BaseTexture[];
  18664. /**
  18665. * Gets the current class name of the material e.g. "MultiMaterial"
  18666. * Mainly use in serialization.
  18667. * @returns the class name
  18668. */
  18669. getClassName(): string;
  18670. /**
  18671. * Checks if the material is ready to render the requested sub mesh
  18672. * @param mesh Define the mesh the submesh belongs to
  18673. * @param subMesh Define the sub mesh to look readyness for
  18674. * @param useInstances Define whether or not the material is used with instances
  18675. * @returns true if ready, otherwise false
  18676. */
  18677. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18678. /**
  18679. * Clones the current material and its related sub materials
  18680. * @param name Define the name of the newly cloned material
  18681. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18682. * @returns the cloned material
  18683. */
  18684. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18685. /**
  18686. * Serializes the materials into a JSON representation.
  18687. * @returns the JSON representation
  18688. */
  18689. serialize(): any;
  18690. /**
  18691. * Dispose the material and release its associated resources
  18692. * @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)
  18693. * @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)
  18694. */
  18695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18696. }
  18697. }
  18698. declare module BABYLON {
  18699. /**
  18700. * Base class of materials working in push mode in babylon JS
  18701. * @hidden
  18702. */
  18703. class PushMaterial extends Material {
  18704. protected _activeEffect: Effect;
  18705. protected _normalMatrix: Matrix;
  18706. /**
  18707. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18708. * This means that the material can keep using a previous shader while a new one is being compiled.
  18709. * This is mostly used when shader parallel compilation is supported (true by default)
  18710. */
  18711. allowShaderHotSwapping: boolean;
  18712. constructor(name: string, scene: Scene);
  18713. getEffect(): Effect;
  18714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18715. /**
  18716. * Binds the given world matrix to the active effect
  18717. *
  18718. * @param world the matrix to bind
  18719. */
  18720. bindOnlyWorldMatrix(world: Matrix): void;
  18721. /**
  18722. * Binds the given normal matrix to the active effect
  18723. *
  18724. * @param normalMatrix the matrix to bind
  18725. */
  18726. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18727. bind(world: Matrix, mesh?: Mesh): void;
  18728. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18729. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18730. }
  18731. }
  18732. declare module BABYLON {
  18733. /**
  18734. * Defines the options associated with the creation of a shader material.
  18735. */
  18736. interface IShaderMaterialOptions {
  18737. /**
  18738. * Does the material work in alpha blend mode
  18739. */
  18740. needAlphaBlending: boolean;
  18741. /**
  18742. * Does the material work in alpha test mode
  18743. */
  18744. needAlphaTesting: boolean;
  18745. /**
  18746. * The list of attribute names used in the shader
  18747. */
  18748. attributes: string[];
  18749. /**
  18750. * The list of unifrom names used in the shader
  18751. */
  18752. uniforms: string[];
  18753. /**
  18754. * The list of UBO names used in the shader
  18755. */
  18756. uniformBuffers: string[];
  18757. /**
  18758. * The list of sampler names used in the shader
  18759. */
  18760. samplers: string[];
  18761. /**
  18762. * The list of defines used in the shader
  18763. */
  18764. defines: string[];
  18765. }
  18766. /**
  18767. * 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.
  18768. *
  18769. * This returned material effects how the mesh will look based on the code in the shaders.
  18770. *
  18771. * @see http://doc.babylonjs.com/how_to/shader_material
  18772. */
  18773. class ShaderMaterial extends Material {
  18774. private _shaderPath;
  18775. private _options;
  18776. private _textures;
  18777. private _textureArrays;
  18778. private _floats;
  18779. private _ints;
  18780. private _floatsArrays;
  18781. private _colors3;
  18782. private _colors3Arrays;
  18783. private _colors4;
  18784. private _vectors2;
  18785. private _vectors3;
  18786. private _vectors4;
  18787. private _matrices;
  18788. private _matrices3x3;
  18789. private _matrices2x2;
  18790. private _vectors2Arrays;
  18791. private _vectors3Arrays;
  18792. private _cachedWorldViewMatrix;
  18793. private _renderId;
  18794. /**
  18795. * Instantiate a new shader material.
  18796. * 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.
  18797. * This returned material effects how the mesh will look based on the code in the shaders.
  18798. * @see http://doc.babylonjs.com/how_to/shader_material
  18799. * @param name Define the name of the material in the scene
  18800. * @param scene Define the scene the material belongs to
  18801. * @param shaderPath Defines the route to the shader code in one of three ways:
  18802. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18803. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18804. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18805. * @param options Define the options used to create the shader
  18806. */
  18807. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18808. /**
  18809. * Gets the current class name of the material e.g. "ShaderMaterial"
  18810. * Mainly use in serialization.
  18811. * @returns the class name
  18812. */
  18813. getClassName(): string;
  18814. /**
  18815. * Specifies if the material will require alpha blending
  18816. * @returns a boolean specifying if alpha blending is needed
  18817. */
  18818. needAlphaBlending(): boolean;
  18819. /**
  18820. * Specifies if this material should be rendered in alpha test mode
  18821. * @returns a boolean specifying if an alpha test is needed.
  18822. */
  18823. needAlphaTesting(): boolean;
  18824. private _checkUniform;
  18825. /**
  18826. * Set a texture in the shader.
  18827. * @param name Define the name of the uniform samplers as defined in the shader
  18828. * @param texture Define the texture to bind to this sampler
  18829. * @return the material itself allowing "fluent" like uniform updates
  18830. */
  18831. setTexture(name: string, texture: Texture): ShaderMaterial;
  18832. /**
  18833. * Set a texture array in the shader.
  18834. * @param name Define the name of the uniform sampler array as defined in the shader
  18835. * @param textures Define the list of textures to bind to this sampler
  18836. * @return the material itself allowing "fluent" like uniform updates
  18837. */
  18838. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18839. /**
  18840. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  18846. /**
  18847. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  18853. /**
  18854. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  18860. /**
  18861. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  18867. /**
  18868. * Set a vec3 array in the shader from a Color3 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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18874. /**
  18875. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  18881. /**
  18882. * Set a vec2 in the shader from a Vector2.
  18883. * @param name Define the name of the uniform as defined in the shader
  18884. * @param value Define the value to give to the uniform
  18885. * @return the material itself allowing "fluent" like uniform updates
  18886. */
  18887. setVector2(name: string, value: Vector2): ShaderMaterial;
  18888. /**
  18889. * Set a vec3 in the shader from a Vector3.
  18890. * @param name Define the name of the uniform as defined in the shader
  18891. * @param value Define the value to give to the uniform
  18892. * @return the material itself allowing "fluent" like uniform updates
  18893. */
  18894. setVector3(name: string, value: Vector3): ShaderMaterial;
  18895. /**
  18896. * Set a vec4 in the shader from a Vector4.
  18897. * @param name Define the name of the uniform as defined in the shader
  18898. * @param value Define the value to give to the uniform
  18899. * @return the material itself allowing "fluent" like uniform updates
  18900. */
  18901. setVector4(name: string, value: Vector4): ShaderMaterial;
  18902. /**
  18903. * Set a mat4 in the shader from a Matrix.
  18904. * @param name Define the name of the uniform as defined in the shader
  18905. * @param value Define the value to give to the uniform
  18906. * @return the material itself allowing "fluent" like uniform updates
  18907. */
  18908. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18909. /**
  18910. * Set a mat3 in the shader from a Float32Array.
  18911. * @param name Define the name of the uniform as defined in the shader
  18912. * @param value Define the value to give to the uniform
  18913. * @return the material itself allowing "fluent" like uniform updates
  18914. */
  18915. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18916. /**
  18917. * Set a mat2 in the shader from a Float32Array.
  18918. * @param name Define the name of the uniform as defined in the shader
  18919. * @param value Define the value to give to the uniform
  18920. * @return the material itself allowing "fluent" like uniform updates
  18921. */
  18922. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18923. /**
  18924. * Set a vec2 array in the shader from a number array.
  18925. * @param name Define the name of the uniform as defined in the shader
  18926. * @param value Define the value to give to the uniform
  18927. * @return the material itself allowing "fluent" like uniform updates
  18928. */
  18929. setArray2(name: string, value: number[]): ShaderMaterial;
  18930. /**
  18931. * Set a vec3 array in the shader from a number array.
  18932. * @param name Define the name of the uniform as defined in the shader
  18933. * @param value Define the value to give to the uniform
  18934. * @return the material itself allowing "fluent" like uniform updates
  18935. */
  18936. setArray3(name: string, value: number[]): ShaderMaterial;
  18937. private _checkCache;
  18938. /**
  18939. * Checks if the material is ready to render the requested mesh
  18940. * @param mesh Define the mesh to render
  18941. * @param useInstances Define whether or not the material is used with instances
  18942. * @returns true if ready, otherwise false
  18943. */
  18944. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18945. /**
  18946. * Binds the world matrix to the material
  18947. * @param world defines the world transformation matrix
  18948. */
  18949. bindOnlyWorldMatrix(world: Matrix): void;
  18950. /**
  18951. * Binds the material to the mesh
  18952. * @param world defines the world transformation matrix
  18953. * @param mesh defines the mesh to bind the material to
  18954. */
  18955. bind(world: Matrix, mesh?: Mesh): void;
  18956. /**
  18957. * Gets the active textures from the material
  18958. * @returns an array of textures
  18959. */
  18960. getActiveTextures(): BaseTexture[];
  18961. /**
  18962. * Specifies if the material uses a texture
  18963. * @param texture defines the texture to check against the material
  18964. * @returns a boolean specifying if the material uses the texture
  18965. */
  18966. hasTexture(texture: BaseTexture): boolean;
  18967. /**
  18968. * Makes a duplicate of the material, and gives it a new name
  18969. * @param name defines the new name for the duplicated material
  18970. * @returns the cloned material
  18971. */
  18972. clone(name: string): ShaderMaterial;
  18973. /**
  18974. * Disposes the material
  18975. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18976. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18977. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18978. */
  18979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18980. /**
  18981. * Serializes this material in a JSON representation
  18982. * @returns the serialized material object
  18983. */
  18984. serialize(): any;
  18985. /**
  18986. * Creates a shader material from parsed shader material data
  18987. * @param source defines the JSON represnetation of the material
  18988. * @param scene defines the hosting scene
  18989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18990. * @returns a new material
  18991. */
  18992. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18993. }
  18994. }
  18995. declare module BABYLON {
  18996. /** @hidden */
  18997. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18998. MAINUV1: boolean;
  18999. MAINUV2: boolean;
  19000. DIFFUSE: boolean;
  19001. DIFFUSEDIRECTUV: number;
  19002. AMBIENT: boolean;
  19003. AMBIENTDIRECTUV: number;
  19004. OPACITY: boolean;
  19005. OPACITYDIRECTUV: number;
  19006. OPACITYRGB: boolean;
  19007. REFLECTION: boolean;
  19008. EMISSIVE: boolean;
  19009. EMISSIVEDIRECTUV: number;
  19010. SPECULAR: boolean;
  19011. SPECULARDIRECTUV: number;
  19012. BUMP: boolean;
  19013. BUMPDIRECTUV: number;
  19014. PARALLAX: boolean;
  19015. PARALLAXOCCLUSION: boolean;
  19016. SPECULAROVERALPHA: boolean;
  19017. CLIPPLANE: boolean;
  19018. CLIPPLANE2: boolean;
  19019. CLIPPLANE3: boolean;
  19020. CLIPPLANE4: boolean;
  19021. ALPHATEST: boolean;
  19022. DEPTHPREPASS: boolean;
  19023. ALPHAFROMDIFFUSE: boolean;
  19024. POINTSIZE: boolean;
  19025. FOG: boolean;
  19026. SPECULARTERM: boolean;
  19027. DIFFUSEFRESNEL: boolean;
  19028. OPACITYFRESNEL: boolean;
  19029. REFLECTIONFRESNEL: boolean;
  19030. REFRACTIONFRESNEL: boolean;
  19031. EMISSIVEFRESNEL: boolean;
  19032. FRESNEL: boolean;
  19033. NORMAL: boolean;
  19034. UV1: boolean;
  19035. UV2: boolean;
  19036. VERTEXCOLOR: boolean;
  19037. VERTEXALPHA: boolean;
  19038. NUM_BONE_INFLUENCERS: number;
  19039. BonesPerMesh: number;
  19040. BONETEXTURE: boolean;
  19041. INSTANCES: boolean;
  19042. GLOSSINESS: boolean;
  19043. ROUGHNESS: boolean;
  19044. EMISSIVEASILLUMINATION: boolean;
  19045. LINKEMISSIVEWITHDIFFUSE: boolean;
  19046. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19047. LIGHTMAP: boolean;
  19048. LIGHTMAPDIRECTUV: number;
  19049. OBJECTSPACE_NORMALMAP: boolean;
  19050. USELIGHTMAPASSHADOWMAP: boolean;
  19051. REFLECTIONMAP_3D: boolean;
  19052. REFLECTIONMAP_SPHERICAL: boolean;
  19053. REFLECTIONMAP_PLANAR: boolean;
  19054. REFLECTIONMAP_CUBIC: boolean;
  19055. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19056. REFLECTIONMAP_PROJECTION: boolean;
  19057. REFLECTIONMAP_SKYBOX: boolean;
  19058. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19059. REFLECTIONMAP_EXPLICIT: boolean;
  19060. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19061. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19062. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19063. INVERTCUBICMAP: boolean;
  19064. LOGARITHMICDEPTH: boolean;
  19065. REFRACTION: boolean;
  19066. REFRACTIONMAP_3D: boolean;
  19067. REFLECTIONOVERALPHA: boolean;
  19068. TWOSIDEDLIGHTING: boolean;
  19069. SHADOWFLOAT: boolean;
  19070. MORPHTARGETS: boolean;
  19071. MORPHTARGETS_NORMAL: boolean;
  19072. MORPHTARGETS_TANGENT: boolean;
  19073. NUM_MORPH_INFLUENCERS: number;
  19074. NONUNIFORMSCALING: boolean;
  19075. PREMULTIPLYALPHA: boolean;
  19076. IMAGEPROCESSING: boolean;
  19077. VIGNETTE: boolean;
  19078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19079. VIGNETTEBLENDMODEOPAQUE: boolean;
  19080. TONEMAPPING: boolean;
  19081. TONEMAPPING_ACES: boolean;
  19082. CONTRAST: boolean;
  19083. COLORCURVES: boolean;
  19084. COLORGRADING: boolean;
  19085. COLORGRADING3D: boolean;
  19086. SAMPLER3DGREENDEPTH: boolean;
  19087. SAMPLER3DBGRMAP: boolean;
  19088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19089. /**
  19090. * If the reflection texture on this material is in linear color space
  19091. * @hidden
  19092. */
  19093. IS_REFLECTION_LINEAR: boolean;
  19094. /**
  19095. * If the refraction texture on this material is in linear color space
  19096. * @hidden
  19097. */
  19098. IS_REFRACTION_LINEAR: boolean;
  19099. EXPOSURE: boolean;
  19100. constructor();
  19101. setReflectionMode(modeToEnable: string): void;
  19102. }
  19103. /**
  19104. * This is the default material used in Babylon. It is the best trade off between quality
  19105. * and performances.
  19106. * @see http://doc.babylonjs.com/babylon101/materials
  19107. */
  19108. class StandardMaterial extends PushMaterial {
  19109. private _diffuseTexture;
  19110. /**
  19111. * The basic texture of the material as viewed under a light.
  19112. */
  19113. diffuseTexture: Nullable<BaseTexture>;
  19114. private _ambientTexture;
  19115. /**
  19116. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19117. */
  19118. ambientTexture: Nullable<BaseTexture>;
  19119. private _opacityTexture;
  19120. /**
  19121. * Define the transparency of the material from a texture.
  19122. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19123. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19124. */
  19125. opacityTexture: Nullable<BaseTexture>;
  19126. private _reflectionTexture;
  19127. /**
  19128. * Define the texture used to display the reflection.
  19129. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19130. */
  19131. reflectionTexture: Nullable<BaseTexture>;
  19132. private _emissiveTexture;
  19133. /**
  19134. * Define texture of the material as if self lit.
  19135. * This will be mixed in the final result even in the absence of light.
  19136. */
  19137. emissiveTexture: Nullable<BaseTexture>;
  19138. private _specularTexture;
  19139. /**
  19140. * Define how the color and intensity of the highlight given by the light in the material.
  19141. */
  19142. specularTexture: Nullable<BaseTexture>;
  19143. private _bumpTexture;
  19144. /**
  19145. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19146. * 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.
  19147. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19148. */
  19149. bumpTexture: Nullable<BaseTexture>;
  19150. private _lightmapTexture;
  19151. /**
  19152. * Complex lighting can be computationally expensive to compute at runtime.
  19153. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19154. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19155. */
  19156. lightmapTexture: Nullable<BaseTexture>;
  19157. private _refractionTexture;
  19158. /**
  19159. * Define the texture used to display the refraction.
  19160. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19161. */
  19162. refractionTexture: Nullable<BaseTexture>;
  19163. /**
  19164. * The color of the material lit by the environmental background lighting.
  19165. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19166. */
  19167. ambientColor: Color3;
  19168. /**
  19169. * The basic color of the material as viewed under a light.
  19170. */
  19171. diffuseColor: Color3;
  19172. /**
  19173. * Define how the color and intensity of the highlight given by the light in the material.
  19174. */
  19175. specularColor: Color3;
  19176. /**
  19177. * Define the color of the material as if self lit.
  19178. * This will be mixed in the final result even in the absence of light.
  19179. */
  19180. emissiveColor: Color3;
  19181. /**
  19182. * Defines how sharp are the highlights in the material.
  19183. * The bigger the value the sharper giving a more glossy feeling to the result.
  19184. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19185. */
  19186. specularPower: number;
  19187. private _useAlphaFromDiffuseTexture;
  19188. /**
  19189. * Does the transparency come from the diffuse texture alpha channel.
  19190. */
  19191. useAlphaFromDiffuseTexture: boolean;
  19192. private _useEmissiveAsIllumination;
  19193. /**
  19194. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19195. */
  19196. useEmissiveAsIllumination: boolean;
  19197. private _linkEmissiveWithDiffuse;
  19198. /**
  19199. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19200. * the emissive level when the final color is close to one.
  19201. */
  19202. linkEmissiveWithDiffuse: boolean;
  19203. private _useSpecularOverAlpha;
  19204. /**
  19205. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19206. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19207. */
  19208. useSpecularOverAlpha: boolean;
  19209. private _useReflectionOverAlpha;
  19210. /**
  19211. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19212. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19213. */
  19214. useReflectionOverAlpha: boolean;
  19215. private _disableLighting;
  19216. /**
  19217. * Does lights from the scene impacts this material.
  19218. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19219. */
  19220. disableLighting: boolean;
  19221. private _useObjectSpaceNormalMap;
  19222. /**
  19223. * Allows using an object space normal map (instead of tangent space).
  19224. */
  19225. useObjectSpaceNormalMap: boolean;
  19226. private _useParallax;
  19227. /**
  19228. * Is parallax enabled or not.
  19229. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19230. */
  19231. useParallax: boolean;
  19232. private _useParallaxOcclusion;
  19233. /**
  19234. * Is parallax occlusion enabled or not.
  19235. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19236. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19237. */
  19238. useParallaxOcclusion: boolean;
  19239. /**
  19240. * 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.
  19241. */
  19242. parallaxScaleBias: number;
  19243. private _roughness;
  19244. /**
  19245. * Helps to define how blurry the reflections should appears in the material.
  19246. */
  19247. roughness: number;
  19248. /**
  19249. * In case of refraction, define the value of the indice of refraction.
  19250. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19251. */
  19252. indexOfRefraction: number;
  19253. /**
  19254. * Invert the refraction texture alongside the y axis.
  19255. * It can be usefull with procedural textures or probe for instance.
  19256. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19257. */
  19258. invertRefractionY: boolean;
  19259. /**
  19260. * Defines the alpha limits in alpha test mode.
  19261. */
  19262. alphaCutOff: number;
  19263. private _useLightmapAsShadowmap;
  19264. /**
  19265. * In case of light mapping, define whether the map contains light or shadow informations.
  19266. */
  19267. useLightmapAsShadowmap: boolean;
  19268. private _diffuseFresnelParameters;
  19269. /**
  19270. * Define the diffuse fresnel parameters of the material.
  19271. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19272. */
  19273. diffuseFresnelParameters: FresnelParameters;
  19274. private _opacityFresnelParameters;
  19275. /**
  19276. * Define the opacity fresnel parameters of the material.
  19277. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19278. */
  19279. opacityFresnelParameters: FresnelParameters;
  19280. private _reflectionFresnelParameters;
  19281. /**
  19282. * Define the reflection fresnel parameters of the material.
  19283. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19284. */
  19285. reflectionFresnelParameters: FresnelParameters;
  19286. private _refractionFresnelParameters;
  19287. /**
  19288. * Define the refraction fresnel parameters of the material.
  19289. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19290. */
  19291. refractionFresnelParameters: FresnelParameters;
  19292. private _emissiveFresnelParameters;
  19293. /**
  19294. * Define the emissive fresnel parameters of the material.
  19295. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19296. */
  19297. emissiveFresnelParameters: FresnelParameters;
  19298. private _useReflectionFresnelFromSpecular;
  19299. /**
  19300. * If true automatically deducts the fresnels values from the material specularity.
  19301. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19302. */
  19303. useReflectionFresnelFromSpecular: boolean;
  19304. private _useGlossinessFromSpecularMapAlpha;
  19305. /**
  19306. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19307. */
  19308. useGlossinessFromSpecularMapAlpha: boolean;
  19309. private _maxSimultaneousLights;
  19310. /**
  19311. * Defines the maximum number of lights that can be used in the material
  19312. */
  19313. maxSimultaneousLights: number;
  19314. private _invertNormalMapX;
  19315. /**
  19316. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19317. */
  19318. invertNormalMapX: boolean;
  19319. private _invertNormalMapY;
  19320. /**
  19321. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19322. */
  19323. invertNormalMapY: boolean;
  19324. private _twoSidedLighting;
  19325. /**
  19326. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19327. */
  19328. twoSidedLighting: boolean;
  19329. /**
  19330. * Default configuration related to image processing available in the standard Material.
  19331. */
  19332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19333. /**
  19334. * Gets the image processing configuration used either in this material.
  19335. */
  19336. /**
  19337. * Sets the Default image processing configuration used either in the this material.
  19338. *
  19339. * If sets to null, the scene one is in use.
  19340. */
  19341. imageProcessingConfiguration: ImageProcessingConfiguration;
  19342. /**
  19343. * Keep track of the image processing observer to allow dispose and replace.
  19344. */
  19345. private _imageProcessingObserver;
  19346. /**
  19347. * Attaches a new image processing configuration to the Standard Material.
  19348. * @param configuration
  19349. */
  19350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19351. /**
  19352. * Gets wether the color curves effect is enabled.
  19353. */
  19354. /**
  19355. * Sets wether the color curves effect is enabled.
  19356. */
  19357. cameraColorCurvesEnabled: boolean;
  19358. /**
  19359. * Gets wether the color grading effect is enabled.
  19360. */
  19361. /**
  19362. * Gets wether the color grading effect is enabled.
  19363. */
  19364. cameraColorGradingEnabled: boolean;
  19365. /**
  19366. * Gets wether tonemapping is enabled or not.
  19367. */
  19368. /**
  19369. * Sets wether tonemapping is enabled or not
  19370. */
  19371. cameraToneMappingEnabled: boolean;
  19372. /**
  19373. * The camera exposure used on this material.
  19374. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19375. * This corresponds to a photographic exposure.
  19376. */
  19377. /**
  19378. * The camera exposure used on this material.
  19379. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19380. * This corresponds to a photographic exposure.
  19381. */
  19382. cameraExposure: number;
  19383. /**
  19384. * Gets The camera contrast used on this material.
  19385. */
  19386. /**
  19387. * Sets The camera contrast used on this material.
  19388. */
  19389. cameraContrast: number;
  19390. /**
  19391. * Gets the Color Grading 2D Lookup Texture.
  19392. */
  19393. /**
  19394. * Sets the Color Grading 2D Lookup Texture.
  19395. */
  19396. cameraColorGradingTexture: Nullable<BaseTexture>;
  19397. /**
  19398. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19399. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19400. * 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;
  19401. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19402. */
  19403. /**
  19404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19406. * 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;
  19407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19408. */
  19409. cameraColorCurves: Nullable<ColorCurves>;
  19410. /**
  19411. * Custom callback helping to override the default shader used in the material.
  19412. */
  19413. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19414. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19415. protected _worldViewProjectionMatrix: Matrix;
  19416. protected _globalAmbientColor: Color3;
  19417. protected _useLogarithmicDepth: boolean;
  19418. /**
  19419. * Instantiates a new standard material.
  19420. * This is the default material used in Babylon. It is the best trade off between quality
  19421. * and performances.
  19422. * @see http://doc.babylonjs.com/babylon101/materials
  19423. * @param name Define the name of the material in the scene
  19424. * @param scene Define the scene the material belong to
  19425. */
  19426. constructor(name: string, scene: Scene);
  19427. /**
  19428. * Gets a boolean indicating that current material needs to register RTT
  19429. */
  19430. readonly hasRenderTargetTextures: boolean;
  19431. /**
  19432. * Gets the current class name of the material e.g. "StandardMaterial"
  19433. * Mainly use in serialization.
  19434. * @returns the class name
  19435. */
  19436. getClassName(): string;
  19437. /**
  19438. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19439. * You can try switching to logarithmic depth.
  19440. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19441. */
  19442. useLogarithmicDepth: boolean;
  19443. /**
  19444. * Specifies if the material will require alpha blending
  19445. * @returns a boolean specifying if alpha blending is needed
  19446. */
  19447. needAlphaBlending(): boolean;
  19448. /**
  19449. * Specifies if this material should be rendered in alpha test mode
  19450. * @returns a boolean specifying if an alpha test is needed.
  19451. */
  19452. needAlphaTesting(): boolean;
  19453. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19454. /**
  19455. * Get the texture used for alpha test purpose.
  19456. * @returns the diffuse texture in case of the standard material.
  19457. */
  19458. getAlphaTestTexture(): Nullable<BaseTexture>;
  19459. /**
  19460. * Get if the submesh is ready to be used and all its information available.
  19461. * Child classes can use it to update shaders
  19462. * @param mesh defines the mesh to check
  19463. * @param subMesh defines which submesh to check
  19464. * @param useInstances specifies that instances should be used
  19465. * @returns a boolean indicating that the submesh is ready or not
  19466. */
  19467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19468. /**
  19469. * Builds the material UBO layouts.
  19470. * Used internally during the effect preparation.
  19471. */
  19472. buildUniformLayout(): void;
  19473. /**
  19474. * Unbinds the material from the mesh
  19475. */
  19476. unbind(): void;
  19477. /**
  19478. * Binds the submesh to this material by preparing the effect and shader to draw
  19479. * @param world defines the world transformation matrix
  19480. * @param mesh defines the mesh containing the submesh
  19481. * @param subMesh defines the submesh to bind the material to
  19482. */
  19483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19484. /**
  19485. * Get the list of animatables in the material.
  19486. * @returns the list of animatables object used in the material
  19487. */
  19488. getAnimatables(): IAnimatable[];
  19489. /**
  19490. * Gets the active textures from the material
  19491. * @returns an array of textures
  19492. */
  19493. getActiveTextures(): BaseTexture[];
  19494. /**
  19495. * Specifies if the material uses a texture
  19496. * @param texture defines the texture to check against the material
  19497. * @returns a boolean specifying if the material uses the texture
  19498. */
  19499. hasTexture(texture: BaseTexture): boolean;
  19500. /**
  19501. * Disposes the material
  19502. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19503. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19504. */
  19505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19506. /**
  19507. * Makes a duplicate of the material, and gives it a new name
  19508. * @param name defines the new name for the duplicated material
  19509. * @returns the cloned material
  19510. */
  19511. clone(name: string): StandardMaterial;
  19512. /**
  19513. * Serializes this material in a JSON representation
  19514. * @returns the serialized material object
  19515. */
  19516. serialize(): any;
  19517. /**
  19518. * Creates a standard material from parsed material data
  19519. * @param source defines the JSON represnetation of the material
  19520. * @param scene defines the hosting scene
  19521. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19522. * @returns a new material
  19523. */
  19524. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19525. private static _DiffuseTextureEnabled;
  19526. /**
  19527. * Are diffuse textures enabled in the application.
  19528. */
  19529. static DiffuseTextureEnabled: boolean;
  19530. private static _AmbientTextureEnabled;
  19531. /**
  19532. * Are ambient textures enabled in the application.
  19533. */
  19534. static AmbientTextureEnabled: boolean;
  19535. private static _OpacityTextureEnabled;
  19536. /**
  19537. * Are opacity textures enabled in the application.
  19538. */
  19539. static OpacityTextureEnabled: boolean;
  19540. private static _ReflectionTextureEnabled;
  19541. /**
  19542. * Are reflection textures enabled in the application.
  19543. */
  19544. static ReflectionTextureEnabled: boolean;
  19545. private static _EmissiveTextureEnabled;
  19546. /**
  19547. * Are emissive textures enabled in the application.
  19548. */
  19549. static EmissiveTextureEnabled: boolean;
  19550. private static _SpecularTextureEnabled;
  19551. /**
  19552. * Are specular textures enabled in the application.
  19553. */
  19554. static SpecularTextureEnabled: boolean;
  19555. private static _BumpTextureEnabled;
  19556. /**
  19557. * Are bump textures enabled in the application.
  19558. */
  19559. static BumpTextureEnabled: boolean;
  19560. private static _LightmapTextureEnabled;
  19561. /**
  19562. * Are lightmap textures enabled in the application.
  19563. */
  19564. static LightmapTextureEnabled: boolean;
  19565. private static _RefractionTextureEnabled;
  19566. /**
  19567. * Are refraction textures enabled in the application.
  19568. */
  19569. static RefractionTextureEnabled: boolean;
  19570. private static _ColorGradingTextureEnabled;
  19571. /**
  19572. * Are color grading textures enabled in the application.
  19573. */
  19574. static ColorGradingTextureEnabled: boolean;
  19575. private static _FresnelEnabled;
  19576. /**
  19577. * Are fresnels enabled in the application.
  19578. */
  19579. static FresnelEnabled: boolean;
  19580. }
  19581. }
  19582. declare module BABYLON {
  19583. /**
  19584. * Uniform buffer objects.
  19585. *
  19586. * Handles blocks of uniform on the GPU.
  19587. *
  19588. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19589. *
  19590. * For more information, please refer to :
  19591. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19592. */
  19593. class UniformBuffer {
  19594. private _engine;
  19595. private _buffer;
  19596. private _data;
  19597. private _bufferData;
  19598. private _dynamic?;
  19599. private _uniformLocations;
  19600. private _uniformSizes;
  19601. private _uniformLocationPointer;
  19602. private _needSync;
  19603. private _noUBO;
  19604. private _currentEffect;
  19605. private static _MAX_UNIFORM_SIZE;
  19606. private static _tempBuffer;
  19607. /**
  19608. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19609. * This is dynamic to allow compat with webgl 1 and 2.
  19610. * You will need to pass the name of the uniform as well as the value.
  19611. */
  19612. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19613. /**
  19614. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19615. * This is dynamic to allow compat with webgl 1 and 2.
  19616. * You will need to pass the name of the uniform as well as the value.
  19617. */
  19618. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19619. /**
  19620. * Lambda to Update a single float in a uniform buffer.
  19621. * This is dynamic to allow compat with webgl 1 and 2.
  19622. * You will need to pass the name of the uniform as well as the value.
  19623. */
  19624. updateFloat: (name: string, x: number) => void;
  19625. /**
  19626. * Lambda to Update a vec2 of float in a uniform buffer.
  19627. * This is dynamic to allow compat with webgl 1 and 2.
  19628. * You will need to pass the name of the uniform as well as the value.
  19629. */
  19630. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19631. /**
  19632. * Lambda to Update a vec3 of float in a uniform buffer.
  19633. * This is dynamic to allow compat with webgl 1 and 2.
  19634. * You will need to pass the name of the uniform as well as the value.
  19635. */
  19636. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19637. /**
  19638. * Lambda to Update a vec4 of float in a uniform buffer.
  19639. * This is dynamic to allow compat with webgl 1 and 2.
  19640. * You will need to pass the name of the uniform as well as the value.
  19641. */
  19642. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19643. /**
  19644. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19645. * This is dynamic to allow compat with webgl 1 and 2.
  19646. * You will need to pass the name of the uniform as well as the value.
  19647. */
  19648. updateMatrix: (name: string, mat: Matrix) => void;
  19649. /**
  19650. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19651. * This is dynamic to allow compat with webgl 1 and 2.
  19652. * You will need to pass the name of the uniform as well as the value.
  19653. */
  19654. updateVector3: (name: string, vector: Vector3) => void;
  19655. /**
  19656. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19657. * This is dynamic to allow compat with webgl 1 and 2.
  19658. * You will need to pass the name of the uniform as well as the value.
  19659. */
  19660. updateVector4: (name: string, vector: Vector4) => void;
  19661. /**
  19662. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19663. * This is dynamic to allow compat with webgl 1 and 2.
  19664. * You will need to pass the name of the uniform as well as the value.
  19665. */
  19666. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19667. /**
  19668. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19669. * This is dynamic to allow compat with webgl 1 and 2.
  19670. * You will need to pass the name of the uniform as well as the value.
  19671. */
  19672. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19673. /**
  19674. * Instantiates a new Uniform buffer objects.
  19675. *
  19676. * Handles blocks of uniform on the GPU.
  19677. *
  19678. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19679. *
  19680. * For more information, please refer to :
  19681. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19682. * @param engine Define the engine the buffer is associated with
  19683. * @param data Define the data contained in the buffer
  19684. * @param dynamic Define if the buffer is updatable
  19685. */
  19686. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19687. /**
  19688. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19689. * or just falling back on setUniformXXX calls.
  19690. */
  19691. readonly useUbo: boolean;
  19692. /**
  19693. * Indicates if the WebGL underlying uniform buffer is in sync
  19694. * with the javascript cache data.
  19695. */
  19696. readonly isSync: boolean;
  19697. /**
  19698. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19699. * Also, a dynamic UniformBuffer will disable cache verification and always
  19700. * update the underlying WebGL uniform buffer to the GPU.
  19701. * @returns if Dynamic, otherwise false
  19702. */
  19703. isDynamic(): boolean;
  19704. /**
  19705. * The data cache on JS side.
  19706. * @returns the underlying data as a float array
  19707. */
  19708. getData(): Float32Array;
  19709. /**
  19710. * The underlying WebGL Uniform buffer.
  19711. * @returns the webgl buffer
  19712. */
  19713. getBuffer(): Nullable<WebGLBuffer>;
  19714. /**
  19715. * std140 layout specifies how to align data within an UBO structure.
  19716. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19717. * for specs.
  19718. */
  19719. private _fillAlignment;
  19720. /**
  19721. * Adds an uniform in the buffer.
  19722. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19723. * for the layout to be correct !
  19724. * @param name Name of the uniform, as used in the uniform block in the shader.
  19725. * @param size Data size, or data directly.
  19726. */
  19727. addUniform(name: string, size: number | number[]): void;
  19728. /**
  19729. * Adds a Matrix 4x4 to the uniform buffer.
  19730. * @param name Name of the uniform, as used in the uniform block in the shader.
  19731. * @param mat A 4x4 matrix.
  19732. */
  19733. addMatrix(name: string, mat: Matrix): void;
  19734. /**
  19735. * Adds a vec2 to the uniform buffer.
  19736. * @param name Name of the uniform, as used in the uniform block in the shader.
  19737. * @param x Define the x component value of the vec2
  19738. * @param y Define the y component value of the vec2
  19739. */
  19740. addFloat2(name: string, x: number, y: number): void;
  19741. /**
  19742. * Adds a vec3 to the uniform buffer.
  19743. * @param name Name of the uniform, as used in the uniform block in the shader.
  19744. * @param x Define the x component value of the vec3
  19745. * @param y Define the y component value of the vec3
  19746. * @param z Define the z component value of the vec3
  19747. */
  19748. addFloat3(name: string, x: number, y: number, z: number): void;
  19749. /**
  19750. * Adds a vec3 to the uniform buffer.
  19751. * @param name Name of the uniform, as used in the uniform block in the shader.
  19752. * @param color Define the vec3 from a Color
  19753. */
  19754. addColor3(name: string, color: Color3): void;
  19755. /**
  19756. * Adds a vec4 to the uniform buffer.
  19757. * @param name Name of the uniform, as used in the uniform block in the shader.
  19758. * @param color Define the rgb components from a Color
  19759. * @param alpha Define the a component of the vec4
  19760. */
  19761. addColor4(name: string, color: Color3, alpha: number): void;
  19762. /**
  19763. * Adds a vec3 to the uniform buffer.
  19764. * @param name Name of the uniform, as used in the uniform block in the shader.
  19765. * @param vector Define the vec3 components from a Vector
  19766. */
  19767. addVector3(name: string, vector: Vector3): void;
  19768. /**
  19769. * Adds a Matrix 3x3 to the uniform buffer.
  19770. * @param name Name of the uniform, as used in the uniform block in the shader.
  19771. */
  19772. addMatrix3x3(name: string): void;
  19773. /**
  19774. * Adds a Matrix 2x2 to the uniform buffer.
  19775. * @param name Name of the uniform, as used in the uniform block in the shader.
  19776. */
  19777. addMatrix2x2(name: string): void;
  19778. /**
  19779. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19780. */
  19781. create(): void;
  19782. /** @hidden */
  19783. _rebuild(): void;
  19784. /**
  19785. * Updates the WebGL Uniform Buffer on the GPU.
  19786. * If the `dynamic` flag is set to true, no cache comparison is done.
  19787. * Otherwise, the buffer will be updated only if the cache differs.
  19788. */
  19789. update(): void;
  19790. /**
  19791. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19792. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19793. * @param data Define the flattened data
  19794. * @param size Define the size of the data.
  19795. */
  19796. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19797. private _updateMatrix3x3ForUniform;
  19798. private _updateMatrix3x3ForEffect;
  19799. private _updateMatrix2x2ForEffect;
  19800. private _updateMatrix2x2ForUniform;
  19801. private _updateFloatForEffect;
  19802. private _updateFloatForUniform;
  19803. private _updateFloat2ForEffect;
  19804. private _updateFloat2ForUniform;
  19805. private _updateFloat3ForEffect;
  19806. private _updateFloat3ForUniform;
  19807. private _updateFloat4ForEffect;
  19808. private _updateFloat4ForUniform;
  19809. private _updateMatrixForEffect;
  19810. private _updateMatrixForUniform;
  19811. private _updateVector3ForEffect;
  19812. private _updateVector3ForUniform;
  19813. private _updateVector4ForEffect;
  19814. private _updateVector4ForUniform;
  19815. private _updateColor3ForEffect;
  19816. private _updateColor3ForUniform;
  19817. private _updateColor4ForEffect;
  19818. private _updateColor4ForUniform;
  19819. /**
  19820. * Sets a sampler uniform on the effect.
  19821. * @param name Define the name of the sampler.
  19822. * @param texture Define the texture to set in the sampler
  19823. */
  19824. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19825. /**
  19826. * Directly updates the value of the uniform in the cache AND on the GPU.
  19827. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19828. * @param data Define the flattened data
  19829. */
  19830. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19831. /**
  19832. * Binds this uniform buffer to an effect.
  19833. * @param effect Define the effect to bind the buffer to
  19834. * @param name Name of the uniform block in the shader.
  19835. */
  19836. bindToEffect(effect: Effect, name: string): void;
  19837. /**
  19838. * Disposes the uniform buffer.
  19839. */
  19840. dispose(): void;
  19841. }
  19842. }
  19843. declare module BABYLON {
  19844. /**
  19845. * Scalar computation library
  19846. */
  19847. class Scalar {
  19848. /**
  19849. * Two pi constants convenient for computation.
  19850. */
  19851. static TwoPi: number;
  19852. /**
  19853. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19854. * @param a number
  19855. * @param b number
  19856. * @param epsilon (default = 1.401298E-45)
  19857. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19858. */
  19859. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19860. /**
  19861. * Returns a string : the upper case translation of the number i to hexadecimal.
  19862. * @param i number
  19863. * @returns the upper case translation of the number i to hexadecimal.
  19864. */
  19865. static ToHex(i: number): string;
  19866. /**
  19867. * Returns -1 if value is negative and +1 is value is positive.
  19868. * @param value the value
  19869. * @returns the value itself if it's equal to zero.
  19870. */
  19871. static Sign(value: number): number;
  19872. /**
  19873. * Returns the value itself if it's between min and max.
  19874. * Returns min if the value is lower than min.
  19875. * Returns max if the value is greater than max.
  19876. * @param value the value to clmap
  19877. * @param min the min value to clamp to (default: 0)
  19878. * @param max the max value to clamp to (default: 1)
  19879. * @returns the clamped value
  19880. */
  19881. static Clamp(value: number, min?: number, max?: number): number;
  19882. /**
  19883. * the log2 of value.
  19884. * @param value the value to compute log2 of
  19885. * @returns the log2 of value.
  19886. */
  19887. static Log2(value: number): number;
  19888. /**
  19889. * Loops the value, so that it is never larger than length and never smaller than 0.
  19890. *
  19891. * This is similar to the modulo operator but it works with floating point numbers.
  19892. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19893. * With t = 5 and length = 2.5, the result would be 0.0.
  19894. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19895. * @param value the value
  19896. * @param length the length
  19897. * @returns the looped value
  19898. */
  19899. static Repeat(value: number, length: number): number;
  19900. /**
  19901. * Normalize the value between 0.0 and 1.0 using min and max values
  19902. * @param value value to normalize
  19903. * @param min max to normalize between
  19904. * @param max min to normalize between
  19905. * @returns the normalized value
  19906. */
  19907. static Normalize(value: number, min: number, max: number): number;
  19908. /**
  19909. * Denormalize the value from 0.0 and 1.0 using min and max values
  19910. * @param normalized value to denormalize
  19911. * @param min max to denormalize between
  19912. * @param max min to denormalize between
  19913. * @returns the denormalized value
  19914. */
  19915. static Denormalize(normalized: number, min: number, max: number): number;
  19916. /**
  19917. * Calculates the shortest difference between two given angles given in degrees.
  19918. * @param current current angle in degrees
  19919. * @param target target angle in degrees
  19920. * @returns the delta
  19921. */
  19922. static DeltaAngle(current: number, target: number): number;
  19923. /**
  19924. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19925. * @param tx value
  19926. * @param length length
  19927. * @returns The returned value will move back and forth between 0 and length
  19928. */
  19929. static PingPong(tx: number, length: number): number;
  19930. /**
  19931. * Interpolates between min and max with smoothing at the limits.
  19932. *
  19933. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19934. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19935. * @param from from
  19936. * @param to to
  19937. * @param tx value
  19938. * @returns the smooth stepped value
  19939. */
  19940. static SmoothStep(from: number, to: number, tx: number): number;
  19941. /**
  19942. * Moves a value current towards target.
  19943. *
  19944. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19945. * Negative values of maxDelta pushes the value away from target.
  19946. * @param current current value
  19947. * @param target target value
  19948. * @param maxDelta max distance to move
  19949. * @returns resulting value
  19950. */
  19951. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19952. /**
  19953. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19954. *
  19955. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19956. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19957. * @param current current value
  19958. * @param target target value
  19959. * @param maxDelta max distance to move
  19960. * @returns resulting angle
  19961. */
  19962. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19963. /**
  19964. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19965. * @param start start value
  19966. * @param end target value
  19967. * @param amount amount to lerp between
  19968. * @returns the lerped value
  19969. */
  19970. static Lerp(start: number, end: number, amount: number): number;
  19971. /**
  19972. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19973. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19974. * @param start start value
  19975. * @param end target value
  19976. * @param amount amount to lerp between
  19977. * @returns the lerped value
  19978. */
  19979. static LerpAngle(start: number, end: number, amount: number): number;
  19980. /**
  19981. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19982. * @param a start value
  19983. * @param b target value
  19984. * @param value value between a and b
  19985. * @returns the inverseLerp value
  19986. */
  19987. static InverseLerp(a: number, b: number, value: number): number;
  19988. /**
  19989. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19990. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19991. * @param value1 spline value
  19992. * @param tangent1 spline value
  19993. * @param value2 spline value
  19994. * @param tangent2 spline value
  19995. * @param amount input value
  19996. * @returns hermite result
  19997. */
  19998. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19999. /**
  20000. * Returns a random float number between and min and max values
  20001. * @param min min value of random
  20002. * @param max max value of random
  20003. * @returns random value
  20004. */
  20005. static RandomRange(min: number, max: number): number;
  20006. /**
  20007. * This function returns percentage of a number in a given range.
  20008. *
  20009. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20010. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20011. * @param number to convert to percentage
  20012. * @param min min range
  20013. * @param max max range
  20014. * @returns the percentage
  20015. */
  20016. static RangeToPercent(number: number, min: number, max: number): number;
  20017. /**
  20018. * This function returns number that corresponds to the percentage in a given range.
  20019. *
  20020. * PercentToRange(0.34,0,100) will return 34.
  20021. * @param percent to convert to number
  20022. * @param min min range
  20023. * @param max max range
  20024. * @returns the number
  20025. */
  20026. static PercentToRange(percent: number, min: number, max: number): number;
  20027. /**
  20028. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20029. * @param angle The angle to normalize in radian.
  20030. * @return The converted angle.
  20031. */
  20032. static NormalizeRadians(angle: number): number;
  20033. }
  20034. }
  20035. declare module BABYLON {
  20036. /**
  20037. * Constant used to convert a value to gamma space
  20038. * @ignorenaming
  20039. */
  20040. const ToGammaSpace: number;
  20041. /**
  20042. * Constant used to convert a value to linear space
  20043. * @ignorenaming
  20044. */
  20045. const ToLinearSpace = 2.2;
  20046. /**
  20047. * Constant used to define the minimal number value in Babylon.js
  20048. * @ignorenaming
  20049. */
  20050. const Epsilon = 0.001;
  20051. /**
  20052. * Class used to hold a RBG color
  20053. */
  20054. class Color3 {
  20055. /**
  20056. * Defines the red component (between 0 and 1, default is 0)
  20057. */
  20058. r: number;
  20059. /**
  20060. * Defines the green component (between 0 and 1, default is 0)
  20061. */
  20062. g: number;
  20063. /**
  20064. * Defines the blue component (between 0 and 1, default is 0)
  20065. */
  20066. b: number;
  20067. /**
  20068. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20069. * @param r defines the red component (between 0 and 1, default is 0)
  20070. * @param g defines the green component (between 0 and 1, default is 0)
  20071. * @param b defines the blue component (between 0 and 1, default is 0)
  20072. */
  20073. constructor(
  20074. /**
  20075. * Defines the red component (between 0 and 1, default is 0)
  20076. */
  20077. r?: number,
  20078. /**
  20079. * Defines the green component (between 0 and 1, default is 0)
  20080. */
  20081. g?: number,
  20082. /**
  20083. * Defines the blue component (between 0 and 1, default is 0)
  20084. */
  20085. b?: number);
  20086. /**
  20087. * Creates a string with the Color3 current values
  20088. * @returns the string representation of the Color3 object
  20089. */
  20090. toString(): string;
  20091. /**
  20092. * Returns the string "Color3"
  20093. * @returns "Color3"
  20094. */
  20095. getClassName(): string;
  20096. /**
  20097. * Compute the Color3 hash code
  20098. * @returns an unique number that can be used to hash Color3 objects
  20099. */
  20100. getHashCode(): number;
  20101. /**
  20102. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20103. * @param array defines the array where to store the r,g,b components
  20104. * @param index defines an optional index in the target array to define where to start storing values
  20105. * @returns the current Color3 object
  20106. */
  20107. toArray(array: FloatArray, index?: number): Color3;
  20108. /**
  20109. * Returns a new Color4 object from the current Color3 and the given alpha
  20110. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20111. * @returns a new Color4 object
  20112. */
  20113. toColor4(alpha?: number): Color4;
  20114. /**
  20115. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20116. * @returns the new array
  20117. */
  20118. asArray(): number[];
  20119. /**
  20120. * Returns the luminance value
  20121. * @returns a float value
  20122. */
  20123. toLuminance(): number;
  20124. /**
  20125. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20126. * @param otherColor defines the second operand
  20127. * @returns the new Color3 object
  20128. */
  20129. multiply(otherColor: Color3): Color3;
  20130. /**
  20131. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20132. * @param otherColor defines the second operand
  20133. * @param result defines the Color3 object where to store the result
  20134. * @returns the current Color3
  20135. */
  20136. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  20137. /**
  20138. * Determines equality between Color3 objects
  20139. * @param otherColor defines the second operand
  20140. * @returns true if the rgb values are equal to the given ones
  20141. */
  20142. equals(otherColor: Color3): boolean;
  20143. /**
  20144. * Determines equality between the current Color3 object and a set of r,b,g values
  20145. * @param r defines the red component to check
  20146. * @param g defines the green component to check
  20147. * @param b defines the blue component to check
  20148. * @returns true if the rgb values are equal to the given ones
  20149. */
  20150. equalsFloats(r: number, g: number, b: number): boolean;
  20151. /**
  20152. * Multiplies in place each rgb value by scale
  20153. * @param scale defines the scaling factor
  20154. * @returns the updated Color3
  20155. */
  20156. scale(scale: number): Color3;
  20157. /**
  20158. * Multiplies the rgb values by scale and stores the result into "result"
  20159. * @param scale defines the scaling factor
  20160. * @param result defines the Color3 object where to store the result
  20161. * @returns the unmodified current Color3
  20162. */
  20163. scaleToRef(scale: number, result: Color3): Color3;
  20164. /**
  20165. * Scale the current Color3 values by a factor and add the result to a given Color3
  20166. * @param scale defines the scale factor
  20167. * @param result defines color to store the result into
  20168. * @returns the unmodified current Color3
  20169. */
  20170. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20171. /**
  20172. * Clamps the rgb values by the min and max values and stores the result into "result"
  20173. * @param min defines minimum clamping value (default is 0)
  20174. * @param max defines maximum clamping value (default is 1)
  20175. * @param result defines color to store the result into
  20176. * @returns the original Color3
  20177. */
  20178. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20179. /**
  20180. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20181. * @param otherColor defines the second operand
  20182. * @returns the new Color3
  20183. */
  20184. add(otherColor: Color3): Color3;
  20185. /**
  20186. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20187. * @param otherColor defines the second operand
  20188. * @param result defines Color3 object to store the result into
  20189. * @returns the unmodified current Color3
  20190. */
  20191. addToRef(otherColor: Color3, result: Color3): Color3;
  20192. /**
  20193. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20194. * @param otherColor defines the second operand
  20195. * @returns the new Color3
  20196. */
  20197. subtract(otherColor: Color3): Color3;
  20198. /**
  20199. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20200. * @param otherColor defines the second operand
  20201. * @param result defines Color3 object to store the result into
  20202. * @returns the unmodified current Color3
  20203. */
  20204. subtractToRef(otherColor: Color3, result: Color3): Color3;
  20205. /**
  20206. * Copy the current object
  20207. * @returns a new Color3 copied the current one
  20208. */
  20209. clone(): Color3;
  20210. /**
  20211. * Copies the rgb values from the source in the current Color3
  20212. * @param source defines the source Color3 object
  20213. * @returns the updated Color3 object
  20214. */
  20215. copyFrom(source: Color3): Color3;
  20216. /**
  20217. * Updates the Color3 rgb values from the given floats
  20218. * @param r defines the red component to read from
  20219. * @param g defines the green component to read from
  20220. * @param b defines the blue component to read from
  20221. * @returns the current Color3 object
  20222. */
  20223. copyFromFloats(r: number, g: number, b: number): Color3;
  20224. /**
  20225. * Updates the Color3 rgb values from the given floats
  20226. * @param r defines the red component to read from
  20227. * @param g defines the green component to read from
  20228. * @param b defines the blue component to read from
  20229. * @returns the current Color3 object
  20230. */
  20231. set(r: number, g: number, b: number): Color3;
  20232. /**
  20233. * Compute the Color3 hexadecimal code as a string
  20234. * @returns a string containing the hexadecimal representation of the Color3 object
  20235. */
  20236. toHexString(): string;
  20237. /**
  20238. * Computes a new Color3 converted from the current one to linear space
  20239. * @returns a new Color3 object
  20240. */
  20241. toLinearSpace(): Color3;
  20242. /**
  20243. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20244. * @param convertedColor defines the Color3 object where to store the linear space version
  20245. * @returns the unmodified Color3
  20246. */
  20247. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20248. /**
  20249. * Computes a new Color3 converted from the current one to gamma space
  20250. * @returns a new Color3 object
  20251. */
  20252. toGammaSpace(): Color3;
  20253. /**
  20254. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20255. * @param convertedColor defines the Color3 object where to store the gamma space version
  20256. * @returns the unmodified Color3
  20257. */
  20258. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20259. /**
  20260. * Creates a new Color3 from the string containing valid hexadecimal values
  20261. * @param hex defines a string containing valid hexadecimal values
  20262. * @returns a new Color3 object
  20263. */
  20264. static FromHexString(hex: string): Color3;
  20265. /**
  20266. * Creates a new Vector3 from the starting index of the given array
  20267. * @param array defines the source array
  20268. * @param offset defines an offset in the source array
  20269. * @returns a new Color3 object
  20270. */
  20271. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  20272. /**
  20273. * Creates a new Color3 from integer values (< 256)
  20274. * @param r defines the red component to read from (value between 0 and 255)
  20275. * @param g defines the green component to read from (value between 0 and 255)
  20276. * @param b defines the blue component to read from (value between 0 and 255)
  20277. * @returns a new Color3 object
  20278. */
  20279. static FromInts(r: number, g: number, b: number): Color3;
  20280. /**
  20281. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20282. * @param start defines the start Color3 value
  20283. * @param end defines the end Color3 value
  20284. * @param amount defines the gradient value between start and end
  20285. * @returns a new Color3 object
  20286. */
  20287. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  20288. /**
  20289. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20290. * @param left defines the start value
  20291. * @param right defines the end value
  20292. * @param amount defines the gradient factor
  20293. * @param result defines the Color3 object where to store the result
  20294. */
  20295. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  20296. /**
  20297. * Returns a Color3 value containing a red color
  20298. * @returns a new Color3 object
  20299. */
  20300. static Red(): Color3;
  20301. /**
  20302. * Returns a Color3 value containing a green color
  20303. * @returns a new Color3 object
  20304. */
  20305. static Green(): Color3;
  20306. /**
  20307. * Returns a Color3 value containing a blue color
  20308. * @returns a new Color3 object
  20309. */
  20310. static Blue(): Color3;
  20311. /**
  20312. * Returns a Color3 value containing a black color
  20313. * @returns a new Color3 object
  20314. */
  20315. static Black(): Color3;
  20316. /**
  20317. * Returns a Color3 value containing a white color
  20318. * @returns a new Color3 object
  20319. */
  20320. static White(): Color3;
  20321. /**
  20322. * Returns a Color3 value containing a purple color
  20323. * @returns a new Color3 object
  20324. */
  20325. static Purple(): Color3;
  20326. /**
  20327. * Returns a Color3 value containing a magenta color
  20328. * @returns a new Color3 object
  20329. */
  20330. static Magenta(): Color3;
  20331. /**
  20332. * Returns a Color3 value containing a yellow color
  20333. * @returns a new Color3 object
  20334. */
  20335. static Yellow(): Color3;
  20336. /**
  20337. * Returns a Color3 value containing a gray color
  20338. * @returns a new Color3 object
  20339. */
  20340. static Gray(): Color3;
  20341. /**
  20342. * Returns a Color3 value containing a teal color
  20343. * @returns a new Color3 object
  20344. */
  20345. static Teal(): Color3;
  20346. /**
  20347. * Returns a Color3 value containing a random color
  20348. * @returns a new Color3 object
  20349. */
  20350. static Random(): Color3;
  20351. }
  20352. /**
  20353. * Class used to hold a RBGA color
  20354. */
  20355. class Color4 {
  20356. /**
  20357. * Defines the red component (between 0 and 1, default is 0)
  20358. */
  20359. r: number;
  20360. /**
  20361. * Defines the green component (between 0 and 1, default is 0)
  20362. */
  20363. g: number;
  20364. /**
  20365. * Defines the blue component (between 0 and 1, default is 0)
  20366. */
  20367. b: number;
  20368. /**
  20369. * Defines the alpha component (between 0 and 1, default is 1)
  20370. */
  20371. a: number;
  20372. /**
  20373. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20374. * @param r defines the red component (between 0 and 1, default is 0)
  20375. * @param g defines the green component (between 0 and 1, default is 0)
  20376. * @param b defines the blue component (between 0 and 1, default is 0)
  20377. * @param a defines the alpha component (between 0 and 1, default is 1)
  20378. */
  20379. constructor(
  20380. /**
  20381. * Defines the red component (between 0 and 1, default is 0)
  20382. */
  20383. r?: number,
  20384. /**
  20385. * Defines the green component (between 0 and 1, default is 0)
  20386. */
  20387. g?: number,
  20388. /**
  20389. * Defines the blue component (between 0 and 1, default is 0)
  20390. */
  20391. b?: number,
  20392. /**
  20393. * Defines the alpha component (between 0 and 1, default is 1)
  20394. */
  20395. a?: number);
  20396. /**
  20397. * Adds in place the given Color4 values to the current Color4 object
  20398. * @param right defines the second operand
  20399. * @returns the current updated Color4 object
  20400. */
  20401. addInPlace(right: Color4): Color4;
  20402. /**
  20403. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20404. * @returns the new array
  20405. */
  20406. asArray(): number[];
  20407. /**
  20408. * Stores from the starting index in the given array the Color4 successive values
  20409. * @param array defines the array where to store the r,g,b components
  20410. * @param index defines an optional index in the target array to define where to start storing values
  20411. * @returns the current Color4 object
  20412. */
  20413. toArray(array: number[], index?: number): Color4;
  20414. /**
  20415. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20416. * @param right defines the second operand
  20417. * @returns a new Color4 object
  20418. */
  20419. add(right: Color4): Color4;
  20420. /**
  20421. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20422. * @param right defines the second operand
  20423. * @returns a new Color4 object
  20424. */
  20425. subtract(right: Color4): Color4;
  20426. /**
  20427. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20428. * @param right defines the second operand
  20429. * @param result defines the Color4 object where to store the result
  20430. * @returns the current Color4 object
  20431. */
  20432. subtractToRef(right: Color4, result: Color4): Color4;
  20433. /**
  20434. * Creates a new Color4 with the current Color4 values multiplied by scale
  20435. * @param scale defines the scaling factor to apply
  20436. * @returns a new Color4 object
  20437. */
  20438. scale(scale: number): Color4;
  20439. /**
  20440. * Multiplies the current Color4 values by scale and stores the result in "result"
  20441. * @param scale defines the scaling factor to apply
  20442. * @param result defines the Color4 object where to store the result
  20443. * @returns the current unmodified Color4
  20444. */
  20445. scaleToRef(scale: number, result: Color4): Color4;
  20446. /**
  20447. * Scale the current Color4 values by a factor and add the result to a given Color4
  20448. * @param scale defines the scale factor
  20449. * @param result defines the Color4 object where to store the result
  20450. * @returns the unmodified current Color4
  20451. */
  20452. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20453. /**
  20454. * Clamps the rgb values by the min and max values and stores the result into "result"
  20455. * @param min defines minimum clamping value (default is 0)
  20456. * @param max defines maximum clamping value (default is 1)
  20457. * @param result defines color to store the result into.
  20458. * @returns the cuurent Color4
  20459. */
  20460. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20461. /**
  20462. * Multipy an Color4 value by another and return a new Color4 object
  20463. * @param color defines the Color4 value to multiply by
  20464. * @returns a new Color4 object
  20465. */
  20466. multiply(color: Color4): Color4;
  20467. /**
  20468. * Multipy a Color4 value by another and push the result in a reference value
  20469. * @param color defines the Color4 value to multiply by
  20470. * @param result defines the Color4 to fill the result in
  20471. * @returns the result Color4
  20472. */
  20473. multiplyToRef(color: Color4, result: Color4): Color4;
  20474. /**
  20475. * Creates a string with the Color4 current values
  20476. * @returns the string representation of the Color4 object
  20477. */
  20478. toString(): string;
  20479. /**
  20480. * Returns the string "Color4"
  20481. * @returns "Color4"
  20482. */
  20483. getClassName(): string;
  20484. /**
  20485. * Compute the Color4 hash code
  20486. * @returns an unique number that can be used to hash Color4 objects
  20487. */
  20488. getHashCode(): number;
  20489. /**
  20490. * Creates a new Color4 copied from the current one
  20491. * @returns a new Color4 object
  20492. */
  20493. clone(): Color4;
  20494. /**
  20495. * Copies the given Color4 values into the current one
  20496. * @param source defines the source Color4 object
  20497. * @returns the current updated Color4 object
  20498. */
  20499. copyFrom(source: Color4): Color4;
  20500. /**
  20501. * Copies the given float values into the current one
  20502. * @param r defines the red component to read from
  20503. * @param g defines the green component to read from
  20504. * @param b defines the blue component to read from
  20505. * @param a defines the alpha component to read from
  20506. * @returns the current updated Color4 object
  20507. */
  20508. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20509. /**
  20510. * Copies the given float values into the current one
  20511. * @param r defines the red component to read from
  20512. * @param g defines the green component to read from
  20513. * @param b defines the blue component to read from
  20514. * @param a defines the alpha component to read from
  20515. * @returns the current updated Color4 object
  20516. */
  20517. set(r: number, g: number, b: number, a: number): Color4;
  20518. /**
  20519. * Compute the Color4 hexadecimal code as a string
  20520. * @returns a string containing the hexadecimal representation of the Color4 object
  20521. */
  20522. toHexString(): string;
  20523. /**
  20524. * Computes a new Color4 converted from the current one to linear space
  20525. * @returns a new Color4 object
  20526. */
  20527. toLinearSpace(): Color4;
  20528. /**
  20529. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20530. * @param convertedColor defines the Color4 object where to store the linear space version
  20531. * @returns the unmodified Color4
  20532. */
  20533. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20534. /**
  20535. * Computes a new Color4 converted from the current one to gamma space
  20536. * @returns a new Color4 object
  20537. */
  20538. toGammaSpace(): Color4;
  20539. /**
  20540. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20541. * @param convertedColor defines the Color4 object where to store the gamma space version
  20542. * @returns the unmodified Color4
  20543. */
  20544. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20545. /**
  20546. * Creates a new Color4 from the string containing valid hexadecimal values
  20547. * @param hex defines a string containing valid hexadecimal values
  20548. * @returns a new Color4 object
  20549. */
  20550. static FromHexString(hex: string): Color4;
  20551. /**
  20552. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20553. * @param left defines the start value
  20554. * @param right defines the end value
  20555. * @param amount defines the gradient factor
  20556. * @returns a new Color4 object
  20557. */
  20558. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20559. /**
  20560. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20561. * @param left defines the start value
  20562. * @param right defines the end value
  20563. * @param amount defines the gradient factor
  20564. * @param result defines the Color4 object where to store data
  20565. */
  20566. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20567. /**
  20568. * Creates a new Color4 from a Color3 and an alpha value
  20569. * @param color3 defines the source Color3 to read from
  20570. * @param alpha defines the alpha component (1.0 by default)
  20571. * @returns a new Color4 object
  20572. */
  20573. static FromColor3(color3: Color3, alpha?: number): Color4;
  20574. /**
  20575. * Creates a new Color4 from the starting index element of the given array
  20576. * @param array defines the source array to read from
  20577. * @param offset defines the offset in the source array
  20578. * @returns a new Color4 object
  20579. */
  20580. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20581. /**
  20582. * Creates a new Color3 from integer values (< 256)
  20583. * @param r defines the red component to read from (value between 0 and 255)
  20584. * @param g defines the green component to read from (value between 0 and 255)
  20585. * @param b defines the blue component to read from (value between 0 and 255)
  20586. * @param a defines the alpha component to read from (value between 0 and 255)
  20587. * @returns a new Color3 object
  20588. */
  20589. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20590. /**
  20591. * Check the content of a given array and convert it to an array containing RGBA data
  20592. * If the original array was already containing count * 4 values then it is returned directly
  20593. * @param colors defines the array to check
  20594. * @param count defines the number of RGBA data to expect
  20595. * @returns an array containing count * 4 values (RGBA)
  20596. */
  20597. static CheckColors4(colors: number[], count: number): number[];
  20598. }
  20599. /**
  20600. * Class representing a vector containing 2 coordinates
  20601. */
  20602. class Vector2 {
  20603. /** defines the first coordinate */
  20604. x: number;
  20605. /** defines the second coordinate */
  20606. y: number;
  20607. /**
  20608. * Creates a new Vector2 from the given x and y coordinates
  20609. * @param x defines the first coordinate
  20610. * @param y defines the second coordinate
  20611. */
  20612. constructor(
  20613. /** defines the first coordinate */
  20614. x?: number,
  20615. /** defines the second coordinate */
  20616. y?: number);
  20617. /**
  20618. * Gets a string with the Vector2 coordinates
  20619. * @returns a string with the Vector2 coordinates
  20620. */
  20621. toString(): string;
  20622. /**
  20623. * Gets class name
  20624. * @returns the string "Vector2"
  20625. */
  20626. getClassName(): string;
  20627. /**
  20628. * Gets current vector hash code
  20629. * @returns the Vector2 hash code as a number
  20630. */
  20631. getHashCode(): number;
  20632. /**
  20633. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20634. * @param array defines the source array
  20635. * @param index defines the offset in source array
  20636. * @returns the current Vector2
  20637. */
  20638. toArray(array: FloatArray, index?: number): Vector2;
  20639. /**
  20640. * Copy the current vector to an array
  20641. * @returns a new array with 2 elements: the Vector2 coordinates.
  20642. */
  20643. asArray(): number[];
  20644. /**
  20645. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20646. * @param source defines the source Vector2
  20647. * @returns the current updated Vector2
  20648. */
  20649. copyFrom(source: Vector2): Vector2;
  20650. /**
  20651. * Sets the Vector2 coordinates with the given floats
  20652. * @param x defines the first coordinate
  20653. * @param y defines the second coordinate
  20654. * @returns the current updated Vector2
  20655. */
  20656. copyFromFloats(x: number, y: number): Vector2;
  20657. /**
  20658. * Sets the Vector2 coordinates with the given floats
  20659. * @param x defines the first coordinate
  20660. * @param y defines the second coordinate
  20661. * @returns the current updated Vector2
  20662. */
  20663. set(x: number, y: number): Vector2;
  20664. /**
  20665. * Add another vector with the current one
  20666. * @param otherVector defines the other vector
  20667. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20668. */
  20669. add(otherVector: Vector2): Vector2;
  20670. /**
  20671. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20672. * @param otherVector defines the other vector
  20673. * @param result defines the target vector
  20674. * @returns the unmodified current Vector2
  20675. */
  20676. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20677. /**
  20678. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20679. * @param otherVector defines the other vector
  20680. * @returns the current updated Vector2
  20681. */
  20682. addInPlace(otherVector: Vector2): Vector2;
  20683. /**
  20684. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20685. * @param otherVector defines the other vector
  20686. * @returns a new Vector2
  20687. */
  20688. addVector3(otherVector: Vector3): Vector2;
  20689. /**
  20690. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20691. * @param otherVector defines the other vector
  20692. * @returns a new Vector2
  20693. */
  20694. subtract(otherVector: Vector2): Vector2;
  20695. /**
  20696. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20697. * @param otherVector defines the other vector
  20698. * @param result defines the target vector
  20699. * @returns the unmodified current Vector2
  20700. */
  20701. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20702. /**
  20703. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20704. * @param otherVector defines the other vector
  20705. * @returns the current updated Vector2
  20706. */
  20707. subtractInPlace(otherVector: Vector2): Vector2;
  20708. /**
  20709. * Multiplies in place the current Vector2 coordinates by the given ones
  20710. * @param otherVector defines the other vector
  20711. * @returns the current updated Vector2
  20712. */
  20713. multiplyInPlace(otherVector: Vector2): Vector2;
  20714. /**
  20715. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20716. * @param otherVector defines the other vector
  20717. * @returns a new Vector2
  20718. */
  20719. multiply(otherVector: Vector2): Vector2;
  20720. /**
  20721. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20722. * @param otherVector defines the other vector
  20723. * @param result defines the target vector
  20724. * @returns the unmodified current Vector2
  20725. */
  20726. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20727. /**
  20728. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20729. * @param x defines the first coordinate
  20730. * @param y defines the second coordinate
  20731. * @returns a new Vector2
  20732. */
  20733. multiplyByFloats(x: number, y: number): Vector2;
  20734. /**
  20735. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20736. * @param otherVector defines the other vector
  20737. * @returns a new Vector2
  20738. */
  20739. divide(otherVector: Vector2): Vector2;
  20740. /**
  20741. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20742. * @param otherVector defines the other vector
  20743. * @param result defines the target vector
  20744. * @returns the unmodified current Vector2
  20745. */
  20746. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20747. /**
  20748. * Divides the current Vector2 coordinates by the given ones
  20749. * @param otherVector defines the other vector
  20750. * @returns the current updated Vector2
  20751. */
  20752. divideInPlace(otherVector: Vector2): Vector2;
  20753. /**
  20754. * Gets a new Vector2 with current Vector2 negated coordinates
  20755. * @returns a new Vector2
  20756. */
  20757. negate(): Vector2;
  20758. /**
  20759. * Multiply the Vector2 coordinates by scale
  20760. * @param scale defines the scaling factor
  20761. * @returns the current updated Vector2
  20762. */
  20763. scaleInPlace(scale: number): Vector2;
  20764. /**
  20765. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20766. * @param scale defines the scaling factor
  20767. * @returns a new Vector2
  20768. */
  20769. scale(scale: number): Vector2;
  20770. /**
  20771. * Scale the current Vector2 values by a factor to a given Vector2
  20772. * @param scale defines the scale factor
  20773. * @param result defines the Vector2 object where to store the result
  20774. * @returns the unmodified current Vector2
  20775. */
  20776. scaleToRef(scale: number, result: Vector2): Vector2;
  20777. /**
  20778. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20779. * @param scale defines the scale factor
  20780. * @param result defines the Vector2 object where to store the result
  20781. * @returns the unmodified current Vector2
  20782. */
  20783. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20784. /**
  20785. * Gets a boolean if two vectors are equals
  20786. * @param otherVector defines the other vector
  20787. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20788. */
  20789. equals(otherVector: Vector2): boolean;
  20790. /**
  20791. * Gets a boolean if two vectors are equals (using an epsilon value)
  20792. * @param otherVector defines the other vector
  20793. * @param epsilon defines the minimal distance to consider equality
  20794. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20795. */
  20796. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20797. /**
  20798. * Gets a new Vector2 from current Vector2 floored values
  20799. * @returns a new Vector2
  20800. */
  20801. floor(): Vector2;
  20802. /**
  20803. * Gets a new Vector2 from current Vector2 floored values
  20804. * @returns a new Vector2
  20805. */
  20806. fract(): Vector2;
  20807. /**
  20808. * Gets the length of the vector
  20809. * @returns the vector length (float)
  20810. */
  20811. length(): number;
  20812. /**
  20813. * Gets the vector squared length
  20814. * @returns the vector squared length (float)
  20815. */
  20816. lengthSquared(): number;
  20817. /**
  20818. * Normalize the vector
  20819. * @returns the current updated Vector2
  20820. */
  20821. normalize(): Vector2;
  20822. /**
  20823. * Gets a new Vector2 copied from the Vector2
  20824. * @returns a new Vector2
  20825. */
  20826. clone(): Vector2;
  20827. /**
  20828. * Gets a new Vector2(0, 0)
  20829. * @returns a new Vector2
  20830. */
  20831. static Zero(): Vector2;
  20832. /**
  20833. * Gets a new Vector2(1, 1)
  20834. * @returns a new Vector2
  20835. */
  20836. static One(): Vector2;
  20837. /**
  20838. * Gets a new Vector2 set from the given index element of the given array
  20839. * @param array defines the data source
  20840. * @param offset defines the offset in the data source
  20841. * @returns a new Vector2
  20842. */
  20843. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20844. /**
  20845. * Sets "result" from the given index element of the given array
  20846. * @param array defines the data source
  20847. * @param offset defines the offset in the data source
  20848. * @param result defines the target vector
  20849. */
  20850. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20851. /**
  20852. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20853. * @param value1 defines 1st point of control
  20854. * @param value2 defines 2nd point of control
  20855. * @param value3 defines 3rd point of control
  20856. * @param value4 defines 4th point of control
  20857. * @param amount defines the interpolation factor
  20858. * @returns a new Vector2
  20859. */
  20860. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20861. /**
  20862. * 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".
  20863. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20864. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20865. * @param value defines the value to clamp
  20866. * @param min defines the lower limit
  20867. * @param max defines the upper limit
  20868. * @returns a new Vector2
  20869. */
  20870. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20871. /**
  20872. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20873. * @param value1 defines the 1st control point
  20874. * @param tangent1 defines the outgoing tangent
  20875. * @param value2 defines the 2nd control point
  20876. * @param tangent2 defines the incoming tangent
  20877. * @param amount defines the interpolation factor
  20878. * @returns a new Vector2
  20879. */
  20880. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20881. /**
  20882. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20883. * @param start defines the start vector
  20884. * @param end defines the end vector
  20885. * @param amount defines the interpolation factor
  20886. * @returns a new Vector2
  20887. */
  20888. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20889. /**
  20890. * Gets the dot product of the vector "left" and the vector "right"
  20891. * @param left defines first vector
  20892. * @param right defines second vector
  20893. * @returns the dot product (float)
  20894. */
  20895. static Dot(left: Vector2, right: Vector2): number;
  20896. /**
  20897. * Returns a new Vector2 equal to the normalized given vector
  20898. * @param vector defines the vector to normalize
  20899. * @returns a new Vector2
  20900. */
  20901. static Normalize(vector: Vector2): Vector2;
  20902. /**
  20903. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20904. * @param left defines 1st vector
  20905. * @param right defines 2nd vector
  20906. * @returns a new Vector2
  20907. */
  20908. static Minimize(left: Vector2, right: Vector2): Vector2;
  20909. /**
  20910. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20911. * @param left defines 1st vector
  20912. * @param right defines 2nd vector
  20913. * @returns a new Vector2
  20914. */
  20915. static Maximize(left: Vector2, right: Vector2): Vector2;
  20916. /**
  20917. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20918. * @param vector defines the vector to transform
  20919. * @param transformation defines the matrix to apply
  20920. * @returns a new Vector2
  20921. */
  20922. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20923. /**
  20924. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20925. * @param vector defines the vector to transform
  20926. * @param transformation defines the matrix to apply
  20927. * @param result defines the target vector
  20928. */
  20929. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20930. /**
  20931. * Determines if a given vector is included in a triangle
  20932. * @param p defines the vector to test
  20933. * @param p0 defines 1st triangle point
  20934. * @param p1 defines 2nd triangle point
  20935. * @param p2 defines 3rd triangle point
  20936. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20937. */
  20938. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20939. /**
  20940. * Gets the distance between the vectors "value1" and "value2"
  20941. * @param value1 defines first vector
  20942. * @param value2 defines second vector
  20943. * @returns the distance between vectors
  20944. */
  20945. static Distance(value1: Vector2, value2: Vector2): number;
  20946. /**
  20947. * Returns the squared distance between the vectors "value1" and "value2"
  20948. * @param value1 defines first vector
  20949. * @param value2 defines second vector
  20950. * @returns the squared distance between vectors
  20951. */
  20952. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20953. /**
  20954. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20955. * @param value1 defines first vector
  20956. * @param value2 defines second vector
  20957. * @returns a new Vector2
  20958. */
  20959. static Center(value1: Vector2, value2: Vector2): Vector2;
  20960. /**
  20961. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20962. * @param p defines the middle point
  20963. * @param segA defines one point of the segment
  20964. * @param segB defines the other point of the segment
  20965. * @returns the shortest distance
  20966. */
  20967. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20968. }
  20969. /**
  20970. * Classed used to store (x,y,z) vector representation
  20971. * A Vector3 is the main object used in 3D geometry
  20972. * It can represent etiher the coordinates of a point the space, either a direction
  20973. * Reminder: Babylon.js uses a left handed forward facing system
  20974. */
  20975. class Vector3 {
  20976. /**
  20977. * Defines the first coordinates (on X axis)
  20978. */
  20979. x: number;
  20980. /**
  20981. * Defines the second coordinates (on Y axis)
  20982. */
  20983. y: number;
  20984. /**
  20985. * Defines the third coordinates (on Z axis)
  20986. */
  20987. z: number;
  20988. /**
  20989. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20990. * @param x defines the first coordinates (on X axis)
  20991. * @param y defines the second coordinates (on Y axis)
  20992. * @param z defines the third coordinates (on Z axis)
  20993. */
  20994. constructor(
  20995. /**
  20996. * Defines the first coordinates (on X axis)
  20997. */
  20998. x?: number,
  20999. /**
  21000. * Defines the second coordinates (on Y axis)
  21001. */
  21002. y?: number,
  21003. /**
  21004. * Defines the third coordinates (on Z axis)
  21005. */
  21006. z?: number);
  21007. /**
  21008. * Creates a string representation of the Vector3
  21009. * @returns a string with the Vector3 coordinates.
  21010. */
  21011. toString(): string;
  21012. /**
  21013. * Gets the class name
  21014. * @returns the string "Vector3"
  21015. */
  21016. getClassName(): string;
  21017. /**
  21018. * Creates the Vector3 hash code
  21019. * @returns a number which tends to be unique between Vector3 instances
  21020. */
  21021. getHashCode(): number;
  21022. /**
  21023. * Creates an array containing three elements : the coordinates of the Vector3
  21024. * @returns a new array of numbers
  21025. */
  21026. asArray(): number[];
  21027. /**
  21028. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21029. * @param array defines the destination array
  21030. * @param index defines the offset in the destination array
  21031. * @returns the current Vector3
  21032. */
  21033. toArray(array: FloatArray, index?: number): Vector3;
  21034. /**
  21035. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21036. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21037. */
  21038. toQuaternion(): Quaternion;
  21039. /**
  21040. * Adds the given vector to the current Vector3
  21041. * @param otherVector defines the second operand
  21042. * @returns the current updated Vector3
  21043. */
  21044. addInPlace(otherVector: Vector3): Vector3;
  21045. /**
  21046. * Adds the given coordinates to the current Vector3
  21047. * @param x defines the x coordinate of the operand
  21048. * @param y defines the y coordinate of the operand
  21049. * @param z defines the z coordinate of the operand
  21050. * @returns the current updated Vector3
  21051. */
  21052. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21053. /**
  21054. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21055. * @param otherVector defines the second operand
  21056. * @returns the resulting Vector3
  21057. */
  21058. add(otherVector: Vector3): Vector3;
  21059. /**
  21060. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21061. * @param otherVector defines the second operand
  21062. * @param result defines the Vector3 object where to store the result
  21063. * @returns the current Vector3
  21064. */
  21065. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  21066. /**
  21067. * Subtract the given vector from the current Vector3
  21068. * @param otherVector defines the second operand
  21069. * @returns the current updated Vector3
  21070. */
  21071. subtractInPlace(otherVector: Vector3): Vector3;
  21072. /**
  21073. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21074. * @param otherVector defines the second operand
  21075. * @returns the resulting Vector3
  21076. */
  21077. subtract(otherVector: Vector3): Vector3;
  21078. /**
  21079. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21080. * @param otherVector defines the second operand
  21081. * @param result defines the Vector3 object where to store the result
  21082. * @returns the current Vector3
  21083. */
  21084. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  21085. /**
  21086. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21087. * @param x defines the x coordinate of the operand
  21088. * @param y defines the y coordinate of the operand
  21089. * @param z defines the z coordinate of the operand
  21090. * @returns the resulting Vector3
  21091. */
  21092. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21093. /**
  21094. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21095. * @param x defines the x coordinate of the operand
  21096. * @param y defines the y coordinate of the operand
  21097. * @param z defines the z coordinate of the operand
  21098. * @param result defines the Vector3 object where to store the result
  21099. * @returns the current Vector3
  21100. */
  21101. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21102. /**
  21103. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21104. * @returns a new Vector3
  21105. */
  21106. negate(): Vector3;
  21107. /**
  21108. * Multiplies the Vector3 coordinates by the float "scale"
  21109. * @param scale defines the multiplier factor
  21110. * @returns the current updated Vector3
  21111. */
  21112. scaleInPlace(scale: number): Vector3;
  21113. /**
  21114. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21115. * @param scale defines the multiplier factor
  21116. * @returns a new Vector3
  21117. */
  21118. scale(scale: number): Vector3;
  21119. /**
  21120. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21121. * @param scale defines the multiplier factor
  21122. * @param result defines the Vector3 object where to store the result
  21123. * @returns the current Vector3
  21124. */
  21125. scaleToRef(scale: number, result: Vector3): Vector3;
  21126. /**
  21127. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21128. * @param scale defines the scale factor
  21129. * @param result defines the Vector3 object where to store the result
  21130. * @returns the unmodified current Vector3
  21131. */
  21132. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21133. /**
  21134. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21135. * @param otherVector defines the second operand
  21136. * @returns true if both vectors are equals
  21137. */
  21138. equals(otherVector: Vector3): boolean;
  21139. /**
  21140. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21141. * @param otherVector defines the second operand
  21142. * @param epsilon defines the minimal distance to define values as equals
  21143. * @returns true if both vectors are distant less than epsilon
  21144. */
  21145. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  21146. /**
  21147. * Returns true if the current Vector3 coordinates equals the given floats
  21148. * @param x defines the x coordinate of the operand
  21149. * @param y defines the y coordinate of the operand
  21150. * @param z defines the z coordinate of the operand
  21151. * @returns true if both vectors are equals
  21152. */
  21153. equalsToFloats(x: number, y: number, z: number): boolean;
  21154. /**
  21155. * Multiplies the current Vector3 coordinates by the given ones
  21156. * @param otherVector defines the second operand
  21157. * @returns the current updated Vector3
  21158. */
  21159. multiplyInPlace(otherVector: Vector3): Vector3;
  21160. /**
  21161. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21162. * @param otherVector defines the second operand
  21163. * @returns the new Vector3
  21164. */
  21165. multiply(otherVector: Vector3): Vector3;
  21166. /**
  21167. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21168. * @param otherVector defines the second operand
  21169. * @param result defines the Vector3 object where to store the result
  21170. * @returns the current Vector3
  21171. */
  21172. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  21173. /**
  21174. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21175. * @param x defines the x coordinate of the operand
  21176. * @param y defines the y coordinate of the operand
  21177. * @param z defines the z coordinate of the operand
  21178. * @returns the new Vector3
  21179. */
  21180. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21181. /**
  21182. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21183. * @param otherVector defines the second operand
  21184. * @returns the new Vector3
  21185. */
  21186. divide(otherVector: Vector3): Vector3;
  21187. /**
  21188. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21189. * @param otherVector defines the second operand
  21190. * @param result defines the Vector3 object where to store the result
  21191. * @returns the current Vector3
  21192. */
  21193. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  21194. /**
  21195. * Divides the current Vector3 coordinates by the given ones.
  21196. * @param otherVector defines the second operand
  21197. * @returns the current updated Vector3
  21198. */
  21199. divideInPlace(otherVector: Vector3): Vector3;
  21200. /**
  21201. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21202. * @param other defines the second operand
  21203. * @returns the current updated Vector3
  21204. */
  21205. minimizeInPlace(other: Vector3): Vector3;
  21206. /**
  21207. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21208. * @param other defines the second operand
  21209. * @returns the current updated Vector3
  21210. */
  21211. maximizeInPlace(other: Vector3): Vector3;
  21212. /**
  21213. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21214. * @param x defines the x coordinate of the operand
  21215. * @param y defines the y coordinate of the operand
  21216. * @param z defines the z coordinate of the operand
  21217. * @returns the current updated Vector3
  21218. */
  21219. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21220. /**
  21221. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21222. * @param x defines the x coordinate of the operand
  21223. * @param y defines the y coordinate of the operand
  21224. * @param z defines the z coordinate of the operand
  21225. * @returns the current updated Vector3
  21226. */
  21227. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21228. /**
  21229. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21230. */
  21231. readonly isNonUniform: boolean;
  21232. /**
  21233. * Gets a new Vector3 from current Vector3 floored values
  21234. * @returns a new Vector3
  21235. */
  21236. floor(): Vector3;
  21237. /**
  21238. * Gets a new Vector3 from current Vector3 floored values
  21239. * @returns a new Vector3
  21240. */
  21241. fract(): Vector3;
  21242. /**
  21243. * Gets the length of the Vector3
  21244. * @returns the length of the Vecto3
  21245. */
  21246. length(): number;
  21247. /**
  21248. * Gets the squared length of the Vector3
  21249. * @returns squared length of the Vector3
  21250. */
  21251. lengthSquared(): number;
  21252. /**
  21253. * Normalize the current Vector3.
  21254. * Please note that this is an in place operation.
  21255. * @returns the current updated Vector3
  21256. */
  21257. normalize(): Vector3;
  21258. /**
  21259. * Normalize the current Vector3 with the given input length.
  21260. * Please note that this is an in place operation.
  21261. * @param len the length of the vector
  21262. * @returns the current updated Vector3
  21263. */
  21264. normalizeFromLength(len: number): Vector3;
  21265. /**
  21266. * Normalize the current Vector3 to a new vector
  21267. * @returns the new Vector3
  21268. */
  21269. normalizeToNew(): Vector3;
  21270. /**
  21271. * Normalize the current Vector3 to the reference
  21272. * @param reference define the Vector3 to update
  21273. * @returns the updated Vector3
  21274. */
  21275. normalizeToRef(reference: Vector3): Vector3;
  21276. /**
  21277. * Creates a new Vector3 copied from the current Vector3
  21278. * @returns the new Vector3
  21279. */
  21280. clone(): Vector3;
  21281. /**
  21282. * Copies the given vector coordinates to the current Vector3 ones
  21283. * @param source defines the source Vector3
  21284. * @returns the current updated Vector3
  21285. */
  21286. copyFrom(source: Vector3): Vector3;
  21287. /**
  21288. * Copies the given floats to the current Vector3 coordinates
  21289. * @param x defines the x coordinate of the operand
  21290. * @param y defines the y coordinate of the operand
  21291. * @param z defines the z coordinate of the operand
  21292. * @returns the current updated Vector3
  21293. */
  21294. copyFromFloats(x: number, y: number, z: number): Vector3;
  21295. /**
  21296. * Copies the given floats to the current Vector3 coordinates
  21297. * @param x defines the x coordinate of the operand
  21298. * @param y defines the y coordinate of the operand
  21299. * @param z defines the z coordinate of the operand
  21300. * @returns the current updated Vector3
  21301. */
  21302. set(x: number, y: number, z: number): Vector3;
  21303. /**
  21304. * Copies the given float to the current Vector3 coordinates
  21305. * @param v defines the x, y and z coordinates of the operand
  21306. * @returns the current updated Vector3
  21307. */
  21308. setAll(v: number): Vector3;
  21309. /**
  21310. * Get the clip factor between two vectors
  21311. * @param vector0 defines the first operand
  21312. * @param vector1 defines the second operand
  21313. * @param axis defines the axis to use
  21314. * @param size defines the size along the axis
  21315. * @returns the clip factor
  21316. */
  21317. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  21318. /**
  21319. * Get angle between two vectors
  21320. * @param vector0 angle between vector0 and vector1
  21321. * @param vector1 angle between vector0 and vector1
  21322. * @param normal direction of the normal
  21323. * @return the angle between vector0 and vector1
  21324. */
  21325. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  21326. /**
  21327. * Returns a new Vector3 set from the index "offset" of the given array
  21328. * @param array defines the source array
  21329. * @param offset defines the offset in the source array
  21330. * @returns the new Vector3
  21331. */
  21332. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  21333. /**
  21334. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21335. * This function is deprecated. Use FromArray instead
  21336. * @param array defines the source array
  21337. * @param offset defines the offset in the source array
  21338. * @returns the new Vector3
  21339. */
  21340. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  21341. /**
  21342. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21343. * @param array defines the source array
  21344. * @param offset defines the offset in the source array
  21345. * @param result defines the Vector3 where to store the result
  21346. */
  21347. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  21348. /**
  21349. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21350. * This function is deprecated. Use FromArrayToRef instead.
  21351. * @param array defines the source array
  21352. * @param offset defines the offset in the source array
  21353. * @param result defines the Vector3 where to store the result
  21354. */
  21355. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  21356. /**
  21357. * Sets the given vector "result" with the given floats.
  21358. * @param x defines the x coordinate of the source
  21359. * @param y defines the y coordinate of the source
  21360. * @param z defines the z coordinate of the source
  21361. * @param result defines the Vector3 where to store the result
  21362. */
  21363. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21364. /**
  21365. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21366. * @returns a new empty Vector3
  21367. */
  21368. static Zero(): Vector3;
  21369. /**
  21370. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21371. * @returns a new unit Vector3
  21372. */
  21373. static One(): Vector3;
  21374. /**
  21375. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21376. * @returns a new up Vector3
  21377. */
  21378. static Up(): Vector3;
  21379. /**
  21380. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21381. * @returns a new down Vector3
  21382. */
  21383. static Down(): Vector3;
  21384. /**
  21385. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21386. * @returns a new forward Vector3
  21387. */
  21388. static Forward(): Vector3;
  21389. /**
  21390. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21391. * @returns a new forward Vector3
  21392. */
  21393. static Backward(): Vector3;
  21394. /**
  21395. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21396. * @returns a new right Vector3
  21397. */
  21398. static Right(): Vector3;
  21399. /**
  21400. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21401. * @returns a new left Vector3
  21402. */
  21403. static Left(): Vector3;
  21404. /**
  21405. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21406. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21407. * @param vector defines the Vector3 to transform
  21408. * @param transformation defines the transformation matrix
  21409. * @returns the transformed Vector3
  21410. */
  21411. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21412. /**
  21413. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21414. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21415. * @param vector defines the Vector3 to transform
  21416. * @param transformation defines the transformation matrix
  21417. * @param result defines the Vector3 where to store the result
  21418. */
  21419. static TransformCoordinatesToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  21420. /**
  21421. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21422. * This method computes tranformed coordinates only, not transformed direction vectors
  21423. * @param x define the x coordinate of the source vector
  21424. * @param y define the y coordinate of the source vector
  21425. * @param z define the z coordinate of the source vector
  21426. * @param transformation defines the transformation matrix
  21427. * @param result defines the Vector3 where to store the result
  21428. */
  21429. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  21430. /**
  21431. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21432. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21433. * @param vector defines the Vector3 to transform
  21434. * @param transformation defines the transformation matrix
  21435. * @returns the new Vector3
  21436. */
  21437. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21438. /**
  21439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21440. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21441. * @param vector defines the Vector3 to transform
  21442. * @param transformation defines the transformation matrix
  21443. * @param result defines the Vector3 where to store the result
  21444. */
  21445. static TransformNormalToRef(vector: Vector3, transformation: Readonly<Matrix>, result: Vector3): void;
  21446. /**
  21447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21448. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21449. * @param x define the x coordinate of the source vector
  21450. * @param y define the y coordinate of the source vector
  21451. * @param z define the z coordinate of the source vector
  21452. * @param transformation defines the transformation matrix
  21453. * @param result defines the Vector3 where to store the result
  21454. */
  21455. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Readonly<Matrix>, result: Vector3): void;
  21456. /**
  21457. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21458. * @param value1 defines the first control point
  21459. * @param value2 defines the second control point
  21460. * @param value3 defines the third control point
  21461. * @param value4 defines the fourth control point
  21462. * @param amount defines the amount on the spline to use
  21463. * @returns the new Vector3
  21464. */
  21465. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21466. /**
  21467. * 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"
  21468. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21469. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21470. * @param value defines the current value
  21471. * @param min defines the lower range value
  21472. * @param max defines the upper range value
  21473. * @returns the new Vector3
  21474. */
  21475. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21476. /**
  21477. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  21478. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21479. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21480. * @param value defines the current value
  21481. * @param min defines the lower range value
  21482. * @param max defines the upper range value
  21483. * @param result defines the Vector3 where to store the result
  21484. */
  21485. static ClampToRef(value: Vector3, min: Vector3, max: Vector3, result: Vector3): void;
  21486. /**
  21487. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21488. * @param value1 defines the first control point
  21489. * @param tangent1 defines the first tangent vector
  21490. * @param value2 defines the second control point
  21491. * @param tangent2 defines the second tangent vector
  21492. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21493. * @returns the new Vector3
  21494. */
  21495. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21496. /**
  21497. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21498. * @param start defines the start value
  21499. * @param end defines the end value
  21500. * @param amount max defines amount between both (between 0 and 1)
  21501. * @returns the new Vector3
  21502. */
  21503. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21504. /**
  21505. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21506. * @param start defines the start value
  21507. * @param end defines the end value
  21508. * @param amount max defines amount between both (between 0 and 1)
  21509. * @param result defines the Vector3 where to store the result
  21510. */
  21511. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21512. /**
  21513. * Returns the dot product (float) between the vectors "left" and "right"
  21514. * @param left defines the left operand
  21515. * @param right defines the right operand
  21516. * @returns the dot product
  21517. */
  21518. static Dot(left: Vector3, right: Vector3): number;
  21519. /**
  21520. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21521. * The cross product is then orthogonal to both "left" and "right"
  21522. * @param left defines the left operand
  21523. * @param right defines the right operand
  21524. * @returns the cross product
  21525. */
  21526. static Cross(left: Vector3, right: Vector3): Vector3;
  21527. /**
  21528. * Sets the given vector "result" with the cross product of "left" and "right"
  21529. * The cross product is then orthogonal to both "left" and "right"
  21530. * @param left defines the left operand
  21531. * @param right defines the right operand
  21532. * @param result defines the Vector3 where to store the result
  21533. */
  21534. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21535. /**
  21536. * Returns a new Vector3 as the normalization of the given vector
  21537. * @param vector defines the Vector3 to normalize
  21538. * @returns the new Vector3
  21539. */
  21540. static Normalize(vector: Vector3): Vector3;
  21541. /**
  21542. * Sets the given vector "result" with the normalization of the given first vector
  21543. * @param vector defines the Vector3 to normalize
  21544. * @param result defines the Vector3 where to store the result
  21545. */
  21546. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21547. /**
  21548. * Project a Vector3 onto screen space
  21549. * @param vector defines the Vector3 to project
  21550. * @param world defines the world matrix to use
  21551. * @param transform defines the transform (view x projection) matrix to use
  21552. * @param viewport defines the screen viewport to use
  21553. * @returns the new Vector3
  21554. */
  21555. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21556. /**
  21557. * Unproject from screen space to object space
  21558. * @param source defines the screen space Vector3 to use
  21559. * @param viewportWidth defines the current width of the viewport
  21560. * @param viewportHeight defines the current height of the viewport
  21561. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21562. * @param transform defines the transform (view x projection) matrix to use
  21563. * @returns the new Vector3
  21564. */
  21565. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21566. /**
  21567. * Unproject from screen space to object space
  21568. * @param source defines the screen space Vector3 to use
  21569. * @param viewportWidth defines the current width of the viewport
  21570. * @param viewportHeight defines the current height of the viewport
  21571. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21572. * @param view defines the view matrix to use
  21573. * @param projection defines the projection matrix to use
  21574. * @returns the new Vector3
  21575. */
  21576. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21577. /**
  21578. * Unproject from screen space to object space
  21579. * @param source defines the screen space Vector3 to use
  21580. * @param viewportWidth defines the current width of the viewport
  21581. * @param viewportHeight defines the current height of the viewport
  21582. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21583. * @param view defines the view matrix to use
  21584. * @param projection defines the projection matrix to use
  21585. * @param result defines the Vector3 where to store the result
  21586. */
  21587. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21588. /**
  21589. * Unproject from screen space to object space
  21590. * @param sourceX defines the screen space x coordinate to use
  21591. * @param sourceY defines the screen space y coordinate to use
  21592. * @param sourceZ defines the screen space z coordinate to use
  21593. * @param viewportWidth defines the current width of the viewport
  21594. * @param viewportHeight defines the current height of the viewport
  21595. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21596. * @param view defines the view matrix to use
  21597. * @param projection defines the projection matrix to use
  21598. * @param result defines the Vector3 where to store the result
  21599. */
  21600. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21601. /**
  21602. * Gets the minimal coordinate values between two Vector3
  21603. * @param left defines the first operand
  21604. * @param right defines the second operand
  21605. * @returns the new Vector3
  21606. */
  21607. static Minimize(left: Vector3, right: Vector3): Vector3;
  21608. /**
  21609. * Gets the maximal coordinate values between two Vector3
  21610. * @param left defines the first operand
  21611. * @param right defines the second operand
  21612. * @returns the new Vector3
  21613. */
  21614. static Maximize(left: Vector3, right: Vector3): Vector3;
  21615. /**
  21616. * Returns the distance between the vectors "value1" and "value2"
  21617. * @param value1 defines the first operand
  21618. * @param value2 defines the second operand
  21619. * @returns the distance
  21620. */
  21621. static Distance(value1: Vector3, value2: Vector3): number;
  21622. /**
  21623. * Returns the squared distance between the vectors "value1" and "value2"
  21624. * @param value1 defines the first operand
  21625. * @param value2 defines the second operand
  21626. * @returns the squared distance
  21627. */
  21628. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21629. /**
  21630. * Returns a new Vector3 located at the center between "value1" and "value2"
  21631. * @param value1 defines the first operand
  21632. * @param value2 defines the second operand
  21633. * @returns the new Vector3
  21634. */
  21635. static Center(value1: Vector3, value2: Vector3): Vector3;
  21636. /**
  21637. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21638. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21639. * to something in order to rotate it from its local system to the given target system
  21640. * Note: axis1, axis2 and axis3 are normalized during this operation
  21641. * @param axis1 defines the first axis
  21642. * @param axis2 defines the second axis
  21643. * @param axis3 defines the third axis
  21644. * @returns a new Vector3
  21645. */
  21646. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21647. /**
  21648. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21649. * @param axis1 defines the first axis
  21650. * @param axis2 defines the second axis
  21651. * @param axis3 defines the third axis
  21652. * @param ref defines the Vector3 where to store the result
  21653. */
  21654. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21655. }
  21656. /**
  21657. * Vector4 class created for EulerAngle class conversion to Quaternion
  21658. */
  21659. class Vector4 {
  21660. /** x value of the vector */
  21661. x: number;
  21662. /** y value of the vector */
  21663. y: number;
  21664. /** z value of the vector */
  21665. z: number;
  21666. /** w value of the vector */
  21667. w: number;
  21668. /**
  21669. * Creates a Vector4 object from the given floats.
  21670. * @param x x value of the vector
  21671. * @param y y value of the vector
  21672. * @param z z value of the vector
  21673. * @param w w value of the vector
  21674. */
  21675. constructor(
  21676. /** x value of the vector */
  21677. x: number,
  21678. /** y value of the vector */
  21679. y: number,
  21680. /** z value of the vector */
  21681. z: number,
  21682. /** w value of the vector */
  21683. w: number);
  21684. /**
  21685. * Returns the string with the Vector4 coordinates.
  21686. * @returns a string containing all the vector values
  21687. */
  21688. toString(): string;
  21689. /**
  21690. * Returns the string "Vector4".
  21691. * @returns "Vector4"
  21692. */
  21693. getClassName(): string;
  21694. /**
  21695. * Returns the Vector4 hash code.
  21696. * @returns a unique hash code
  21697. */
  21698. getHashCode(): number;
  21699. /**
  21700. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21701. * @returns the resulting array
  21702. */
  21703. asArray(): number[];
  21704. /**
  21705. * Populates the given array from the given index with the Vector4 coordinates.
  21706. * @param array array to populate
  21707. * @param index index of the array to start at (default: 0)
  21708. * @returns the Vector4.
  21709. */
  21710. toArray(array: FloatArray, index?: number): Vector4;
  21711. /**
  21712. * Adds the given vector to the current Vector4.
  21713. * @param otherVector the vector to add
  21714. * @returns the updated Vector4.
  21715. */
  21716. addInPlace(otherVector: Vector4): Vector4;
  21717. /**
  21718. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21719. * @param otherVector the vector to add
  21720. * @returns the resulting vector
  21721. */
  21722. add(otherVector: Vector4): Vector4;
  21723. /**
  21724. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21725. * @param otherVector the vector to add
  21726. * @param result the vector to store the result
  21727. * @returns the current Vector4.
  21728. */
  21729. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21730. /**
  21731. * Subtract in place the given vector from the current Vector4.
  21732. * @param otherVector the vector to subtract
  21733. * @returns the updated Vector4.
  21734. */
  21735. subtractInPlace(otherVector: Vector4): Vector4;
  21736. /**
  21737. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21738. * @param otherVector the vector to add
  21739. * @returns the new vector with the result
  21740. */
  21741. subtract(otherVector: Vector4): Vector4;
  21742. /**
  21743. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21744. * @param otherVector the vector to subtract
  21745. * @param result the vector to store the result
  21746. * @returns the current Vector4.
  21747. */
  21748. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21749. /**
  21750. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21751. */
  21752. /**
  21753. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21754. * @param x value to subtract
  21755. * @param y value to subtract
  21756. * @param z value to subtract
  21757. * @param w value to subtract
  21758. * @returns new vector containing the result
  21759. */
  21760. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21761. /**
  21762. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21763. * @param x value to subtract
  21764. * @param y value to subtract
  21765. * @param z value to subtract
  21766. * @param w value to subtract
  21767. * @param result the vector to store the result in
  21768. * @returns the current Vector4.
  21769. */
  21770. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21771. /**
  21772. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21773. * @returns a new vector with the negated values
  21774. */
  21775. negate(): Vector4;
  21776. /**
  21777. * Multiplies the current Vector4 coordinates by scale (float).
  21778. * @param scale the number to scale with
  21779. * @returns the updated Vector4.
  21780. */
  21781. scaleInPlace(scale: number): Vector4;
  21782. /**
  21783. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21784. * @param scale the number to scale with
  21785. * @returns a new vector with the result
  21786. */
  21787. scale(scale: number): Vector4;
  21788. /**
  21789. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21790. * @param scale the number to scale with
  21791. * @param result a vector to store the result in
  21792. * @returns the current Vector4.
  21793. */
  21794. scaleToRef(scale: number, result: Vector4): Vector4;
  21795. /**
  21796. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21797. * @param scale defines the scale factor
  21798. * @param result defines the Vector4 object where to store the result
  21799. * @returns the unmodified current Vector4
  21800. */
  21801. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21802. /**
  21803. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21804. * @param otherVector the vector to compare against
  21805. * @returns true if they are equal
  21806. */
  21807. equals(otherVector: Vector4): boolean;
  21808. /**
  21809. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21810. * @param otherVector vector to compare against
  21811. * @param epsilon (Default: very small number)
  21812. * @returns true if they are equal
  21813. */
  21814. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21815. /**
  21816. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21817. * @param x x value to compare against
  21818. * @param y y value to compare against
  21819. * @param z z value to compare against
  21820. * @param w w value to compare against
  21821. * @returns true if equal
  21822. */
  21823. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21824. /**
  21825. * Multiplies in place the current Vector4 by the given one.
  21826. * @param otherVector vector to multiple with
  21827. * @returns the updated Vector4.
  21828. */
  21829. multiplyInPlace(otherVector: Vector4): Vector4;
  21830. /**
  21831. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21832. * @param otherVector vector to multiple with
  21833. * @returns resulting new vector
  21834. */
  21835. multiply(otherVector: Vector4): Vector4;
  21836. /**
  21837. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21838. * @param otherVector vector to multiple with
  21839. * @param result vector to store the result
  21840. * @returns the current Vector4.
  21841. */
  21842. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21843. /**
  21844. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21845. * @param x x value multiply with
  21846. * @param y y value multiply with
  21847. * @param z z value multiply with
  21848. * @param w w value multiply with
  21849. * @returns resulting new vector
  21850. */
  21851. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21852. /**
  21853. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21854. * @param otherVector vector to devide with
  21855. * @returns resulting new vector
  21856. */
  21857. divide(otherVector: Vector4): Vector4;
  21858. /**
  21859. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21860. * @param otherVector vector to devide with
  21861. * @param result vector to store the result
  21862. * @returns the current Vector4.
  21863. */
  21864. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21865. /**
  21866. * Divides the current Vector3 coordinates by the given ones.
  21867. * @param otherVector vector to devide with
  21868. * @returns the updated Vector3.
  21869. */
  21870. divideInPlace(otherVector: Vector4): Vector4;
  21871. /**
  21872. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21873. * @param other defines the second operand
  21874. * @returns the current updated Vector4
  21875. */
  21876. minimizeInPlace(other: Vector4): Vector4;
  21877. /**
  21878. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21879. * @param other defines the second operand
  21880. * @returns the current updated Vector4
  21881. */
  21882. maximizeInPlace(other: Vector4): Vector4;
  21883. /**
  21884. * Gets a new Vector4 from current Vector4 floored values
  21885. * @returns a new Vector4
  21886. */
  21887. floor(): Vector4;
  21888. /**
  21889. * Gets a new Vector4 from current Vector3 floored values
  21890. * @returns a new Vector4
  21891. */
  21892. fract(): Vector4;
  21893. /**
  21894. * Returns the Vector4 length (float).
  21895. * @returns the length
  21896. */
  21897. length(): number;
  21898. /**
  21899. * Returns the Vector4 squared length (float).
  21900. * @returns the length squared
  21901. */
  21902. lengthSquared(): number;
  21903. /**
  21904. * Normalizes in place the Vector4.
  21905. * @returns the updated Vector4.
  21906. */
  21907. normalize(): Vector4;
  21908. /**
  21909. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21910. * @returns this converted to a new vector3
  21911. */
  21912. toVector3(): Vector3;
  21913. /**
  21914. * Returns a new Vector4 copied from the current one.
  21915. * @returns the new cloned vector
  21916. */
  21917. clone(): Vector4;
  21918. /**
  21919. * Updates the current Vector4 with the given one coordinates.
  21920. * @param source the source vector to copy from
  21921. * @returns the updated Vector4.
  21922. */
  21923. copyFrom(source: Vector4): Vector4;
  21924. /**
  21925. * Updates the current Vector4 coordinates with the given floats.
  21926. * @param x float to copy from
  21927. * @param y float to copy from
  21928. * @param z float to copy from
  21929. * @param w float to copy from
  21930. * @returns the updated Vector4.
  21931. */
  21932. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21933. /**
  21934. * Updates the current Vector4 coordinates with the given floats.
  21935. * @param x float to set from
  21936. * @param y float to set from
  21937. * @param z float to set from
  21938. * @param w float to set from
  21939. * @returns the updated Vector4.
  21940. */
  21941. set(x: number, y: number, z: number, w: number): Vector4;
  21942. /**
  21943. * Copies the given float to the current Vector3 coordinates
  21944. * @param v defines the x, y, z and w coordinates of the operand
  21945. * @returns the current updated Vector3
  21946. */
  21947. setAll(v: number): Vector4;
  21948. /**
  21949. * Returns a new Vector4 set from the starting index of the given array.
  21950. * @param array the array to pull values from
  21951. * @param offset the offset into the array to start at
  21952. * @returns the new vector
  21953. */
  21954. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21955. /**
  21956. * Updates the given vector "result" from the starting index of the given array.
  21957. * @param array the array to pull values from
  21958. * @param offset the offset into the array to start at
  21959. * @param result the vector to store the result in
  21960. */
  21961. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21962. /**
  21963. * Updates the given vector "result" from the starting index of the given Float32Array.
  21964. * @param array the array to pull values from
  21965. * @param offset the offset into the array to start at
  21966. * @param result the vector to store the result in
  21967. */
  21968. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21969. /**
  21970. * Updates the given vector "result" coordinates from the given floats.
  21971. * @param x float to set from
  21972. * @param y float to set from
  21973. * @param z float to set from
  21974. * @param w float to set from
  21975. * @param result the vector to the floats in
  21976. */
  21977. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21978. /**
  21979. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21980. * @returns the new vector
  21981. */
  21982. static Zero(): Vector4;
  21983. /**
  21984. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21985. * @returns the new vector
  21986. */
  21987. static One(): Vector4;
  21988. /**
  21989. * Returns a new normalized Vector4 from the given one.
  21990. * @param vector the vector to normalize
  21991. * @returns the vector
  21992. */
  21993. static Normalize(vector: Vector4): Vector4;
  21994. /**
  21995. * Updates the given vector "result" from the normalization of the given one.
  21996. * @param vector the vector to normalize
  21997. * @param result the vector to store the result in
  21998. */
  21999. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  22000. /**
  22001. * Returns a vector with the minimum values from the left and right vectors
  22002. * @param left left vector to minimize
  22003. * @param right right vector to minimize
  22004. * @returns a new vector with the minimum of the left and right vector values
  22005. */
  22006. static Minimize(left: Vector4, right: Vector4): Vector4;
  22007. /**
  22008. * Returns a vector with the maximum values from the left and right vectors
  22009. * @param left left vector to maximize
  22010. * @param right right vector to maximize
  22011. * @returns a new vector with the maximum of the left and right vector values
  22012. */
  22013. static Maximize(left: Vector4, right: Vector4): Vector4;
  22014. /**
  22015. * Returns the distance (float) between the vectors "value1" and "value2".
  22016. * @param value1 value to calulate the distance between
  22017. * @param value2 value to calulate the distance between
  22018. * @return the distance between the two vectors
  22019. */
  22020. static Distance(value1: Vector4, value2: Vector4): number;
  22021. /**
  22022. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22023. * @param value1 value to calulate the distance between
  22024. * @param value2 value to calulate the distance between
  22025. * @return the distance between the two vectors squared
  22026. */
  22027. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  22028. /**
  22029. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22030. * @param value1 value to calulate the center between
  22031. * @param value2 value to calulate the center between
  22032. * @return the center between the two vectors
  22033. */
  22034. static Center(value1: Vector4, value2: Vector4): Vector4;
  22035. /**
  22036. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22037. * This methods computes transformed normalized direction vectors only.
  22038. * @param vector the vector to transform
  22039. * @param transformation the transformation matrix to apply
  22040. * @returns the new vector
  22041. */
  22042. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  22043. /**
  22044. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22045. * This methods computes transformed normalized direction vectors only.
  22046. * @param vector the vector to transform
  22047. * @param transformation the transformation matrix to apply
  22048. * @param result the vector to store the result in
  22049. */
  22050. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  22051. /**
  22052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22053. * This methods computes transformed normalized direction vectors only.
  22054. * @param x value to transform
  22055. * @param y value to transform
  22056. * @param z value to transform
  22057. * @param w value to transform
  22058. * @param transformation the transformation matrix to apply
  22059. * @param result the vector to store the results in
  22060. */
  22061. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  22062. }
  22063. /**
  22064. * Interface for the size containing width and height
  22065. */
  22066. interface ISize {
  22067. /**
  22068. * Width
  22069. */
  22070. width: number;
  22071. /**
  22072. * Heighht
  22073. */
  22074. height: number;
  22075. }
  22076. /**
  22077. * Size containing widht and height
  22078. */
  22079. class Size implements ISize {
  22080. /**
  22081. * Width
  22082. */
  22083. width: number;
  22084. /**
  22085. * Height
  22086. */
  22087. height: number;
  22088. /**
  22089. * Creates a Size object from the given width and height (floats).
  22090. * @param width width of the new size
  22091. * @param height height of the new size
  22092. */
  22093. constructor(width: number, height: number);
  22094. /**
  22095. * Returns a string with the Size width and height
  22096. * @returns a string with the Size width and height
  22097. */
  22098. toString(): string;
  22099. /**
  22100. * "Size"
  22101. * @returns the string "Size"
  22102. */
  22103. getClassName(): string;
  22104. /**
  22105. * Returns the Size hash code.
  22106. * @returns a hash code for a unique width and height
  22107. */
  22108. getHashCode(): number;
  22109. /**
  22110. * Updates the current size from the given one.
  22111. * @param src the given size
  22112. */
  22113. copyFrom(src: Size): void;
  22114. /**
  22115. * Updates in place the current Size from the given floats.
  22116. * @param width width of the new size
  22117. * @param height height of the new size
  22118. * @returns the updated Size.
  22119. */
  22120. copyFromFloats(width: number, height: number): Size;
  22121. /**
  22122. * Updates in place the current Size from the given floats.
  22123. * @param width width to set
  22124. * @param height height to set
  22125. * @returns the updated Size.
  22126. */
  22127. set(width: number, height: number): Size;
  22128. /**
  22129. * Multiplies the width and height by numbers
  22130. * @param w factor to multiple the width by
  22131. * @param h factor to multiple the height by
  22132. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22133. */
  22134. multiplyByFloats(w: number, h: number): Size;
  22135. /**
  22136. * Clones the size
  22137. * @returns a new Size copied from the given one.
  22138. */
  22139. clone(): Size;
  22140. /**
  22141. * True if the current Size and the given one width and height are strictly equal.
  22142. * @param other the other size to compare against
  22143. * @returns True if the current Size and the given one width and height are strictly equal.
  22144. */
  22145. equals(other: Size): boolean;
  22146. /**
  22147. * The surface of the Size : width * height (float).
  22148. */
  22149. readonly surface: number;
  22150. /**
  22151. * Create a new size of zero
  22152. * @returns a new Size set to (0.0, 0.0)
  22153. */
  22154. static Zero(): Size;
  22155. /**
  22156. * Sums the width and height of two sizes
  22157. * @param otherSize size to add to this size
  22158. * @returns a new Size set as the addition result of the current Size and the given one.
  22159. */
  22160. add(otherSize: Size): Size;
  22161. /**
  22162. * Subtracts the width and height of two
  22163. * @param otherSize size to subtract to this size
  22164. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22165. */
  22166. subtract(otherSize: Size): Size;
  22167. /**
  22168. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22169. * @param start starting size to lerp between
  22170. * @param end end size to lerp between
  22171. * @param amount amount to lerp between the start and end values
  22172. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22173. */
  22174. static Lerp(start: Size, end: Size, amount: number): Size;
  22175. }
  22176. /**
  22177. * Class used to store quaternion data
  22178. * @see https://en.wikipedia.org/wiki/Quaternion
  22179. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22180. */
  22181. class Quaternion {
  22182. /** defines the first component (0 by default) */
  22183. x: number;
  22184. /** defines the second component (0 by default) */
  22185. y: number;
  22186. /** defines the third component (0 by default) */
  22187. z: number;
  22188. /** defines the fourth component (1.0 by default) */
  22189. w: number;
  22190. /**
  22191. * Creates a new Quaternion from the given floats
  22192. * @param x defines the first component (0 by default)
  22193. * @param y defines the second component (0 by default)
  22194. * @param z defines the third component (0 by default)
  22195. * @param w defines the fourth component (1.0 by default)
  22196. */
  22197. constructor(
  22198. /** defines the first component (0 by default) */
  22199. x?: number,
  22200. /** defines the second component (0 by default) */
  22201. y?: number,
  22202. /** defines the third component (0 by default) */
  22203. z?: number,
  22204. /** defines the fourth component (1.0 by default) */
  22205. w?: number);
  22206. /**
  22207. * Gets a string representation for the current quaternion
  22208. * @returns a string with the Quaternion coordinates
  22209. */
  22210. toString(): string;
  22211. /**
  22212. * Gets the class name of the quaternion
  22213. * @returns the string "Quaternion"
  22214. */
  22215. getClassName(): string;
  22216. /**
  22217. * Gets a hash code for this quaternion
  22218. * @returns the quaternion hash code
  22219. */
  22220. getHashCode(): number;
  22221. /**
  22222. * Copy the quaternion to an array
  22223. * @returns a new array populated with 4 elements from the quaternion coordinates
  22224. */
  22225. asArray(): number[];
  22226. /**
  22227. * Check if two quaternions are equals
  22228. * @param otherQuaternion defines the second operand
  22229. * @return true if the current quaternion and the given one coordinates are strictly equals
  22230. */
  22231. equals(otherQuaternion: Quaternion): boolean;
  22232. /**
  22233. * Clone the current quaternion
  22234. * @returns a new quaternion copied from the current one
  22235. */
  22236. clone(): Quaternion;
  22237. /**
  22238. * Copy a quaternion to the current one
  22239. * @param other defines the other quaternion
  22240. * @returns the updated current quaternion
  22241. */
  22242. copyFrom(other: Quaternion): Quaternion;
  22243. /**
  22244. * Updates the current quaternion with the given float coordinates
  22245. * @param x defines the x coordinate
  22246. * @param y defines the y coordinate
  22247. * @param z defines the z coordinate
  22248. * @param w defines the w coordinate
  22249. * @returns the updated current quaternion
  22250. */
  22251. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22252. /**
  22253. * Updates the current quaternion from the given float coordinates
  22254. * @param x defines the x coordinate
  22255. * @param y defines the y coordinate
  22256. * @param z defines the z coordinate
  22257. * @param w defines the w coordinate
  22258. * @returns the updated current quaternion
  22259. */
  22260. set(x: number, y: number, z: number, w: number): Quaternion;
  22261. /**
  22262. * Adds two quaternions
  22263. * @param other defines the second operand
  22264. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22265. */
  22266. add(other: Quaternion): Quaternion;
  22267. /**
  22268. * Add a quaternion to the current one
  22269. * @param other defines the quaternion to add
  22270. * @returns the current quaternion
  22271. */
  22272. addInPlace(other: Quaternion): Quaternion;
  22273. /**
  22274. * Subtract two quaternions
  22275. * @param other defines the second operand
  22276. * @returns a new quaternion as the subtraction result of the given one from the current one
  22277. */
  22278. subtract(other: Quaternion): Quaternion;
  22279. /**
  22280. * Multiplies the current quaternion by a scale factor
  22281. * @param value defines the scale factor
  22282. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22283. */
  22284. scale(value: number): Quaternion;
  22285. /**
  22286. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22287. * @param scale defines the scale factor
  22288. * @param result defines the Quaternion object where to store the result
  22289. * @returns the unmodified current quaternion
  22290. */
  22291. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22292. /**
  22293. * Multiplies in place the current quaternion by a scale factor
  22294. * @param value defines the scale factor
  22295. * @returns the current modified quaternion
  22296. */
  22297. scaleInPlace(value: number): Quaternion;
  22298. /**
  22299. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22300. * @param scale defines the scale factor
  22301. * @param result defines the Quaternion object where to store the result
  22302. * @returns the unmodified current quaternion
  22303. */
  22304. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22305. /**
  22306. * Multiplies two quaternions
  22307. * @param q1 defines the second operand
  22308. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22309. */
  22310. multiply(q1: Quaternion): Quaternion;
  22311. /**
  22312. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22313. * @param q1 defines the second operand
  22314. * @param result defines the target quaternion
  22315. * @returns the current quaternion
  22316. */
  22317. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  22318. /**
  22319. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22320. * @param q1 defines the second operand
  22321. * @returns the currentupdated quaternion
  22322. */
  22323. multiplyInPlace(q1: Quaternion): Quaternion;
  22324. /**
  22325. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22326. * @param ref defines the target quaternion
  22327. * @returns the current quaternion
  22328. */
  22329. conjugateToRef(ref: Quaternion): Quaternion;
  22330. /**
  22331. * Conjugates in place (1-q) the current quaternion
  22332. * @returns the current updated quaternion
  22333. */
  22334. conjugateInPlace(): Quaternion;
  22335. /**
  22336. * Conjugates in place (1-q) the current quaternion
  22337. * @returns a new quaternion
  22338. */
  22339. conjugate(): Quaternion;
  22340. /**
  22341. * Gets length of current quaternion
  22342. * @returns the quaternion length (float)
  22343. */
  22344. length(): number;
  22345. /**
  22346. * Normalize in place the current quaternion
  22347. * @returns the current updated quaternion
  22348. */
  22349. normalize(): Quaternion;
  22350. /**
  22351. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22352. * @param order is a reserved parameter and is ignore for now
  22353. * @returns a new Vector3 containing the Euler angles
  22354. */
  22355. toEulerAngles(order?: string): Vector3;
  22356. /**
  22357. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22358. * @param result defines the vector which will be filled with the Euler angles
  22359. * @param order is a reserved parameter and is ignore for now
  22360. * @returns the current unchanged quaternion
  22361. */
  22362. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22363. /**
  22364. * Updates the given rotation matrix with the current quaternion values
  22365. * @param result defines the target matrix
  22366. * @returns the current unchanged quaternion
  22367. */
  22368. toRotationMatrix(result: Matrix): Quaternion;
  22369. /**
  22370. * Updates the current quaternion from the given rotation matrix values
  22371. * @param matrix defines the source matrix
  22372. * @returns the current updated quaternion
  22373. */
  22374. fromRotationMatrix(matrix: Matrix): Quaternion;
  22375. /**
  22376. * Creates a new quaternion from a rotation matrix
  22377. * @param matrix defines the source matrix
  22378. * @returns a new quaternion created from the given rotation matrix values
  22379. */
  22380. static FromRotationMatrix(matrix: Matrix): Quaternion;
  22381. /**
  22382. * Updates the given quaternion with the given rotation matrix values
  22383. * @param matrix defines the source matrix
  22384. * @param result defines the target quaternion
  22385. */
  22386. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  22387. /**
  22388. * Returns the dot product (float) between the quaternions "left" and "right"
  22389. * @param left defines the left operand
  22390. * @param right defines the right operand
  22391. * @returns the dot product
  22392. */
  22393. static Dot(left: Quaternion, right: Quaternion): number;
  22394. /**
  22395. * Checks if the two quaternions are close to each other
  22396. * @param quat0 defines the first quaternion to check
  22397. * @param quat1 defines the second quaternion to check
  22398. * @returns true if the two quaternions are close to each other
  22399. */
  22400. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  22401. /**
  22402. * Creates an empty quaternion
  22403. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22404. */
  22405. static Zero(): Quaternion;
  22406. /**
  22407. * Inverse a given quaternion
  22408. * @param q defines the source quaternion
  22409. * @returns a new quaternion as the inverted current quaternion
  22410. */
  22411. static Inverse(q: Quaternion): Quaternion;
  22412. /**
  22413. * Creates an identity quaternion
  22414. * @returns the identity quaternion
  22415. */
  22416. static Identity(): Quaternion;
  22417. /**
  22418. * Gets a boolean indicating if the given quaternion is identity
  22419. * @param quaternion defines the quaternion to check
  22420. * @returns true if the quaternion is identity
  22421. */
  22422. static IsIdentity(quaternion: Quaternion): boolean;
  22423. /**
  22424. * Creates a quaternion from a rotation around an axis
  22425. * @param axis defines the axis to use
  22426. * @param angle defines the angle to use
  22427. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22428. */
  22429. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22430. /**
  22431. * Creates a rotation around an axis and stores it into the given quaternion
  22432. * @param axis defines the axis to use
  22433. * @param angle defines the angle to use
  22434. * @param result defines the target quaternion
  22435. * @returns the target quaternion
  22436. */
  22437. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22438. /**
  22439. * Creates a new quaternion from data stored into an array
  22440. * @param array defines the data source
  22441. * @param offset defines the offset in the source array where the data starts
  22442. * @returns a new quaternion
  22443. */
  22444. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22445. /**
  22446. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22447. * @param yaw defines the rotation around Y axis
  22448. * @param pitch defines the rotation around X axis
  22449. * @param roll defines the rotation around Z axis
  22450. * @returns the new quaternion
  22451. */
  22452. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22453. /**
  22454. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22455. * @param yaw defines the rotation around Y axis
  22456. * @param pitch defines the rotation around X axis
  22457. * @param roll defines the rotation around Z axis
  22458. * @param result defines the target quaternion
  22459. */
  22460. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22461. /**
  22462. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22463. * @param alpha defines the rotation around first axis
  22464. * @param beta defines the rotation around second axis
  22465. * @param gamma defines the rotation around third axis
  22466. * @returns the new quaternion
  22467. */
  22468. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22469. /**
  22470. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22471. * @param alpha defines the rotation around first axis
  22472. * @param beta defines the rotation around second axis
  22473. * @param gamma defines the rotation around third axis
  22474. * @param result defines the target quaternion
  22475. */
  22476. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22477. /**
  22478. * 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)
  22479. * @param axis1 defines the first axis
  22480. * @param axis2 defines the second axis
  22481. * @param axis3 defines the third axis
  22482. * @returns the new quaternion
  22483. */
  22484. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22485. /**
  22486. * 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
  22487. * @param axis1 defines the first axis
  22488. * @param axis2 defines the second axis
  22489. * @param axis3 defines the third axis
  22490. * @param ref defines the target quaternion
  22491. */
  22492. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22493. /**
  22494. * Interpolates between two quaternions
  22495. * @param left defines first quaternion
  22496. * @param right defines second quaternion
  22497. * @param amount defines the gradient to use
  22498. * @returns the new interpolated quaternion
  22499. */
  22500. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22501. /**
  22502. * Interpolates between two quaternions and stores it into a target quaternion
  22503. * @param left defines first quaternion
  22504. * @param right defines second quaternion
  22505. * @param amount defines the gradient to use
  22506. * @param result defines the target quaternion
  22507. */
  22508. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22509. /**
  22510. * Interpolate between two quaternions using Hermite interpolation
  22511. * @param value1 defines first quaternion
  22512. * @param tangent1 defines the incoming tangent
  22513. * @param value2 defines second quaternion
  22514. * @param tangent2 defines the outgoing tangent
  22515. * @param amount defines the target quaternion
  22516. * @returns the new interpolated quaternion
  22517. */
  22518. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22519. }
  22520. /**
  22521. * Class used to store matrix data (4x4)
  22522. */
  22523. class Matrix {
  22524. private static _updateFlagSeed;
  22525. private static _identityReadOnly;
  22526. private _isIdentity;
  22527. private _isIdentityDirty;
  22528. private _isIdentity3x2;
  22529. private _isIdentity3x2Dirty;
  22530. /**
  22531. * Gets the update flag of the matrix which is an unique number for the matrix.
  22532. * It will be incremented every time the matrix data change.
  22533. * You can use it to speed the comparison between two versions of the same matrix.
  22534. */
  22535. updateFlag: number;
  22536. private readonly _m;
  22537. /**
  22538. * Gets the internal data of the matrix
  22539. */
  22540. readonly m: Readonly<Float32Array>;
  22541. /** @hidden */
  22542. _markAsUpdated(): void;
  22543. /** @hidden */
  22544. private _updateIdentityStatus;
  22545. /**
  22546. * Creates an empty matrix (filled with zeros)
  22547. */
  22548. constructor();
  22549. /**
  22550. * Check if the current matrix is identity
  22551. * @returns true is the matrix is the identity matrix
  22552. */
  22553. isIdentity(): boolean;
  22554. /**
  22555. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22556. * @returns true is the matrix is the identity matrix
  22557. */
  22558. isIdentityAs3x2(): boolean;
  22559. /**
  22560. * Gets the determinant of the matrix
  22561. * @returns the matrix determinant
  22562. */
  22563. determinant(): number;
  22564. /**
  22565. * Returns the matrix as a Float32Array
  22566. * @returns the matrix underlying array
  22567. */
  22568. toArray(): Readonly<Float32Array>;
  22569. /**
  22570. * Returns the matrix as a Float32Array
  22571. * @returns the matrix underlying array.
  22572. */
  22573. asArray(): Readonly<Float32Array>;
  22574. /**
  22575. * Inverts the current matrix in place
  22576. * @returns the current inverted matrix
  22577. */
  22578. invert(): Matrix;
  22579. /**
  22580. * Sets all the matrix elements to zero
  22581. * @returns the current matrix
  22582. */
  22583. reset(): Matrix;
  22584. /**
  22585. * Adds the current matrix with a second one
  22586. * @param other defines the matrix to add
  22587. * @returns a new matrix as the addition of the current matrix and the given one
  22588. */
  22589. add(other: Matrix): Matrix;
  22590. /**
  22591. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22592. * @param other defines the matrix to add
  22593. * @param result defines the target matrix
  22594. * @returns the current matrix
  22595. */
  22596. addToRef(other: Matrix, result: Matrix): Matrix;
  22597. /**
  22598. * Adds in place the given matrix to the current matrix
  22599. * @param other defines the second operand
  22600. * @returns the current updated matrix
  22601. */
  22602. addToSelf(other: Matrix): Matrix;
  22603. /**
  22604. * Sets the given matrix to the current inverted Matrix
  22605. * @param other defines the target matrix
  22606. * @returns the unmodified current matrix
  22607. */
  22608. invertToRef(other: Matrix): Matrix;
  22609. /**
  22610. * add a value at the specified position in the current Matrix
  22611. * @param index the index of the value within the matrix. between 0 and 15.
  22612. * @param value the value to be added
  22613. * @returns the current updated matrix
  22614. */
  22615. addAtIndex(index: number, value: number): Matrix;
  22616. /**
  22617. * mutiply the specified position in the current Matrix by a value
  22618. * @param index the index of the value within the matrix. between 0 and 15.
  22619. * @param value the value to be added
  22620. * @returns the current updated matrix
  22621. */
  22622. multiplyAtIndex(index: number, value: number): Matrix;
  22623. /**
  22624. * Inserts the translation vector (using 3 floats) in the current matrix
  22625. * @param x defines the 1st component of the translation
  22626. * @param y defines the 2nd component of the translation
  22627. * @param z defines the 3rd component of the translation
  22628. * @returns the current updated matrix
  22629. */
  22630. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22631. /**
  22632. * Inserts the translation vector in the current matrix
  22633. * @param vector3 defines the translation to insert
  22634. * @returns the current updated matrix
  22635. */
  22636. setTranslation(vector3: Vector3): Matrix;
  22637. /**
  22638. * Gets the translation value of the current matrix
  22639. * @returns a new Vector3 as the extracted translation from the matrix
  22640. */
  22641. getTranslation(): Vector3;
  22642. /**
  22643. * Fill a Vector3 with the extracted translation from the matrix
  22644. * @param result defines the Vector3 where to store the translation
  22645. * @returns the current matrix
  22646. */
  22647. getTranslationToRef(result: Vector3): Matrix;
  22648. /**
  22649. * Remove rotation and scaling part from the matrix
  22650. * @returns the updated matrix
  22651. */
  22652. removeRotationAndScaling(): Matrix;
  22653. /**
  22654. * Multiply two matrices
  22655. * @param other defines the second operand
  22656. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22657. */
  22658. multiply(other: Readonly<Matrix>): Matrix;
  22659. /**
  22660. * Copy the current matrix from the given one
  22661. * @param other defines the source matrix
  22662. * @returns the current updated matrix
  22663. */
  22664. copyFrom(other: Readonly<Matrix>): Matrix;
  22665. /**
  22666. * Populates the given array from the starting index with the current matrix values
  22667. * @param array defines the target array
  22668. * @param offset defines the offset in the target array where to start storing values
  22669. * @returns the current matrix
  22670. */
  22671. copyToArray(array: Float32Array, offset?: number): Matrix;
  22672. /**
  22673. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22674. * @param other defines the second operand
  22675. * @param result defines the matrix where to store the multiplication
  22676. * @returns the current matrix
  22677. */
  22678. multiplyToRef(other: Readonly<Matrix>, result: Matrix): Matrix;
  22679. /**
  22680. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22681. * @param other defines the second operand
  22682. * @param result defines the array where to store the multiplication
  22683. * @param offset defines the offset in the target array where to start storing values
  22684. * @returns the current matrix
  22685. */
  22686. multiplyToArray(other: Readonly<Matrix>, result: Float32Array, offset: number): Matrix;
  22687. /**
  22688. * Check equality between this matrix and a second one
  22689. * @param value defines the second matrix to compare
  22690. * @returns true is the current matrix and the given one values are strictly equal
  22691. */
  22692. equals(value: Matrix): boolean;
  22693. /**
  22694. * Clone the current matrix
  22695. * @returns a new matrix from the current matrix
  22696. */
  22697. clone(): Matrix;
  22698. /**
  22699. * Returns the name of the current matrix class
  22700. * @returns the string "Matrix"
  22701. */
  22702. getClassName(): string;
  22703. /**
  22704. * Gets the hash code of the current matrix
  22705. * @returns the hash code
  22706. */
  22707. getHashCode(): number;
  22708. /**
  22709. * Decomposes the current Matrix into a translation, rotation and scaling components
  22710. * @param scale defines the scale vector3 given as a reference to update
  22711. * @param rotation defines the rotation quaternion given as a reference to update
  22712. * @param translation defines the translation vector3 given as a reference to update
  22713. * @returns true if operation was successful
  22714. */
  22715. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22716. /**
  22717. * Gets specific row of the matrix
  22718. * @param index defines the number of the row to get
  22719. * @returns the index-th row of the current matrix as a new Vector4
  22720. */
  22721. getRow(index: number): Nullable<Vector4>;
  22722. /**
  22723. * Sets the index-th row of the current matrix to the vector4 values
  22724. * @param index defines the number of the row to set
  22725. * @param row defines the target vector4
  22726. * @returns the updated current matrix
  22727. */
  22728. setRow(index: number, row: Vector4): Matrix;
  22729. /**
  22730. * Compute the transpose of the matrix
  22731. * @returns the new transposed matrix
  22732. */
  22733. transpose(): Matrix;
  22734. /**
  22735. * Compute the transpose of the matrix and store it in a given matrix
  22736. * @param result defines the target matrix
  22737. * @returns the current matrix
  22738. */
  22739. transposeToRef(result: Matrix): Matrix;
  22740. /**
  22741. * Sets the index-th row of the current matrix with the given 4 x float values
  22742. * @param index defines the row index
  22743. * @param x defines the x component to set
  22744. * @param y defines the y component to set
  22745. * @param z defines the z component to set
  22746. * @param w defines the w component to set
  22747. * @returns the updated current matrix
  22748. */
  22749. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22750. /**
  22751. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22752. * @param scale defines the scale factor
  22753. * @returns a new matrix
  22754. */
  22755. scale(scale: number): Matrix;
  22756. /**
  22757. * Scale the current matrix values by a factor to a given result matrix
  22758. * @param scale defines the scale factor
  22759. * @param result defines the matrix to store the result
  22760. * @returns the current matrix
  22761. */
  22762. scaleToRef(scale: number, result: Matrix): Matrix;
  22763. /**
  22764. * Scale the current matrix values by a factor and add the result to a given matrix
  22765. * @param scale defines the scale factor
  22766. * @param result defines the Matrix to store the result
  22767. * @returns the current matrix
  22768. */
  22769. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22770. /**
  22771. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22772. * @param ref matrix to store the result
  22773. */
  22774. toNormalMatrix(ref: Matrix): void;
  22775. /**
  22776. * Gets only rotation part of the current matrix
  22777. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22778. */
  22779. getRotationMatrix(): Matrix;
  22780. /**
  22781. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22782. * @param result defines the target matrix to store data to
  22783. * @returns the current matrix
  22784. */
  22785. getRotationMatrixToRef(result: Matrix): Matrix;
  22786. /**
  22787. * Toggles model matrix from being right handed to left handed in place and vice versa
  22788. */
  22789. toggleModelMatrixHandInPlace(): void;
  22790. /**
  22791. * Toggles projection matrix from being right handed to left handed in place and vice versa
  22792. */
  22793. toggleProjectionMatrixHandInPlace(): void;
  22794. /**
  22795. * Creates a matrix from an array
  22796. * @param array defines the source array
  22797. * @param offset defines an offset in the source array
  22798. * @returns a new Matrix set from the starting index of the given array
  22799. */
  22800. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22801. /**
  22802. * Copy the content of an array into a given matrix
  22803. * @param array defines the source array
  22804. * @param offset defines an offset in the source array
  22805. * @param result defines the target matrix
  22806. */
  22807. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22808. /**
  22809. * Stores an array into a matrix after having multiplied each component by a given factor
  22810. * @param array defines the source array
  22811. * @param offset defines the offset in the source array
  22812. * @param scale defines the scaling factor
  22813. * @param result defines the target matrix
  22814. */
  22815. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22816. /**
  22817. * Gets an identity matrix that must not be updated
  22818. */
  22819. static readonly IdentityReadOnly: Readonly<Matrix>;
  22820. /**
  22821. * Stores a list of values (16) inside a given matrix
  22822. * @param initialM11 defines 1st value of 1st row
  22823. * @param initialM12 defines 2nd value of 1st row
  22824. * @param initialM13 defines 3rd value of 1st row
  22825. * @param initialM14 defines 4th value of 1st row
  22826. * @param initialM21 defines 1st value of 2nd row
  22827. * @param initialM22 defines 2nd value of 2nd row
  22828. * @param initialM23 defines 3rd value of 2nd row
  22829. * @param initialM24 defines 4th value of 2nd row
  22830. * @param initialM31 defines 1st value of 3rd row
  22831. * @param initialM32 defines 2nd value of 3rd row
  22832. * @param initialM33 defines 3rd value of 3rd row
  22833. * @param initialM34 defines 4th value of 3rd row
  22834. * @param initialM41 defines 1st value of 4th row
  22835. * @param initialM42 defines 2nd value of 4th row
  22836. * @param initialM43 defines 3rd value of 4th row
  22837. * @param initialM44 defines 4th value of 4th row
  22838. * @param result defines the target matrix
  22839. */
  22840. 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;
  22841. /**
  22842. * Creates new matrix from a list of values (16)
  22843. * @param initialM11 defines 1st value of 1st row
  22844. * @param initialM12 defines 2nd value of 1st row
  22845. * @param initialM13 defines 3rd value of 1st row
  22846. * @param initialM14 defines 4th value of 1st row
  22847. * @param initialM21 defines 1st value of 2nd row
  22848. * @param initialM22 defines 2nd value of 2nd row
  22849. * @param initialM23 defines 3rd value of 2nd row
  22850. * @param initialM24 defines 4th value of 2nd row
  22851. * @param initialM31 defines 1st value of 3rd row
  22852. * @param initialM32 defines 2nd value of 3rd row
  22853. * @param initialM33 defines 3rd value of 3rd row
  22854. * @param initialM34 defines 4th value of 3rd row
  22855. * @param initialM41 defines 1st value of 4th row
  22856. * @param initialM42 defines 2nd value of 4th row
  22857. * @param initialM43 defines 3rd value of 4th row
  22858. * @param initialM44 defines 4th value of 4th row
  22859. * @returns the new matrix
  22860. */
  22861. 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;
  22862. /**
  22863. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22864. * @param scale defines the scale vector3
  22865. * @param rotation defines the rotation quaternion
  22866. * @param translation defines the translation vector3
  22867. * @returns a new matrix
  22868. */
  22869. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22870. /**
  22871. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22872. * @param scale defines the scale vector3
  22873. * @param rotation defines the rotation quaternion
  22874. * @param translation defines the translation vector3
  22875. * @param result defines the target matrix
  22876. */
  22877. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22878. /**
  22879. * Creates a new identity matrix
  22880. * @returns a new identity matrix
  22881. */
  22882. static Identity(): Matrix;
  22883. /**
  22884. * Creates a new identity matrix and stores the result in a given matrix
  22885. * @param result defines the target matrix
  22886. */
  22887. static IdentityToRef(result: Matrix): void;
  22888. /**
  22889. * Creates a new zero matrix
  22890. * @returns a new zero matrix
  22891. */
  22892. static Zero(): Matrix;
  22893. /**
  22894. * Creates a new rotation matrix for "angle" radians around the X axis
  22895. * @param angle defines the angle (in radians) to use
  22896. * @return the new matrix
  22897. */
  22898. static RotationX(angle: number): Matrix;
  22899. /**
  22900. * Creates a new matrix as the invert of a given matrix
  22901. * @param source defines the source matrix
  22902. * @returns the new matrix
  22903. */
  22904. static Invert(source: Matrix): Matrix;
  22905. /**
  22906. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22907. * @param angle defines the angle (in radians) to use
  22908. * @param result defines the target matrix
  22909. */
  22910. static RotationXToRef(angle: number, result: Matrix): void;
  22911. /**
  22912. * Creates a new rotation matrix for "angle" radians around the Y axis
  22913. * @param angle defines the angle (in radians) to use
  22914. * @return the new matrix
  22915. */
  22916. static RotationY(angle: number): Matrix;
  22917. /**
  22918. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22919. * @param angle defines the angle (in radians) to use
  22920. * @param result defines the target matrix
  22921. */
  22922. static RotationYToRef(angle: number, result: Matrix): void;
  22923. /**
  22924. * Creates a new rotation matrix for "angle" radians around the Z axis
  22925. * @param angle defines the angle (in radians) to use
  22926. * @return the new matrix
  22927. */
  22928. static RotationZ(angle: number): Matrix;
  22929. /**
  22930. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22931. * @param angle defines the angle (in radians) to use
  22932. * @param result defines the target matrix
  22933. */
  22934. static RotationZToRef(angle: number, result: Matrix): void;
  22935. /**
  22936. * Creates a new rotation matrix for "angle" radians around the given axis
  22937. * @param axis defines the axis to use
  22938. * @param angle defines the angle (in radians) to use
  22939. * @return the new matrix
  22940. */
  22941. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22942. /**
  22943. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22944. * @param axis defines the axis to use
  22945. * @param angle defines the angle (in radians) to use
  22946. * @param result defines the target matrix
  22947. */
  22948. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22949. /**
  22950. * Creates a rotation matrix
  22951. * @param yaw defines the yaw angle in radians (Y axis)
  22952. * @param pitch defines the pitch angle in radians (X axis)
  22953. * @param roll defines the roll angle in radians (X axis)
  22954. * @returns the new rotation matrix
  22955. */
  22956. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22957. /**
  22958. * Creates a rotation matrix and stores it in a given matrix
  22959. * @param yaw defines the yaw angle in radians (Y axis)
  22960. * @param pitch defines the pitch angle in radians (X axis)
  22961. * @param roll defines the roll angle in radians (X axis)
  22962. * @param result defines the target matrix
  22963. */
  22964. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22965. /**
  22966. * Creates a scaling matrix
  22967. * @param x defines the scale factor on X axis
  22968. * @param y defines the scale factor on Y axis
  22969. * @param z defines the scale factor on Z axis
  22970. * @returns the new matrix
  22971. */
  22972. static Scaling(x: number, y: number, z: number): Matrix;
  22973. /**
  22974. * Creates a scaling matrix and stores it in a given matrix
  22975. * @param x defines the scale factor on X axis
  22976. * @param y defines the scale factor on Y axis
  22977. * @param z defines the scale factor on Z axis
  22978. * @param result defines the target matrix
  22979. */
  22980. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22981. /**
  22982. * Creates a translation matrix
  22983. * @param x defines the translation on X axis
  22984. * @param y defines the translation on Y axis
  22985. * @param z defines the translationon Z axis
  22986. * @returns the new matrix
  22987. */
  22988. static Translation(x: number, y: number, z: number): Matrix;
  22989. /**
  22990. * Creates a translation matrix and stores it in a given matrix
  22991. * @param x defines the translation on X axis
  22992. * @param y defines the translation on Y axis
  22993. * @param z defines the translationon Z axis
  22994. * @param result defines the target matrix
  22995. */
  22996. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22997. /**
  22998. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22999. * @param startValue defines the start value
  23000. * @param endValue defines the end value
  23001. * @param gradient defines the gradient factor
  23002. * @returns the new matrix
  23003. */
  23004. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  23005. /**
  23006. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23007. * @param startValue defines the start value
  23008. * @param endValue defines the end value
  23009. * @param gradient defines the gradient factor
  23010. * @param result defines the Matrix object where to store data
  23011. */
  23012. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  23013. /**
  23014. * Builds a new matrix whose values are computed by:
  23015. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23016. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23017. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23018. * @param startValue defines the first matrix
  23019. * @param endValue defines the second matrix
  23020. * @param gradient defines the gradient between the two matrices
  23021. * @returns the new matrix
  23022. */
  23023. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  23024. /**
  23025. * Update a matrix to values which are computed by:
  23026. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23027. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23028. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23029. * @param startValue defines the first matrix
  23030. * @param endValue defines the second matrix
  23031. * @param gradient defines the gradient between the two matrices
  23032. * @param result defines the target matrix
  23033. */
  23034. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  23035. /**
  23036. * 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"
  23037. * This function works in left handed mode
  23038. * @param eye defines the final position of the entity
  23039. * @param target defines where the entity should look at
  23040. * @param up defines the up vector for the entity
  23041. * @returns the new matrix
  23042. */
  23043. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  23044. /**
  23045. * 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".
  23046. * This function works in left handed mode
  23047. * @param eye defines the final position of the entity
  23048. * @param target defines where the entity should look at
  23049. * @param up defines the up vector for the entity
  23050. * @param result defines the target matrix
  23051. */
  23052. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  23053. /**
  23054. * 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"
  23055. * This function works in right handed mode
  23056. * @param eye defines the final position of the entity
  23057. * @param target defines where the entity should look at
  23058. * @param up defines the up vector for the entity
  23059. * @returns the new matrix
  23060. */
  23061. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  23062. /**
  23063. * 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".
  23064. * This function works in right handed mode
  23065. * @param eye defines the final position of the entity
  23066. * @param target defines where the entity should look at
  23067. * @param up defines the up vector for the entity
  23068. * @param result defines the target matrix
  23069. */
  23070. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  23071. /**
  23072. * Create a left-handed orthographic projection matrix
  23073. * @param width defines the viewport width
  23074. * @param height defines the viewport height
  23075. * @param znear defines the near clip plane
  23076. * @param zfar defines the far clip plane
  23077. * @returns a new matrix as a left-handed orthographic projection matrix
  23078. */
  23079. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23080. /**
  23081. * Store a left-handed orthographic projection to a given matrix
  23082. * @param width defines the viewport width
  23083. * @param height defines the viewport height
  23084. * @param znear defines the near clip plane
  23085. * @param zfar defines the far clip plane
  23086. * @param result defines the target matrix
  23087. */
  23088. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23089. /**
  23090. * Create a left-handed orthographic projection matrix
  23091. * @param left defines the viewport left coordinate
  23092. * @param right defines the viewport right coordinate
  23093. * @param bottom defines the viewport bottom coordinate
  23094. * @param top defines the viewport top coordinate
  23095. * @param znear defines the near clip plane
  23096. * @param zfar defines the far clip plane
  23097. * @returns a new matrix as a left-handed orthographic projection matrix
  23098. */
  23099. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23100. /**
  23101. * Stores a left-handed orthographic projection into a given matrix
  23102. * @param left defines the viewport left coordinate
  23103. * @param right defines the viewport right coordinate
  23104. * @param bottom defines the viewport bottom coordinate
  23105. * @param top defines the viewport top coordinate
  23106. * @param znear defines the near clip plane
  23107. * @param zfar defines the far clip plane
  23108. * @param result defines the target matrix
  23109. */
  23110. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23111. /**
  23112. * Creates a right-handed orthographic projection matrix
  23113. * @param left defines the viewport left coordinate
  23114. * @param right defines the viewport right coordinate
  23115. * @param bottom defines the viewport bottom coordinate
  23116. * @param top defines the viewport top coordinate
  23117. * @param znear defines the near clip plane
  23118. * @param zfar defines the far clip plane
  23119. * @returns a new matrix as a right-handed orthographic projection matrix
  23120. */
  23121. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23122. /**
  23123. * Stores a right-handed orthographic projection into a given matrix
  23124. * @param left defines the viewport left coordinate
  23125. * @param right defines the viewport right coordinate
  23126. * @param bottom defines the viewport bottom coordinate
  23127. * @param top defines the viewport top coordinate
  23128. * @param znear defines the near clip plane
  23129. * @param zfar defines the far clip plane
  23130. * @param result defines the target matrix
  23131. */
  23132. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23133. /**
  23134. * Creates a left-handed perspective projection matrix
  23135. * @param width defines the viewport width
  23136. * @param height defines the viewport height
  23137. * @param znear defines the near clip plane
  23138. * @param zfar defines the far clip plane
  23139. * @returns a new matrix as a left-handed perspective projection matrix
  23140. */
  23141. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23142. /**
  23143. * Creates a left-handed perspective projection matrix
  23144. * @param fov defines the horizontal field of view
  23145. * @param aspect defines the aspect ratio
  23146. * @param znear defines the near clip plane
  23147. * @param zfar defines the far clip plane
  23148. * @returns a new matrix as a left-handed perspective projection matrix
  23149. */
  23150. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23151. /**
  23152. * Stores a left-handed perspective projection into a given matrix
  23153. * @param fov defines the horizontal field of view
  23154. * @param aspect defines the aspect ratio
  23155. * @param znear defines the near clip plane
  23156. * @param zfar defines the far clip plane
  23157. * @param result defines the target matrix
  23158. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23159. */
  23160. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23161. /**
  23162. * Creates a right-handed perspective projection matrix
  23163. * @param fov defines the horizontal field of view
  23164. * @param aspect defines the aspect ratio
  23165. * @param znear defines the near clip plane
  23166. * @param zfar defines the far clip plane
  23167. * @returns a new matrix as a right-handed perspective projection matrix
  23168. */
  23169. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23170. /**
  23171. * Stores a right-handed perspective projection into a given matrix
  23172. * @param fov defines the horizontal field of view
  23173. * @param aspect defines the aspect ratio
  23174. * @param znear defines the near clip plane
  23175. * @param zfar defines the far clip plane
  23176. * @param result defines the target matrix
  23177. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23178. */
  23179. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23180. /**
  23181. * Stores a perspective projection for WebVR info a given matrix
  23182. * @param fov defines the field of view
  23183. * @param znear defines the near clip plane
  23184. * @param zfar defines the far clip plane
  23185. * @param result defines the target matrix
  23186. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23187. */
  23188. static PerspectiveFovWebVRToRef(fov: {
  23189. upDegrees: number;
  23190. downDegrees: number;
  23191. leftDegrees: number;
  23192. rightDegrees: number;
  23193. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23194. /**
  23195. * Computes a complete transformation matrix
  23196. * @param viewport defines the viewport to use
  23197. * @param world defines the world matrix
  23198. * @param view defines the view matrix
  23199. * @param projection defines the projection matrix
  23200. * @param zmin defines the near clip plane
  23201. * @param zmax defines the far clip plane
  23202. * @returns the transformation matrix
  23203. */
  23204. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  23205. /**
  23206. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23207. * @param matrix defines the matrix to use
  23208. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23209. */
  23210. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  23211. /**
  23212. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23213. * @param matrix defines the matrix to use
  23214. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23215. */
  23216. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  23217. /**
  23218. * Compute the transpose of a given matrix
  23219. * @param matrix defines the matrix to transpose
  23220. * @returns the new matrix
  23221. */
  23222. static Transpose(matrix: Matrix): Matrix;
  23223. /**
  23224. * Compute the transpose of a matrix and store it in a target matrix
  23225. * @param matrix defines the matrix to transpose
  23226. * @param result defines the target matrix
  23227. */
  23228. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  23229. /**
  23230. * Computes a reflection matrix from a plane
  23231. * @param plane defines the reflection plane
  23232. * @returns a new matrix
  23233. */
  23234. static Reflection(plane: Plane): Matrix;
  23235. /**
  23236. * Computes a reflection matrix from a plane
  23237. * @param plane defines the reflection plane
  23238. * @param result defines the target matrix
  23239. */
  23240. static ReflectionToRef(plane: Plane, result: Matrix): void;
  23241. /**
  23242. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23243. * @param xaxis defines the value of the 1st axis
  23244. * @param yaxis defines the value of the 2nd axis
  23245. * @param zaxis defines the value of the 3rd axis
  23246. * @param result defines the target matrix
  23247. */
  23248. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  23249. /**
  23250. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23251. * @param quat defines the quaternion to use
  23252. * @param result defines the target matrix
  23253. */
  23254. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  23255. }
  23256. /**
  23257. * Represens a plane by the equation ax + by + cz + d = 0
  23258. */
  23259. class Plane {
  23260. /**
  23261. * Normal of the plane (a,b,c)
  23262. */
  23263. normal: Vector3;
  23264. /**
  23265. * d component of the plane
  23266. */
  23267. d: number;
  23268. /**
  23269. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23270. * @param a a component of the plane
  23271. * @param b b component of the plane
  23272. * @param c c component of the plane
  23273. * @param d d component of the plane
  23274. */
  23275. constructor(a: number, b: number, c: number, d: number);
  23276. /**
  23277. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23278. */
  23279. asArray(): number[];
  23280. /**
  23281. * @returns a new plane copied from the current Plane.
  23282. */
  23283. clone(): Plane;
  23284. /**
  23285. * @returns the string "Plane".
  23286. */
  23287. getClassName(): string;
  23288. /**
  23289. * @returns the Plane hash code.
  23290. */
  23291. getHashCode(): number;
  23292. /**
  23293. * Normalize the current Plane in place.
  23294. * @returns the updated Plane.
  23295. */
  23296. normalize(): Plane;
  23297. /**
  23298. * Applies a transformation the plane and returns the result
  23299. * @param transformation the transformation matrix to be applied to the plane
  23300. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23301. */
  23302. transform(transformation: Matrix): Plane;
  23303. /**
  23304. * Calcualtte the dot product between the point and the plane normal
  23305. * @param point point to calculate the dot product with
  23306. * @returns the dot product (float) of the point coordinates and the plane normal.
  23307. */
  23308. dotCoordinate(point: Vector3): number;
  23309. /**
  23310. * Updates the current Plane from the plane defined by the three given points.
  23311. * @param point1 one of the points used to contruct the plane
  23312. * @param point2 one of the points used to contruct the plane
  23313. * @param point3 one of the points used to contruct the plane
  23314. * @returns the updated Plane.
  23315. */
  23316. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23317. /**
  23318. * Checks if the plane is facing a given direction
  23319. * @param direction the direction to check if the plane is facing
  23320. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23321. * @returns True is the vector "direction" is the same side than the plane normal.
  23322. */
  23323. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  23324. /**
  23325. * Calculates the distance to a point
  23326. * @param point point to calculate distance to
  23327. * @returns the signed distance (float) from the given point to the Plane.
  23328. */
  23329. signedDistanceTo(point: Vector3): number;
  23330. /**
  23331. * Creates a plane from an array
  23332. * @param array the array to create a plane from
  23333. * @returns a new Plane from the given array.
  23334. */
  23335. static FromArray(array: ArrayLike<number>): Plane;
  23336. /**
  23337. * Creates a plane from three points
  23338. * @param point1 point used to create the plane
  23339. * @param point2 point used to create the plane
  23340. * @param point3 point used to create the plane
  23341. * @returns a new Plane defined by the three given points.
  23342. */
  23343. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23344. /**
  23345. * Creates a plane from an origin point and a normal
  23346. * @param origin origin of the plane to be constructed
  23347. * @param normal normal of the plane to be constructed
  23348. * @returns a new Plane the normal vector to this plane at the given origin point.
  23349. * Note : the vector "normal" is updated because normalized.
  23350. */
  23351. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  23352. /**
  23353. * Calculates the distance from a plane and a point
  23354. * @param origin origin of the plane to be constructed
  23355. * @param normal normal of the plane to be constructed
  23356. * @param point point to calculate distance to
  23357. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23358. */
  23359. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  23360. }
  23361. /**
  23362. * Class used to represent a viewport on screen
  23363. */
  23364. class Viewport {
  23365. /** viewport left coordinate */
  23366. x: number;
  23367. /** viewport top coordinate */
  23368. y: number;
  23369. /**viewport width */
  23370. width: number;
  23371. /** viewport height */
  23372. height: number;
  23373. /**
  23374. * Creates a Viewport object located at (x, y) and sized (width, height)
  23375. * @param x defines viewport left coordinate
  23376. * @param y defines viewport top coordinate
  23377. * @param width defines the viewport width
  23378. * @param height defines the viewport height
  23379. */
  23380. constructor(
  23381. /** viewport left coordinate */
  23382. x: number,
  23383. /** viewport top coordinate */
  23384. y: number,
  23385. /**viewport width */
  23386. width: number,
  23387. /** viewport height */
  23388. height: number);
  23389. /**
  23390. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23391. * @param renderWidthOrEngine defines either an engine or the rendering width
  23392. * @param renderHeight defines the rendering height
  23393. * @returns a new Viewport
  23394. */
  23395. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23396. /**
  23397. * Returns a new Viewport copied from the current one
  23398. * @returns a new Viewport
  23399. */
  23400. clone(): Viewport;
  23401. }
  23402. /**
  23403. * Reprasents a camera frustum
  23404. */
  23405. class Frustum {
  23406. /**
  23407. * Gets the planes representing the frustum
  23408. * @param transform matrix to be applied to the returned planes
  23409. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23410. */
  23411. static GetPlanes(transform: Matrix): Plane[];
  23412. /**
  23413. * Gets the near frustum plane transformed by the transform matrix
  23414. * @param transform transformation matrix to be applied to the resulting frustum plane
  23415. * @param frustumPlane the resuling frustum plane
  23416. */
  23417. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23418. /**
  23419. * Gets the far frustum plane transformed by the transform matrix
  23420. * @param transform transformation matrix to be applied to the resulting frustum plane
  23421. * @param frustumPlane the resuling frustum plane
  23422. */
  23423. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23424. /**
  23425. * Gets the left frustum plane transformed by the transform matrix
  23426. * @param transform transformation matrix to be applied to the resulting frustum plane
  23427. * @param frustumPlane the resuling frustum plane
  23428. */
  23429. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23430. /**
  23431. * Gets the right frustum plane transformed by the transform matrix
  23432. * @param transform transformation matrix to be applied to the resulting frustum plane
  23433. * @param frustumPlane the resuling frustum plane
  23434. */
  23435. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23436. /**
  23437. * Gets the top frustum plane transformed by the transform matrix
  23438. * @param transform transformation matrix to be applied to the resulting frustum plane
  23439. * @param frustumPlane the resuling frustum plane
  23440. */
  23441. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23442. /**
  23443. * Gets the bottom frustum plane transformed by the transform matrix
  23444. * @param transform transformation matrix to be applied to the resulting frustum plane
  23445. * @param frustumPlane the resuling frustum plane
  23446. */
  23447. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23448. /**
  23449. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23450. * @param transform transformation matrix to be applied to the resulting frustum planes
  23451. * @param frustumPlanes the resuling frustum planes
  23452. */
  23453. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23454. }
  23455. /** Defines supported spaces */
  23456. enum Space {
  23457. /** Local (object) space */
  23458. LOCAL = 0,
  23459. /** World space */
  23460. WORLD = 1,
  23461. /** Bone space */
  23462. BONE = 2
  23463. }
  23464. /** Defines the 3 main axes */
  23465. class Axis {
  23466. /** X axis */
  23467. static X: Vector3;
  23468. /** Y axis */
  23469. static Y: Vector3;
  23470. /** Z axis */
  23471. static Z: Vector3;
  23472. }
  23473. /** Class used to represent a Bezier curve */
  23474. class BezierCurve {
  23475. /**
  23476. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23477. * @param t defines the time
  23478. * @param x1 defines the left coordinate on X axis
  23479. * @param y1 defines the left coordinate on Y axis
  23480. * @param x2 defines the right coordinate on X axis
  23481. * @param y2 defines the right coordinate on Y axis
  23482. * @returns the interpolated value
  23483. */
  23484. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23485. }
  23486. /**
  23487. * Defines potential orientation for back face culling
  23488. */
  23489. enum Orientation {
  23490. /**
  23491. * Clockwise
  23492. */
  23493. CW = 0,
  23494. /** Counter clockwise */
  23495. CCW = 1
  23496. }
  23497. /**
  23498. * Defines angle representation
  23499. */
  23500. class Angle {
  23501. private _radians;
  23502. /**
  23503. * Creates an Angle object of "radians" radians (float).
  23504. */
  23505. constructor(radians: number);
  23506. /**
  23507. * Get value in degrees
  23508. * @returns the Angle value in degrees (float)
  23509. */
  23510. degrees(): number;
  23511. /**
  23512. * Get value in radians
  23513. * @returns the Angle value in radians (float)
  23514. */
  23515. radians(): number;
  23516. /**
  23517. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23518. * @param a defines first vector
  23519. * @param b defines second vector
  23520. * @returns a new Angle
  23521. */
  23522. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23523. /**
  23524. * Gets a new Angle object from the given float in radians
  23525. * @param radians defines the angle value in radians
  23526. * @returns a new Angle
  23527. */
  23528. static FromRadians(radians: number): Angle;
  23529. /**
  23530. * Gets a new Angle object from the given float in degrees
  23531. * @param degrees defines the angle value in degrees
  23532. * @returns a new Angle
  23533. */
  23534. static FromDegrees(degrees: number): Angle;
  23535. }
  23536. /**
  23537. * This represents an arc in a 2d space.
  23538. */
  23539. class Arc2 {
  23540. /** Defines the start point of the arc */
  23541. startPoint: Vector2;
  23542. /** Defines the mid point of the arc */
  23543. midPoint: Vector2;
  23544. /** Defines the end point of the arc */
  23545. endPoint: Vector2;
  23546. /**
  23547. * Defines the center point of the arc.
  23548. */
  23549. centerPoint: Vector2;
  23550. /**
  23551. * Defines the radius of the arc.
  23552. */
  23553. radius: number;
  23554. /**
  23555. * Defines the angle of the arc (from mid point to end point).
  23556. */
  23557. angle: Angle;
  23558. /**
  23559. * Defines the start angle of the arc (from start point to middle point).
  23560. */
  23561. startAngle: Angle;
  23562. /**
  23563. * Defines the orientation of the arc (clock wise/counter clock wise).
  23564. */
  23565. orientation: Orientation;
  23566. /**
  23567. * Creates an Arc object from the three given points : start, middle and end.
  23568. * @param startPoint Defines the start point of the arc
  23569. * @param midPoint Defines the midlle point of the arc
  23570. * @param endPoint Defines the end point of the arc
  23571. */
  23572. constructor(
  23573. /** Defines the start point of the arc */
  23574. startPoint: Vector2,
  23575. /** Defines the mid point of the arc */
  23576. midPoint: Vector2,
  23577. /** Defines the end point of the arc */
  23578. endPoint: Vector2);
  23579. }
  23580. /**
  23581. * Represents a 2D path made up of multiple 2D points
  23582. */
  23583. class Path2 {
  23584. private _points;
  23585. private _length;
  23586. /**
  23587. * If the path start and end point are the same
  23588. */
  23589. closed: boolean;
  23590. /**
  23591. * Creates a Path2 object from the starting 2D coordinates x and y.
  23592. * @param x the starting points x value
  23593. * @param y the starting points y value
  23594. */
  23595. constructor(x: number, y: number);
  23596. /**
  23597. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23598. * @param x the added points x value
  23599. * @param y the added points y value
  23600. * @returns the updated Path2.
  23601. */
  23602. addLineTo(x: number, y: number): Path2;
  23603. /**
  23604. * 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.
  23605. * @param midX middle point x value
  23606. * @param midY middle point y value
  23607. * @param endX end point x value
  23608. * @param endY end point y value
  23609. * @param numberOfSegments (default: 36)
  23610. * @returns the updated Path2.
  23611. */
  23612. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23613. /**
  23614. * Closes the Path2.
  23615. * @returns the Path2.
  23616. */
  23617. close(): Path2;
  23618. /**
  23619. * Gets the sum of the distance between each sequential point in the path
  23620. * @returns the Path2 total length (float).
  23621. */
  23622. length(): number;
  23623. /**
  23624. * Gets the points which construct the path
  23625. * @returns the Path2 internal array of points.
  23626. */
  23627. getPoints(): Vector2[];
  23628. /**
  23629. * Retreives the point at the distance aways from the starting point
  23630. * @param normalizedLengthPosition the length along the path to retreive the point from
  23631. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23632. */
  23633. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23634. /**
  23635. * Creates a new path starting from an x and y position
  23636. * @param x starting x value
  23637. * @param y starting y value
  23638. * @returns a new Path2 starting at the coordinates (x, y).
  23639. */
  23640. static StartingAt(x: number, y: number): Path2;
  23641. }
  23642. /**
  23643. * Represents a 3D path made up of multiple 3D points
  23644. */
  23645. class Path3D {
  23646. /**
  23647. * an array of Vector3, the curve axis of the Path3D
  23648. */
  23649. path: Vector3[];
  23650. private _curve;
  23651. private _distances;
  23652. private _tangents;
  23653. private _normals;
  23654. private _binormals;
  23655. private _raw;
  23656. /**
  23657. * new Path3D(path, normal, raw)
  23658. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23659. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23660. * @param path an array of Vector3, the curve axis of the Path3D
  23661. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23662. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23663. */
  23664. constructor(
  23665. /**
  23666. * an array of Vector3, the curve axis of the Path3D
  23667. */
  23668. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23669. /**
  23670. * Returns the Path3D array of successive Vector3 designing its curve.
  23671. * @returns the Path3D array of successive Vector3 designing its curve.
  23672. */
  23673. getCurve(): Vector3[];
  23674. /**
  23675. * Returns an array populated with tangent vectors on each Path3D curve point.
  23676. * @returns an array populated with tangent vectors on each Path3D curve point.
  23677. */
  23678. getTangents(): Vector3[];
  23679. /**
  23680. * Returns an array populated with normal vectors on each Path3D curve point.
  23681. * @returns an array populated with normal vectors on each Path3D curve point.
  23682. */
  23683. getNormals(): Vector3[];
  23684. /**
  23685. * Returns an array populated with binormal vectors on each Path3D curve point.
  23686. * @returns an array populated with binormal vectors on each Path3D curve point.
  23687. */
  23688. getBinormals(): Vector3[];
  23689. /**
  23690. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23691. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23692. */
  23693. getDistances(): number[];
  23694. /**
  23695. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23696. * @param path path which all values are copied into the curves points
  23697. * @param firstNormal which should be projected onto the curve
  23698. * @returns the same object updated.
  23699. */
  23700. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23701. private _compute;
  23702. private _getFirstNonNullVector;
  23703. private _getLastNonNullVector;
  23704. private _normalVector;
  23705. }
  23706. /**
  23707. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23708. * A Curve3 is designed from a series of successive Vector3.
  23709. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23710. */
  23711. class Curve3 {
  23712. private _points;
  23713. private _length;
  23714. /**
  23715. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23716. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23717. * @param v1 (Vector3) the control point
  23718. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23719. * @param nbPoints (integer) the wanted number of points in the curve
  23720. * @returns the created Curve3
  23721. */
  23722. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23723. /**
  23724. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23725. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23726. * @param v1 (Vector3) the first control point
  23727. * @param v2 (Vector3) the second control point
  23728. * @param v3 (Vector3) the end point of the Cubic Bezier
  23729. * @param nbPoints (integer) the wanted number of points in the curve
  23730. * @returns the created Curve3
  23731. */
  23732. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23733. /**
  23734. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23735. * @param p1 (Vector3) the origin point of the Hermite Spline
  23736. * @param t1 (Vector3) the tangent vector at the origin point
  23737. * @param p2 (Vector3) the end point of the Hermite Spline
  23738. * @param t2 (Vector3) the tangent vector at the end point
  23739. * @param nbPoints (integer) the wanted number of points in the curve
  23740. * @returns the created Curve3
  23741. */
  23742. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23743. /**
  23744. * Returns a Curve3 object along a CatmullRom Spline curve :
  23745. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23746. * @param nbPoints (integer) the wanted number of points between each curve control points
  23747. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23748. * @returns the created Curve3
  23749. */
  23750. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23751. /**
  23752. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23753. * A Curve3 is designed from a series of successive Vector3.
  23754. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23755. * @param points points which make up the curve
  23756. */
  23757. constructor(points: Vector3[]);
  23758. /**
  23759. * @returns the Curve3 stored array of successive Vector3
  23760. */
  23761. getPoints(): Vector3[];
  23762. /**
  23763. * @returns the computed length (float) of the curve.
  23764. */
  23765. length(): number;
  23766. /**
  23767. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23768. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23769. * curveA and curveB keep unchanged.
  23770. * @param curve the curve to continue from this curve
  23771. * @returns the newly constructed curve
  23772. */
  23773. continue(curve: Curve3): Curve3;
  23774. private _computeLength;
  23775. }
  23776. /**
  23777. * Contains position and normal vectors for a vertex
  23778. */
  23779. class PositionNormalVertex {
  23780. /** the position of the vertex (defaut: 0,0,0) */
  23781. position: Vector3;
  23782. /** the normal of the vertex (defaut: 0,1,0) */
  23783. normal: Vector3;
  23784. /**
  23785. * Creates a PositionNormalVertex
  23786. * @param position the position of the vertex (defaut: 0,0,0)
  23787. * @param normal the normal of the vertex (defaut: 0,1,0)
  23788. */
  23789. constructor(
  23790. /** the position of the vertex (defaut: 0,0,0) */
  23791. position?: Vector3,
  23792. /** the normal of the vertex (defaut: 0,1,0) */
  23793. normal?: Vector3);
  23794. /**
  23795. * Clones the PositionNormalVertex
  23796. * @returns the cloned PositionNormalVertex
  23797. */
  23798. clone(): PositionNormalVertex;
  23799. }
  23800. /**
  23801. * Contains position, normal and uv vectors for a vertex
  23802. */
  23803. class PositionNormalTextureVertex {
  23804. /** the position of the vertex (defaut: 0,0,0) */
  23805. position: Vector3;
  23806. /** the normal of the vertex (defaut: 0,1,0) */
  23807. normal: Vector3;
  23808. /** the uv of the vertex (default: 0,0) */
  23809. uv: Vector2;
  23810. /**
  23811. * Creates a PositionNormalTextureVertex
  23812. * @param position the position of the vertex (defaut: 0,0,0)
  23813. * @param normal the normal of the vertex (defaut: 0,1,0)
  23814. * @param uv the uv of the vertex (default: 0,0)
  23815. */
  23816. constructor(
  23817. /** the position of the vertex (defaut: 0,0,0) */
  23818. position?: Vector3,
  23819. /** the normal of the vertex (defaut: 0,1,0) */
  23820. normal?: Vector3,
  23821. /** the uv of the vertex (default: 0,0) */
  23822. uv?: Vector2);
  23823. /**
  23824. * Clones the PositionNormalTextureVertex
  23825. * @returns the cloned PositionNormalTextureVertex
  23826. */
  23827. clone(): PositionNormalTextureVertex;
  23828. }
  23829. /**
  23830. * @hidden
  23831. */
  23832. class Tmp {
  23833. static Color3: Color3[];
  23834. static Color4: Color4[];
  23835. static Vector2: Vector2[];
  23836. static Vector3: Vector3[];
  23837. static Vector4: Vector4[];
  23838. static Quaternion: Quaternion[];
  23839. static Matrix: Matrix[];
  23840. }
  23841. }
  23842. declare module BABYLON {
  23843. /**
  23844. * Class representing spherical polynomial coefficients to the 3rd degree
  23845. */
  23846. class SphericalPolynomial {
  23847. /**
  23848. * The x coefficients of the spherical polynomial
  23849. */
  23850. x: Vector3;
  23851. /**
  23852. * The y coefficients of the spherical polynomial
  23853. */
  23854. y: Vector3;
  23855. /**
  23856. * The z coefficients of the spherical polynomial
  23857. */
  23858. z: Vector3;
  23859. /**
  23860. * The xx coefficients of the spherical polynomial
  23861. */
  23862. xx: Vector3;
  23863. /**
  23864. * The yy coefficients of the spherical polynomial
  23865. */
  23866. yy: Vector3;
  23867. /**
  23868. * The zz coefficients of the spherical polynomial
  23869. */
  23870. zz: Vector3;
  23871. /**
  23872. * The xy coefficients of the spherical polynomial
  23873. */
  23874. xy: Vector3;
  23875. /**
  23876. * The yz coefficients of the spherical polynomial
  23877. */
  23878. yz: Vector3;
  23879. /**
  23880. * The zx coefficients of the spherical polynomial
  23881. */
  23882. zx: Vector3;
  23883. /**
  23884. * Adds an ambient color to the spherical polynomial
  23885. * @param color the color to add
  23886. */
  23887. addAmbient(color: Color3): void;
  23888. /**
  23889. * Scales the spherical polynomial by the given amount
  23890. * @param scale the amount to scale
  23891. */
  23892. scale(scale: number): void;
  23893. /**
  23894. * Gets the spherical polynomial from harmonics
  23895. * @param harmonics the spherical harmonics
  23896. * @returns the spherical polynomial
  23897. */
  23898. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23899. /**
  23900. * Constructs a spherical polynomial from an array.
  23901. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23902. * @returns the spherical polynomial
  23903. */
  23904. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23905. }
  23906. /**
  23907. * Class representing spherical harmonics coefficients to the 3rd degree
  23908. */
  23909. class SphericalHarmonics {
  23910. /**
  23911. * The l0,0 coefficients of the spherical harmonics
  23912. */
  23913. l00: Vector3;
  23914. /**
  23915. * The l1,-1 coefficients of the spherical harmonics
  23916. */
  23917. l1_1: Vector3;
  23918. /**
  23919. * The l1,0 coefficients of the spherical harmonics
  23920. */
  23921. l10: Vector3;
  23922. /**
  23923. * The l1,1 coefficients of the spherical harmonics
  23924. */
  23925. l11: Vector3;
  23926. /**
  23927. * The l2,-2 coefficients of the spherical harmonics
  23928. */
  23929. l2_2: Vector3;
  23930. /**
  23931. * The l2,-1 coefficients of the spherical harmonics
  23932. */
  23933. l2_1: Vector3;
  23934. /**
  23935. * The l2,0 coefficients of the spherical harmonics
  23936. */
  23937. l20: Vector3;
  23938. /**
  23939. * The l2,1 coefficients of the spherical harmonics
  23940. */
  23941. l21: Vector3;
  23942. /**
  23943. * The l2,2 coefficients of the spherical harmonics
  23944. */
  23945. lL22: Vector3;
  23946. /**
  23947. * Adds a light to the spherical harmonics
  23948. * @param direction the direction of the light
  23949. * @param color the color of the light
  23950. * @param deltaSolidAngle the delta solid angle of the light
  23951. */
  23952. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23953. /**
  23954. * Scales the spherical harmonics by the given amount
  23955. * @param scale the amount to scale
  23956. */
  23957. scale(scale: number): void;
  23958. /**
  23959. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23960. *
  23961. * ```
  23962. * E_lm = A_l * L_lm
  23963. * ```
  23964. *
  23965. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23966. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23967. * the scaling factors are given in equation 9.
  23968. */
  23969. convertIncidentRadianceToIrradiance(): void;
  23970. /**
  23971. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23972. *
  23973. * ```
  23974. * L = (1/pi) * E * rho
  23975. * ```
  23976. *
  23977. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23978. */
  23979. convertIrradianceToLambertianRadiance(): void;
  23980. /**
  23981. * Gets the spherical harmonics from polynomial
  23982. * @param polynomial the spherical polynomial
  23983. * @returns the spherical harmonics
  23984. */
  23985. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23986. /**
  23987. * Constructs a spherical harmonics from an array.
  23988. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23989. * @returns the spherical harmonics
  23990. */
  23991. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23992. }
  23993. }
  23994. declare module BABYLON {
  23995. /**
  23996. * Class used to store all common mesh properties
  23997. */
  23998. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23999. /** No occlusion */
  24000. static OCCLUSION_TYPE_NONE: number;
  24001. /** Occlusion set to optimisitic */
  24002. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24003. /** Occlusion set to strict */
  24004. static OCCLUSION_TYPE_STRICT: number;
  24005. /** Use an accurante occlusion algorithm */
  24006. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24007. /** Use a conservative occlusion algorithm */
  24008. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24009. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24010. static readonly CULLINGSTRATEGY_STANDARD: number;
  24011. /** Culling strategy with bounding sphere only and then frustum culling */
  24012. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24013. /**
  24014. * No billboard
  24015. */
  24016. static readonly BILLBOARDMODE_NONE: number;
  24017. /** Billboard on X axis */
  24018. static readonly BILLBOARDMODE_X: number;
  24019. /** Billboard on Y axis */
  24020. static readonly BILLBOARDMODE_Y: number;
  24021. /** Billboard on Z axis */
  24022. static readonly BILLBOARDMODE_Z: number;
  24023. /** Billboard on all axes */
  24024. static readonly BILLBOARDMODE_ALL: number;
  24025. private _facetData;
  24026. /** Gets ot sets the culling strategy to use to find visible meshes */
  24027. cullingStrategy: number;
  24028. /**
  24029. * Gets the number of facets in the mesh
  24030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24031. */
  24032. readonly facetNb: number;
  24033. /**
  24034. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24036. */
  24037. partitioningSubdivisions: number;
  24038. /**
  24039. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24040. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24042. */
  24043. partitioningBBoxRatio: number;
  24044. /**
  24045. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24046. * Works only for updatable meshes.
  24047. * Doesn't work with multi-materials
  24048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24049. */
  24050. mustDepthSortFacets: boolean;
  24051. /**
  24052. * The location (Vector3) where the facet depth sort must be computed from.
  24053. * By default, the active camera position.
  24054. * Used only when facet depth sort is enabled
  24055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24056. */
  24057. facetDepthSortFrom: Vector3;
  24058. /**
  24059. * gets a boolean indicating if facetData is enabled
  24060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24061. */
  24062. readonly isFacetDataEnabled: boolean;
  24063. /** @hidden */
  24064. _updateNonUniformScalingState(value: boolean): boolean;
  24065. /**
  24066. * An event triggered when this mesh collides with another one
  24067. */
  24068. onCollideObservable: Observable<AbstractMesh>;
  24069. private _onCollideObserver;
  24070. /** Set a function to call when this mesh collides with another one */
  24071. onCollide: () => void;
  24072. /**
  24073. * An event triggered when the collision's position changes
  24074. */
  24075. onCollisionPositionChangeObservable: Observable<Vector3>;
  24076. private _onCollisionPositionChangeObserver;
  24077. /** Set a function to call when the collision's position changes */
  24078. onCollisionPositionChange: () => void;
  24079. /**
  24080. * An event triggered when material is changed
  24081. */
  24082. onMaterialChangedObservable: Observable<AbstractMesh>;
  24083. /**
  24084. * Gets or sets the orientation for POV movement & rotation
  24085. */
  24086. definedFacingForward: boolean;
  24087. /** @hidden */
  24088. _occlusionQuery: Nullable<WebGLQuery>;
  24089. private _visibility;
  24090. /**
  24091. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24092. */
  24093. /**
  24094. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24095. */
  24096. visibility: number;
  24097. /** Gets or sets the alpha index used to sort transparent meshes
  24098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24099. */
  24100. alphaIndex: number;
  24101. /**
  24102. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24103. */
  24104. isVisible: boolean;
  24105. /**
  24106. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24107. */
  24108. isPickable: boolean;
  24109. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24110. showSubMeshesBoundingBox: boolean;
  24111. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24112. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24113. */
  24114. isBlocker: boolean;
  24115. /**
  24116. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24117. */
  24118. enablePointerMoveEvents: boolean;
  24119. /**
  24120. * Specifies the rendering group id for this mesh (0 by default)
  24121. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24122. */
  24123. renderingGroupId: number;
  24124. private _material;
  24125. /** Gets or sets current material */
  24126. material: Nullable<Material>;
  24127. private _receiveShadows;
  24128. /**
  24129. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24130. * @see http://doc.babylonjs.com/babylon101/shadows
  24131. */
  24132. receiveShadows: boolean;
  24133. /** Defines color to use when rendering outline */
  24134. outlineColor: Color3;
  24135. /** Define width to use when rendering outline */
  24136. outlineWidth: number;
  24137. /** Defines color to use when rendering overlay */
  24138. overlayColor: Color3;
  24139. /** Defines alpha to use when rendering overlay */
  24140. overlayAlpha: number;
  24141. private _hasVertexAlpha;
  24142. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24143. hasVertexAlpha: boolean;
  24144. private _useVertexColors;
  24145. /** 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) */
  24146. useVertexColors: boolean;
  24147. private _computeBonesUsingShaders;
  24148. /**
  24149. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24150. */
  24151. computeBonesUsingShaders: boolean;
  24152. private _numBoneInfluencers;
  24153. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24154. numBoneInfluencers: number;
  24155. private _applyFog;
  24156. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24157. applyFog: boolean;
  24158. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24159. useOctreeForRenderingSelection: boolean;
  24160. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24161. useOctreeForPicking: boolean;
  24162. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24163. useOctreeForCollisions: boolean;
  24164. private _layerMask;
  24165. /**
  24166. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24167. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24168. */
  24169. layerMask: number;
  24170. /**
  24171. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24172. */
  24173. alwaysSelectAsActiveMesh: boolean;
  24174. /**
  24175. * Gets or sets the current action manager
  24176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24177. */
  24178. actionManager: Nullable<ActionManager>;
  24179. private _checkCollisions;
  24180. private _collisionMask;
  24181. private _collisionGroup;
  24182. /**
  24183. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24185. */
  24186. ellipsoid: Vector3;
  24187. /**
  24188. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24190. */
  24191. ellipsoidOffset: Vector3;
  24192. private _collider;
  24193. private _oldPositionForCollisions;
  24194. private _diffPositionForCollisions;
  24195. /**
  24196. * Gets or sets a collision mask used to mask collisions (default is -1).
  24197. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24198. */
  24199. collisionMask: number;
  24200. /**
  24201. * Gets or sets the current collision group mask (-1 by default).
  24202. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24203. */
  24204. collisionGroup: number;
  24205. /**
  24206. * Defines edge width used when edgesRenderer is enabled
  24207. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24208. */
  24209. edgesWidth: number;
  24210. /**
  24211. * Defines edge color used when edgesRenderer is enabled
  24212. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24213. */
  24214. edgesColor: Color4;
  24215. /** @hidden */
  24216. _edgesRenderer: Nullable<IEdgesRenderer>;
  24217. /** @hidden */
  24218. _masterMesh: Nullable<AbstractMesh>;
  24219. /** @hidden */
  24220. _boundingInfo: Nullable<BoundingInfo>;
  24221. /** @hidden */
  24222. _renderId: number;
  24223. /**
  24224. * Gets or sets the list of subMeshes
  24225. * @see http://doc.babylonjs.com/how_to/multi_materials
  24226. */
  24227. subMeshes: SubMesh[];
  24228. /** @hidden */
  24229. _intersectionsInProgress: AbstractMesh[];
  24230. /** @hidden */
  24231. _unIndexed: boolean;
  24232. /** @hidden */
  24233. _lightSources: Light[];
  24234. /** @hidden */
  24235. readonly _positions: Nullable<Vector3[]>;
  24236. /** @hidden */
  24237. _waitingActions: any;
  24238. /** @hidden */
  24239. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24240. private _skeleton;
  24241. /** @hidden */
  24242. _bonesTransformMatrices: Nullable<Float32Array>;
  24243. /**
  24244. * Gets or sets a skeleton to apply skining transformations
  24245. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24246. */
  24247. skeleton: Nullable<Skeleton>;
  24248. /**
  24249. * An event triggered when the mesh is rebuilt.
  24250. */
  24251. onRebuildObservable: Observable<AbstractMesh>;
  24252. /**
  24253. * Creates a new AbstractMesh
  24254. * @param name defines the name of the mesh
  24255. * @param scene defines the hosting scene
  24256. */
  24257. constructor(name: string, scene?: Nullable<Scene>);
  24258. /**
  24259. * Returns the string "AbstractMesh"
  24260. * @returns "AbstractMesh"
  24261. */
  24262. getClassName(): string;
  24263. /**
  24264. * Gets a string representation of the current mesh
  24265. * @param fullDetails defines a boolean indicating if full details must be included
  24266. * @returns a string representation of the current mesh
  24267. */
  24268. toString(fullDetails?: boolean): string;
  24269. /** @hidden */
  24270. _rebuild(): void;
  24271. /** @hidden */
  24272. _resyncLightSources(): void;
  24273. /** @hidden */
  24274. _resyncLighSource(light: Light): void;
  24275. /** @hidden */
  24276. _unBindEffect(): void;
  24277. /** @hidden */
  24278. _removeLightSource(light: Light): void;
  24279. private _markSubMeshesAsDirty;
  24280. /** @hidden */
  24281. _markSubMeshesAsLightDirty(): void;
  24282. /** @hidden */
  24283. _markSubMeshesAsAttributesDirty(): void;
  24284. /** @hidden */
  24285. _markSubMeshesAsMiscDirty(): void;
  24286. /**
  24287. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24288. */
  24289. scaling: Vector3;
  24290. /**
  24291. * Returns true if the mesh is blocked. Implemented by child classes
  24292. */
  24293. readonly isBlocked: boolean;
  24294. /**
  24295. * Returns the mesh itself by default. Implemented by child classes
  24296. * @param camera defines the camera to use to pick the right LOD level
  24297. * @returns the currentAbstractMesh
  24298. */
  24299. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24300. /**
  24301. * Returns 0 by default. Implemented by child classes
  24302. * @returns an integer
  24303. */
  24304. getTotalVertices(): number;
  24305. /**
  24306. * Returns null by default. Implemented by child classes
  24307. * @returns null
  24308. */
  24309. getIndices(): Nullable<IndicesArray>;
  24310. /**
  24311. * Returns the array of the requested vertex data kind. Implemented by child classes
  24312. * @param kind defines the vertex data kind to use
  24313. * @returns null
  24314. */
  24315. getVerticesData(kind: string): Nullable<FloatArray>;
  24316. /**
  24317. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24318. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24319. * Note that a new underlying VertexBuffer object is created each call.
  24320. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24321. * @param kind defines vertex data kind:
  24322. * * BABYLON.VertexBuffer.PositionKind
  24323. * * BABYLON.VertexBuffer.UVKind
  24324. * * BABYLON.VertexBuffer.UV2Kind
  24325. * * BABYLON.VertexBuffer.UV3Kind
  24326. * * BABYLON.VertexBuffer.UV4Kind
  24327. * * BABYLON.VertexBuffer.UV5Kind
  24328. * * BABYLON.VertexBuffer.UV6Kind
  24329. * * BABYLON.VertexBuffer.ColorKind
  24330. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24331. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24332. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24333. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @param updatable defines if the data must be flagged as updatable (or static)
  24336. * @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
  24337. * @returns the current mesh
  24338. */
  24339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24340. /**
  24341. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24342. * If the mesh has no geometry, it is simply returned as it is.
  24343. * @param kind defines vertex data kind:
  24344. * * BABYLON.VertexBuffer.PositionKind
  24345. * * BABYLON.VertexBuffer.UVKind
  24346. * * BABYLON.VertexBuffer.UV2Kind
  24347. * * BABYLON.VertexBuffer.UV3Kind
  24348. * * BABYLON.VertexBuffer.UV4Kind
  24349. * * BABYLON.VertexBuffer.UV5Kind
  24350. * * BABYLON.VertexBuffer.UV6Kind
  24351. * * BABYLON.VertexBuffer.ColorKind
  24352. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24353. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24354. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24355. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24356. * @param data defines the data source
  24357. * @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
  24358. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24359. * @returns the current mesh
  24360. */
  24361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24362. /**
  24363. * Sets the mesh indices,
  24364. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24365. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24366. * @param totalVertices Defines the total number of vertices
  24367. * @returns the current mesh
  24368. */
  24369. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24370. /**
  24371. * Gets a boolean indicating if specific vertex data is present
  24372. * @param kind defines the vertex data kind to use
  24373. * @returns true is data kind is present
  24374. */
  24375. isVerticesDataPresent(kind: string): boolean;
  24376. /**
  24377. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24378. * @returns a BoundingInfo
  24379. */
  24380. getBoundingInfo(): BoundingInfo;
  24381. /**
  24382. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24383. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24384. * @returns the current mesh
  24385. */
  24386. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24387. /**
  24388. * Overwrite the current bounding info
  24389. * @param boundingInfo defines the new bounding info
  24390. * @returns the current mesh
  24391. */
  24392. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24393. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24394. readonly useBones: boolean;
  24395. /** @hidden */
  24396. _preActivate(): void;
  24397. /** @hidden */
  24398. _preActivateForIntermediateRendering(renderId: number): void;
  24399. /** @hidden */
  24400. _activate(renderId: number): void;
  24401. /**
  24402. * Gets the current world matrix
  24403. * @returns a Matrix
  24404. */
  24405. getWorldMatrix(): Matrix;
  24406. /** @hidden */
  24407. _getWorldMatrixDeterminant(): number;
  24408. /**
  24409. * Perform relative position change from the point of view of behind the front of the mesh.
  24410. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24411. * Supports definition of mesh facing forward or backward
  24412. * @param amountRight defines the distance on the right axis
  24413. * @param amountUp defines the distance on the up axis
  24414. * @param amountForward defines the distance on the forward axis
  24415. * @returns the current mesh
  24416. */
  24417. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24418. /**
  24419. * Calculate relative position change from the point of view of behind the front of the mesh.
  24420. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24421. * Supports definition of mesh facing forward or backward
  24422. * @param amountRight defines the distance on the right axis
  24423. * @param amountUp defines the distance on the up axis
  24424. * @param amountForward defines the distance on the forward axis
  24425. * @returns the new displacement vector
  24426. */
  24427. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24428. /**
  24429. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24430. * Supports definition of mesh facing forward or backward
  24431. * @param flipBack defines the flip
  24432. * @param twirlClockwise defines the twirl
  24433. * @param tiltRight defines the tilt
  24434. * @returns the current mesh
  24435. */
  24436. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24437. /**
  24438. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24439. * Supports definition of mesh facing forward or backward.
  24440. * @param flipBack defines the flip
  24441. * @param twirlClockwise defines the twirl
  24442. * @param tiltRight defines the tilt
  24443. * @returns the new rotation vector
  24444. */
  24445. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24446. /**
  24447. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24448. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24449. * @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
  24450. * @returns the new bounding vectors
  24451. */
  24452. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24453. min: Vector3;
  24454. max: Vector3;
  24455. };
  24456. /** @hidden */
  24457. _updateBoundingInfo(): AbstractMesh;
  24458. /** @hidden */
  24459. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24460. /** @hidden */
  24461. protected _afterComputeWorldMatrix(): void;
  24462. /**
  24463. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24464. * A mesh is in the frustum if its bounding box intersects the frustum
  24465. * @param frustumPlanes defines the frustum to test
  24466. * @returns true if the mesh is in the frustum planes
  24467. */
  24468. isInFrustum(frustumPlanes: Plane[]): boolean;
  24469. /**
  24470. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24471. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24472. * @param frustumPlanes defines the frustum to test
  24473. * @returns true if the mesh is completely in the frustum planes
  24474. */
  24475. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24476. /**
  24477. * True if the mesh intersects another mesh or a SolidParticle object
  24478. * @param mesh defines a target mesh or SolidParticle to test
  24479. * @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)
  24480. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24481. * @returns true if there is an intersection
  24482. */
  24483. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24484. /**
  24485. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24486. * @param point defines the point to test
  24487. * @returns true if there is an intersection
  24488. */
  24489. intersectsPoint(point: Vector3): boolean;
  24490. /**
  24491. * Gets the position of the current mesh in camera space
  24492. * @param camera defines the camera to use
  24493. * @returns a position
  24494. */
  24495. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24496. /**
  24497. * Returns the distance from the mesh to the active camera
  24498. * @param camera defines the camera to use
  24499. * @returns the distance
  24500. */
  24501. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24502. /**
  24503. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24505. */
  24506. checkCollisions: boolean;
  24507. /**
  24508. * Gets Collider object used to compute collisions (not physics)
  24509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24510. */
  24511. readonly collider: Collider;
  24512. /**
  24513. * Move the mesh using collision engine
  24514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24515. * @param displacement defines the requested displacement vector
  24516. * @returns the current mesh
  24517. */
  24518. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24519. private _onCollisionPositionChange;
  24520. /** @hidden */
  24521. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24522. /** @hidden */
  24523. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24524. /** @hidden */
  24525. _checkCollision(collider: Collider): AbstractMesh;
  24526. /** @hidden */
  24527. _generatePointsArray(): boolean;
  24528. /**
  24529. * Checks if the passed Ray intersects with the mesh
  24530. * @param ray defines the ray to use
  24531. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24532. * @returns the picking info
  24533. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24534. */
  24535. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24536. /**
  24537. * Clones the current mesh
  24538. * @param name defines the mesh name
  24539. * @param newParent defines the new mesh parent
  24540. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24541. * @returns the new mesh
  24542. */
  24543. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24544. /**
  24545. * Disposes all the submeshes of the current meshnp
  24546. * @returns the current mesh
  24547. */
  24548. releaseSubMeshes(): AbstractMesh;
  24549. /**
  24550. * Releases resources associated with this abstract mesh.
  24551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24553. */
  24554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24555. /**
  24556. * Adds the passed mesh as a child to the current mesh
  24557. * @param mesh defines the child mesh
  24558. * @returns the current mesh
  24559. */
  24560. addChild(mesh: AbstractMesh): AbstractMesh;
  24561. /**
  24562. * Removes the passed mesh from the current mesh children list
  24563. * @param mesh defines the child mesh
  24564. * @returns the current mesh
  24565. */
  24566. removeChild(mesh: AbstractMesh): AbstractMesh;
  24567. /** @hidden */
  24568. private _initFacetData;
  24569. /**
  24570. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24571. * This method can be called within the render loop.
  24572. * 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
  24573. * @returns the current mesh
  24574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24575. */
  24576. updateFacetData(): AbstractMesh;
  24577. /**
  24578. * Returns the facetLocalNormals array.
  24579. * The normals are expressed in the mesh local spac
  24580. * @returns an array of Vector3
  24581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24582. */
  24583. getFacetLocalNormals(): Vector3[];
  24584. /**
  24585. * Returns the facetLocalPositions array.
  24586. * The facet positions are expressed in the mesh local space
  24587. * @returns an array of Vector3
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24589. */
  24590. getFacetLocalPositions(): Vector3[];
  24591. /**
  24592. * Returns the facetLocalPartioning array
  24593. * @returns an array of array of numbers
  24594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24595. */
  24596. getFacetLocalPartitioning(): number[][];
  24597. /**
  24598. * Returns the i-th facet position in the world system.
  24599. * This method allocates a new Vector3 per call
  24600. * @param i defines the facet index
  24601. * @returns a new Vector3
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24603. */
  24604. getFacetPosition(i: number): Vector3;
  24605. /**
  24606. * Sets the reference Vector3 with the i-th facet position in the world system
  24607. * @param i defines the facet index
  24608. * @param ref defines the target vector
  24609. * @returns the current mesh
  24610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24611. */
  24612. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24613. /**
  24614. * Returns the i-th facet normal in the world system.
  24615. * This method allocates a new Vector3 per call
  24616. * @param i defines the facet index
  24617. * @returns a new Vector3
  24618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24619. */
  24620. getFacetNormal(i: number): Vector3;
  24621. /**
  24622. * Sets the reference Vector3 with the i-th facet normal in the world system
  24623. * @param i defines the facet index
  24624. * @param ref defines the target vector
  24625. * @returns the current mesh
  24626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24627. */
  24628. getFacetNormalToRef(i: number, ref: Vector3): this;
  24629. /**
  24630. * 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)
  24631. * @param x defines x coordinate
  24632. * @param y defines y coordinate
  24633. * @param z defines z coordinate
  24634. * @returns the array of facet indexes
  24635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24636. */
  24637. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24638. /**
  24639. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24640. * @param projected sets as the (x,y,z) world projection on the facet
  24641. * @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
  24642. * @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
  24643. * @param x defines x coordinate
  24644. * @param y defines y coordinate
  24645. * @param z defines z coordinate
  24646. * @returns the face index if found (or null instead)
  24647. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24648. */
  24649. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24650. /**
  24651. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24652. * @param projected sets as the (x,y,z) local projection on the facet
  24653. * @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
  24654. * @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
  24655. * @param x defines x coordinate
  24656. * @param y defines y coordinate
  24657. * @param z defines z coordinate
  24658. * @returns the face index if found (or null instead)
  24659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24660. */
  24661. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24662. /**
  24663. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24664. * @returns the parameters
  24665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24666. */
  24667. getFacetDataParameters(): any;
  24668. /**
  24669. * Disables the feature FacetData and frees the related memory
  24670. * @returns the current mesh
  24671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24672. */
  24673. disableFacetData(): AbstractMesh;
  24674. /**
  24675. * Updates the AbstractMesh indices array
  24676. * @param indices defines the data source
  24677. * @returns the current mesh
  24678. */
  24679. updateIndices(indices: IndicesArray): AbstractMesh;
  24680. /**
  24681. * Creates new normals data for the mesh
  24682. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24683. * @returns the current mesh
  24684. */
  24685. createNormals(updatable: boolean): AbstractMesh;
  24686. /**
  24687. * Align the mesh with a normal
  24688. * @param normal defines the normal to use
  24689. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24690. * @returns the current mesh
  24691. */
  24692. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24693. /** @hidden */
  24694. _checkOcclusionQuery(): boolean;
  24695. }
  24696. }
  24697. declare module BABYLON {
  24698. /**
  24699. * Class used to store data that will be store in GPU memory
  24700. */
  24701. class Buffer {
  24702. private _engine;
  24703. private _buffer;
  24704. /** @hidden */
  24705. _data: Nullable<DataArray>;
  24706. private _updatable;
  24707. private _instanced;
  24708. /**
  24709. * Gets the byte stride.
  24710. */
  24711. readonly byteStride: number;
  24712. /**
  24713. * Constructor
  24714. * @param engine the engine
  24715. * @param data the data to use for this buffer
  24716. * @param updatable whether the data is updatable
  24717. * @param stride the stride (optional)
  24718. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24719. * @param instanced whether the buffer is instanced (optional)
  24720. * @param useBytes set to true if the stride in in bytes (optional)
  24721. */
  24722. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24723. /**
  24724. * Create a new VertexBuffer based on the current buffer
  24725. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24726. * @param offset defines offset in the buffer (0 by default)
  24727. * @param size defines the size in floats of attributes (position is 3 for instance)
  24728. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24729. * @param instanced defines if the vertex buffer contains indexed data
  24730. * @param useBytes defines if the offset and stride are in bytes
  24731. * @returns the new vertex buffer
  24732. */
  24733. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24734. /**
  24735. * Gets a boolean indicating if the Buffer is updatable?
  24736. * @returns true if the buffer is updatable
  24737. */
  24738. isUpdatable(): boolean;
  24739. /**
  24740. * Gets current buffer's data
  24741. * @returns a DataArray or null
  24742. */
  24743. getData(): Nullable<DataArray>;
  24744. /**
  24745. * Gets underlying native buffer
  24746. * @returns underlying native buffer
  24747. */
  24748. getBuffer(): Nullable<WebGLBuffer>;
  24749. /**
  24750. * Gets the stride in float32 units (i.e. byte stride / 4).
  24751. * May not be an integer if the byte stride is not divisible by 4.
  24752. * DEPRECATED. Use byteStride instead.
  24753. * @returns the stride in float32 units
  24754. */
  24755. getStrideSize(): number;
  24756. /**
  24757. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24758. * @param data defines the data to store
  24759. */
  24760. create(data?: Nullable<DataArray>): void;
  24761. /** @hidden */
  24762. _rebuild(): void;
  24763. /**
  24764. * Update current buffer data
  24765. * @param data defines the data to store
  24766. */
  24767. update(data: DataArray): void;
  24768. /**
  24769. * Updates the data directly.
  24770. * @param data the new data
  24771. * @param offset the new offset
  24772. * @param vertexCount the vertex count (optional)
  24773. * @param useBytes set to true if the offset is in bytes
  24774. */
  24775. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24776. /**
  24777. * Release all resources
  24778. */
  24779. dispose(): void;
  24780. }
  24781. }
  24782. declare module BABYLON {
  24783. /**
  24784. * Class for building Constructive Solid Geometry
  24785. */
  24786. class CSG {
  24787. private polygons;
  24788. /**
  24789. * The world matrix
  24790. */
  24791. matrix: Matrix;
  24792. /**
  24793. * Stores the position
  24794. */
  24795. position: Vector3;
  24796. /**
  24797. * Stores the rotation
  24798. */
  24799. rotation: Vector3;
  24800. /**
  24801. * Stores the rotation quaternion
  24802. */
  24803. rotationQuaternion: Nullable<Quaternion>;
  24804. /**
  24805. * Stores the scaling vector
  24806. */
  24807. scaling: Vector3;
  24808. /**
  24809. * Convert the BABYLON.Mesh to BABYLON.CSG
  24810. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24811. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24812. */
  24813. static FromMesh(mesh: Mesh): CSG;
  24814. /**
  24815. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24816. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24817. */
  24818. private static FromPolygons;
  24819. /**
  24820. * Clones, or makes a deep copy, of the BABYLON.CSG
  24821. * @returns A new BABYLON.CSG
  24822. */
  24823. clone(): CSG;
  24824. /**
  24825. * Unions this CSG with another CSG
  24826. * @param csg The CSG to union against this CSG
  24827. * @returns The unioned CSG
  24828. */
  24829. union(csg: CSG): CSG;
  24830. /**
  24831. * Unions this CSG with another CSG in place
  24832. * @param csg The CSG to union against this CSG
  24833. */
  24834. unionInPlace(csg: CSG): void;
  24835. /**
  24836. * Subtracts this CSG with another CSG
  24837. * @param csg The CSG to subtract against this CSG
  24838. * @returns A new BABYLON.CSG
  24839. */
  24840. subtract(csg: CSG): CSG;
  24841. /**
  24842. * Subtracts this CSG with another CSG in place
  24843. * @param csg The CSG to subtact against this CSG
  24844. */
  24845. subtractInPlace(csg: CSG): void;
  24846. /**
  24847. * Intersect this CSG with another CSG
  24848. * @param csg The CSG to intersect against this CSG
  24849. * @returns A new BABYLON.CSG
  24850. */
  24851. intersect(csg: CSG): CSG;
  24852. /**
  24853. * Intersects this CSG with another CSG in place
  24854. * @param csg The CSG to intersect against this CSG
  24855. */
  24856. intersectInPlace(csg: CSG): void;
  24857. /**
  24858. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24859. * not modified.
  24860. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24861. */
  24862. inverse(): CSG;
  24863. /**
  24864. * Inverses the BABYLON.CSG in place
  24865. */
  24866. inverseInPlace(): void;
  24867. /**
  24868. * This is used to keep meshes transformations so they can be restored
  24869. * when we build back a Babylon Mesh
  24870. * NB : All CSG operations are performed in world coordinates
  24871. * @param csg The BABYLON.CSG to copy the transform attributes from
  24872. * @returns This BABYLON.CSG
  24873. */
  24874. copyTransformAttributes(csg: CSG): CSG;
  24875. /**
  24876. * Build Raw mesh from CSG
  24877. * Coordinates here are in world space
  24878. * @param name The name of the mesh geometry
  24879. * @param scene The BABYLON.Scene
  24880. * @param keepSubMeshes Specifies if the submeshes should be kept
  24881. * @returns A new BABYLON.Mesh
  24882. */
  24883. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24884. /**
  24885. * Build Mesh from CSG taking material and transforms into account
  24886. * @param name The name of the BABYLON.Mesh
  24887. * @param material The material of the BABYLON.Mesh
  24888. * @param scene The BABYLON.Scene
  24889. * @param keepSubMeshes Specifies if submeshes should be kept
  24890. * @returns The new BABYLON.Mesh
  24891. */
  24892. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24893. }
  24894. }
  24895. declare module BABYLON {
  24896. /**
  24897. * Class used to store geometry data (vertex buffers + index buffer)
  24898. */
  24899. class Geometry implements IGetSetVerticesData {
  24900. /**
  24901. * Gets or sets the unique ID of the geometry
  24902. */
  24903. id: string;
  24904. /**
  24905. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24906. */
  24907. delayLoadState: number;
  24908. /**
  24909. * Gets the file containing the data to load when running in delay load state
  24910. */
  24911. delayLoadingFile: Nullable<string>;
  24912. /**
  24913. * Callback called when the geometry is updated
  24914. */
  24915. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24916. private _scene;
  24917. private _engine;
  24918. private _meshes;
  24919. private _totalVertices;
  24920. /** @hidden */
  24921. _indices: IndicesArray;
  24922. /** @hidden */
  24923. _vertexBuffers: {
  24924. [key: string]: VertexBuffer;
  24925. };
  24926. private _isDisposed;
  24927. private _extend;
  24928. private _boundingBias;
  24929. /** @hidden */
  24930. _delayInfo: Array<string>;
  24931. private _indexBuffer;
  24932. private _indexBufferIsUpdatable;
  24933. /** @hidden */
  24934. _boundingInfo: Nullable<BoundingInfo>;
  24935. /** @hidden */
  24936. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24937. /** @hidden */
  24938. _softwareSkinningFrameId: number;
  24939. private _vertexArrayObjects;
  24940. private _updatable;
  24941. /** @hidden */
  24942. _positions: Nullable<Vector3[]>;
  24943. /**
  24944. * 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
  24945. */
  24946. /**
  24947. * 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
  24948. */
  24949. boundingBias: Vector2;
  24950. /**
  24951. * Static function used to attach a new empty geometry to a mesh
  24952. * @param mesh defines the mesh to attach the geometry to
  24953. * @returns the new Geometry
  24954. */
  24955. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24956. /**
  24957. * Creates a new geometry
  24958. * @param id defines the unique ID
  24959. * @param scene defines the hosting scene
  24960. * @param vertexData defines the VertexData used to get geometry data
  24961. * @param updatable defines if geometry must be updatable (false by default)
  24962. * @param mesh defines the mesh that will be associated with the geometry
  24963. */
  24964. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24965. /**
  24966. * Gets the current extend of the geometry
  24967. */
  24968. readonly extend: {
  24969. minimum: Vector3;
  24970. maximum: Vector3;
  24971. };
  24972. /**
  24973. * Gets the hosting scene
  24974. * @returns the hosting Scene
  24975. */
  24976. getScene(): Scene;
  24977. /**
  24978. * Gets the hosting engine
  24979. * @returns the hosting Engine
  24980. */
  24981. getEngine(): Engine;
  24982. /**
  24983. * Defines if the geometry is ready to use
  24984. * @returns true if the geometry is ready to be used
  24985. */
  24986. isReady(): boolean;
  24987. /**
  24988. * Gets a value indicating that the geometry should not be serialized
  24989. */
  24990. readonly doNotSerialize: boolean;
  24991. /** @hidden */
  24992. _rebuild(): void;
  24993. /**
  24994. * Affects all geometry data in one call
  24995. * @param vertexData defines the geometry data
  24996. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24997. */
  24998. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24999. /**
  25000. * Set specific vertex data
  25001. * @param kind defines the data kind (Position, normal, etc...)
  25002. * @param data defines the vertex data to use
  25003. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25004. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25005. */
  25006. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25007. /**
  25008. * Removes a specific vertex data
  25009. * @param kind defines the data kind (Position, normal, etc...)
  25010. */
  25011. removeVerticesData(kind: string): void;
  25012. /**
  25013. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25014. * @param buffer defines the vertex buffer to use
  25015. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25016. */
  25017. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25018. /**
  25019. * Update a specific vertex buffer
  25020. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25021. * It will do nothing if the buffer is not updatable
  25022. * @param kind defines the data kind (Position, normal, etc...)
  25023. * @param data defines the data to use
  25024. * @param offset defines the offset in the target buffer where to store the data
  25025. * @param useBytes set to true if the offset is in bytes
  25026. */
  25027. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25028. /**
  25029. * Update a specific vertex buffer
  25030. * This function will create a new buffer if the current one is not updatable
  25031. * @param kind defines the data kind (Position, normal, etc...)
  25032. * @param data defines the data to use
  25033. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25034. */
  25035. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25036. private _updateBoundingInfo;
  25037. /** @hidden */
  25038. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25039. /**
  25040. * Gets total number of vertices
  25041. * @returns the total number of vertices
  25042. */
  25043. getTotalVertices(): number;
  25044. /**
  25045. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25046. * @param kind defines the data kind (Position, normal, etc...)
  25047. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25048. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25049. * @returns a float array containing vertex data
  25050. */
  25051. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25052. /**
  25053. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25054. * @param kind defines the data kind (Position, normal, etc...)
  25055. * @returns true if the vertex buffer with the specified kind is updatable
  25056. */
  25057. isVertexBufferUpdatable(kind: string): boolean;
  25058. /**
  25059. * Gets a specific vertex buffer
  25060. * @param kind defines the data kind (Position, normal, etc...)
  25061. * @returns a VertexBuffer
  25062. */
  25063. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25064. /**
  25065. * Returns all vertex buffers
  25066. * @return an object holding all vertex buffers indexed by kind
  25067. */
  25068. getVertexBuffers(): Nullable<{
  25069. [key: string]: VertexBuffer;
  25070. }>;
  25071. /**
  25072. * Gets a boolean indicating if specific vertex buffer is present
  25073. * @param kind defines the data kind (Position, normal, etc...)
  25074. * @returns true if data is present
  25075. */
  25076. isVerticesDataPresent(kind: string): boolean;
  25077. /**
  25078. * Gets a list of all attached data kinds (Position, normal, etc...)
  25079. * @returns a list of string containing all kinds
  25080. */
  25081. getVerticesDataKinds(): string[];
  25082. /**
  25083. * Update index buffer
  25084. * @param indices defines the indices to store in the index buffer
  25085. * @param offset defines the offset in the target buffer where to store the data
  25086. */
  25087. updateIndices(indices: IndicesArray, offset?: number): void;
  25088. /**
  25089. * Creates a new index buffer
  25090. * @param indices defines the indices to store in the index buffer
  25091. * @param totalVertices defines the total number of vertices (could be null)
  25092. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25093. */
  25094. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25095. /**
  25096. * Return the total number of indices
  25097. * @returns the total number of indices
  25098. */
  25099. getTotalIndices(): number;
  25100. /**
  25101. * Gets the index buffer array
  25102. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25103. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25104. * @returns the index buffer array
  25105. */
  25106. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25107. /**
  25108. * Gets the index buffer
  25109. * @return the index buffer
  25110. */
  25111. getIndexBuffer(): Nullable<WebGLBuffer>;
  25112. /** @hidden */
  25113. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25114. /**
  25115. * Release the associated resources for a specific mesh
  25116. * @param mesh defines the source mesh
  25117. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25118. */
  25119. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25120. /**
  25121. * Apply current geometry to a given mesh
  25122. * @param mesh defines the mesh to apply geometry to
  25123. */
  25124. applyToMesh(mesh: Mesh): void;
  25125. private _updateExtend;
  25126. private _applyToMesh;
  25127. private notifyUpdate;
  25128. /**
  25129. * Load the geometry if it was flagged as delay loaded
  25130. * @param scene defines the hosting scene
  25131. * @param onLoaded defines a callback called when the geometry is loaded
  25132. */
  25133. load(scene: Scene, onLoaded?: () => void): void;
  25134. private _queueLoad;
  25135. /**
  25136. * Invert the geometry to move from a right handed system to a left handed one.
  25137. */
  25138. toLeftHanded(): void;
  25139. /** @hidden */
  25140. _resetPointsArrayCache(): void;
  25141. /** @hidden */
  25142. _generatePointsArray(): boolean;
  25143. /**
  25144. * Gets a value indicating if the geometry is disposed
  25145. * @returns true if the geometry was disposed
  25146. */
  25147. isDisposed(): boolean;
  25148. private _disposeVertexArrayObjects;
  25149. /**
  25150. * Free all associated resources
  25151. */
  25152. dispose(): void;
  25153. /**
  25154. * Clone the current geometry into a new geometry
  25155. * @param id defines the unique ID of the new geometry
  25156. * @returns a new geometry object
  25157. */
  25158. copy(id: string): Geometry;
  25159. /**
  25160. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25161. * @return a JSON representation of the current geometry data (without the vertices data)
  25162. */
  25163. serialize(): any;
  25164. private toNumberArray;
  25165. /**
  25166. * Serialize all vertices data into a JSON oject
  25167. * @returns a JSON representation of the current geometry data
  25168. */
  25169. serializeVerticeData(): any;
  25170. /**
  25171. * Extracts a clone of a mesh geometry
  25172. * @param mesh defines the source mesh
  25173. * @param id defines the unique ID of the new geometry object
  25174. * @returns the new geometry object
  25175. */
  25176. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25177. /**
  25178. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25179. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25180. * Be aware Math.random() could cause collisions, but:
  25181. * "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"
  25182. * @returns a string containing a new GUID
  25183. */
  25184. static RandomId(): string;
  25185. /** @hidden */
  25186. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25187. private static _CleanMatricesWeights;
  25188. /**
  25189. * Create a new geometry from persisted data (Using .babylon file format)
  25190. * @param parsedVertexData defines the persisted data
  25191. * @param scene defines the hosting scene
  25192. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25193. * @returns the new geometry object
  25194. */
  25195. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25196. }
  25197. /**
  25198. * Abstract class used to provide common services for all typed geometries
  25199. * @hidden
  25200. */
  25201. class _PrimitiveGeometry extends Geometry {
  25202. private _canBeRegenerated;
  25203. private _beingRegenerated;
  25204. /**
  25205. * Creates a new typed geometry
  25206. * @param id defines the unique ID of the geometry
  25207. * @param scene defines the hosting scene
  25208. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25209. * @param mesh defines the hosting mesh (can be null)
  25210. */
  25211. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25212. /**
  25213. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25214. * @returns true if the geometry can be regenerated
  25215. */
  25216. canBeRegenerated(): boolean;
  25217. /**
  25218. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25219. */
  25220. regenerate(): void;
  25221. /**
  25222. * Clone the geometry
  25223. * @param id defines the unique ID of the new geometry
  25224. * @returns the new geometry
  25225. */
  25226. asNewGeometry(id: string): Geometry;
  25227. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25228. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25229. /** @hidden */
  25230. _regenerateVertexData(): VertexData;
  25231. copy(id: string): Geometry;
  25232. serialize(): any;
  25233. }
  25234. /**
  25235. * Creates a ribbon geometry
  25236. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25237. */
  25238. class RibbonGeometry extends _PrimitiveGeometry {
  25239. /**
  25240. * Defines the array of paths to use
  25241. */
  25242. pathArray: Vector3[][];
  25243. /**
  25244. * Defines if the last and first points of each path in your pathArray must be joined
  25245. */
  25246. closeArray: boolean;
  25247. /**
  25248. * Defines if the last and first points of each path in your pathArray must be joined
  25249. */
  25250. closePath: boolean;
  25251. /**
  25252. * Defines the offset between points
  25253. */
  25254. offset: number;
  25255. /**
  25256. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25257. */
  25258. side: number;
  25259. /**
  25260. * Creates a ribbon geometry
  25261. * @param id defines the unique ID of the geometry
  25262. * @param scene defines the hosting scene
  25263. * @param pathArray defines the array of paths to use
  25264. * @param closeArray defines if the last path and the first path must be joined
  25265. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25266. * @param offset defines the offset between points
  25267. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25268. * @param mesh defines the hosting mesh (can be null)
  25269. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25270. */
  25271. constructor(id: string, scene: Scene,
  25272. /**
  25273. * Defines the array of paths to use
  25274. */
  25275. pathArray: Vector3[][],
  25276. /**
  25277. * Defines if the last and first points of each path in your pathArray must be joined
  25278. */
  25279. closeArray: boolean,
  25280. /**
  25281. * Defines if the last and first points of each path in your pathArray must be joined
  25282. */
  25283. closePath: boolean,
  25284. /**
  25285. * Defines the offset between points
  25286. */
  25287. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25288. /**
  25289. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25290. */
  25291. side?: number);
  25292. /** @hidden */
  25293. _regenerateVertexData(): VertexData;
  25294. copy(id: string): Geometry;
  25295. }
  25296. /**
  25297. * Creates a box geometry
  25298. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25299. */
  25300. class BoxGeometry extends _PrimitiveGeometry {
  25301. /**
  25302. * Defines the zise of the box (width, height and depth are the same)
  25303. */
  25304. size: number;
  25305. /**
  25306. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25307. */
  25308. side: number;
  25309. /**
  25310. * Creates a box geometry
  25311. * @param id defines the unique ID of the geometry
  25312. * @param scene defines the hosting scene
  25313. * @param size defines the zise of the box (width, height and depth are the same)
  25314. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25315. * @param mesh defines the hosting mesh (can be null)
  25316. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25317. */
  25318. constructor(id: string, scene: Scene,
  25319. /**
  25320. * Defines the zise of the box (width, height and depth are the same)
  25321. */
  25322. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25323. /**
  25324. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25325. */
  25326. side?: number);
  25327. /** @hidden */
  25328. _regenerateVertexData(): VertexData;
  25329. copy(id: string): Geometry;
  25330. serialize(): any;
  25331. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25332. }
  25333. /**
  25334. * Creates a sphere geometry
  25335. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25336. */
  25337. class SphereGeometry extends _PrimitiveGeometry {
  25338. /**
  25339. * Defines the number of segments to use to create the sphere
  25340. */
  25341. segments: number;
  25342. /**
  25343. * Defines the diameter of the sphere
  25344. */
  25345. diameter: number;
  25346. /**
  25347. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25348. */
  25349. side: number;
  25350. /**
  25351. * Create a new sphere geometry
  25352. * @param id defines the unique ID of the geometry
  25353. * @param scene defines the hosting scene
  25354. * @param segments defines the number of segments to use to create the sphere
  25355. * @param diameter defines the diameter of the sphere
  25356. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25357. * @param mesh defines the hosting mesh (can be null)
  25358. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25359. */
  25360. constructor(id: string, scene: Scene,
  25361. /**
  25362. * Defines the number of segments to use to create the sphere
  25363. */
  25364. segments: number,
  25365. /**
  25366. * Defines the diameter of the sphere
  25367. */
  25368. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25369. /**
  25370. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25371. */
  25372. side?: number);
  25373. /** @hidden */
  25374. _regenerateVertexData(): VertexData;
  25375. copy(id: string): Geometry;
  25376. serialize(): any;
  25377. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25378. }
  25379. /**
  25380. * Creates a disc geometry
  25381. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25382. */
  25383. class DiscGeometry extends _PrimitiveGeometry {
  25384. /**
  25385. * Defines the radius of the disc
  25386. */
  25387. radius: number;
  25388. /**
  25389. * Defines the tesselation factor to apply to the disc
  25390. */
  25391. tessellation: number;
  25392. /**
  25393. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25394. */
  25395. side: number;
  25396. /**
  25397. * Creates a new disc geometry
  25398. * @param id defines the unique ID of the geometry
  25399. * @param scene defines the hosting scene
  25400. * @param radius defines the radius of the disc
  25401. * @param tessellation defines the tesselation factor to apply to the disc
  25402. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25403. * @param mesh defines the hosting mesh (can be null)
  25404. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25405. */
  25406. constructor(id: string, scene: Scene,
  25407. /**
  25408. * Defines the radius of the disc
  25409. */
  25410. radius: number,
  25411. /**
  25412. * Defines the tesselation factor to apply to the disc
  25413. */
  25414. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25415. /**
  25416. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25417. */
  25418. side?: number);
  25419. /** @hidden */
  25420. _regenerateVertexData(): VertexData;
  25421. copy(id: string): Geometry;
  25422. }
  25423. /**
  25424. * Creates a new cylinder geometry
  25425. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25426. */
  25427. class CylinderGeometry extends _PrimitiveGeometry {
  25428. /**
  25429. * Defines the height of the cylinder
  25430. */
  25431. height: number;
  25432. /**
  25433. * Defines the diameter of the cylinder's top cap
  25434. */
  25435. diameterTop: number;
  25436. /**
  25437. * Defines the diameter of the cylinder's bottom cap
  25438. */
  25439. diameterBottom: number;
  25440. /**
  25441. * Defines the tessellation factor to apply to the cylinder
  25442. */
  25443. tessellation: number;
  25444. /**
  25445. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25446. */
  25447. subdivisions: number;
  25448. /**
  25449. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25450. */
  25451. side: number;
  25452. /**
  25453. * Creates a new cylinder geometry
  25454. * @param id defines the unique ID of the geometry
  25455. * @param scene defines the hosting scene
  25456. * @param height defines the height of the cylinder
  25457. * @param diameterTop defines the diameter of the cylinder's top cap
  25458. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25459. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25460. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25461. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25462. * @param mesh defines the hosting mesh (can be null)
  25463. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25464. */
  25465. constructor(id: string, scene: Scene,
  25466. /**
  25467. * Defines the height of the cylinder
  25468. */
  25469. height: number,
  25470. /**
  25471. * Defines the diameter of the cylinder's top cap
  25472. */
  25473. diameterTop: number,
  25474. /**
  25475. * Defines the diameter of the cylinder's bottom cap
  25476. */
  25477. diameterBottom: number,
  25478. /**
  25479. * Defines the tessellation factor to apply to the cylinder
  25480. */
  25481. tessellation: number,
  25482. /**
  25483. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25484. */
  25485. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25486. /**
  25487. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25488. */
  25489. side?: number);
  25490. /** @hidden */
  25491. _regenerateVertexData(): VertexData;
  25492. copy(id: string): Geometry;
  25493. serialize(): any;
  25494. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25495. }
  25496. /**
  25497. * Creates a new torus geometry
  25498. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25499. */
  25500. class TorusGeometry extends _PrimitiveGeometry {
  25501. /**
  25502. * Defines the diameter of the torus
  25503. */
  25504. diameter: number;
  25505. /**
  25506. * Defines the thickness of the torus (ie. internal diameter)
  25507. */
  25508. thickness: number;
  25509. /**
  25510. * Defines the tesselation factor to apply to the torus
  25511. */
  25512. tessellation: number;
  25513. /**
  25514. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25515. */
  25516. side: number;
  25517. /**
  25518. * Creates a new torus geometry
  25519. * @param id defines the unique ID of the geometry
  25520. * @param scene defines the hosting scene
  25521. * @param diameter defines the diameter of the torus
  25522. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25523. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25524. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25525. * @param mesh defines the hosting mesh (can be null)
  25526. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25527. */
  25528. constructor(id: string, scene: Scene,
  25529. /**
  25530. * Defines the diameter of the torus
  25531. */
  25532. diameter: number,
  25533. /**
  25534. * Defines the thickness of the torus (ie. internal diameter)
  25535. */
  25536. thickness: number,
  25537. /**
  25538. * Defines the tesselation factor to apply to the torus
  25539. */
  25540. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25541. /**
  25542. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25543. */
  25544. side?: number);
  25545. /** @hidden */
  25546. _regenerateVertexData(): VertexData;
  25547. copy(id: string): Geometry;
  25548. serialize(): any;
  25549. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25550. }
  25551. /**
  25552. * Creates a new ground geometry
  25553. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25554. */
  25555. class GroundGeometry extends _PrimitiveGeometry {
  25556. /**
  25557. * Defines the width of the ground
  25558. */
  25559. width: number;
  25560. /**
  25561. * Defines the height of the ground
  25562. */
  25563. height: number;
  25564. /**
  25565. * Defines the subdivisions to apply to the ground
  25566. */
  25567. subdivisions: number;
  25568. /**
  25569. * Creates a new ground geometry
  25570. * @param id defines the unique ID of the geometry
  25571. * @param scene defines the hosting scene
  25572. * @param width defines the width of the ground
  25573. * @param height defines the height of the ground
  25574. * @param subdivisions defines the subdivisions to apply to the ground
  25575. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25576. * @param mesh defines the hosting mesh (can be null)
  25577. */
  25578. constructor(id: string, scene: Scene,
  25579. /**
  25580. * Defines the width of the ground
  25581. */
  25582. width: number,
  25583. /**
  25584. * Defines the height of the ground
  25585. */
  25586. height: number,
  25587. /**
  25588. * Defines the subdivisions to apply to the ground
  25589. */
  25590. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25591. /** @hidden */
  25592. _regenerateVertexData(): VertexData;
  25593. copy(id: string): Geometry;
  25594. serialize(): any;
  25595. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25596. }
  25597. /**
  25598. * Creates a tiled ground geometry
  25599. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25600. */
  25601. class TiledGroundGeometry extends _PrimitiveGeometry {
  25602. /**
  25603. * Defines the minimum value on X axis
  25604. */
  25605. xmin: number;
  25606. /**
  25607. * Defines the minimum value on Z axis
  25608. */
  25609. zmin: number;
  25610. /**
  25611. * Defines the maximum value on X axis
  25612. */
  25613. xmax: number;
  25614. /**
  25615. * Defines the maximum value on Z axis
  25616. */
  25617. zmax: number;
  25618. /**
  25619. * Defines the subdivisions to apply to the ground
  25620. */
  25621. subdivisions: {
  25622. w: number;
  25623. h: number;
  25624. };
  25625. /**
  25626. * Defines the precision to use when computing the tiles
  25627. */
  25628. precision: {
  25629. w: number;
  25630. h: number;
  25631. };
  25632. /**
  25633. * Creates a tiled ground geometry
  25634. * @param id defines the unique ID of the geometry
  25635. * @param scene defines the hosting scene
  25636. * @param xmin defines the minimum value on X axis
  25637. * @param zmin defines the minimum value on Z axis
  25638. * @param xmax defines the maximum value on X axis
  25639. * @param zmax defines the maximum value on Z axis
  25640. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25641. * @param precision defines the precision to use when computing the tiles
  25642. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25643. * @param mesh defines the hosting mesh (can be null)
  25644. */
  25645. constructor(id: string, scene: Scene,
  25646. /**
  25647. * Defines the minimum value on X axis
  25648. */
  25649. xmin: number,
  25650. /**
  25651. * Defines the minimum value on Z axis
  25652. */
  25653. zmin: number,
  25654. /**
  25655. * Defines the maximum value on X axis
  25656. */
  25657. xmax: number,
  25658. /**
  25659. * Defines the maximum value on Z axis
  25660. */
  25661. zmax: number,
  25662. /**
  25663. * Defines the subdivisions to apply to the ground
  25664. */
  25665. subdivisions: {
  25666. w: number;
  25667. h: number;
  25668. },
  25669. /**
  25670. * Defines the precision to use when computing the tiles
  25671. */
  25672. precision: {
  25673. w: number;
  25674. h: number;
  25675. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25676. /** @hidden */
  25677. _regenerateVertexData(): VertexData;
  25678. copy(id: string): Geometry;
  25679. }
  25680. /**
  25681. * Creates a plane geometry
  25682. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25683. */
  25684. class PlaneGeometry extends _PrimitiveGeometry {
  25685. /**
  25686. * Defines the size of the plane (width === height)
  25687. */
  25688. size: number;
  25689. /**
  25690. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25691. */
  25692. side: number;
  25693. /**
  25694. * Creates a plane geometry
  25695. * @param id defines the unique ID of the geometry
  25696. * @param scene defines the hosting scene
  25697. * @param size defines the size of the plane (width === height)
  25698. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25699. * @param mesh defines the hosting mesh (can be null)
  25700. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25701. */
  25702. constructor(id: string, scene: Scene,
  25703. /**
  25704. * Defines the size of the plane (width === height)
  25705. */
  25706. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25707. /**
  25708. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25709. */
  25710. side?: number);
  25711. /** @hidden */
  25712. _regenerateVertexData(): VertexData;
  25713. copy(id: string): Geometry;
  25714. serialize(): any;
  25715. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25716. }
  25717. /**
  25718. * Creates a torus knot geometry
  25719. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25720. */
  25721. class TorusKnotGeometry extends _PrimitiveGeometry {
  25722. /**
  25723. * Defines the radius of the torus knot
  25724. */
  25725. radius: number;
  25726. /**
  25727. * Defines the thickness of the torus knot tube
  25728. */
  25729. tube: number;
  25730. /**
  25731. * Defines the number of radial segments
  25732. */
  25733. radialSegments: number;
  25734. /**
  25735. * Defines the number of tubular segments
  25736. */
  25737. tubularSegments: number;
  25738. /**
  25739. * Defines the first number of windings
  25740. */
  25741. p: number;
  25742. /**
  25743. * Defines the second number of windings
  25744. */
  25745. q: number;
  25746. /**
  25747. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25748. */
  25749. side: number;
  25750. /**
  25751. * Creates a torus knot geometry
  25752. * @param id defines the unique ID of the geometry
  25753. * @param scene defines the hosting scene
  25754. * @param radius defines the radius of the torus knot
  25755. * @param tube defines the thickness of the torus knot tube
  25756. * @param radialSegments defines the number of radial segments
  25757. * @param tubularSegments defines the number of tubular segments
  25758. * @param p defines the first number of windings
  25759. * @param q defines the second number of windings
  25760. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25761. * @param mesh defines the hosting mesh (can be null)
  25762. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25763. */
  25764. constructor(id: string, scene: Scene,
  25765. /**
  25766. * Defines the radius of the torus knot
  25767. */
  25768. radius: number,
  25769. /**
  25770. * Defines the thickness of the torus knot tube
  25771. */
  25772. tube: number,
  25773. /**
  25774. * Defines the number of radial segments
  25775. */
  25776. radialSegments: number,
  25777. /**
  25778. * Defines the number of tubular segments
  25779. */
  25780. tubularSegments: number,
  25781. /**
  25782. * Defines the first number of windings
  25783. */
  25784. p: number,
  25785. /**
  25786. * Defines the second number of windings
  25787. */
  25788. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25789. /**
  25790. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25791. */
  25792. side?: number);
  25793. /** @hidden */
  25794. _regenerateVertexData(): VertexData;
  25795. copy(id: string): Geometry;
  25796. serialize(): any;
  25797. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25798. }
  25799. }
  25800. declare module BABYLON {
  25801. /**
  25802. * Mesh representing the gorund
  25803. */
  25804. class GroundMesh extends Mesh {
  25805. /** If octree should be generated */
  25806. generateOctree: boolean;
  25807. private _heightQuads;
  25808. /** @hidden */
  25809. _subdivisionsX: number;
  25810. /** @hidden */
  25811. _subdivisionsY: number;
  25812. /** @hidden */
  25813. _width: number;
  25814. /** @hidden */
  25815. _height: number;
  25816. /** @hidden */
  25817. _minX: number;
  25818. /** @hidden */
  25819. _maxX: number;
  25820. /** @hidden */
  25821. _minZ: number;
  25822. /** @hidden */
  25823. _maxZ: number;
  25824. constructor(name: string, scene: Scene);
  25825. /**
  25826. * "GroundMesh"
  25827. * @returns "GroundMesh"
  25828. */
  25829. getClassName(): string;
  25830. /**
  25831. * The minimum of x and y subdivisions
  25832. */
  25833. readonly subdivisions: number;
  25834. /**
  25835. * X subdivisions
  25836. */
  25837. readonly subdivisionsX: number;
  25838. /**
  25839. * Y subdivisions
  25840. */
  25841. readonly subdivisionsY: number;
  25842. /**
  25843. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25844. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25845. * @param chunksCount the number of subdivisions for x and y
  25846. * @param octreeBlocksSize (Default: 32)
  25847. */
  25848. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25849. /**
  25850. * Returns a height (y) value in the Worl system :
  25851. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25852. * @param x x coordinate
  25853. * @param z z coordinate
  25854. * @returns the ground y position if (x, z) are outside the ground surface.
  25855. */
  25856. getHeightAtCoordinates(x: number, z: number): number;
  25857. /**
  25858. * Returns a normalized vector (Vector3) orthogonal to the ground
  25859. * at the ground coordinates (x, z) expressed in the World system.
  25860. * @param x x coordinate
  25861. * @param z z coordinate
  25862. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25863. */
  25864. getNormalAtCoordinates(x: number, z: number): Vector3;
  25865. /**
  25866. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25867. * at the ground coordinates (x, z) expressed in the World system.
  25868. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25869. * @param x x coordinate
  25870. * @param z z coordinate
  25871. * @param ref vector to store the result
  25872. * @returns the GroundMesh.
  25873. */
  25874. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25875. /**
  25876. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25877. * if the ground has been updated.
  25878. * This can be used in the render loop.
  25879. * @returns the GroundMesh.
  25880. */
  25881. updateCoordinateHeights(): GroundMesh;
  25882. private _getFacetAt;
  25883. private _initHeightQuads;
  25884. private _computeHeightQuads;
  25885. /**
  25886. * Serializes this ground mesh
  25887. * @param serializationObject object to write serialization to
  25888. */
  25889. serialize(serializationObject: any): void;
  25890. /**
  25891. * Parses a serialized ground mesh
  25892. * @param parsedMesh the serialized mesh
  25893. * @param scene the scene to create the ground mesh in
  25894. * @returns the created ground mesh
  25895. */
  25896. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25897. }
  25898. }
  25899. declare module BABYLON {
  25900. /**
  25901. * Creates an instance based on a source mesh.
  25902. */
  25903. class InstancedMesh extends AbstractMesh {
  25904. private _sourceMesh;
  25905. private _currentLOD;
  25906. /** @hidden */
  25907. _indexInSourceMeshInstanceArray: number;
  25908. constructor(name: string, source: Mesh);
  25909. /**
  25910. * Returns the string "InstancedMesh".
  25911. */
  25912. getClassName(): string;
  25913. /**
  25914. * If the source mesh receives shadows
  25915. */
  25916. readonly receiveShadows: boolean;
  25917. /**
  25918. * The material of the source mesh
  25919. */
  25920. readonly material: Nullable<Material>;
  25921. /**
  25922. * Visibility of the source mesh
  25923. */
  25924. readonly visibility: number;
  25925. /**
  25926. * Skeleton of the source mesh
  25927. */
  25928. readonly skeleton: Nullable<Skeleton>;
  25929. /**
  25930. * Rendering ground id of the source mesh
  25931. */
  25932. renderingGroupId: number;
  25933. /**
  25934. * Returns the total number of vertices (integer).
  25935. */
  25936. getTotalVertices(): number;
  25937. /**
  25938. * The source mesh of the instance
  25939. */
  25940. readonly sourceMesh: Mesh;
  25941. /**
  25942. * Is this node ready to be used/rendered
  25943. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25944. * @return {boolean} is it ready
  25945. */
  25946. isReady(completeCheck?: boolean): boolean;
  25947. /**
  25948. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25949. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25950. * @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.
  25951. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25952. */
  25953. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25954. /**
  25955. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25956. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25957. * The `data` are either a numeric array either a Float32Array.
  25958. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25959. * 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).
  25960. * Note that a new underlying VertexBuffer object is created each call.
  25961. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25962. *
  25963. * Possible `kind` values :
  25964. * - BABYLON.VertexBuffer.PositionKind
  25965. * - BABYLON.VertexBuffer.UVKind
  25966. * - BABYLON.VertexBuffer.UV2Kind
  25967. * - BABYLON.VertexBuffer.UV3Kind
  25968. * - BABYLON.VertexBuffer.UV4Kind
  25969. * - BABYLON.VertexBuffer.UV5Kind
  25970. * - BABYLON.VertexBuffer.UV6Kind
  25971. * - BABYLON.VertexBuffer.ColorKind
  25972. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25973. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25974. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25975. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25976. *
  25977. * Returns the Mesh.
  25978. */
  25979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25980. /**
  25981. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25982. * If the mesh has no geometry, it is simply returned as it is.
  25983. * The `data` are either a numeric array either a Float32Array.
  25984. * No new underlying VertexBuffer object is created.
  25985. * 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.
  25986. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25987. *
  25988. * Possible `kind` values :
  25989. * - BABYLON.VertexBuffer.PositionKind
  25990. * - BABYLON.VertexBuffer.UVKind
  25991. * - BABYLON.VertexBuffer.UV2Kind
  25992. * - BABYLON.VertexBuffer.UV3Kind
  25993. * - BABYLON.VertexBuffer.UV4Kind
  25994. * - BABYLON.VertexBuffer.UV5Kind
  25995. * - BABYLON.VertexBuffer.UV6Kind
  25996. * - BABYLON.VertexBuffer.ColorKind
  25997. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25998. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25999. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26000. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26001. *
  26002. * Returns the Mesh.
  26003. */
  26004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26005. /**
  26006. * Sets the mesh indices.
  26007. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26008. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26009. * This method creates a new index buffer each call.
  26010. * Returns the Mesh.
  26011. */
  26012. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26013. /**
  26014. * Boolean : True if the mesh owns the requested kind of data.
  26015. */
  26016. isVerticesDataPresent(kind: string): boolean;
  26017. /**
  26018. * Returns an array of indices (IndicesArray).
  26019. */
  26020. getIndices(): Nullable<IndicesArray>;
  26021. readonly _positions: Nullable<Vector3[]>;
  26022. /**
  26023. * reconstructs and updates the BoundingInfo of the mesh.
  26024. * @returns the mesh.
  26025. */
  26026. refreshBoundingInfo(): InstancedMesh;
  26027. /** @hidden */
  26028. _preActivate(): InstancedMesh;
  26029. /** @hidden */
  26030. _activate(renderId: number): InstancedMesh;
  26031. /**
  26032. * Returns the current associated LOD AbstractMesh.
  26033. */
  26034. getLOD(camera: Camera): AbstractMesh;
  26035. /** @hidden */
  26036. _syncSubMeshes(): InstancedMesh;
  26037. /** @hidden */
  26038. _generatePointsArray(): boolean;
  26039. /**
  26040. * Creates a new InstancedMesh from the current mesh.
  26041. * - name (string) : the cloned mesh name
  26042. * - newParent (optional Node) : the optional Node to parent the clone to.
  26043. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26044. *
  26045. * Returns the clone.
  26046. */
  26047. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26048. /**
  26049. * Disposes the InstancedMesh.
  26050. * Returns nothing.
  26051. */
  26052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26053. }
  26054. }
  26055. declare module BABYLON {
  26056. /**
  26057. * Line mesh
  26058. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26059. */
  26060. class LinesMesh extends Mesh {
  26061. /**
  26062. * If vertex color should be applied to the mesh
  26063. */
  26064. useVertexColor?: boolean | undefined;
  26065. /**
  26066. * If vertex alpha should be applied to the mesh
  26067. */
  26068. useVertexAlpha?: boolean | undefined;
  26069. /**
  26070. * Color of the line (Default: White)
  26071. */
  26072. color: Color3;
  26073. /**
  26074. * Alpha of the line (Default: 1)
  26075. */
  26076. alpha: number;
  26077. /**
  26078. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26079. * This margin is expressed in world space coordinates, so its value may vary.
  26080. * Default value is 0.1
  26081. * @returns the intersection Threshold value.
  26082. */
  26083. /**
  26084. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26085. * This margin is expressed in world space coordinates, so its value may vary.
  26086. */
  26087. intersectionThreshold: number;
  26088. private _intersectionThreshold;
  26089. private _colorShader;
  26090. /**
  26091. * Creates a new LinesMesh
  26092. * @param name defines the name
  26093. * @param scene defines the hosting scene
  26094. * @param parent defines the parent mesh if any
  26095. * @param source defines the optional source LinesMesh used to clone data from
  26096. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26097. * When false, achieved by calling a clone(), also passing False.
  26098. * This will make creation of children, recursive.
  26099. * @param useVertexColor defines if this LinesMesh supports vertex color
  26100. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26101. */
  26102. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26103. /**
  26104. * If vertex color should be applied to the mesh
  26105. */
  26106. useVertexColor?: boolean | undefined,
  26107. /**
  26108. * If vertex alpha should be applied to the mesh
  26109. */
  26110. useVertexAlpha?: boolean | undefined);
  26111. /**
  26112. * Returns the string "LineMesh"
  26113. */
  26114. getClassName(): string;
  26115. /**
  26116. * @hidden
  26117. */
  26118. /**
  26119. * @hidden
  26120. */
  26121. material: Material;
  26122. /**
  26123. * @hidden
  26124. */
  26125. readonly checkCollisions: boolean;
  26126. /** @hidden */
  26127. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26128. /** @hidden */
  26129. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26130. /**
  26131. * Disposes of the line mesh
  26132. * @param doNotRecurse If children should be disposed
  26133. */
  26134. dispose(doNotRecurse?: boolean): void;
  26135. /**
  26136. * Returns a new LineMesh object cloned from the current one.
  26137. */
  26138. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26139. }
  26140. }
  26141. declare module BABYLON {
  26142. /**
  26143. * @hidden
  26144. **/
  26145. class _CreationDataStorage {
  26146. closePath?: boolean;
  26147. closeArray?: boolean;
  26148. idx: number[];
  26149. dashSize: number;
  26150. gapSize: number;
  26151. path3D: Path3D;
  26152. pathArray: Vector3[][];
  26153. arc: number;
  26154. radius: number;
  26155. cap: number;
  26156. tessellation: number;
  26157. }
  26158. /**
  26159. * @hidden
  26160. **/
  26161. class _InstanceDataStorage {
  26162. visibleInstances: any;
  26163. renderIdForInstances: number[];
  26164. batchCache: _InstancesBatch;
  26165. instancesBufferSize: number;
  26166. instancesBuffer: Nullable<Buffer>;
  26167. instancesData: Float32Array;
  26168. overridenInstanceCount: number;
  26169. }
  26170. /**
  26171. * @hidden
  26172. **/
  26173. class _InstancesBatch {
  26174. mustReturn: boolean;
  26175. visibleInstances: Nullable<InstancedMesh[]>[];
  26176. renderSelf: boolean[];
  26177. }
  26178. /**
  26179. * Class used to represent renderable models
  26180. */
  26181. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26182. /**
  26183. * Mesh side orientation : usually the external or front surface
  26184. */
  26185. static readonly FRONTSIDE: number;
  26186. /**
  26187. * Mesh side orientation : usually the internal or back surface
  26188. */
  26189. static readonly BACKSIDE: number;
  26190. /**
  26191. * Mesh side orientation : both internal and external or front and back surfaces
  26192. */
  26193. static readonly DOUBLESIDE: number;
  26194. /**
  26195. * Mesh side orientation : by default, `FRONTSIDE`
  26196. */
  26197. static readonly DEFAULTSIDE: number;
  26198. /**
  26199. * Mesh cap setting : no cap
  26200. */
  26201. static readonly NO_CAP: number;
  26202. /**
  26203. * Mesh cap setting : one cap at the beginning of the mesh
  26204. */
  26205. static readonly CAP_START: number;
  26206. /**
  26207. * Mesh cap setting : one cap at the end of the mesh
  26208. */
  26209. static readonly CAP_END: number;
  26210. /**
  26211. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26212. */
  26213. static readonly CAP_ALL: number;
  26214. private _onBeforeRenderObservable;
  26215. private _onAfterRenderObservable;
  26216. private _onBeforeDrawObservable;
  26217. /**
  26218. * An event triggered before rendering the mesh
  26219. */
  26220. readonly onBeforeRenderObservable: Observable<Mesh>;
  26221. /**
  26222. * An event triggered after rendering the mesh
  26223. */
  26224. readonly onAfterRenderObservable: Observable<Mesh>;
  26225. /**
  26226. * An event triggered before drawing the mesh
  26227. */
  26228. readonly onBeforeDrawObservable: Observable<Mesh>;
  26229. private _onBeforeDrawObserver;
  26230. /**
  26231. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26232. */
  26233. onBeforeDraw: () => void;
  26234. /**
  26235. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26236. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26237. */
  26238. delayLoadState: number;
  26239. /**
  26240. * Gets the list of instances created from this mesh
  26241. * it is not supposed to be modified manually.
  26242. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26243. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26244. */
  26245. instances: InstancedMesh[];
  26246. /**
  26247. * Gets the file containing delay loading data for this mesh
  26248. */
  26249. delayLoadingFile: string;
  26250. /** @hidden */
  26251. _binaryInfo: any;
  26252. private _LODLevels;
  26253. /**
  26254. * User defined function used to change how LOD level selection is done
  26255. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26256. */
  26257. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26258. private _morphTargetManager;
  26259. /**
  26260. * Gets or sets the morph target manager
  26261. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26262. */
  26263. morphTargetManager: Nullable<MorphTargetManager>;
  26264. /** @hidden */
  26265. _creationDataStorage: Nullable<_CreationDataStorage>;
  26266. /** @hidden */
  26267. _geometry: Nullable<Geometry>;
  26268. /** @hidden */
  26269. _delayInfo: Array<string>;
  26270. /** @hidden */
  26271. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26272. /** @hidden */
  26273. _instanceDataStorage: _InstanceDataStorage;
  26274. private _effectiveMaterial;
  26275. /** @hidden */
  26276. _shouldGenerateFlatShading: boolean;
  26277. private _preActivateId;
  26278. /** @hidden */
  26279. _originalBuilderSideOrientation: number;
  26280. /**
  26281. * Use this property to change the original side orientation defined at construction time
  26282. */
  26283. overrideMaterialSideOrientation: Nullable<number>;
  26284. private _areNormalsFrozen;
  26285. private _sourcePositions;
  26286. private _sourceNormals;
  26287. private _source;
  26288. private meshMap;
  26289. /**
  26290. * Gets the source mesh (the one used to clone this one from)
  26291. */
  26292. readonly source: Nullable<Mesh>;
  26293. /**
  26294. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26295. */
  26296. isUnIndexed: boolean;
  26297. /**
  26298. * @constructor
  26299. * @param name The value used by scene.getMeshByName() to do a lookup.
  26300. * @param scene The scene to add this mesh to.
  26301. * @param parent The parent of this mesh, if it has one
  26302. * @param source An optional Mesh from which geometry is shared, cloned.
  26303. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26304. * When false, achieved by calling a clone(), also passing False.
  26305. * This will make creation of children, recursive.
  26306. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26307. */
  26308. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26309. /**
  26310. * Gets the class name
  26311. * @returns the string "Mesh".
  26312. */
  26313. getClassName(): string;
  26314. /**
  26315. * Returns a description of this mesh
  26316. * @param fullDetails define if full details about this mesh must be used
  26317. * @returns a descriptive string representing this mesh
  26318. */
  26319. toString(fullDetails?: boolean): string;
  26320. /** @hidden */
  26321. _unBindEffect(): void;
  26322. /**
  26323. * Gets a boolean indicating if this mesh has LOD
  26324. */
  26325. readonly hasLODLevels: boolean;
  26326. /**
  26327. * Gets the list of MeshLODLevel associated with the current mesh
  26328. * @returns an array of MeshLODLevel
  26329. */
  26330. getLODLevels(): MeshLODLevel[];
  26331. private _sortLODLevels;
  26332. /**
  26333. * Add a mesh as LOD level triggered at the given distance.
  26334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26335. * @param distance The distance from the center of the object to show this level
  26336. * @param mesh The mesh to be added as LOD level (can be null)
  26337. * @return This mesh (for chaining)
  26338. */
  26339. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26340. /**
  26341. * Returns the LOD level mesh at the passed distance or null if not found.
  26342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26343. * @param distance The distance from the center of the object to show this level
  26344. * @returns a Mesh or `null`
  26345. */
  26346. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26347. /**
  26348. * Remove a mesh from the LOD array
  26349. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26350. * @param mesh defines the mesh to be removed
  26351. * @return This mesh (for chaining)
  26352. */
  26353. removeLODLevel(mesh: Mesh): Mesh;
  26354. /**
  26355. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26356. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26357. * @param camera defines the camera to use to compute distance
  26358. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26359. * @return This mesh (for chaining)
  26360. */
  26361. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26362. /**
  26363. * Gets the mesh internal Geometry object
  26364. */
  26365. readonly geometry: Nullable<Geometry>;
  26366. /**
  26367. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26368. * @returns the total number of vertices
  26369. */
  26370. getTotalVertices(): number;
  26371. /**
  26372. * Returns the content of an associated vertex buffer
  26373. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26374. * - BABYLON.VertexBuffer.PositionKind
  26375. * - BABYLON.VertexBuffer.UVKind
  26376. * - BABYLON.VertexBuffer.UV2Kind
  26377. * - BABYLON.VertexBuffer.UV3Kind
  26378. * - BABYLON.VertexBuffer.UV4Kind
  26379. * - BABYLON.VertexBuffer.UV5Kind
  26380. * - BABYLON.VertexBuffer.UV6Kind
  26381. * - BABYLON.VertexBuffer.ColorKind
  26382. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26383. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26384. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26385. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26386. * @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
  26387. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26388. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26389. */
  26390. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26391. /**
  26392. * Returns the mesh VertexBuffer object from the requested `kind`
  26393. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26394. * - BABYLON.VertexBuffer.PositionKind
  26395. * - BABYLON.VertexBuffer.UVKind
  26396. * - BABYLON.VertexBuffer.UV2Kind
  26397. * - BABYLON.VertexBuffer.UV3Kind
  26398. * - BABYLON.VertexBuffer.UV4Kind
  26399. * - BABYLON.VertexBuffer.UV5Kind
  26400. * - BABYLON.VertexBuffer.UV6Kind
  26401. * - BABYLON.VertexBuffer.ColorKind
  26402. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26403. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26404. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26405. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26406. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26407. */
  26408. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26409. /**
  26410. * Tests if a specific vertex buffer is associated with this mesh
  26411. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26412. * - BABYLON.VertexBuffer.PositionKind
  26413. * - BABYLON.VertexBuffer.UVKind
  26414. * - BABYLON.VertexBuffer.UV2Kind
  26415. * - BABYLON.VertexBuffer.UV3Kind
  26416. * - BABYLON.VertexBuffer.UV4Kind
  26417. * - BABYLON.VertexBuffer.UV5Kind
  26418. * - BABYLON.VertexBuffer.UV6Kind
  26419. * - BABYLON.VertexBuffer.ColorKind
  26420. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26421. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26422. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26423. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26424. * @returns a boolean
  26425. */
  26426. isVerticesDataPresent(kind: string): boolean;
  26427. /**
  26428. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26429. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26430. * - BABYLON.VertexBuffer.PositionKind
  26431. * - BABYLON.VertexBuffer.UVKind
  26432. * - BABYLON.VertexBuffer.UV2Kind
  26433. * - BABYLON.VertexBuffer.UV3Kind
  26434. * - BABYLON.VertexBuffer.UV4Kind
  26435. * - BABYLON.VertexBuffer.UV5Kind
  26436. * - BABYLON.VertexBuffer.UV6Kind
  26437. * - BABYLON.VertexBuffer.ColorKind
  26438. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26439. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26440. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26441. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26442. * @returns a boolean
  26443. */
  26444. isVertexBufferUpdatable(kind: string): boolean;
  26445. /**
  26446. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26447. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26448. * - BABYLON.VertexBuffer.PositionKind
  26449. * - BABYLON.VertexBuffer.UVKind
  26450. * - BABYLON.VertexBuffer.UV2Kind
  26451. * - BABYLON.VertexBuffer.UV3Kind
  26452. * - BABYLON.VertexBuffer.UV4Kind
  26453. * - BABYLON.VertexBuffer.UV5Kind
  26454. * - BABYLON.VertexBuffer.UV6Kind
  26455. * - BABYLON.VertexBuffer.ColorKind
  26456. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26457. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26458. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26459. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26460. * @returns an array of strings
  26461. */
  26462. getVerticesDataKinds(): string[];
  26463. /**
  26464. * Returns a positive integer : the total number of indices in this mesh geometry.
  26465. * @returns the numner of indices or zero if the mesh has no geometry.
  26466. */
  26467. getTotalIndices(): number;
  26468. /**
  26469. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26470. * @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.
  26471. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26472. * @returns the indices array or an empty array if the mesh has no geometry
  26473. */
  26474. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26475. readonly isBlocked: boolean;
  26476. /**
  26477. * Determine if the current mesh is ready to be rendered
  26478. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26479. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26480. * @returns true if all associated assets are ready (material, textures, shaders)
  26481. */
  26482. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26483. /**
  26484. * 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.
  26485. */
  26486. readonly areNormalsFrozen: boolean;
  26487. /**
  26488. * 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.
  26489. * @returns the current mesh
  26490. */
  26491. freezeNormals(): Mesh;
  26492. /**
  26493. * 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
  26494. * @returns the current mesh
  26495. */
  26496. unfreezeNormals(): Mesh;
  26497. /**
  26498. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26499. */
  26500. overridenInstanceCount: number;
  26501. /** @hidden */
  26502. _preActivate(): Mesh;
  26503. /** @hidden */
  26504. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26505. /** @hidden */
  26506. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26507. /**
  26508. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26509. * This means the mesh underlying bounding box and sphere are recomputed.
  26510. * @returns the current mesh
  26511. */
  26512. refreshBoundingInfo(): Mesh;
  26513. /** @hidden */
  26514. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26515. private _getPositionData;
  26516. /** @hidden */
  26517. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26518. /**
  26519. * This function will subdivide the mesh into multiple submeshes
  26520. * @param count defines the expected number of submeshes
  26521. */
  26522. subdivide(count: number): void;
  26523. /**
  26524. * Copy a FloatArray into a specific associated vertex buffer
  26525. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26526. * - BABYLON.VertexBuffer.PositionKind
  26527. * - BABYLON.VertexBuffer.UVKind
  26528. * - BABYLON.VertexBuffer.UV2Kind
  26529. * - BABYLON.VertexBuffer.UV3Kind
  26530. * - BABYLON.VertexBuffer.UV4Kind
  26531. * - BABYLON.VertexBuffer.UV5Kind
  26532. * - BABYLON.VertexBuffer.UV6Kind
  26533. * - BABYLON.VertexBuffer.ColorKind
  26534. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26535. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26536. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26537. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26538. * @param data defines the data source
  26539. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26540. * @param stride defines the data stride size (can be null)
  26541. * @returns the current mesh
  26542. */
  26543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26544. /**
  26545. * Flags an associated vertex buffer as updatable
  26546. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26547. * - BABYLON.VertexBuffer.PositionKind
  26548. * - BABYLON.VertexBuffer.UVKind
  26549. * - BABYLON.VertexBuffer.UV2Kind
  26550. * - BABYLON.VertexBuffer.UV3Kind
  26551. * - BABYLON.VertexBuffer.UV4Kind
  26552. * - BABYLON.VertexBuffer.UV5Kind
  26553. * - BABYLON.VertexBuffer.UV6Kind
  26554. * - BABYLON.VertexBuffer.ColorKind
  26555. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26556. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26557. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26558. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26559. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26560. */
  26561. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26562. /**
  26563. * Sets the mesh global Vertex Buffer
  26564. * @param buffer defines the buffer to use
  26565. * @returns the current mesh
  26566. */
  26567. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26568. /**
  26569. * Update a specific associated vertex buffer
  26570. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26571. * - BABYLON.VertexBuffer.PositionKind
  26572. * - BABYLON.VertexBuffer.UVKind
  26573. * - BABYLON.VertexBuffer.UV2Kind
  26574. * - BABYLON.VertexBuffer.UV3Kind
  26575. * - BABYLON.VertexBuffer.UV4Kind
  26576. * - BABYLON.VertexBuffer.UV5Kind
  26577. * - BABYLON.VertexBuffer.UV6Kind
  26578. * - BABYLON.VertexBuffer.ColorKind
  26579. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26580. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26581. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26582. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26583. * @param data defines the data source
  26584. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26585. * @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)
  26586. * @returns the current mesh
  26587. */
  26588. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26589. /**
  26590. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26591. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26592. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26593. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26594. * @returns the current mesh
  26595. */
  26596. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26597. /**
  26598. * Creates a un-shared specific occurence of the geometry for the mesh.
  26599. * @returns the current mesh
  26600. */
  26601. makeGeometryUnique(): Mesh;
  26602. /**
  26603. * Set the index buffer of this mesh
  26604. * @param indices defines the source data
  26605. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26606. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26607. * @returns the current mesh
  26608. */
  26609. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26610. /**
  26611. * Update the current index buffer
  26612. * @param indices defines the source data
  26613. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26614. * @returns the current mesh
  26615. */
  26616. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26617. /**
  26618. * Invert the geometry to move from a right handed system to a left handed one.
  26619. * @returns the current mesh
  26620. */
  26621. toLeftHanded(): Mesh;
  26622. /** @hidden */
  26623. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26624. /** @hidden */
  26625. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26626. /**
  26627. * Registers for this mesh a javascript function called just before the rendering process
  26628. * @param func defines the function to call before rendering this mesh
  26629. * @returns the current mesh
  26630. */
  26631. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26632. /**
  26633. * Disposes a previously registered javascript function called before the rendering
  26634. * @param func defines the function to remove
  26635. * @returns the current mesh
  26636. */
  26637. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26638. /**
  26639. * Registers for this mesh a javascript function called just after the rendering is complete
  26640. * @param func defines the function to call after rendering this mesh
  26641. * @returns the current mesh
  26642. */
  26643. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26644. /**
  26645. * Disposes a previously registered javascript function called after the rendering.
  26646. * @param func defines the function to remove
  26647. * @returns the current mesh
  26648. */
  26649. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26650. /** @hidden */
  26651. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26652. /** @hidden */
  26653. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26654. /** @hidden */
  26655. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26656. /**
  26657. * 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
  26658. * @param subMesh defines the subMesh to render
  26659. * @param enableAlphaMode defines if alpha mode can be changed
  26660. * @returns the current mesh
  26661. */
  26662. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26663. private _onBeforeDraw;
  26664. /**
  26665. * Renormalize the mesh and patch it up if there are no weights
  26666. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26667. * However in the case of zero weights then we set just a single influence to 1.
  26668. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26669. */
  26670. cleanMatrixWeights(): void;
  26671. private normalizeSkinFourWeights;
  26672. private normalizeSkinWeightsAndExtra;
  26673. /**
  26674. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26675. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26676. * the user know there was an issue with importing the mesh
  26677. * @returns a validation object with skinned, valid and report string
  26678. */
  26679. validateSkinning(): {
  26680. skinned: boolean;
  26681. valid: boolean;
  26682. report: string;
  26683. };
  26684. /** @hidden */
  26685. _checkDelayState(): Mesh;
  26686. private _queueLoad;
  26687. /**
  26688. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26689. * A mesh is in the frustum if its bounding box intersects the frustum
  26690. * @param frustumPlanes defines the frustum to test
  26691. * @returns true if the mesh is in the frustum planes
  26692. */
  26693. isInFrustum(frustumPlanes: Plane[]): boolean;
  26694. /**
  26695. * Sets the mesh material by the material or multiMaterial `id` property
  26696. * @param id is a string identifying the material or the multiMaterial
  26697. * @returns the current mesh
  26698. */
  26699. setMaterialByID(id: string): Mesh;
  26700. /**
  26701. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26702. * @returns an array of IAnimatable
  26703. */
  26704. getAnimatables(): IAnimatable[];
  26705. /**
  26706. * Modifies the mesh geometry according to the passed transformation matrix.
  26707. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26708. * The mesh normals are modified using the same transformation.
  26709. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26710. * @param transform defines the transform matrix to use
  26711. * @see http://doc.babylonjs.com/resources/baking_transformations
  26712. * @returns the current mesh
  26713. */
  26714. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26715. /**
  26716. * Modifies the mesh geometry according to its own current World Matrix.
  26717. * The mesh World Matrix is then reset.
  26718. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26719. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26720. * @see http://doc.babylonjs.com/resources/baking_transformations
  26721. * @returns the current mesh
  26722. */
  26723. bakeCurrentTransformIntoVertices(): Mesh;
  26724. /** @hidden */
  26725. readonly _positions: Nullable<Vector3[]>;
  26726. /** @hidden */
  26727. _resetPointsArrayCache(): Mesh;
  26728. /** @hidden */
  26729. _generatePointsArray(): boolean;
  26730. /**
  26731. * Returns a new Mesh object generated from the current mesh properties.
  26732. * This method must not get confused with createInstance()
  26733. * @param name is a string, the name given to the new mesh
  26734. * @param newParent can be any Node object (default `null`)
  26735. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26736. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26737. * @returns a new mesh
  26738. */
  26739. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26740. /**
  26741. * Releases resources associated with this mesh.
  26742. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26743. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26744. */
  26745. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26746. /**
  26747. * Modifies the mesh geometry according to a displacement map.
  26748. * 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.
  26749. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26750. * @param url is a string, the URL from the image file is to be downloaded.
  26751. * @param minHeight is the lower limit of the displacement.
  26752. * @param maxHeight is the upper limit of the displacement.
  26753. * @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.
  26754. * @param uvOffset is an optional vector2 used to offset UV.
  26755. * @param uvScale is an optional vector2 used to scale UV.
  26756. * @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.
  26757. * @returns the Mesh.
  26758. */
  26759. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26760. /**
  26761. * Modifies the mesh geometry according to a displacementMap buffer.
  26762. * 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.
  26763. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26764. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26765. * @param heightMapWidth is the width of the buffer image.
  26766. * @param heightMapHeight is the height of the buffer image.
  26767. * @param minHeight is the lower limit of the displacement.
  26768. * @param maxHeight is the upper limit of the displacement.
  26769. * @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.
  26770. * @param uvOffset is an optional vector2 used to offset UV.
  26771. * @param uvScale is an optional vector2 used to scale UV.
  26772. * @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.
  26773. * @returns the Mesh.
  26774. */
  26775. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26776. /**
  26777. * Modify the mesh to get a flat shading rendering.
  26778. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26779. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26780. * @returns current mesh
  26781. */
  26782. convertToFlatShadedMesh(): Mesh;
  26783. /**
  26784. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26785. * In other words, more vertices, no more indices and a single bigger VBO.
  26786. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26787. * @returns current mesh
  26788. */
  26789. convertToUnIndexedMesh(): Mesh;
  26790. /**
  26791. * Inverses facet orientations.
  26792. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26793. * @param flipNormals will also inverts the normals
  26794. * @returns current mesh
  26795. */
  26796. flipFaces(flipNormals?: boolean): Mesh;
  26797. /**
  26798. * Creates a new InstancedMesh object from the mesh model.
  26799. * Warning : this method is not supported for Line mesh and LineSystem
  26800. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26801. * @param name defines the name of the new instance
  26802. * @returns a new InstancedMesh
  26803. */
  26804. createInstance(name: string): InstancedMesh;
  26805. /**
  26806. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26807. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26808. * @returns the current mesh
  26809. */
  26810. synchronizeInstances(): Mesh;
  26811. /**
  26812. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26813. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26814. * This should be used together with the simplification to avoid disappearing triangles.
  26815. * @param successCallback an optional success callback to be called after the optimization finished.
  26816. * @returns the current mesh
  26817. */
  26818. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26819. /**
  26820. * Serialize current mesh
  26821. * @param serializationObject defines the object which will receive the serialization data
  26822. */
  26823. serialize(serializationObject: any): void;
  26824. /** @hidden */
  26825. _syncGeometryWithMorphTargetManager(): void;
  26826. /**
  26827. * Returns a new Mesh object parsed from the source provided.
  26828. * @param parsedMesh is the source
  26829. * @param scene defines the hosting scene
  26830. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26831. * @returns a new Mesh
  26832. */
  26833. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26834. /**
  26835. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26836. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26837. * @param name defines the name of the mesh to create
  26838. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26839. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26840. * @param closePath creates a seam between the first and the last points of each path of the path array
  26841. * @param offset is taken in account only if the `pathArray` is containing a single path
  26842. * @param scene defines the hosting scene
  26843. * @param updatable defines if the mesh must be flagged as updatable
  26844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26845. * @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)
  26846. * @returns a new Mesh
  26847. */
  26848. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26849. /**
  26850. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26851. * @param name defines the name of the mesh to create
  26852. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26853. * @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
  26854. * @param scene defines the hosting scene
  26855. * @param updatable defines if the mesh must be flagged as updatable
  26856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26857. * @returns a new Mesh
  26858. */
  26859. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26860. /**
  26861. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26862. * @param name defines the name of the mesh to create
  26863. * @param size sets the size (float) of each box side (default 1)
  26864. * @param scene defines the hosting scene
  26865. * @param updatable defines if the mesh must be flagged as updatable
  26866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26867. * @returns a new Mesh
  26868. */
  26869. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26870. /**
  26871. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26872. * @param name defines the name of the mesh to create
  26873. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26874. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26875. * @param scene defines the hosting scene
  26876. * @param updatable defines if the mesh must be flagged as updatable
  26877. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26878. * @returns a new Mesh
  26879. */
  26880. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26881. /**
  26882. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26883. * @param name defines the name of the mesh to create
  26884. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26885. * @param diameterTop set the top cap diameter (floats, default 1)
  26886. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26887. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26888. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26889. * @param scene defines the hosting scene
  26890. * @param updatable defines if the mesh must be flagged as updatable
  26891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26892. * @returns a new Mesh
  26893. */
  26894. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26895. /**
  26896. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26897. * @param name defines the name of the mesh to create
  26898. * @param diameter sets the diameter size (float) of the torus (default 1)
  26899. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26900. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26901. * @param scene defines the hosting scene
  26902. * @param updatable defines if the mesh must be flagged as updatable
  26903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26904. * @returns a new Mesh
  26905. */
  26906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26907. /**
  26908. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26909. * @param name defines the name of the mesh to create
  26910. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26911. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26912. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26913. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26914. * @param p the number of windings on X axis (positive integers, default 2)
  26915. * @param q the number of windings on Y axis (positive integers, default 3)
  26916. * @param scene defines the hosting scene
  26917. * @param updatable defines if the mesh must be flagged as updatable
  26918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26919. * @returns a new Mesh
  26920. */
  26921. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26922. /**
  26923. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26924. * @param name defines the name of the mesh to create
  26925. * @param points is an array successive Vector3
  26926. * @param scene defines the hosting scene
  26927. * @param updatable defines if the mesh must be flagged as updatable
  26928. * @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).
  26929. * @returns a new Mesh
  26930. */
  26931. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26932. /**
  26933. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26934. * @param name defines the name of the mesh to create
  26935. * @param points is an array successive Vector3
  26936. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26937. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26938. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26939. * @param scene defines the hosting scene
  26940. * @param updatable defines if the mesh must be flagged as updatable
  26941. * @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)
  26942. * @returns a new Mesh
  26943. */
  26944. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26945. /**
  26946. * Creates a polygon mesh.
  26947. * Please consider using the same method from the MeshBuilder class instead.
  26948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26949. * 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.
  26950. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26951. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26952. * Remember you can only change the shape positions, not their number when updating a polygon.
  26953. */
  26954. /**
  26955. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26956. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26957. * @param name defines the name of the mesh to create
  26958. * @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
  26959. * @param scene defines the hosting scene
  26960. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26961. * @param updatable defines if the mesh must be flagged as updatable
  26962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26963. * @returns a new Mesh
  26964. */
  26965. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26966. /**
  26967. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26968. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26969. * @param name defines the name of the mesh to create
  26970. * @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
  26971. * @param depth defines the height of extrusion
  26972. * @param scene defines the hosting scene
  26973. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26974. * @param updatable defines if the mesh must be flagged as updatable
  26975. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26976. * @returns a new Mesh
  26977. */
  26978. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26979. /**
  26980. * Creates an extruded shape mesh.
  26981. * 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
  26982. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26983. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26984. * @param name defines the name of the mesh to create
  26985. * @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
  26986. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26987. * @param scale is the value to scale the shape
  26988. * @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
  26989. * @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
  26990. * @param scene defines the hosting scene
  26991. * @param updatable defines if the mesh must be flagged as updatable
  26992. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26993. * @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)
  26994. * @returns a new Mesh
  26995. */
  26996. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26997. /**
  26998. * Creates an custom extruded shape mesh.
  26999. * The custom extrusion is a parametric shape.
  27000. * It has no predefined shape. Its final shape will depend on the input parameters.
  27001. * Please consider using the same method from the MeshBuilder class instead
  27002. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27003. * @param name defines the name of the mesh to create
  27004. * @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
  27005. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27006. * @param scaleFunction is a custom Javascript function called on each path point
  27007. * @param rotationFunction is a custom Javascript function called on each path point
  27008. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27009. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27010. * @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
  27011. * @param scene defines the hosting scene
  27012. * @param updatable defines if the mesh must be flagged as updatable
  27013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27014. * @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)
  27015. * @returns a new Mesh
  27016. */
  27017. 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;
  27018. /**
  27019. * Creates lathe mesh.
  27020. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27021. * Please consider using the same method from the MeshBuilder class instead
  27022. * @param name defines the name of the mesh to create
  27023. * @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
  27024. * @param radius is the radius value of the lathe
  27025. * @param tessellation is the side number of the lathe.
  27026. * @param scene defines the hosting scene
  27027. * @param updatable defines if the mesh must be flagged as updatable
  27028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27029. * @returns a new Mesh
  27030. */
  27031. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27032. /**
  27033. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27034. * @param name defines the name of the mesh to create
  27035. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27036. * @param scene defines the hosting scene
  27037. * @param updatable defines if the mesh must be flagged as updatable
  27038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27039. * @returns a new Mesh
  27040. */
  27041. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27042. /**
  27043. * Creates a ground mesh.
  27044. * Please consider using the same method from the MeshBuilder class instead
  27045. * @param name defines the name of the mesh to create
  27046. * @param width set the width of the ground
  27047. * @param height set the height of the ground
  27048. * @param subdivisions sets the number of subdivisions per side
  27049. * @param scene defines the hosting scene
  27050. * @param updatable defines if the mesh must be flagged as updatable
  27051. * @returns a new Mesh
  27052. */
  27053. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27054. /**
  27055. * Creates a tiled ground mesh.
  27056. * Please consider using the same method from the MeshBuilder class instead
  27057. * @param name defines the name of the mesh to create
  27058. * @param xmin set the ground minimum X coordinate
  27059. * @param zmin set the ground minimum Y coordinate
  27060. * @param xmax set the ground maximum X coordinate
  27061. * @param zmax set the ground maximum Z coordinate
  27062. * @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
  27063. * @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
  27064. * @param scene defines the hosting scene
  27065. * @param updatable defines if the mesh must be flagged as updatable
  27066. * @returns a new Mesh
  27067. */
  27068. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27069. w: number;
  27070. h: number;
  27071. }, precision: {
  27072. w: number;
  27073. h: number;
  27074. }, scene: Scene, updatable?: boolean): Mesh;
  27075. /**
  27076. * Creates a ground mesh from a height map.
  27077. * Please consider using the same method from the MeshBuilder class instead
  27078. * @see http://doc.babylonjs.com/babylon101/height_map
  27079. * @param name defines the name of the mesh to create
  27080. * @param url sets the URL of the height map image resource
  27081. * @param width set the ground width size
  27082. * @param height set the ground height size
  27083. * @param subdivisions sets the number of subdivision per side
  27084. * @param minHeight is the minimum altitude on the ground
  27085. * @param maxHeight is the maximum altitude on the ground
  27086. * @param scene defines the hosting scene
  27087. * @param updatable defines if the mesh must be flagged as updatable
  27088. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27089. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27090. * @returns a new Mesh
  27091. */
  27092. 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;
  27093. /**
  27094. * Creates a tube mesh.
  27095. * The tube is a parametric shape.
  27096. * It has no predefined shape. Its final shape will depend on the input parameters.
  27097. * Please consider using the same method from the MeshBuilder class instead
  27098. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27099. * @param name defines the name of the mesh to create
  27100. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27101. * @param radius sets the tube radius size
  27102. * @param tessellation is the number of sides on the tubular surface
  27103. * @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
  27104. * @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
  27105. * @param scene defines the hosting scene
  27106. * @param updatable defines if the mesh must be flagged as updatable
  27107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27108. * @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)
  27109. * @returns a new Mesh
  27110. */
  27111. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27112. (i: number, distance: number): number;
  27113. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27114. /**
  27115. * Creates a polyhedron mesh.
  27116. * Please consider using the same method from the MeshBuilder class instead.
  27117. * * 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
  27118. * * The parameter `size` (positive float, default 1) sets the polygon size
  27119. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27120. * * 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`
  27121. * * 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
  27122. * * 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)`)
  27123. * * 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
  27124. * * 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
  27125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27126. * * 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
  27127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27128. * @param name defines the name of the mesh to create
  27129. * @param options defines the options used to create the mesh
  27130. * @param scene defines the hosting scene
  27131. * @returns a new Mesh
  27132. */
  27133. static CreatePolyhedron(name: string, options: {
  27134. type?: number;
  27135. size?: number;
  27136. sizeX?: number;
  27137. sizeY?: number;
  27138. sizeZ?: number;
  27139. custom?: any;
  27140. faceUV?: Vector4[];
  27141. faceColors?: Color4[];
  27142. updatable?: boolean;
  27143. sideOrientation?: number;
  27144. }, scene: Scene): Mesh;
  27145. /**
  27146. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27147. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27148. * * 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`)
  27149. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27150. * * 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
  27151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27152. * * 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
  27153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27154. * @param name defines the name of the mesh
  27155. * @param options defines the options used to create the mesh
  27156. * @param scene defines the hosting scene
  27157. * @returns a new Mesh
  27158. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27159. */
  27160. static CreateIcoSphere(name: string, options: {
  27161. radius?: number;
  27162. flat?: boolean;
  27163. subdivisions?: number;
  27164. sideOrientation?: number;
  27165. updatable?: boolean;
  27166. }, scene: Scene): Mesh;
  27167. /**
  27168. * Creates a decal mesh.
  27169. * Please consider using the same method from the MeshBuilder class instead.
  27170. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27171. * @param name defines the name of the mesh
  27172. * @param sourceMesh defines the mesh receiving the decal
  27173. * @param position sets the position of the decal in world coordinates
  27174. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27175. * @param size sets the decal scaling
  27176. * @param angle sets the angle to rotate the decal
  27177. * @returns a new Mesh
  27178. */
  27179. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27180. /**
  27181. * Prepare internal position array for software CPU skinning
  27182. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27183. */
  27184. setPositionsForCPUSkinning(): Float32Array;
  27185. /**
  27186. * Prepare internal normal array for software CPU skinning
  27187. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27188. */
  27189. setNormalsForCPUSkinning(): Float32Array;
  27190. /**
  27191. * Updates the vertex buffer by applying transformation from the bones
  27192. * @param skeleton defines the skeleton to apply to current mesh
  27193. * @returns the current mesh
  27194. */
  27195. applySkeleton(skeleton: Skeleton): Mesh;
  27196. /**
  27197. * 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
  27198. * @param meshes defines the list of meshes to scan
  27199. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27200. */
  27201. static MinMax(meshes: AbstractMesh[]): {
  27202. min: Vector3;
  27203. max: Vector3;
  27204. };
  27205. /**
  27206. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27207. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27208. * @returns a vector3
  27209. */
  27210. static Center(meshesOrMinMaxVector: {
  27211. min: Vector3;
  27212. max: Vector3;
  27213. } | AbstractMesh[]): Vector3;
  27214. /**
  27215. * Merge the array of meshes into a single mesh for performance reasons.
  27216. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27217. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27218. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27219. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27220. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27221. * @returns a new mesh
  27222. */
  27223. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27224. /** @hidden */
  27225. addInstance(instance: InstancedMesh): void;
  27226. /** @hidden */
  27227. removeInstance(instance: InstancedMesh): void;
  27228. }
  27229. }
  27230. declare module BABYLON {
  27231. /**
  27232. * Define an interface for all classes that will get and set the data on vertices
  27233. */
  27234. interface IGetSetVerticesData {
  27235. /**
  27236. * Gets a boolean indicating if specific vertex data is present
  27237. * @param kind defines the vertex data kind to use
  27238. * @returns true is data kind is present
  27239. */
  27240. isVerticesDataPresent(kind: string): boolean;
  27241. /**
  27242. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27243. * @param kind defines the data kind (Position, normal, etc...)
  27244. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27245. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27246. * @returns a float array containing vertex data
  27247. */
  27248. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27249. /**
  27250. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27251. * @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.
  27252. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27253. * @returns the indices array or an empty array if the mesh has no geometry
  27254. */
  27255. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27256. /**
  27257. * Set specific vertex data
  27258. * @param kind defines the data kind (Position, normal, etc...)
  27259. * @param data defines the vertex data to use
  27260. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27261. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27262. */
  27263. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27264. /**
  27265. * Update a specific associated vertex buffer
  27266. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27267. * - BABYLON.VertexBuffer.PositionKind
  27268. * - BABYLON.VertexBuffer.UVKind
  27269. * - BABYLON.VertexBuffer.UV2Kind
  27270. * - BABYLON.VertexBuffer.UV3Kind
  27271. * - BABYLON.VertexBuffer.UV4Kind
  27272. * - BABYLON.VertexBuffer.UV5Kind
  27273. * - BABYLON.VertexBuffer.UV6Kind
  27274. * - BABYLON.VertexBuffer.ColorKind
  27275. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27276. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27277. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27278. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27279. * @param data defines the data source
  27280. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27281. * @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)
  27282. */
  27283. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27284. /**
  27285. * Creates a new index buffer
  27286. * @param indices defines the indices to store in the index buffer
  27287. * @param totalVertices defines the total number of vertices (could be null)
  27288. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27289. */
  27290. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27291. }
  27292. /**
  27293. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27294. */
  27295. class VertexData {
  27296. /**
  27297. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27298. */
  27299. positions: Nullable<FloatArray>;
  27300. /**
  27301. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27302. */
  27303. normals: Nullable<FloatArray>;
  27304. /**
  27305. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27306. */
  27307. tangents: Nullable<FloatArray>;
  27308. /**
  27309. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27310. */
  27311. uvs: Nullable<FloatArray>;
  27312. /**
  27313. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27314. */
  27315. uvs2: Nullable<FloatArray>;
  27316. /**
  27317. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27318. */
  27319. uvs3: Nullable<FloatArray>;
  27320. /**
  27321. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27322. */
  27323. uvs4: Nullable<FloatArray>;
  27324. /**
  27325. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27326. */
  27327. uvs5: Nullable<FloatArray>;
  27328. /**
  27329. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27330. */
  27331. uvs6: Nullable<FloatArray>;
  27332. /**
  27333. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27334. */
  27335. colors: Nullable<FloatArray>;
  27336. /**
  27337. * 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).
  27338. */
  27339. matricesIndices: Nullable<FloatArray>;
  27340. /**
  27341. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27342. */
  27343. matricesWeights: Nullable<FloatArray>;
  27344. /**
  27345. * An array extending the number of possible indices
  27346. */
  27347. matricesIndicesExtra: Nullable<FloatArray>;
  27348. /**
  27349. * An array extending the number of possible weights when the number of indices is extended
  27350. */
  27351. matricesWeightsExtra: Nullable<FloatArray>;
  27352. /**
  27353. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27354. */
  27355. indices: Nullable<IndicesArray>;
  27356. /**
  27357. * Uses the passed data array to set the set the values for the specified kind of data
  27358. * @param data a linear array of floating numbers
  27359. * @param kind the type of data that is being set, eg positions, colors etc
  27360. */
  27361. set(data: FloatArray, kind: string): void;
  27362. /**
  27363. * Associates the vertexData to the passed Mesh.
  27364. * Sets it as updatable or not (default `false`)
  27365. * @param mesh the mesh the vertexData is applied to
  27366. * @param updatable when used and having the value true allows new data to update the vertexData
  27367. * @returns the VertexData
  27368. */
  27369. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27370. /**
  27371. * Associates the vertexData to the passed Geometry.
  27372. * Sets it as updatable or not (default `false`)
  27373. * @param geometry the geometry the vertexData is applied to
  27374. * @param updatable when used and having the value true allows new data to update the vertexData
  27375. * @returns VertexData
  27376. */
  27377. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27378. /**
  27379. * Updates the associated mesh
  27380. * @param mesh the mesh to be updated
  27381. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27382. * @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
  27383. * @returns VertexData
  27384. */
  27385. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27386. /**
  27387. * Updates the associated geometry
  27388. * @param geometry the geometry to be updated
  27389. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27390. * @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
  27391. * @returns VertexData.
  27392. */
  27393. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27394. private _applyTo;
  27395. private _update;
  27396. /**
  27397. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27398. * @param matrix the transforming matrix
  27399. * @returns the VertexData
  27400. */
  27401. transform(matrix: Matrix): VertexData;
  27402. /**
  27403. * Merges the passed VertexData into the current one
  27404. * @param other the VertexData to be merged into the current one
  27405. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27406. * @returns the modified VertexData
  27407. */
  27408. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27409. private _mergeElement;
  27410. private _validate;
  27411. /**
  27412. * Serializes the VertexData
  27413. * @returns a serialized object
  27414. */
  27415. serialize(): any;
  27416. /**
  27417. * Extracts the vertexData from a mesh
  27418. * @param mesh the mesh from which to extract the VertexData
  27419. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27420. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27421. * @returns the object VertexData associated to the passed mesh
  27422. */
  27423. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27424. /**
  27425. * Extracts the vertexData from the geometry
  27426. * @param geometry the geometry from which to extract the VertexData
  27427. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27428. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27429. * @returns the object VertexData associated to the passed mesh
  27430. */
  27431. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27432. private static _ExtractFrom;
  27433. /**
  27434. * Creates the VertexData for a Ribbon
  27435. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27436. * * pathArray array of paths, each of which an array of successive Vector3
  27437. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27438. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27439. * * 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
  27440. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27441. * * 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)
  27442. * * 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)
  27443. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27444. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27445. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27446. * @returns the VertexData of the ribbon
  27447. */
  27448. static CreateRibbon(options: {
  27449. pathArray: Vector3[][];
  27450. closeArray?: boolean;
  27451. closePath?: boolean;
  27452. offset?: number;
  27453. sideOrientation?: number;
  27454. frontUVs?: Vector4;
  27455. backUVs?: Vector4;
  27456. invertUV?: boolean;
  27457. uvs?: Vector2[];
  27458. colors?: Color4[];
  27459. }): VertexData;
  27460. /**
  27461. * Creates the VertexData for a box
  27462. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27463. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27464. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27465. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27466. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27467. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27468. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27469. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27470. * * 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)
  27471. * * 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)
  27472. * @returns the VertexData of the box
  27473. */
  27474. static CreateBox(options: {
  27475. size?: number;
  27476. width?: number;
  27477. height?: number;
  27478. depth?: number;
  27479. faceUV?: Vector4[];
  27480. faceColors?: Color4[];
  27481. sideOrientation?: number;
  27482. frontUVs?: Vector4;
  27483. backUVs?: Vector4;
  27484. }): VertexData;
  27485. /**
  27486. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27487. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27488. * * segments sets the number of horizontal strips optional, default 32
  27489. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27490. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27491. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27492. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27493. * * 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
  27494. * * 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
  27495. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27496. * * 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)
  27497. * * 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)
  27498. * @returns the VertexData of the ellipsoid
  27499. */
  27500. static CreateSphere(options: {
  27501. segments?: number;
  27502. diameter?: number;
  27503. diameterX?: number;
  27504. diameterY?: number;
  27505. diameterZ?: number;
  27506. arc?: number;
  27507. slice?: number;
  27508. sideOrientation?: number;
  27509. frontUVs?: Vector4;
  27510. backUVs?: Vector4;
  27511. }): VertexData;
  27512. /**
  27513. * Creates the VertexData for a cylinder, cone or prism
  27514. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27515. * * height sets the height (y direction) of the cylinder, optional, default 2
  27516. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27517. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27518. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27519. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27520. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27521. * * 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
  27522. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27523. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27524. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27525. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27526. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27527. * * 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)
  27528. * * 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)
  27529. * @returns the VertexData of the cylinder, cone or prism
  27530. */
  27531. static CreateCylinder(options: {
  27532. height?: number;
  27533. diameterTop?: number;
  27534. diameterBottom?: number;
  27535. diameter?: number;
  27536. tessellation?: number;
  27537. subdivisions?: number;
  27538. arc?: number;
  27539. faceColors?: Color4[];
  27540. faceUV?: Vector4[];
  27541. hasRings?: boolean;
  27542. enclose?: boolean;
  27543. sideOrientation?: number;
  27544. frontUVs?: Vector4;
  27545. backUVs?: Vector4;
  27546. }): VertexData;
  27547. /**
  27548. * Creates the VertexData for a torus
  27549. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27550. * * diameter the diameter of the torus, optional default 1
  27551. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27552. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27553. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27554. * * 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)
  27555. * * 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)
  27556. * @returns the VertexData of the torus
  27557. */
  27558. static CreateTorus(options: {
  27559. diameter?: number;
  27560. thickness?: number;
  27561. tessellation?: number;
  27562. sideOrientation?: number;
  27563. frontUVs?: Vector4;
  27564. backUVs?: Vector4;
  27565. }): VertexData;
  27566. /**
  27567. * Creates the VertexData of the LineSystem
  27568. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27569. * - lines an array of lines, each line being an array of successive Vector3
  27570. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27571. * @returns the VertexData of the LineSystem
  27572. */
  27573. static CreateLineSystem(options: {
  27574. lines: Vector3[][];
  27575. colors?: Nullable<Color4[][]>;
  27576. }): VertexData;
  27577. /**
  27578. * Create the VertexData for a DashedLines
  27579. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27580. * - points an array successive Vector3
  27581. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27582. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27583. * - dashNb the intended total number of dashes, optional, default 200
  27584. * @returns the VertexData for the DashedLines
  27585. */
  27586. static CreateDashedLines(options: {
  27587. points: Vector3[];
  27588. dashSize?: number;
  27589. gapSize?: number;
  27590. dashNb?: number;
  27591. }): VertexData;
  27592. /**
  27593. * Creates the VertexData for a Ground
  27594. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27595. * - width the width (x direction) of the ground, optional, default 1
  27596. * - height the height (z direction) of the ground, optional, default 1
  27597. * - subdivisions the number of subdivisions per side, optional, default 1
  27598. * @returns the VertexData of the Ground
  27599. */
  27600. static CreateGround(options: {
  27601. width?: number;
  27602. height?: number;
  27603. subdivisions?: number;
  27604. subdivisionsX?: number;
  27605. subdivisionsY?: number;
  27606. }): VertexData;
  27607. /**
  27608. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27609. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27610. * * xmin the ground minimum X coordinate, optional, default -1
  27611. * * zmin the ground minimum Z coordinate, optional, default -1
  27612. * * xmax the ground maximum X coordinate, optional, default 1
  27613. * * zmax the ground maximum Z coordinate, optional, default 1
  27614. * * 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}
  27615. * * 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}
  27616. * @returns the VertexData of the TiledGround
  27617. */
  27618. static CreateTiledGround(options: {
  27619. xmin: number;
  27620. zmin: number;
  27621. xmax: number;
  27622. zmax: number;
  27623. subdivisions?: {
  27624. w: number;
  27625. h: number;
  27626. };
  27627. precision?: {
  27628. w: number;
  27629. h: number;
  27630. };
  27631. }): VertexData;
  27632. /**
  27633. * Creates the VertexData of the Ground designed from a heightmap
  27634. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27635. * * width the width (x direction) of the ground
  27636. * * height the height (z direction) of the ground
  27637. * * subdivisions the number of subdivisions per side
  27638. * * minHeight the minimum altitude on the ground, optional, default 0
  27639. * * maxHeight the maximum altitude on the ground, optional default 1
  27640. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27641. * * buffer the array holding the image color data
  27642. * * bufferWidth the width of image
  27643. * * bufferHeight the height of image
  27644. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27645. * @returns the VertexData of the Ground designed from a heightmap
  27646. */
  27647. static CreateGroundFromHeightMap(options: {
  27648. width: number;
  27649. height: number;
  27650. subdivisions: number;
  27651. minHeight: number;
  27652. maxHeight: number;
  27653. colorFilter: Color3;
  27654. buffer: Uint8Array;
  27655. bufferWidth: number;
  27656. bufferHeight: number;
  27657. alphaFilter: number;
  27658. }): VertexData;
  27659. /**
  27660. * Creates the VertexData for a Plane
  27661. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27662. * * size sets the width and height of the plane to the value of size, optional default 1
  27663. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27664. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27665. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27666. * * 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)
  27667. * * 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)
  27668. * @returns the VertexData of the box
  27669. */
  27670. static CreatePlane(options: {
  27671. size?: number;
  27672. width?: number;
  27673. height?: number;
  27674. sideOrientation?: number;
  27675. frontUVs?: Vector4;
  27676. backUVs?: Vector4;
  27677. }): VertexData;
  27678. /**
  27679. * Creates the VertexData of the Disc or regular Polygon
  27680. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27681. * * radius the radius of the disc, optional default 0.5
  27682. * * tessellation the number of polygon sides, optional, default 64
  27683. * * 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
  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 box
  27688. */
  27689. static CreateDisc(options: {
  27690. radius?: number;
  27691. tessellation?: number;
  27692. arc?: number;
  27693. sideOrientation?: number;
  27694. frontUVs?: Vector4;
  27695. backUVs?: Vector4;
  27696. }): VertexData;
  27697. /**
  27698. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27699. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27700. * @param polygon a mesh built from polygonTriangulation.build()
  27701. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27702. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27703. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27704. * @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)
  27705. * @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)
  27706. * @returns the VertexData of the Polygon
  27707. */
  27708. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27709. /**
  27710. * Creates the VertexData of the IcoSphere
  27711. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27712. * * radius the radius of the IcoSphere, optional default 1
  27713. * * radiusX allows stretching in the x direction, optional, default radius
  27714. * * radiusY allows stretching in the y direction, optional, default radius
  27715. * * radiusZ allows stretching in the z direction, optional, default radius
  27716. * * flat when true creates a flat shaded mesh, optional, default true
  27717. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27718. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27719. * * 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)
  27720. * * 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)
  27721. * @returns the VertexData of the IcoSphere
  27722. */
  27723. static CreateIcoSphere(options: {
  27724. radius?: number;
  27725. radiusX?: number;
  27726. radiusY?: number;
  27727. radiusZ?: number;
  27728. flat?: boolean;
  27729. subdivisions?: number;
  27730. sideOrientation?: number;
  27731. frontUVs?: Vector4;
  27732. backUVs?: Vector4;
  27733. }): VertexData;
  27734. /**
  27735. * Creates the VertexData for a Polyhedron
  27736. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27737. * * type provided types are:
  27738. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27739. * * 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)
  27740. * * size the size of the IcoSphere, optional default 1
  27741. * * sizeX allows stretching in the x direction, optional, default size
  27742. * * sizeY allows stretching in the y direction, optional, default size
  27743. * * sizeZ allows stretching in the z direction, optional, default size
  27744. * * 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
  27745. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27746. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27747. * * flat when true creates a flat shaded mesh, optional, default true
  27748. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27749. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27750. * * 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)
  27751. * * 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)
  27752. * @returns the VertexData of the Polyhedron
  27753. */
  27754. static CreatePolyhedron(options: {
  27755. type?: number;
  27756. size?: number;
  27757. sizeX?: number;
  27758. sizeY?: number;
  27759. sizeZ?: number;
  27760. custom?: any;
  27761. faceUV?: Vector4[];
  27762. faceColors?: Color4[];
  27763. flat?: boolean;
  27764. sideOrientation?: number;
  27765. frontUVs?: Vector4;
  27766. backUVs?: Vector4;
  27767. }): VertexData;
  27768. /**
  27769. * Creates the VertexData for a TorusKnot
  27770. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27771. * * radius the radius of the torus knot, optional, default 2
  27772. * * tube the thickness of the tube, optional, default 0.5
  27773. * * radialSegments the number of sides on each tube segments, optional, default 32
  27774. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27775. * * p the number of windings around the z axis, optional, default 2
  27776. * * q the number of windings around the x axis, optional, default 3
  27777. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27778. * * 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)
  27779. * * 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)
  27780. * @returns the VertexData of the Torus Knot
  27781. */
  27782. static CreateTorusKnot(options: {
  27783. radius?: number;
  27784. tube?: number;
  27785. radialSegments?: number;
  27786. tubularSegments?: number;
  27787. p?: number;
  27788. q?: number;
  27789. sideOrientation?: number;
  27790. frontUVs?: Vector4;
  27791. backUVs?: Vector4;
  27792. }): VertexData;
  27793. /**
  27794. * Compute normals for given positions and indices
  27795. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27796. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27797. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27798. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27799. * * facetNormals : optional array of facet normals (vector3)
  27800. * * facetPositions : optional array of facet positions (vector3)
  27801. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27802. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27803. * * bInfo : optional bounding info, required for facetPartitioning computation
  27804. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27805. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27806. * * useRightHandedSystem: optional boolean to for right handed system computation
  27807. * * depthSort : optional boolean to enable the facet depth sort computation
  27808. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27809. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27810. */
  27811. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27812. facetNormals?: any;
  27813. facetPositions?: any;
  27814. facetPartitioning?: any;
  27815. ratio?: number;
  27816. bInfo?: any;
  27817. bbSize?: Vector3;
  27818. subDiv?: any;
  27819. useRightHandedSystem?: boolean;
  27820. depthSort?: boolean;
  27821. distanceTo?: Vector3;
  27822. depthSortedFacets?: any;
  27823. }): void;
  27824. private static _ComputeSides;
  27825. /**
  27826. * Applies VertexData created from the imported parameters to the geometry
  27827. * @param parsedVertexData the parsed data from an imported file
  27828. * @param geometry the geometry to apply the VertexData to
  27829. */
  27830. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27831. }
  27832. }
  27833. declare module BABYLON {
  27834. /**
  27835. * Class containing static functions to help procedurally build meshes
  27836. */
  27837. class MeshBuilder {
  27838. private static updateSideOrientation;
  27839. /**
  27840. * Creates a box mesh
  27841. * * The parameter `size` sets the size (float) of each box side (default 1)
  27842. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27843. * * 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)
  27844. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27846. * * 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
  27847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27848. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27849. * @param name defines the name of the mesh
  27850. * @param options defines the options used to create the mesh
  27851. * @param scene defines the hosting scene
  27852. * @returns the box mesh
  27853. */
  27854. static CreateBox(name: string, options: {
  27855. size?: number;
  27856. width?: number;
  27857. height?: number;
  27858. depth?: number;
  27859. faceUV?: Vector4[];
  27860. faceColors?: Color4[];
  27861. sideOrientation?: number;
  27862. frontUVs?: Vector4;
  27863. backUVs?: Vector4;
  27864. updatable?: boolean;
  27865. }, scene?: Nullable<Scene>): Mesh;
  27866. /**
  27867. * Creates a sphere mesh
  27868. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27869. * * 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`)
  27870. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27871. * * 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
  27872. * * 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)
  27873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27874. * * 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
  27875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27876. * @param name defines the name of the mesh
  27877. * @param options defines the options used to create the mesh
  27878. * @param scene defines the hosting scene
  27879. * @returns the sphere mesh
  27880. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27881. */
  27882. static CreateSphere(name: string, options: {
  27883. segments?: number;
  27884. diameter?: number;
  27885. diameterX?: number;
  27886. diameterY?: number;
  27887. diameterZ?: number;
  27888. arc?: number;
  27889. slice?: number;
  27890. sideOrientation?: number;
  27891. frontUVs?: Vector4;
  27892. backUVs?: Vector4;
  27893. updatable?: boolean;
  27894. }, scene: any): Mesh;
  27895. /**
  27896. * Creates a plane polygonal mesh. By default, this is a disc
  27897. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27898. * * 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
  27899. * * 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
  27900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27901. * * 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
  27902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27903. * @param name defines the name of the mesh
  27904. * @param options defines the options used to create the mesh
  27905. * @param scene defines the hosting scene
  27906. * @returns the plane polygonal mesh
  27907. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27908. */
  27909. static CreateDisc(name: string, options: {
  27910. radius?: number;
  27911. tessellation?: number;
  27912. arc?: number;
  27913. updatable?: boolean;
  27914. sideOrientation?: number;
  27915. frontUVs?: Vector4;
  27916. backUVs?: Vector4;
  27917. }, scene?: Nullable<Scene>): Mesh;
  27918. /**
  27919. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27920. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27921. * * 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`)
  27922. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27923. * * 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
  27924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27925. * * 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
  27926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27927. * @param name defines the name of the mesh
  27928. * @param options defines the options used to create the mesh
  27929. * @param scene defines the hosting scene
  27930. * @returns the icosahedron mesh
  27931. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27932. */
  27933. static CreateIcoSphere(name: string, options: {
  27934. radius?: number;
  27935. radiusX?: number;
  27936. radiusY?: number;
  27937. radiusZ?: number;
  27938. flat?: boolean;
  27939. subdivisions?: number;
  27940. sideOrientation?: number;
  27941. frontUVs?: Vector4;
  27942. backUVs?: Vector4;
  27943. updatable?: boolean;
  27944. }, scene: Scene): Mesh;
  27945. /**
  27946. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27947. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27948. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27949. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27950. * * 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
  27951. * * 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
  27952. * * 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
  27953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27954. * * 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
  27955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27956. * * 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
  27957. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27958. * * 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
  27959. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27961. * @param name defines the name of the mesh
  27962. * @param options defines the options used to create the mesh
  27963. * @param scene defines the hosting scene
  27964. * @returns the ribbon mesh
  27965. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27966. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27967. */
  27968. static CreateRibbon(name: string, options: {
  27969. pathArray: Vector3[][];
  27970. closeArray?: boolean;
  27971. closePath?: boolean;
  27972. offset?: number;
  27973. updatable?: boolean;
  27974. sideOrientation?: number;
  27975. frontUVs?: Vector4;
  27976. backUVs?: Vector4;
  27977. instance?: Mesh;
  27978. invertUV?: boolean;
  27979. uvs?: Vector2[];
  27980. colors?: Color4[];
  27981. }, scene?: Nullable<Scene>): Mesh;
  27982. /**
  27983. * Creates a cylinder or a cone mesh
  27984. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27985. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27986. * * 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.
  27987. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27988. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27989. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27990. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27991. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27992. * * 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).
  27993. * * 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
  27994. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27995. * * 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
  27996. * * 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.
  27997. * * If `enclose` is false, a ring surface is one element.
  27998. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27999. * * 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
  28000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28001. * * 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
  28002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28003. * @param name defines the name of the mesh
  28004. * @param options defines the options used to create the mesh
  28005. * @param scene defines the hosting scene
  28006. * @returns the cylinder mesh
  28007. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28008. */
  28009. static CreateCylinder(name: string, options: {
  28010. height?: number;
  28011. diameterTop?: number;
  28012. diameterBottom?: number;
  28013. diameter?: number;
  28014. tessellation?: number;
  28015. subdivisions?: number;
  28016. arc?: number;
  28017. faceColors?: Color4[];
  28018. faceUV?: Vector4[];
  28019. updatable?: boolean;
  28020. hasRings?: boolean;
  28021. enclose?: boolean;
  28022. sideOrientation?: number;
  28023. frontUVs?: Vector4;
  28024. backUVs?: Vector4;
  28025. }, scene: any): Mesh;
  28026. /**
  28027. * Creates a torus mesh
  28028. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28029. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28030. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28032. * * 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
  28033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28034. * @param name defines the name of the mesh
  28035. * @param options defines the options used to create the mesh
  28036. * @param scene defines the hosting scene
  28037. * @returns the torus mesh
  28038. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28039. */
  28040. static CreateTorus(name: string, options: {
  28041. diameter?: number;
  28042. thickness?: number;
  28043. tessellation?: number;
  28044. updatable?: boolean;
  28045. sideOrientation?: number;
  28046. frontUVs?: Vector4;
  28047. backUVs?: Vector4;
  28048. }, scene: any): Mesh;
  28049. /**
  28050. * Creates a torus knot mesh
  28051. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28052. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28053. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28054. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28056. * * 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
  28057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28058. * @param name defines the name of the mesh
  28059. * @param options defines the options used to create the mesh
  28060. * @param scene defines the hosting scene
  28061. * @returns the torus knot mesh
  28062. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28063. */
  28064. static CreateTorusKnot(name: string, options: {
  28065. radius?: number;
  28066. tube?: number;
  28067. radialSegments?: number;
  28068. tubularSegments?: number;
  28069. p?: number;
  28070. q?: number;
  28071. updatable?: boolean;
  28072. sideOrientation?: number;
  28073. frontUVs?: Vector4;
  28074. backUVs?: Vector4;
  28075. }, scene: any): Mesh;
  28076. /**
  28077. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28078. * * 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
  28079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28080. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28081. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28082. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28083. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28084. * * 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
  28085. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28088. * @param name defines the name of the new line system
  28089. * @param options defines the options used to create the line system
  28090. * @param scene defines the hosting scene
  28091. * @returns a new line system mesh
  28092. */
  28093. static CreateLineSystem(name: string, options: {
  28094. lines: Vector3[][];
  28095. updatable?: boolean;
  28096. instance?: Nullable<LinesMesh>;
  28097. colors?: Nullable<Color4[][]>;
  28098. useVertexAlpha?: boolean;
  28099. }, scene: Nullable<Scene>): LinesMesh;
  28100. /**
  28101. * Creates a line mesh
  28102. * 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
  28103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28104. * * The parameter `points` is an array successive Vector3
  28105. * * 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
  28106. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28108. * * When updating an instance, remember that only point positions can change, not the number of points
  28109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28110. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28111. * @param name defines the name of the new line system
  28112. * @param options defines the options used to create the line system
  28113. * @param scene defines the hosting scene
  28114. * @returns a new line mesh
  28115. */
  28116. static CreateLines(name: string, options: {
  28117. points: Vector3[];
  28118. updatable?: boolean;
  28119. instance?: Nullable<LinesMesh>;
  28120. colors?: Color4[];
  28121. useVertexAlpha?: boolean;
  28122. }, scene?: Nullable<Scene>): LinesMesh;
  28123. /**
  28124. * Creates a dashed line mesh
  28125. * * 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
  28126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28127. * * The parameter `points` is an array successive Vector3
  28128. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28129. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28130. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28131. * * 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
  28132. * * When updating an instance, remember that only point positions can change, not the number of points
  28133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28134. * @param name defines the name of the mesh
  28135. * @param options defines the options used to create the mesh
  28136. * @param scene defines the hosting scene
  28137. * @returns the dashed line mesh
  28138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28139. */
  28140. static CreateDashedLines(name: string, options: {
  28141. points: Vector3[];
  28142. dashSize?: number;
  28143. gapSize?: number;
  28144. dashNb?: number;
  28145. updatable?: boolean;
  28146. instance?: LinesMesh;
  28147. }, scene?: Nullable<Scene>): LinesMesh;
  28148. /**
  28149. * 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.
  28150. * * 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.
  28151. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28152. * * 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.
  28153. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28154. * * 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
  28155. * * 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
  28156. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28158. * * 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
  28159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28161. * @param name defines the name of the mesh
  28162. * @param options defines the options used to create the mesh
  28163. * @param scene defines the hosting scene
  28164. * @returns the extruded shape mesh
  28165. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28166. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28167. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28168. */
  28169. static ExtrudeShape(name: string, options: {
  28170. shape: Vector3[];
  28171. path: Vector3[];
  28172. scale?: number;
  28173. rotation?: number;
  28174. cap?: number;
  28175. updatable?: boolean;
  28176. sideOrientation?: number;
  28177. frontUVs?: Vector4;
  28178. backUVs?: Vector4;
  28179. instance?: Mesh;
  28180. invertUV?: boolean;
  28181. }, scene?: Nullable<Scene>): Mesh;
  28182. /**
  28183. * Creates an custom extruded shape mesh.
  28184. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28185. * * 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.
  28186. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28187. * * 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
  28188. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28189. * * 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
  28190. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28191. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28192. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28193. * * 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
  28194. * * 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
  28195. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28197. * * 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
  28198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28200. * @param name defines the name of the mesh
  28201. * @param options defines the options used to create the mesh
  28202. * @param scene defines the hosting scene
  28203. * @returns the custom extruded shape mesh
  28204. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28205. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28206. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28207. */
  28208. static ExtrudeShapeCustom(name: string, options: {
  28209. shape: Vector3[];
  28210. path: Vector3[];
  28211. scaleFunction?: any;
  28212. rotationFunction?: any;
  28213. ribbonCloseArray?: boolean;
  28214. ribbonClosePath?: boolean;
  28215. cap?: number;
  28216. updatable?: boolean;
  28217. sideOrientation?: number;
  28218. frontUVs?: Vector4;
  28219. backUVs?: Vector4;
  28220. instance?: Mesh;
  28221. invertUV?: boolean;
  28222. }, scene: Scene): Mesh;
  28223. /**
  28224. * Creates lathe mesh.
  28225. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28226. * * 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
  28227. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28228. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28229. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28230. * * 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
  28231. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28232. * * 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
  28233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28234. * * 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
  28235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28237. * @param name defines the name of the mesh
  28238. * @param options defines the options used to create the mesh
  28239. * @param scene defines the hosting scene
  28240. * @returns the lathe mesh
  28241. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28242. */
  28243. static CreateLathe(name: string, options: {
  28244. shape: Vector3[];
  28245. radius?: number;
  28246. tessellation?: number;
  28247. clip?: number;
  28248. arc?: number;
  28249. closed?: boolean;
  28250. updatable?: boolean;
  28251. sideOrientation?: number;
  28252. frontUVs?: Vector4;
  28253. backUVs?: Vector4;
  28254. cap?: number;
  28255. invertUV?: boolean;
  28256. }, scene: Scene): Mesh;
  28257. /**
  28258. * Creates a plane mesh
  28259. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28260. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28261. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28263. * * 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
  28264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28265. * @param name defines the name of the mesh
  28266. * @param options defines the options used to create the mesh
  28267. * @param scene defines the hosting scene
  28268. * @returns the plane mesh
  28269. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28270. */
  28271. static CreatePlane(name: string, options: {
  28272. size?: number;
  28273. width?: number;
  28274. height?: number;
  28275. sideOrientation?: number;
  28276. frontUVs?: Vector4;
  28277. backUVs?: Vector4;
  28278. updatable?: boolean;
  28279. sourcePlane?: Plane;
  28280. }, scene: Scene): Mesh;
  28281. /**
  28282. * Creates a ground mesh
  28283. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28284. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28286. * @param name defines the name of the mesh
  28287. * @param options defines the options used to create the mesh
  28288. * @param scene defines the hosting scene
  28289. * @returns the ground mesh
  28290. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28291. */
  28292. static CreateGround(name: string, options: {
  28293. width?: number;
  28294. height?: number;
  28295. subdivisions?: number;
  28296. subdivisionsX?: number;
  28297. subdivisionsY?: number;
  28298. updatable?: boolean;
  28299. }, scene: any): Mesh;
  28300. /**
  28301. * Creates a tiled ground mesh
  28302. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28303. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28304. * * 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
  28305. * * 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
  28306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28307. * @param name defines the name of the mesh
  28308. * @param options defines the options used to create the mesh
  28309. * @param scene defines the hosting scene
  28310. * @returns the tiled ground mesh
  28311. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28312. */
  28313. static CreateTiledGround(name: string, options: {
  28314. xmin: number;
  28315. zmin: number;
  28316. xmax: number;
  28317. zmax: number;
  28318. subdivisions?: {
  28319. w: number;
  28320. h: number;
  28321. };
  28322. precision?: {
  28323. w: number;
  28324. h: number;
  28325. };
  28326. updatable?: boolean;
  28327. }, scene: Scene): Mesh;
  28328. /**
  28329. * Creates a ground mesh from a height map
  28330. * * The parameter `url` sets the URL of the height map image resource.
  28331. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28332. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28333. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28334. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28335. * * 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.
  28336. * * 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).
  28337. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28339. * @param name defines the name of the mesh
  28340. * @param url defines the url to the height map
  28341. * @param options defines the options used to create the mesh
  28342. * @param scene defines the hosting scene
  28343. * @returns the ground mesh
  28344. * @see http://doc.babylonjs.com/babylon101/height_map
  28345. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28346. */
  28347. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28348. width?: number;
  28349. height?: number;
  28350. subdivisions?: number;
  28351. minHeight?: number;
  28352. maxHeight?: number;
  28353. colorFilter?: Color3;
  28354. alphaFilter?: number;
  28355. updatable?: boolean;
  28356. onReady?: (mesh: GroundMesh) => void;
  28357. }, scene: Scene): GroundMesh;
  28358. /**
  28359. * Creates a polygon mesh
  28360. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28361. * * 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
  28362. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28364. * * 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)
  28365. * * Remember you can only change the shape positions, not their number when updating a polygon
  28366. * @param name defines the name of the mesh
  28367. * @param options defines the options used to create the mesh
  28368. * @param scene defines the hosting scene
  28369. * @returns the polygon mesh
  28370. */
  28371. static CreatePolygon(name: string, options: {
  28372. shape: Vector3[];
  28373. holes?: Vector3[][];
  28374. depth?: number;
  28375. faceUV?: Vector4[];
  28376. faceColors?: Color4[];
  28377. updatable?: boolean;
  28378. sideOrientation?: number;
  28379. frontUVs?: Vector4;
  28380. backUVs?: Vector4;
  28381. }, scene: Scene): Mesh;
  28382. /**
  28383. * Creates an extruded polygon mesh, with depth in the Y direction.
  28384. * * 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)
  28385. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28386. * @param name defines the name of the mesh
  28387. * @param options defines the options used to create the mesh
  28388. * @param scene defines the hosting scene
  28389. * @returns the polygon mesh
  28390. */
  28391. static ExtrudePolygon(name: string, options: {
  28392. shape: Vector3[];
  28393. holes?: Vector3[][];
  28394. depth?: number;
  28395. faceUV?: Vector4[];
  28396. faceColors?: Color4[];
  28397. updatable?: boolean;
  28398. sideOrientation?: number;
  28399. frontUVs?: Vector4;
  28400. backUVs?: Vector4;
  28401. }, scene: Scene): Mesh;
  28402. /**
  28403. * Creates a tube mesh.
  28404. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28405. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28406. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28407. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28408. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28409. * * 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)
  28410. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28411. * * 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
  28412. * * 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
  28413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28414. * * 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
  28415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28417. * @param name defines the name of the mesh
  28418. * @param options defines the options used to create the mesh
  28419. * @param scene defines the hosting scene
  28420. * @returns the tube mesh
  28421. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28422. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28423. */
  28424. static CreateTube(name: string, options: {
  28425. path: Vector3[];
  28426. radius?: number;
  28427. tessellation?: number;
  28428. radiusFunction?: {
  28429. (i: number, distance: number): number;
  28430. };
  28431. cap?: number;
  28432. arc?: number;
  28433. updatable?: boolean;
  28434. sideOrientation?: number;
  28435. frontUVs?: Vector4;
  28436. backUVs?: Vector4;
  28437. instance?: Mesh;
  28438. invertUV?: boolean;
  28439. }, scene: Scene): Mesh;
  28440. /**
  28441. * Creates a polyhedron mesh
  28442. * * 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
  28443. * * The parameter `size` (positive float, default 1) sets the polygon size
  28444. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28445. * * 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`
  28446. * * 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
  28447. * * 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)`)
  28448. * * 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
  28449. * * 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
  28450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28451. * * 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
  28452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28453. * @param name defines the name of the mesh
  28454. * @param options defines the options used to create the mesh
  28455. * @param scene defines the hosting scene
  28456. * @returns the polyhedron mesh
  28457. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28458. */
  28459. static CreatePolyhedron(name: string, options: {
  28460. type?: number;
  28461. size?: number;
  28462. sizeX?: number;
  28463. sizeY?: number;
  28464. sizeZ?: number;
  28465. custom?: any;
  28466. faceUV?: Vector4[];
  28467. faceColors?: Color4[];
  28468. flat?: boolean;
  28469. updatable?: boolean;
  28470. sideOrientation?: number;
  28471. frontUVs?: Vector4;
  28472. backUVs?: Vector4;
  28473. }, scene: Scene): Mesh;
  28474. /**
  28475. * Creates a decal mesh.
  28476. * 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
  28477. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28478. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28479. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28480. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28481. * @param name defines the name of the mesh
  28482. * @param sourceMesh defines the mesh where the decal must be applied
  28483. * @param options defines the options used to create the mesh
  28484. * @param scene defines the hosting scene
  28485. * @returns the decal mesh
  28486. * @see http://doc.babylonjs.com/how_to/decals
  28487. */
  28488. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28489. position?: Vector3;
  28490. normal?: Vector3;
  28491. size?: Vector3;
  28492. angle?: number;
  28493. }): Mesh;
  28494. private static _ExtrudeShapeGeneric;
  28495. }
  28496. }
  28497. declare module BABYLON {
  28498. /**
  28499. * Class used to represent a specific level of detail of a mesh
  28500. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28501. */
  28502. class MeshLODLevel {
  28503. /** Defines the distance where this level should star being displayed */
  28504. distance: number;
  28505. /** Defines the mesh to use to render this level */
  28506. mesh: Nullable<Mesh>;
  28507. /**
  28508. * Creates a new LOD level
  28509. * @param distance defines the distance where this level should star being displayed
  28510. * @param mesh defines the mesh to use to render this level
  28511. */
  28512. constructor(
  28513. /** Defines the distance where this level should star being displayed */
  28514. distance: number,
  28515. /** Defines the mesh to use to render this level */
  28516. mesh: Nullable<Mesh>);
  28517. }
  28518. }
  28519. declare module BABYLON {
  28520. /**
  28521. * A simplifier interface for future simplification implementations
  28522. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28523. */
  28524. interface ISimplifier {
  28525. /**
  28526. * Simplification of a given mesh according to the given settings.
  28527. * Since this requires computation, it is assumed that the function runs async.
  28528. * @param settings The settings of the simplification, including quality and distance
  28529. * @param successCallback A callback that will be called after the mesh was simplified.
  28530. * @param errorCallback in case of an error, this callback will be called. optional.
  28531. */
  28532. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28533. }
  28534. /**
  28535. * Expected simplification settings.
  28536. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28537. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28538. */
  28539. interface ISimplificationSettings {
  28540. /**
  28541. * Gets or sets the expected quality
  28542. */
  28543. quality: number;
  28544. /**
  28545. * Gets or sets the distance when this optimized version should be used
  28546. */
  28547. distance: number;
  28548. /**
  28549. * Gets an already optimized mesh
  28550. */
  28551. optimizeMesh?: boolean;
  28552. }
  28553. /**
  28554. * Class used to specify simplification options
  28555. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28556. */
  28557. class SimplificationSettings implements ISimplificationSettings {
  28558. /** expected quality */
  28559. quality: number;
  28560. /** distance when this optimized version should be used */
  28561. distance: number;
  28562. /** already optimized mesh */
  28563. optimizeMesh?: boolean | undefined;
  28564. /**
  28565. * Creates a SimplificationSettings
  28566. * @param quality expected quality
  28567. * @param distance distance when this optimized version should be used
  28568. * @param optimizeMesh already optimized mesh
  28569. */
  28570. constructor(
  28571. /** expected quality */
  28572. quality: number,
  28573. /** distance when this optimized version should be used */
  28574. distance: number,
  28575. /** already optimized mesh */
  28576. optimizeMesh?: boolean | undefined);
  28577. }
  28578. /**
  28579. * Interface used to define a simplification task
  28580. */
  28581. interface ISimplificationTask {
  28582. /**
  28583. * Array of settings
  28584. */
  28585. settings: Array<ISimplificationSettings>;
  28586. /**
  28587. * Simplification type
  28588. */
  28589. simplificationType: SimplificationType;
  28590. /**
  28591. * Mesh to simplify
  28592. */
  28593. mesh: Mesh;
  28594. /**
  28595. * Callback called on success
  28596. */
  28597. successCallback?: () => void;
  28598. /**
  28599. * Defines if parallel processing can be used
  28600. */
  28601. parallelProcessing: boolean;
  28602. }
  28603. /**
  28604. * Queue used to order the simplification tasks
  28605. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28606. */
  28607. class SimplificationQueue {
  28608. private _simplificationArray;
  28609. /**
  28610. * Gets a boolean indicating that the process is still running
  28611. */
  28612. running: boolean;
  28613. /**
  28614. * Creates a new queue
  28615. */
  28616. constructor();
  28617. /**
  28618. * Adds a new simplification task
  28619. * @param task defines a task to add
  28620. */
  28621. addTask(task: ISimplificationTask): void;
  28622. /**
  28623. * Execute next task
  28624. */
  28625. executeNext(): void;
  28626. /**
  28627. * Execute a simplification task
  28628. * @param task defines the task to run
  28629. */
  28630. runSimplification(task: ISimplificationTask): void;
  28631. private getSimplifier;
  28632. }
  28633. /**
  28634. * The implemented types of simplification
  28635. * At the moment only Quadratic Error Decimation is implemented
  28636. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28637. */
  28638. enum SimplificationType {
  28639. /** Quadratic error decimation */
  28640. QUADRATIC = 0
  28641. }
  28642. }
  28643. declare module BABYLON {
  28644. interface Scene {
  28645. /** @hidden (Backing field) */
  28646. _simplificationQueue: SimplificationQueue;
  28647. /**
  28648. * Gets or sets the simplification queue attached to the scene
  28649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28650. */
  28651. simplificationQueue: SimplificationQueue;
  28652. }
  28653. interface Mesh {
  28654. /**
  28655. * Simplify the mesh according to the given array of settings.
  28656. * Function will return immediately and will simplify async
  28657. * @param settings a collection of simplification settings
  28658. * @param parallelProcessing should all levels calculate parallel or one after the other
  28659. * @param simplificationType the type of simplification to run
  28660. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28661. * @returns the current mesh
  28662. */
  28663. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28664. }
  28665. /**
  28666. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28667. * created in a scene
  28668. */
  28669. class SimplicationQueueSceneComponent implements ISceneComponent {
  28670. /**
  28671. * The component name helpfull to identify the component in the list of scene components.
  28672. */
  28673. readonly name: string;
  28674. /**
  28675. * The scene the component belongs to.
  28676. */
  28677. scene: Scene;
  28678. /**
  28679. * Creates a new instance of the component for the given scene
  28680. * @param scene Defines the scene to register the component in
  28681. */
  28682. constructor(scene: Scene);
  28683. /**
  28684. * Registers the component in a given scene
  28685. */
  28686. register(): void;
  28687. /**
  28688. * Rebuilds the elements related to this component in case of
  28689. * context lost for instance.
  28690. */
  28691. rebuild(): void;
  28692. /**
  28693. * Disposes the component and the associated ressources
  28694. */
  28695. dispose(): void;
  28696. private _beforeCameraUpdate;
  28697. }
  28698. }
  28699. declare module BABYLON {
  28700. /**
  28701. * Polygon
  28702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28703. */
  28704. class Polygon {
  28705. /**
  28706. * Creates a rectangle
  28707. * @param xmin bottom X coord
  28708. * @param ymin bottom Y coord
  28709. * @param xmax top X coord
  28710. * @param ymax top Y coord
  28711. * @returns points that make the resulting rectation
  28712. */
  28713. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28714. /**
  28715. * Creates a circle
  28716. * @param radius radius of circle
  28717. * @param cx scale in x
  28718. * @param cy scale in y
  28719. * @param numberOfSides number of sides that make up the circle
  28720. * @returns points that make the resulting circle
  28721. */
  28722. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28723. /**
  28724. * Creates a polygon from input string
  28725. * @param input Input polygon data
  28726. * @returns the parsed points
  28727. */
  28728. static Parse(input: string): Vector2[];
  28729. /**
  28730. * Starts building a polygon from x and y coordinates
  28731. * @param x x coordinate
  28732. * @param y y coordinate
  28733. * @returns the started path2
  28734. */
  28735. static StartingAt(x: number, y: number): Path2;
  28736. }
  28737. /**
  28738. * Builds a polygon
  28739. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28740. */
  28741. class PolygonMeshBuilder {
  28742. private _points;
  28743. private _outlinepoints;
  28744. private _holes;
  28745. private _name;
  28746. private _scene;
  28747. private _epoints;
  28748. private _eholes;
  28749. private _addToepoint;
  28750. /**
  28751. * Creates a PolygonMeshBuilder
  28752. * @param name name of the builder
  28753. * @param contours Path of the polygon
  28754. * @param scene scene to add to
  28755. */
  28756. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28757. /**
  28758. * Adds a whole within the polygon
  28759. * @param hole Array of points defining the hole
  28760. * @returns this
  28761. */
  28762. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28763. /**
  28764. * Creates the polygon
  28765. * @param updatable If the mesh should be updatable
  28766. * @param depth The depth of the mesh created
  28767. * @returns the created mesh
  28768. */
  28769. build(updatable?: boolean, depth?: number): Mesh;
  28770. /**
  28771. * Adds a side to the polygon
  28772. * @param positions points that make the polygon
  28773. * @param normals normals of the polygon
  28774. * @param uvs uvs of the polygon
  28775. * @param indices indices of the polygon
  28776. * @param bounds bounds of the polygon
  28777. * @param points points of the polygon
  28778. * @param depth depth of the polygon
  28779. * @param flip flip of the polygon
  28780. */
  28781. private addSide;
  28782. }
  28783. }
  28784. declare module BABYLON {
  28785. /**
  28786. * Base class for submeshes
  28787. */
  28788. class BaseSubMesh {
  28789. /** @hidden */
  28790. _materialDefines: Nullable<MaterialDefines>;
  28791. /** @hidden */
  28792. _materialEffect: Nullable<Effect>;
  28793. /**
  28794. * Gets associated effect
  28795. */
  28796. readonly effect: Nullable<Effect>;
  28797. /**
  28798. * Sets associated effect (effect used to render this submesh)
  28799. * @param effect defines the effect to associate with
  28800. * @param defines defines the set of defines used to compile this effect
  28801. */
  28802. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28803. }
  28804. /**
  28805. * Defines a subdivision inside a mesh
  28806. */
  28807. class SubMesh extends BaseSubMesh implements ICullable {
  28808. /** the material index to use */
  28809. materialIndex: number;
  28810. /** vertex index start */
  28811. verticesStart: number;
  28812. /** vertices count */
  28813. verticesCount: number;
  28814. /** index start */
  28815. indexStart: number;
  28816. /** indices count */
  28817. indexCount: number;
  28818. /** @hidden */
  28819. _linesIndexCount: number;
  28820. private _mesh;
  28821. private _renderingMesh;
  28822. private _boundingInfo;
  28823. private _linesIndexBuffer;
  28824. /** @hidden */
  28825. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28826. /** @hidden */
  28827. _trianglePlanes: Plane[];
  28828. /** @hidden */
  28829. _lastColliderTransformMatrix: Matrix;
  28830. /** @hidden */
  28831. _renderId: number;
  28832. /** @hidden */
  28833. _alphaIndex: number;
  28834. /** @hidden */
  28835. _distanceToCamera: number;
  28836. /** @hidden */
  28837. _id: number;
  28838. private _currentMaterial;
  28839. /**
  28840. * Add a new submesh to a mesh
  28841. * @param materialIndex defines the material index to use
  28842. * @param verticesStart defines vertex index start
  28843. * @param verticesCount defines vertices count
  28844. * @param indexStart defines index start
  28845. * @param indexCount defines indices count
  28846. * @param mesh defines the parent mesh
  28847. * @param renderingMesh defines an optional rendering mesh
  28848. * @param createBoundingBox defines if bounding box should be created for this submesh
  28849. * @returns the new submesh
  28850. */
  28851. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28852. /**
  28853. * Creates a new submesh
  28854. * @param materialIndex defines the material index to use
  28855. * @param verticesStart defines vertex index start
  28856. * @param verticesCount defines vertices count
  28857. * @param indexStart defines index start
  28858. * @param indexCount defines indices count
  28859. * @param mesh defines the parent mesh
  28860. * @param renderingMesh defines an optional rendering mesh
  28861. * @param createBoundingBox defines if bounding box should be created for this submesh
  28862. */
  28863. constructor(
  28864. /** the material index to use */
  28865. materialIndex: number,
  28866. /** vertex index start */
  28867. verticesStart: number,
  28868. /** vertices count */
  28869. verticesCount: number,
  28870. /** index start */
  28871. indexStart: number,
  28872. /** indices count */
  28873. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28874. /**
  28875. * Returns true if this submesh covers the entire parent mesh
  28876. * @ignorenaming
  28877. */
  28878. readonly IsGlobal: boolean;
  28879. /**
  28880. * Returns the submesh BoudingInfo object
  28881. * @returns current bounding info (or mesh's one if the submesh is global)
  28882. */
  28883. getBoundingInfo(): BoundingInfo;
  28884. /**
  28885. * Sets the submesh BoundingInfo
  28886. * @param boundingInfo defines the new bounding info to use
  28887. * @returns the SubMesh
  28888. */
  28889. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28890. /**
  28891. * Returns the mesh of the current submesh
  28892. * @return the parent mesh
  28893. */
  28894. getMesh(): AbstractMesh;
  28895. /**
  28896. * Returns the rendering mesh of the submesh
  28897. * @returns the rendering mesh (could be different from parent mesh)
  28898. */
  28899. getRenderingMesh(): Mesh;
  28900. /**
  28901. * Returns the submesh material
  28902. * @returns null or the current material
  28903. */
  28904. getMaterial(): Nullable<Material>;
  28905. /**
  28906. * Sets a new updated BoundingInfo object to the submesh
  28907. * @returns the SubMesh
  28908. */
  28909. refreshBoundingInfo(): SubMesh;
  28910. /** @hidden */
  28911. _checkCollision(collider: Collider): boolean;
  28912. /**
  28913. * Updates the submesh BoundingInfo
  28914. * @param world defines the world matrix to use to update the bounding info
  28915. * @returns the submesh
  28916. */
  28917. updateBoundingInfo(world: Matrix): SubMesh;
  28918. /**
  28919. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28920. * @param frustumPlanes defines the frustum planes
  28921. * @returns true if the submesh is intersecting with the frustum
  28922. */
  28923. isInFrustum(frustumPlanes: Plane[]): boolean;
  28924. /**
  28925. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28926. * @param frustumPlanes defines the frustum planes
  28927. * @returns true if the submesh is inside the frustum
  28928. */
  28929. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28930. /**
  28931. * Renders the submesh
  28932. * @param enableAlphaMode defines if alpha needs to be used
  28933. * @returns the submesh
  28934. */
  28935. render(enableAlphaMode: boolean): SubMesh;
  28936. /**
  28937. * @hidden
  28938. */
  28939. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  28940. /**
  28941. * Checks if the submesh intersects with a ray
  28942. * @param ray defines the ray to test
  28943. * @returns true is the passed ray intersects the submesh bounding box
  28944. */
  28945. canIntersects(ray: Ray): boolean;
  28946. /**
  28947. * Intersects current submesh with a ray
  28948. * @param ray defines the ray to test
  28949. * @param positions defines mesh's positions array
  28950. * @param indices defines mesh's indices array
  28951. * @param fastCheck defines if only bounding info should be used
  28952. * @returns intersection info or null if no intersection
  28953. */
  28954. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28955. /** @hidden */
  28956. private _intersectLines;
  28957. /** @hidden */
  28958. private _intersectTriangles;
  28959. /** @hidden */
  28960. _rebuild(): void;
  28961. /**
  28962. * Creates a new submesh from the passed mesh
  28963. * @param newMesh defines the new hosting mesh
  28964. * @param newRenderingMesh defines an optional rendering mesh
  28965. * @returns the new submesh
  28966. */
  28967. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28968. /**
  28969. * Release associated resources
  28970. */
  28971. dispose(): void;
  28972. /**
  28973. * Creates a new submesh from indices data
  28974. * @param materialIndex the index of the main mesh material
  28975. * @param startIndex the index where to start the copy in the mesh indices array
  28976. * @param indexCount the number of indices to copy then from the startIndex
  28977. * @param mesh the main mesh to create the submesh from
  28978. * @param renderingMesh the optional rendering mesh
  28979. * @returns a new submesh
  28980. */
  28981. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28982. }
  28983. }
  28984. declare module BABYLON {
  28985. /**
  28986. * 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.
  28987. * @see https://doc.babylonjs.com/how_to/transformnode
  28988. */
  28989. class TransformNode extends Node {
  28990. /**
  28991. * Object will not rotate to face the camera
  28992. */
  28993. static BILLBOARDMODE_NONE: number;
  28994. /**
  28995. * Object will rotate to face the camera but only on the x axis
  28996. */
  28997. static BILLBOARDMODE_X: number;
  28998. /**
  28999. * Object will rotate to face the camera but only on the y axis
  29000. */
  29001. static BILLBOARDMODE_Y: number;
  29002. /**
  29003. * Object will rotate to face the camera but only on the z axis
  29004. */
  29005. static BILLBOARDMODE_Z: number;
  29006. /**
  29007. * Object will rotate to face the camera
  29008. */
  29009. static BILLBOARDMODE_ALL: number;
  29010. private _forward;
  29011. private _forwardInverted;
  29012. private _up;
  29013. private _right;
  29014. private _rightInverted;
  29015. private _position;
  29016. private _rotation;
  29017. private _rotationQuaternion;
  29018. protected _scaling: Vector3;
  29019. protected _isDirty: boolean;
  29020. private _transformToBoneReferal;
  29021. /**
  29022. * Set the billboard mode. Default is 0.
  29023. *
  29024. * | Value | Type | Description |
  29025. * | --- | --- | --- |
  29026. * | 0 | BILLBOARDMODE_NONE | |
  29027. * | 1 | BILLBOARDMODE_X | |
  29028. * | 2 | BILLBOARDMODE_Y | |
  29029. * | 4 | BILLBOARDMODE_Z | |
  29030. * | 7 | BILLBOARDMODE_ALL | |
  29031. *
  29032. */
  29033. billboardMode: number;
  29034. /**
  29035. * 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
  29036. */
  29037. scalingDeterminant: number;
  29038. /**
  29039. * Sets the distance of the object to max, often used by skybox
  29040. */
  29041. infiniteDistance: boolean;
  29042. /**
  29043. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29044. * By default the system will update normals to compensate
  29045. */
  29046. ignoreNonUniformScaling: boolean;
  29047. /** @hidden */
  29048. _poseMatrix: Matrix;
  29049. private _localWorld;
  29050. private _absolutePosition;
  29051. private _pivotMatrix;
  29052. private _pivotMatrixInverse;
  29053. private _postMultiplyPivotMatrix;
  29054. protected _isWorldMatrixFrozen: boolean;
  29055. /** @hidden */
  29056. _indexInSceneTransformNodesArray: number;
  29057. /**
  29058. * An event triggered after the world matrix is updated
  29059. */
  29060. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29061. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29062. /**
  29063. * Gets a string identifying the name of the class
  29064. * @returns "TransformNode" string
  29065. */
  29066. getClassName(): string;
  29067. /**
  29068. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29069. */
  29070. position: Vector3;
  29071. /**
  29072. * 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)).
  29073. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29074. */
  29075. rotation: Vector3;
  29076. /**
  29077. * 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)).
  29078. */
  29079. scaling: Vector3;
  29080. /**
  29081. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29082. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29083. */
  29084. rotationQuaternion: Nullable<Quaternion>;
  29085. /**
  29086. * The forward direction of that transform in world space.
  29087. */
  29088. readonly forward: Vector3;
  29089. /**
  29090. * The up direction of that transform in world space.
  29091. */
  29092. readonly up: Vector3;
  29093. /**
  29094. * The right direction of that transform in world space.
  29095. */
  29096. readonly right: Vector3;
  29097. /**
  29098. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29099. * @param matrix the matrix to copy the pose from
  29100. * @returns this TransformNode.
  29101. */
  29102. updatePoseMatrix(matrix: Matrix): TransformNode;
  29103. /**
  29104. * Returns the mesh Pose matrix.
  29105. * @returns the pose matrix
  29106. */
  29107. getPoseMatrix(): Matrix;
  29108. /** @hidden */
  29109. _isSynchronized(): boolean;
  29110. /** @hidden */
  29111. _initCache(): void;
  29112. /**
  29113. * Flag the transform node as dirty (Forcing it to update everything)
  29114. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29115. * @returns this transform node
  29116. */
  29117. markAsDirty(property: string): TransformNode;
  29118. /**
  29119. * Returns the current mesh absolute position.
  29120. * Returns a Vector3.
  29121. */
  29122. readonly absolutePosition: Vector3;
  29123. /**
  29124. * Sets a new matrix to apply before all other transformation
  29125. * @param matrix defines the transform matrix
  29126. * @returns the current TransformNode
  29127. */
  29128. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29129. /**
  29130. * Sets a new pivot matrix to the current node
  29131. * @param matrix defines the new pivot matrix to use
  29132. * @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
  29133. * @returns the current TransformNode
  29134. */
  29135. setPivotMatrix(matrix: Readonly<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29136. /**
  29137. * Returns the mesh pivot matrix.
  29138. * Default : Identity.
  29139. * @returns the matrix
  29140. */
  29141. getPivotMatrix(): Matrix;
  29142. /**
  29143. * Prevents the World matrix to be computed any longer.
  29144. * @returns the TransformNode.
  29145. */
  29146. freezeWorldMatrix(): TransformNode;
  29147. /**
  29148. * Allows back the World matrix computation.
  29149. * @returns the TransformNode.
  29150. */
  29151. unfreezeWorldMatrix(): this;
  29152. /**
  29153. * True if the World matrix has been frozen.
  29154. */
  29155. readonly isWorldMatrixFrozen: boolean;
  29156. /**
  29157. * Retuns the mesh absolute position in the World.
  29158. * @returns a Vector3.
  29159. */
  29160. getAbsolutePosition(): Vector3;
  29161. /**
  29162. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29163. * @param absolutePosition the absolute position to set
  29164. * @returns the TransformNode.
  29165. */
  29166. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29167. /**
  29168. * Sets the mesh position in its local space.
  29169. * @param vector3 the position to set in localspace
  29170. * @returns the TransformNode.
  29171. */
  29172. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29173. /**
  29174. * Returns the mesh position in the local space from the current World matrix values.
  29175. * @returns a new Vector3.
  29176. */
  29177. getPositionExpressedInLocalSpace(): Vector3;
  29178. /**
  29179. * Translates the mesh along the passed Vector3 in its local space.
  29180. * @param vector3 the distance to translate in localspace
  29181. * @returns the TransformNode.
  29182. */
  29183. locallyTranslate(vector3: Vector3): TransformNode;
  29184. private static _lookAtVectorCache;
  29185. /**
  29186. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29187. * @param targetPoint the position (must be in same space as current mesh) to look at
  29188. * @param yawCor optional yaw (y-axis) correction in radians
  29189. * @param pitchCor optional pitch (x-axis) correction in radians
  29190. * @param rollCor optional roll (z-axis) correction in radians
  29191. * @param space the choosen space of the target
  29192. * @returns the TransformNode.
  29193. */
  29194. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29195. /**
  29196. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29197. * This Vector3 is expressed in the World space.
  29198. * @param localAxis axis to rotate
  29199. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29200. */
  29201. getDirection(localAxis: Vector3): Vector3;
  29202. /**
  29203. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29204. * localAxis is expressed in the mesh local space.
  29205. * result is computed in the Wordl space from the mesh World matrix.
  29206. * @param localAxis axis to rotate
  29207. * @param result the resulting transformnode
  29208. * @returns this TransformNode.
  29209. */
  29210. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29211. /**
  29212. * Sets a new pivot point to the current node
  29213. * @param point defines the new pivot point to use
  29214. * @param space defines if the point is in world or local space (local by default)
  29215. * @returns the current TransformNode
  29216. */
  29217. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29218. /**
  29219. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29220. * @returns the pivot point
  29221. */
  29222. getPivotPoint(): Vector3;
  29223. /**
  29224. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29225. * @param result the vector3 to store the result
  29226. * @returns this TransformNode.
  29227. */
  29228. getPivotPointToRef(result: Vector3): TransformNode;
  29229. /**
  29230. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29231. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29232. */
  29233. getAbsolutePivotPoint(): Vector3;
  29234. /**
  29235. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29236. * @param result vector3 to store the result
  29237. * @returns this TransformNode.
  29238. */
  29239. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29240. /**
  29241. * Defines the passed node as the parent of the current node.
  29242. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29243. * @param node the node ot set as the parent
  29244. * @returns this TransformNode.
  29245. */
  29246. setParent(node: Nullable<Node>): TransformNode;
  29247. private _nonUniformScaling;
  29248. /**
  29249. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29250. */
  29251. readonly nonUniformScaling: boolean;
  29252. /** @hidden */
  29253. _updateNonUniformScalingState(value: boolean): boolean;
  29254. /**
  29255. * Attach the current TransformNode to another TransformNode associated with a bone
  29256. * @param bone Bone affecting the TransformNode
  29257. * @param affectedTransformNode TransformNode associated with the bone
  29258. * @returns this object
  29259. */
  29260. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29261. /**
  29262. * Detach the transform node if its associated with a bone
  29263. * @returns this object
  29264. */
  29265. detachFromBone(): TransformNode;
  29266. private static _rotationAxisCache;
  29267. /**
  29268. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29269. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29270. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29271. * The passed axis is also normalized.
  29272. * @param axis the axis to rotate around
  29273. * @param amount the amount to rotate in radians
  29274. * @param space Space to rotate in (Default: local)
  29275. * @returns the TransformNode.
  29276. */
  29277. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29278. /**
  29279. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29280. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29281. * The passed axis is also normalized. .
  29282. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29283. * @param point the point to rotate around
  29284. * @param axis the axis to rotate around
  29285. * @param amount the amount to rotate in radians
  29286. * @returns the TransformNode
  29287. */
  29288. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29289. /**
  29290. * Translates the mesh along the axis vector for the passed distance in the given space.
  29291. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29292. * @param axis the axis to translate in
  29293. * @param distance the distance to translate
  29294. * @param space Space to rotate in (Default: local)
  29295. * @returns the TransformNode.
  29296. */
  29297. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29298. /**
  29299. * Adds a rotation step to the mesh current rotation.
  29300. * x, y, z are Euler angles expressed in radians.
  29301. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29302. * This means this rotation is made in the mesh local space only.
  29303. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29304. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29305. * ```javascript
  29306. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29307. * ```
  29308. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29309. * 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.
  29310. * @param x Rotation to add
  29311. * @param y Rotation to add
  29312. * @param z Rotation to add
  29313. * @returns the TransformNode.
  29314. */
  29315. addRotation(x: number, y: number, z: number): TransformNode;
  29316. /**
  29317. * Computes the world matrix of the node
  29318. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29319. * @returns the world matrix
  29320. */
  29321. computeWorldMatrix(force?: boolean): Matrix;
  29322. protected _afterComputeWorldMatrix(): void;
  29323. /**
  29324. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29325. * @param func callback function to add
  29326. *
  29327. * @returns the TransformNode.
  29328. */
  29329. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29330. /**
  29331. * Removes a registered callback function.
  29332. * @param func callback function to remove
  29333. * @returns the TransformNode.
  29334. */
  29335. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29336. /**
  29337. * Clone the current transform node
  29338. * @param name Name of the new clone
  29339. * @param newParent New parent for the clone
  29340. * @param doNotCloneChildren Do not clone children hierarchy
  29341. * @returns the new transform node
  29342. */
  29343. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29344. /**
  29345. * Serializes the objects information.
  29346. * @param currentSerializationObject defines the object to serialize in
  29347. * @returns the serialized object
  29348. */
  29349. serialize(currentSerializationObject?: any): any;
  29350. /**
  29351. * Returns a new TransformNode object parsed from the source provided.
  29352. * @param parsedTransformNode is the source.
  29353. * @param scene the scne the object belongs to
  29354. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29355. * @returns a new TransformNode object parsed from the source provided.
  29356. */
  29357. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29358. /**
  29359. * Releases resources associated with this transform node.
  29360. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29361. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29362. */
  29363. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29364. }
  29365. }
  29366. declare module BABYLON {
  29367. /**
  29368. * Specialized buffer used to store vertex data
  29369. */
  29370. class VertexBuffer {
  29371. /** @hidden */
  29372. _buffer: Buffer;
  29373. private _kind;
  29374. private _size;
  29375. private _ownsBuffer;
  29376. private _instanced;
  29377. private _instanceDivisor;
  29378. /**
  29379. * The byte type.
  29380. */
  29381. static readonly BYTE: number;
  29382. /**
  29383. * The unsigned byte type.
  29384. */
  29385. static readonly UNSIGNED_BYTE: number;
  29386. /**
  29387. * The short type.
  29388. */
  29389. static readonly SHORT: number;
  29390. /**
  29391. * The unsigned short type.
  29392. */
  29393. static readonly UNSIGNED_SHORT: number;
  29394. /**
  29395. * The integer type.
  29396. */
  29397. static readonly INT: number;
  29398. /**
  29399. * The unsigned integer type.
  29400. */
  29401. static readonly UNSIGNED_INT: number;
  29402. /**
  29403. * The float type.
  29404. */
  29405. static readonly FLOAT: number;
  29406. /**
  29407. * Gets or sets the instance divisor when in instanced mode
  29408. */
  29409. instanceDivisor: number;
  29410. /**
  29411. * Gets the byte stride.
  29412. */
  29413. readonly byteStride: number;
  29414. /**
  29415. * Gets the byte offset.
  29416. */
  29417. readonly byteOffset: number;
  29418. /**
  29419. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29420. */
  29421. readonly normalized: boolean;
  29422. /**
  29423. * Gets the data type of each component in the array.
  29424. */
  29425. readonly type: number;
  29426. /**
  29427. * Constructor
  29428. * @param engine the engine
  29429. * @param data the data to use for this vertex buffer
  29430. * @param kind the vertex buffer kind
  29431. * @param updatable whether the data is updatable
  29432. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29433. * @param stride the stride (optional)
  29434. * @param instanced whether the buffer is instanced (optional)
  29435. * @param offset the offset of the data (optional)
  29436. * @param size the number of components (optional)
  29437. * @param type the type of the component (optional)
  29438. * @param normalized whether the data contains normalized data (optional)
  29439. * @param useBytes set to true if stride and offset are in bytes (optional)
  29440. */
  29441. 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);
  29442. /** @hidden */
  29443. _rebuild(): void;
  29444. /**
  29445. * Returns the kind of the VertexBuffer (string)
  29446. * @returns a string
  29447. */
  29448. getKind(): string;
  29449. /**
  29450. * Gets a boolean indicating if the VertexBuffer is updatable?
  29451. * @returns true if the buffer is updatable
  29452. */
  29453. isUpdatable(): boolean;
  29454. /**
  29455. * Gets current buffer's data
  29456. * @returns a DataArray or null
  29457. */
  29458. getData(): Nullable<DataArray>;
  29459. /**
  29460. * Gets underlying native buffer
  29461. * @returns underlying native buffer
  29462. */
  29463. getBuffer(): Nullable<WebGLBuffer>;
  29464. /**
  29465. * Gets the stride in float32 units (i.e. byte stride / 4).
  29466. * May not be an integer if the byte stride is not divisible by 4.
  29467. * DEPRECATED. Use byteStride instead.
  29468. * @returns the stride in float32 units
  29469. */
  29470. getStrideSize(): number;
  29471. /**
  29472. * Returns the offset as a multiple of the type byte length.
  29473. * DEPRECATED. Use byteOffset instead.
  29474. * @returns the offset in bytes
  29475. */
  29476. getOffset(): number;
  29477. /**
  29478. * Returns the number of components per vertex attribute (integer)
  29479. * @returns the size in float
  29480. */
  29481. getSize(): number;
  29482. /**
  29483. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29484. * @returns true if this buffer is instanced
  29485. */
  29486. getIsInstanced(): boolean;
  29487. /**
  29488. * Returns the instancing divisor, zero for non-instanced (integer).
  29489. * @returns a number
  29490. */
  29491. getInstanceDivisor(): number;
  29492. /**
  29493. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29494. * @param data defines the data to store
  29495. */
  29496. create(data?: DataArray): void;
  29497. /**
  29498. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29499. * This function will create a new buffer if the current one is not updatable
  29500. * @param data defines the data to store
  29501. */
  29502. update(data: DataArray): void;
  29503. /**
  29504. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29505. * Returns the directly updated WebGLBuffer.
  29506. * @param data the new data
  29507. * @param offset the new offset
  29508. * @param useBytes set to true if the offset is in bytes
  29509. */
  29510. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29511. /**
  29512. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29513. */
  29514. dispose(): void;
  29515. /**
  29516. * Enumerates each value of this vertex buffer as numbers.
  29517. * @param count the number of values to enumerate
  29518. * @param callback the callback function called for each value
  29519. */
  29520. forEach(count: number, callback: (value: number, index: number) => void): void;
  29521. /**
  29522. * Positions
  29523. */
  29524. static readonly PositionKind: string;
  29525. /**
  29526. * Normals
  29527. */
  29528. static readonly NormalKind: string;
  29529. /**
  29530. * Tangents
  29531. */
  29532. static readonly TangentKind: string;
  29533. /**
  29534. * Texture coordinates
  29535. */
  29536. static readonly UVKind: string;
  29537. /**
  29538. * Texture coordinates 2
  29539. */
  29540. static readonly UV2Kind: string;
  29541. /**
  29542. * Texture coordinates 3
  29543. */
  29544. static readonly UV3Kind: string;
  29545. /**
  29546. * Texture coordinates 4
  29547. */
  29548. static readonly UV4Kind: string;
  29549. /**
  29550. * Texture coordinates 5
  29551. */
  29552. static readonly UV5Kind: string;
  29553. /**
  29554. * Texture coordinates 6
  29555. */
  29556. static readonly UV6Kind: string;
  29557. /**
  29558. * Colors
  29559. */
  29560. static readonly ColorKind: string;
  29561. /**
  29562. * Matrix indices (for bones)
  29563. */
  29564. static readonly MatricesIndicesKind: string;
  29565. /**
  29566. * Matrix weights (for bones)
  29567. */
  29568. static readonly MatricesWeightsKind: string;
  29569. /**
  29570. * Additional matrix indices (for bones)
  29571. */
  29572. static readonly MatricesIndicesExtraKind: string;
  29573. /**
  29574. * Additional matrix weights (for bones)
  29575. */
  29576. static readonly MatricesWeightsExtraKind: string;
  29577. /**
  29578. * Deduces the stride given a kind.
  29579. * @param kind The kind string to deduce
  29580. * @returns The deduced stride
  29581. */
  29582. static DeduceStride(kind: string): number;
  29583. /**
  29584. * Gets the byte length of the given type.
  29585. * @param type the type
  29586. * @returns the number of bytes
  29587. */
  29588. static GetTypeByteLength(type: number): number;
  29589. /**
  29590. * Enumerates each value of the given parameters as numbers.
  29591. * @param data the data to enumerate
  29592. * @param byteOffset the byte offset of the data
  29593. * @param byteStride the byte stride of the data
  29594. * @param componentCount the number of components per element
  29595. * @param componentType the type of the component
  29596. * @param count the total number of components
  29597. * @param normalized whether the data is normalized
  29598. * @param callback the callback function called for each value
  29599. */
  29600. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29601. private static _GetFloatValue;
  29602. }
  29603. }
  29604. declare module BABYLON {
  29605. /**
  29606. * Defines a target to use with MorphTargetManager
  29607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29608. */
  29609. class MorphTarget implements IAnimatable {
  29610. /** defines the name of the target */
  29611. name: string;
  29612. /**
  29613. * Gets or sets the list of animations
  29614. */
  29615. animations: Animation[];
  29616. private _scene;
  29617. private _positions;
  29618. private _normals;
  29619. private _tangents;
  29620. private _influence;
  29621. /**
  29622. * Observable raised when the influence changes
  29623. */
  29624. onInfluenceChanged: Observable<boolean>;
  29625. /** @hidden */
  29626. _onDataLayoutChanged: Observable<void>;
  29627. /**
  29628. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29629. */
  29630. influence: number;
  29631. private _animationPropertiesOverride;
  29632. /**
  29633. * Gets or sets the animation properties override
  29634. */
  29635. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29636. /**
  29637. * Creates a new MorphTarget
  29638. * @param name defines the name of the target
  29639. * @param influence defines the influence to use
  29640. */
  29641. constructor(
  29642. /** defines the name of the target */
  29643. name: string, influence?: number, scene?: Nullable<Scene>);
  29644. /**
  29645. * Gets a boolean defining if the target contains position data
  29646. */
  29647. readonly hasPositions: boolean;
  29648. /**
  29649. * Gets a boolean defining if the target contains normal data
  29650. */
  29651. readonly hasNormals: boolean;
  29652. /**
  29653. * Gets a boolean defining if the target contains tangent data
  29654. */
  29655. readonly hasTangents: boolean;
  29656. /**
  29657. * Affects position data to this target
  29658. * @param data defines the position data to use
  29659. */
  29660. setPositions(data: Nullable<FloatArray>): void;
  29661. /**
  29662. * Gets the position data stored in this target
  29663. * @returns a FloatArray containing the position data (or null if not present)
  29664. */
  29665. getPositions(): Nullable<FloatArray>;
  29666. /**
  29667. * Affects normal data to this target
  29668. * @param data defines the normal data to use
  29669. */
  29670. setNormals(data: Nullable<FloatArray>): void;
  29671. /**
  29672. * Gets the normal data stored in this target
  29673. * @returns a FloatArray containing the normal data (or null if not present)
  29674. */
  29675. getNormals(): Nullable<FloatArray>;
  29676. /**
  29677. * Affects tangent data to this target
  29678. * @param data defines the tangent data to use
  29679. */
  29680. setTangents(data: Nullable<FloatArray>): void;
  29681. /**
  29682. * Gets the tangent data stored in this target
  29683. * @returns a FloatArray containing the tangent data (or null if not present)
  29684. */
  29685. getTangents(): Nullable<FloatArray>;
  29686. /**
  29687. * Serializes the current target into a Serialization object
  29688. * @returns the serialized object
  29689. */
  29690. serialize(): any;
  29691. /**
  29692. * Creates a new target from serialized data
  29693. * @param serializationObject defines the serialized data to use
  29694. * @returns a new MorphTarget
  29695. */
  29696. static Parse(serializationObject: any): MorphTarget;
  29697. /**
  29698. * Creates a MorphTarget from mesh data
  29699. * @param mesh defines the source mesh
  29700. * @param name defines the name to use for the new target
  29701. * @param influence defines the influence to attach to the target
  29702. * @returns a new MorphTarget
  29703. */
  29704. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29705. }
  29706. }
  29707. declare module BABYLON {
  29708. /**
  29709. * This class is used to deform meshes using morphing between different targets
  29710. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29711. */
  29712. class MorphTargetManager {
  29713. private _targets;
  29714. private _targetInfluenceChangedObservers;
  29715. private _targetDataLayoutChangedObservers;
  29716. private _activeTargets;
  29717. private _scene;
  29718. private _influences;
  29719. private _supportsNormals;
  29720. private _supportsTangents;
  29721. private _vertexCount;
  29722. private _uniqueId;
  29723. private _tempInfluences;
  29724. /**
  29725. * Creates a new MorphTargetManager
  29726. * @param scene defines the current scene
  29727. */
  29728. constructor(scene?: Nullable<Scene>);
  29729. /**
  29730. * Gets the unique ID of this manager
  29731. */
  29732. readonly uniqueId: number;
  29733. /**
  29734. * Gets the number of vertices handled by this manager
  29735. */
  29736. readonly vertexCount: number;
  29737. /**
  29738. * Gets a boolean indicating if this manager supports morphing of normals
  29739. */
  29740. readonly supportsNormals: boolean;
  29741. /**
  29742. * Gets a boolean indicating if this manager supports morphing of tangents
  29743. */
  29744. readonly supportsTangents: boolean;
  29745. /**
  29746. * Gets the number of targets stored in this manager
  29747. */
  29748. readonly numTargets: number;
  29749. /**
  29750. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29751. */
  29752. readonly numInfluencers: number;
  29753. /**
  29754. * Gets the list of influences (one per target)
  29755. */
  29756. readonly influences: Float32Array;
  29757. /**
  29758. * Gets the active target at specified index. An active target is a target with an influence > 0
  29759. * @param index defines the index to check
  29760. * @returns the requested target
  29761. */
  29762. getActiveTarget(index: number): MorphTarget;
  29763. /**
  29764. * Gets the target at specified index
  29765. * @param index defines the index to check
  29766. * @returns the requested target
  29767. */
  29768. getTarget(index: number): MorphTarget;
  29769. /**
  29770. * Add a new target to this manager
  29771. * @param target defines the target to add
  29772. */
  29773. addTarget(target: MorphTarget): void;
  29774. /**
  29775. * Removes a target from the manager
  29776. * @param target defines the target to remove
  29777. */
  29778. removeTarget(target: MorphTarget): void;
  29779. /**
  29780. * Serializes the current manager into a Serialization object
  29781. * @returns the serialized object
  29782. */
  29783. serialize(): any;
  29784. private _syncActiveTargets;
  29785. /**
  29786. * Syncrhonize the targets with all the meshes using this morph target manager
  29787. */
  29788. synchronize(): void;
  29789. /**
  29790. * Creates a new MorphTargetManager from serialized data
  29791. * @param serializationObject defines the serialized data
  29792. * @param scene defines the hosting scene
  29793. * @returns the new MorphTargetManager
  29794. */
  29795. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29796. }
  29797. }
  29798. declare module BABYLON {
  29799. /**
  29800. * Class used to enable access to IndexedDB
  29801. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29802. */
  29803. class Database implements IOfflineProvider {
  29804. private _callbackManifestChecked;
  29805. private _currentSceneUrl;
  29806. private _db;
  29807. private _enableSceneOffline;
  29808. private _enableTexturesOffline;
  29809. private _manifestVersionFound;
  29810. private _mustUpdateRessources;
  29811. private _hasReachedQuota;
  29812. private _isSupported;
  29813. private _idbFactory;
  29814. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29815. private static IsUASupportingBlobStorage;
  29816. /**
  29817. * Gets a boolean indicating if Database storate is enabled (off by default)
  29818. */
  29819. static IDBStorageEnabled: boolean;
  29820. /**
  29821. * Gets a boolean indicating if scene must be saved in the database
  29822. */
  29823. readonly enableSceneOffline: boolean;
  29824. /**
  29825. * Gets a boolean indicating if textures must be saved in the database
  29826. */
  29827. readonly enableTexturesOffline: boolean;
  29828. /**
  29829. * Creates a new Database
  29830. * @param urlToScene defines the url to load the scene
  29831. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29832. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29833. */
  29834. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29835. private static _ParseURL;
  29836. private static _ReturnFullUrlLocation;
  29837. private _checkManifestFile;
  29838. /**
  29839. * Open the database and make it available
  29840. * @param successCallback defines the callback to call on success
  29841. * @param errorCallback defines the callback to call on error
  29842. */
  29843. open(successCallback: () => void, errorCallback: () => void): void;
  29844. /**
  29845. * Loads an image from the database
  29846. * @param url defines the url to load from
  29847. * @param image defines the target DOM image
  29848. */
  29849. loadImage(url: string, image: HTMLImageElement): void;
  29850. private _loadImageFromDBAsync;
  29851. private _saveImageIntoDBAsync;
  29852. private _checkVersionFromDB;
  29853. private _loadVersionFromDBAsync;
  29854. private _saveVersionIntoDBAsync;
  29855. /**
  29856. * Loads a file from database
  29857. * @param url defines the URL to load from
  29858. * @param sceneLoaded defines a callback to call on success
  29859. * @param progressCallBack defines a callback to call when progress changed
  29860. * @param errorCallback defines a callback to call on error
  29861. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29862. */
  29863. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29864. private _loadFileAsync;
  29865. private _saveFileAsync;
  29866. }
  29867. }
  29868. declare module BABYLON {
  29869. /**
  29870. * Class used to enable access to offline support
  29871. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29872. */
  29873. interface IOfflineProvider {
  29874. /**
  29875. * Gets a boolean indicating if scene must be saved in the database
  29876. */
  29877. enableSceneOffline: boolean;
  29878. /**
  29879. * Gets a boolean indicating if textures must be saved in the database
  29880. */
  29881. enableTexturesOffline: boolean;
  29882. /**
  29883. * Open the offline support and make it available
  29884. * @param successCallback defines the callback to call on success
  29885. * @param errorCallback defines the callback to call on error
  29886. */
  29887. open(successCallback: () => void, errorCallback: () => void): void;
  29888. /**
  29889. * Loads an image from the offline support
  29890. * @param url defines the url to load from
  29891. * @param image defines the target DOM image
  29892. */
  29893. loadImage(url: string, image: HTMLImageElement): void;
  29894. /**
  29895. * Loads a file from offline support
  29896. * @param url defines the URL to load from
  29897. * @param sceneLoaded defines a callback to call on success
  29898. * @param progressCallBack defines a callback to call when progress changed
  29899. * @param errorCallback defines a callback to call on error
  29900. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29901. */
  29902. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29903. }
  29904. }
  29905. declare module BABYLON {
  29906. /**
  29907. * Interface used to describe a physics joint
  29908. */
  29909. interface PhysicsImpostorJoint {
  29910. /** Defines the main impostor to which the joint is linked */
  29911. mainImpostor: PhysicsImpostor;
  29912. /** Defines the impostor that is connected to the main impostor using this joint */
  29913. connectedImpostor: PhysicsImpostor;
  29914. /** Defines the joint itself */
  29915. joint: PhysicsJoint;
  29916. }
  29917. /** @hidden */
  29918. interface IPhysicsEnginePlugin {
  29919. world: any;
  29920. name: string;
  29921. setGravity(gravity: Vector3): void;
  29922. setTimeStep(timeStep: number): void;
  29923. getTimeStep(): number;
  29924. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29925. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29926. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29927. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29928. removePhysicsBody(impostor: PhysicsImpostor): void;
  29929. generateJoint(joint: PhysicsImpostorJoint): void;
  29930. removeJoint(joint: PhysicsImpostorJoint): void;
  29931. isSupported(): boolean;
  29932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29934. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29936. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29937. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29938. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29939. getBodyMass(impostor: PhysicsImpostor): number;
  29940. getBodyFriction(impostor: PhysicsImpostor): number;
  29941. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29942. getBodyRestitution(impostor: PhysicsImpostor): number;
  29943. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29944. sleepBody(impostor: PhysicsImpostor): void;
  29945. wakeUpBody(impostor: PhysicsImpostor): void;
  29946. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29947. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  29948. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  29949. getRadius(impostor: PhysicsImpostor): number;
  29950. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29952. dispose(): void;
  29953. }
  29954. /**
  29955. * Interface used to define a physics engine
  29956. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29957. */
  29958. interface IPhysicsEngine {
  29959. /**
  29960. * Gets the gravity vector used by the simulation
  29961. */
  29962. gravity: Vector3;
  29963. /**
  29964. * Sets the gravity vector used by the simulation
  29965. * @param gravity defines the gravity vector to use
  29966. */
  29967. setGravity(gravity: Vector3): void;
  29968. /**
  29969. * Set the time step of the physics engine.
  29970. * Default is 1/60.
  29971. * To slow it down, enter 1/600 for example.
  29972. * To speed it up, 1/30
  29973. * @param newTimeStep the new timestep to apply to this world.
  29974. */
  29975. setTimeStep(newTimeStep: number): void;
  29976. /**
  29977. * Get the time step of the physics engine.
  29978. * @returns the current time step
  29979. */
  29980. getTimeStep(): number;
  29981. /**
  29982. * Release all resources
  29983. */
  29984. dispose(): void;
  29985. /**
  29986. * Gets the name of the current physics plugin
  29987. * @returns the name of the plugin
  29988. */
  29989. getPhysicsPluginName(): string;
  29990. /**
  29991. * Adding a new impostor for the impostor tracking.
  29992. * This will be done by the impostor itself.
  29993. * @param impostor the impostor to add
  29994. */
  29995. addImpostor(impostor: PhysicsImpostor): void;
  29996. /**
  29997. * Remove an impostor from the engine.
  29998. * This impostor and its mesh will not longer be updated by the physics engine.
  29999. * @param impostor the impostor to remove
  30000. */
  30001. removeImpostor(impostor: PhysicsImpostor): void;
  30002. /**
  30003. * Add a joint to the physics engine
  30004. * @param mainImpostor defines the main impostor to which the joint is added.
  30005. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30006. * @param joint defines the joint that will connect both impostors.
  30007. */
  30008. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30009. /**
  30010. * Removes a joint from the simulation
  30011. * @param mainImpostor defines the impostor used with the joint
  30012. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30013. * @param joint defines the joint to remove
  30014. */
  30015. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30016. /**
  30017. * Gets the current plugin used to run the simulation
  30018. * @returns current plugin
  30019. */
  30020. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30021. /**
  30022. * Gets the list of physic impostors
  30023. * @returns an array of PhysicsImpostor
  30024. */
  30025. getImpostors(): Array<PhysicsImpostor>;
  30026. /**
  30027. * Gets the impostor for a physics enabled object
  30028. * @param object defines the object impersonated by the impostor
  30029. * @returns the PhysicsImpostor or null if not found
  30030. */
  30031. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30032. /**
  30033. * Gets the impostor for a physics body object
  30034. * @param body defines physics body used by the impostor
  30035. * @returns the PhysicsImpostor or null if not found
  30036. */
  30037. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30038. /**
  30039. * Called by the scene. No need to call it.
  30040. * @param delta defines the timespam between frames
  30041. */
  30042. _step(delta: number): void;
  30043. }
  30044. }
  30045. declare module BABYLON {
  30046. /**
  30047. * Class used to control physics engine
  30048. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30049. */
  30050. class PhysicsEngine implements IPhysicsEngine {
  30051. private _physicsPlugin;
  30052. /**
  30053. * Global value used to control the smallest number supported by the simulation
  30054. */
  30055. static Epsilon: number;
  30056. private _impostors;
  30057. private _joints;
  30058. /**
  30059. * Gets the gravity vector used by the simulation
  30060. */
  30061. gravity: Vector3;
  30062. /**
  30063. * Creates a new Physics Engine
  30064. * @param gravity defines the gravity vector used by the simulation
  30065. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  30066. */
  30067. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  30068. /**
  30069. * Sets the gravity vector used by the simulation
  30070. * @param gravity defines the gravity vector to use
  30071. */
  30072. setGravity(gravity: Vector3): void;
  30073. /**
  30074. * Set the time step of the physics engine.
  30075. * Default is 1/60.
  30076. * To slow it down, enter 1/600 for example.
  30077. * To speed it up, 1/30
  30078. * @param newTimeStep defines the new timestep to apply to this world.
  30079. */
  30080. setTimeStep(newTimeStep?: number): void;
  30081. /**
  30082. * Get the time step of the physics engine.
  30083. * @returns the current time step
  30084. */
  30085. getTimeStep(): number;
  30086. /**
  30087. * Release all resources
  30088. */
  30089. dispose(): void;
  30090. /**
  30091. * Gets the name of the current physics plugin
  30092. * @returns the name of the plugin
  30093. */
  30094. getPhysicsPluginName(): string;
  30095. /**
  30096. * Adding a new impostor for the impostor tracking.
  30097. * This will be done by the impostor itself.
  30098. * @param impostor the impostor to add
  30099. */
  30100. addImpostor(impostor: PhysicsImpostor): void;
  30101. /**
  30102. * Remove an impostor from the engine.
  30103. * This impostor and its mesh will not longer be updated by the physics engine.
  30104. * @param impostor the impostor to remove
  30105. */
  30106. removeImpostor(impostor: PhysicsImpostor): void;
  30107. /**
  30108. * Add a joint to the physics engine
  30109. * @param mainImpostor defines the main impostor to which the joint is added.
  30110. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30111. * @param joint defines the joint that will connect both impostors.
  30112. */
  30113. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30114. /**
  30115. * Removes a joint from the simulation
  30116. * @param mainImpostor defines the impostor used with the joint
  30117. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30118. * @param joint defines the joint to remove
  30119. */
  30120. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30121. /**
  30122. * Called by the scene. No need to call it.
  30123. * @param delta defines the timespam between frames
  30124. */
  30125. _step(delta: number): void;
  30126. /**
  30127. * Gets the current plugin used to run the simulation
  30128. * @returns current plugin
  30129. */
  30130. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30131. /**
  30132. * Gets the list of physic impostors
  30133. * @returns an array of PhysicsImpostor
  30134. */
  30135. getImpostors(): Array<PhysicsImpostor>;
  30136. /**
  30137. * Gets the impostor for a physics enabled object
  30138. * @param object defines the object impersonated by the impostor
  30139. * @returns the PhysicsImpostor or null if not found
  30140. */
  30141. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30142. /**
  30143. * Gets the impostor for a physics body object
  30144. * @param body defines physics body used by the impostor
  30145. * @returns the PhysicsImpostor or null if not found
  30146. */
  30147. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30148. }
  30149. }
  30150. declare module BABYLON {
  30151. interface Scene {
  30152. /** @hidden (Backing field) */
  30153. _physicsEngine: Nullable<IPhysicsEngine>;
  30154. /**
  30155. * Gets the current physics engine
  30156. * @returns a IPhysicsEngine or null if none attached
  30157. */
  30158. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30159. /**
  30160. * Enables physics to the current scene
  30161. * @param gravity defines the scene's gravity for the physics engine
  30162. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30163. * @return a boolean indicating if the physics engine was initialized
  30164. */
  30165. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30166. /**
  30167. * Disables and disposes the physics engine associated with the scene
  30168. */
  30169. disablePhysicsEngine(): void;
  30170. /**
  30171. * Gets a boolean indicating if there is an active physics engine
  30172. * @returns a boolean indicating if there is an active physics engine
  30173. */
  30174. isPhysicsEnabled(): boolean;
  30175. /**
  30176. * Deletes a physics compound impostor
  30177. * @param compound defines the compound to delete
  30178. */
  30179. deleteCompoundImpostor(compound: any): void;
  30180. /**
  30181. * An event triggered when physic simulation is about to be run
  30182. */
  30183. onBeforePhysicsObservable: Observable<Scene>;
  30184. /**
  30185. * An event triggered when physic simulation has been done
  30186. */
  30187. onAfterPhysicsObservable: Observable<Scene>;
  30188. }
  30189. interface AbstractMesh {
  30190. /** @hidden */
  30191. _physicsImpostor: Nullable<PhysicsImpostor>;
  30192. /**
  30193. * Gets or sets impostor used for physic simulation
  30194. * @see http://doc.babylonjs.com/features/physics_engine
  30195. */
  30196. physicsImpostor: Nullable<PhysicsImpostor>;
  30197. /**
  30198. * Gets the current physics impostor
  30199. * @see http://doc.babylonjs.com/features/physics_engine
  30200. * @returns a physics impostor or null
  30201. */
  30202. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30203. /** Apply a physic impulse to the mesh
  30204. * @param force defines the force to apply
  30205. * @param contactPoint defines where to apply the force
  30206. * @returns the current mesh
  30207. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30208. */
  30209. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30210. /**
  30211. * Creates a physic joint between two meshes
  30212. * @param otherMesh defines the other mesh to use
  30213. * @param pivot1 defines the pivot to use on this mesh
  30214. * @param pivot2 defines the pivot to use on the other mesh
  30215. * @param options defines additional options (can be plugin dependent)
  30216. * @returns the current mesh
  30217. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30218. */
  30219. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30220. /** @hidden */
  30221. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30222. }
  30223. /**
  30224. * Defines the physics engine scene component responsible to manage a physics engine
  30225. */
  30226. class PhysicsEngineSceneComponent implements ISceneComponent {
  30227. /**
  30228. * The component name helpful to identify the component in the list of scene components.
  30229. */
  30230. readonly name: string;
  30231. /**
  30232. * The scene the component belongs to.
  30233. */
  30234. scene: Scene;
  30235. /**
  30236. * Creates a new instance of the component for the given scene
  30237. * @param scene Defines the scene to register the component in
  30238. */
  30239. constructor(scene: Scene);
  30240. /**
  30241. * Registers the component in a given scene
  30242. */
  30243. register(): void;
  30244. /**
  30245. * Rebuilds the elements related to this component in case of
  30246. * context lost for instance.
  30247. */
  30248. rebuild(): void;
  30249. /**
  30250. * Disposes the component and the associated ressources
  30251. */
  30252. dispose(): void;
  30253. }
  30254. }
  30255. declare module BABYLON {
  30256. /**
  30257. * A helper for physics simulations
  30258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30259. */
  30260. class PhysicsHelper {
  30261. private _scene;
  30262. private _physicsEngine;
  30263. /**
  30264. * Initializes the Physics helper
  30265. * @param scene Babylon.js scene
  30266. */
  30267. constructor(scene: Scene);
  30268. /**
  30269. * Applies a radial explosion impulse
  30270. * @param origin the origin of the explosion
  30271. * @param radius the explosion radius
  30272. * @param strength the explosion strength
  30273. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30274. * @returns A physics radial explosion event, or null
  30275. */
  30276. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30277. /**
  30278. * Applies a radial explosion force
  30279. * @param origin the origin of the explosion
  30280. * @param radius the explosion radius
  30281. * @param strength the explosion strength
  30282. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30283. * @returns A physics radial explosion event, or null
  30284. */
  30285. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30286. /**
  30287. * Creates a gravitational field
  30288. * @param origin the origin of the explosion
  30289. * @param radius the explosion radius
  30290. * @param strength the explosion strength
  30291. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30292. * @returns A physics gravitational field event, or null
  30293. */
  30294. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30295. /**
  30296. * Creates a physics updraft event
  30297. * @param origin the origin of the updraft
  30298. * @param radius the radius of the updraft
  30299. * @param strength the strength of the updraft
  30300. * @param height the height of the updraft
  30301. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30302. * @returns A physics updraft event, or null
  30303. */
  30304. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30305. /**
  30306. * Creates a physics vortex event
  30307. * @param origin the of the vortex
  30308. * @param radius the radius of the vortex
  30309. * @param strength the strength of the vortex
  30310. * @param height the height of the vortex
  30311. * @returns a Physics vortex event, or null
  30312. * A physics vortex event or null
  30313. */
  30314. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30315. }
  30316. /**
  30317. * Represents a physics radial explosion event
  30318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30319. */
  30320. class PhysicsRadialExplosionEvent {
  30321. private _scene;
  30322. private _sphere;
  30323. private _sphereOptions;
  30324. private _rays;
  30325. private _dataFetched;
  30326. /**
  30327. * Initializes a radial explosioin event
  30328. * @param scene BabylonJS scene
  30329. */
  30330. constructor(scene: Scene);
  30331. /**
  30332. * Returns the data related to the radial explosion event (sphere & rays).
  30333. * @returns The radial explosion event data
  30334. */
  30335. getData(): PhysicsRadialExplosionEventData;
  30336. /**
  30337. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30338. * @param impostor A physics imposter
  30339. * @param origin the origin of the explosion
  30340. * @param radius the explosion radius
  30341. * @param strength the explosion strength
  30342. * @param falloff possible options: Constant & Linear
  30343. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30344. */
  30345. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30346. /**
  30347. * Disposes the sphere.
  30348. * @param force Specifies if the sphere should be disposed by force
  30349. */
  30350. dispose(force?: boolean): void;
  30351. /*** Helpers ***/
  30352. private _prepareSphere;
  30353. private _intersectsWithSphere;
  30354. }
  30355. /**
  30356. * Represents a gravitational field event
  30357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30358. */
  30359. class PhysicsGravitationalFieldEvent {
  30360. private _physicsHelper;
  30361. private _scene;
  30362. private _origin;
  30363. private _radius;
  30364. private _strength;
  30365. private _falloff;
  30366. private _tickCallback;
  30367. private _sphere;
  30368. private _dataFetched;
  30369. /**
  30370. * Initializes the physics gravitational field event
  30371. * @param physicsHelper A physics helper
  30372. * @param scene BabylonJS scene
  30373. * @param origin The origin position of the gravitational field event
  30374. * @param radius The radius of the gravitational field event
  30375. * @param strength The strength of the gravitational field event
  30376. * @param falloff The falloff for the gravitational field event
  30377. */
  30378. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30379. /**
  30380. * Returns the data related to the gravitational field event (sphere).
  30381. * @returns A gravitational field event
  30382. */
  30383. getData(): PhysicsGravitationalFieldEventData;
  30384. /**
  30385. * Enables the gravitational field.
  30386. */
  30387. enable(): void;
  30388. /**
  30389. * Disables the gravitational field.
  30390. */
  30391. disable(): void;
  30392. /**
  30393. * Disposes the sphere.
  30394. * @param force The force to dispose from the gravitational field event
  30395. */
  30396. dispose(force?: boolean): void;
  30397. private _tick;
  30398. }
  30399. /**
  30400. * Represents a physics updraft event
  30401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30402. */
  30403. class PhysicsUpdraftEvent {
  30404. private _scene;
  30405. private _origin;
  30406. private _radius;
  30407. private _strength;
  30408. private _height;
  30409. private _updraftMode;
  30410. private _physicsEngine;
  30411. private _originTop;
  30412. private _originDirection;
  30413. private _tickCallback;
  30414. private _cylinder;
  30415. private _cylinderPosition;
  30416. private _dataFetched;
  30417. /**
  30418. * Initializes the physics updraft event
  30419. * @param _scene BabylonJS scene
  30420. * @param _origin The origin position of the updraft
  30421. * @param _radius The radius of the updraft
  30422. * @param _strength The strength of the updraft
  30423. * @param _height The height of the updraft
  30424. * @param _updraftMode The mode of the updraft
  30425. */
  30426. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30427. /**
  30428. * Returns the data related to the updraft event (cylinder).
  30429. * @returns A physics updraft event
  30430. */
  30431. getData(): PhysicsUpdraftEventData;
  30432. /**
  30433. * Enables the updraft.
  30434. */
  30435. enable(): void;
  30436. /**
  30437. * Disables the cortex.
  30438. */
  30439. disable(): void;
  30440. /**
  30441. * Disposes the sphere.
  30442. * @param force Specifies if the updraft should be disposed by force
  30443. */
  30444. dispose(force?: boolean): void;
  30445. private getImpostorForceAndContactPoint;
  30446. private _tick;
  30447. /*** Helpers ***/
  30448. private _prepareCylinder;
  30449. private _intersectsWithCylinder;
  30450. }
  30451. /**
  30452. * Represents a physics vortex event
  30453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30454. */
  30455. class PhysicsVortexEvent {
  30456. private _scene;
  30457. private _origin;
  30458. private _radius;
  30459. private _strength;
  30460. private _height;
  30461. private _physicsEngine;
  30462. private _originTop;
  30463. private _centripetalForceThreshold;
  30464. private _updraftMultiplier;
  30465. private _tickCallback;
  30466. private _cylinder;
  30467. private _cylinderPosition;
  30468. private _dataFetched;
  30469. /**
  30470. * Initializes the physics vortex event
  30471. * @param _scene The BabylonJS scene
  30472. * @param _origin The origin position of the vortex
  30473. * @param _radius The radius of the vortex
  30474. * @param _strength The strength of the vortex
  30475. * @param _height The height of the vortex
  30476. */
  30477. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30478. /**
  30479. * Returns the data related to the vortex event (cylinder).
  30480. * @returns The physics vortex event data
  30481. */
  30482. getData(): PhysicsVortexEventData;
  30483. /**
  30484. * Enables the vortex.
  30485. */
  30486. enable(): void;
  30487. /**
  30488. * Disables the cortex.
  30489. */
  30490. disable(): void;
  30491. /**
  30492. * Disposes the sphere.
  30493. * @param force
  30494. */
  30495. dispose(force?: boolean): void;
  30496. private getImpostorForceAndContactPoint;
  30497. private _tick;
  30498. /*** Helpers ***/
  30499. private _prepareCylinder;
  30500. private _intersectsWithCylinder;
  30501. }
  30502. /**
  30503. * The strenght of the force in correspondence to the distance of the affected object
  30504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30505. */
  30506. enum PhysicsRadialImpulseFalloff {
  30507. /** Defines that impulse is constant in strength across it's whole radius */
  30508. Constant = 0,
  30509. /** DEfines that impulse gets weaker if it's further from the origin */
  30510. Linear = 1
  30511. }
  30512. /**
  30513. * The strength of the force in correspondence to the distance of the affected object
  30514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30515. */
  30516. enum PhysicsUpdraftMode {
  30517. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30518. Center = 0,
  30519. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30520. Perpendicular = 1
  30521. }
  30522. /**
  30523. * Interface for a physics force and contact point
  30524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30525. */
  30526. interface PhysicsForceAndContactPoint {
  30527. /**
  30528. * The force applied at the contact point
  30529. */
  30530. force: Vector3;
  30531. /**
  30532. * The contact point
  30533. */
  30534. contactPoint: Vector3;
  30535. }
  30536. /**
  30537. * Interface for radial explosion event data
  30538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30539. */
  30540. interface PhysicsRadialExplosionEventData {
  30541. /**
  30542. * A sphere used for the radial explosion event
  30543. */
  30544. sphere: Mesh;
  30545. /**
  30546. * An array of rays for the radial explosion event
  30547. */
  30548. rays: Array<Ray>;
  30549. }
  30550. /**
  30551. * Interface for gravitational field event data
  30552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30553. */
  30554. interface PhysicsGravitationalFieldEventData {
  30555. /**
  30556. * A sphere mesh used for the gravitational field event
  30557. */
  30558. sphere: Mesh;
  30559. }
  30560. /**
  30561. * Interface for updraft event data
  30562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30563. */
  30564. interface PhysicsUpdraftEventData {
  30565. /**
  30566. * A cylinder used for the updraft event
  30567. */
  30568. cylinder: Mesh;
  30569. }
  30570. /**
  30571. * Interface for vortex event data
  30572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30573. */
  30574. interface PhysicsVortexEventData {
  30575. /**
  30576. * A cylinder used for the vortex event
  30577. */
  30578. cylinder: Mesh;
  30579. }
  30580. }
  30581. declare module BABYLON {
  30582. /**
  30583. * The interface for the physics imposter parameters
  30584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30585. */
  30586. interface PhysicsImpostorParameters {
  30587. /**
  30588. * The mass of the physics imposter
  30589. */
  30590. mass: number;
  30591. /**
  30592. * The friction of the physics imposter
  30593. */
  30594. friction?: number;
  30595. /**
  30596. * The coefficient of restitution of the physics imposter
  30597. */
  30598. restitution?: number;
  30599. /**
  30600. * The native options of the physics imposter
  30601. */
  30602. nativeOptions?: any;
  30603. /**
  30604. * Specifies if the parent should be ignored
  30605. */
  30606. ignoreParent?: boolean;
  30607. /**
  30608. * Specifies if bi-directional transformations should be disabled
  30609. */
  30610. disableBidirectionalTransformation?: boolean;
  30611. }
  30612. /**
  30613. * Interface for a physics-enabled object
  30614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30615. */
  30616. interface IPhysicsEnabledObject {
  30617. /**
  30618. * The position of the physics-enabled object
  30619. */
  30620. position: Vector3;
  30621. /**
  30622. * The rotation of the physics-enabled object
  30623. */
  30624. rotationQuaternion: Nullable<Quaternion>;
  30625. /**
  30626. * The scale of the physics-enabled object
  30627. */
  30628. scaling: Vector3;
  30629. /**
  30630. * The rotation of the physics-enabled object
  30631. */
  30632. rotation?: Vector3;
  30633. /**
  30634. * The parent of the physics-enabled object
  30635. */
  30636. parent?: any;
  30637. /**
  30638. * The bounding info of the physics-enabled object
  30639. * @returns The bounding info of the physics-enabled object
  30640. */
  30641. getBoundingInfo(): BoundingInfo;
  30642. /**
  30643. * Computes the world matrix
  30644. * @param force Specifies if the world matrix should be computed by force
  30645. * @returns A world matrix
  30646. */
  30647. computeWorldMatrix(force: boolean): Matrix;
  30648. /**
  30649. * Gets the world matrix
  30650. * @returns A world matrix
  30651. */
  30652. getWorldMatrix?(): Matrix;
  30653. /**
  30654. * Gets the child meshes
  30655. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  30656. * @returns An array of abstract meshes
  30657. */
  30658. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  30659. /**
  30660. * Gets the vertex data
  30661. * @param kind The type of vertex data
  30662. * @returns A nullable array of numbers, or a float32 array
  30663. */
  30664. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  30665. /**
  30666. * Gets the indices from the mesh
  30667. * @returns A nullable array of index arrays
  30668. */
  30669. getIndices?(): Nullable<IndicesArray>;
  30670. /**
  30671. * Gets the scene from the mesh
  30672. * @returns the indices array or null
  30673. */
  30674. getScene?(): Scene;
  30675. /**
  30676. * Gets the absolute position from the mesh
  30677. * @returns the absolute position
  30678. */
  30679. getAbsolutePosition(): Vector3;
  30680. /**
  30681. * Gets the absolute pivot point from the mesh
  30682. * @returns the absolute pivot point
  30683. */
  30684. getAbsolutePivotPoint(): Vector3;
  30685. /**
  30686. * Rotates the mesh
  30687. * @param axis The axis of rotation
  30688. * @param amount The amount of rotation
  30689. * @param space The space of the rotation
  30690. * @returns The rotation transform node
  30691. */
  30692. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  30693. /**
  30694. * Translates the mesh
  30695. * @param axis The axis of translation
  30696. * @param distance The distance of translation
  30697. * @param space The space of the translation
  30698. * @returns The transform node
  30699. */
  30700. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  30701. /**
  30702. * Sets the absolute position of the mesh
  30703. * @param absolutePosition The absolute position of the mesh
  30704. * @returns The transform node
  30705. */
  30706. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  30707. /**
  30708. * Gets the class name of the mesh
  30709. * @returns The class name
  30710. */
  30711. getClassName(): string;
  30712. }
  30713. /**
  30714. * Represents a physics imposter
  30715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30716. */
  30717. class PhysicsImpostor {
  30718. /**
  30719. * The physics-enabled object used as the physics imposter
  30720. */
  30721. object: IPhysicsEnabledObject;
  30722. /**
  30723. * The type of the physics imposter
  30724. */
  30725. type: number;
  30726. private _options;
  30727. private _scene?;
  30728. /**
  30729. * The default object size of the imposter
  30730. */
  30731. static DEFAULT_OBJECT_SIZE: Vector3;
  30732. /**
  30733. * The identity quaternion of the imposter
  30734. */
  30735. static IDENTITY_QUATERNION: Quaternion;
  30736. private _physicsEngine;
  30737. private _physicsBody;
  30738. private _bodyUpdateRequired;
  30739. private _onBeforePhysicsStepCallbacks;
  30740. private _onAfterPhysicsStepCallbacks;
  30741. private _onPhysicsCollideCallbacks;
  30742. private _deltaPosition;
  30743. private _deltaRotation;
  30744. private _deltaRotationConjugated;
  30745. private _parent;
  30746. private _isDisposed;
  30747. private static _tmpVecs;
  30748. private static _tmpQuat;
  30749. /**
  30750. * Specifies if the physics imposter is disposed
  30751. */
  30752. readonly isDisposed: boolean;
  30753. /**
  30754. * Gets the mass of the physics imposter
  30755. */
  30756. mass: number;
  30757. /**
  30758. * Gets the coefficient of friction
  30759. */
  30760. /**
  30761. * Sets the coefficient of friction
  30762. */
  30763. friction: number;
  30764. /**
  30765. * Gets the coefficient of restitution
  30766. */
  30767. /**
  30768. * Sets the coefficient of restitution
  30769. */
  30770. restitution: number;
  30771. /**
  30772. * The unique id of the physics imposter
  30773. * set by the physics engine when adding this impostor to the array
  30774. */
  30775. uniqueId: number;
  30776. private _joints;
  30777. /**
  30778. * Initializes the physics imposter
  30779. * @param object The physics-enabled object used as the physics imposter
  30780. * @param type The type of the physics imposter
  30781. * @param _options The options for the physics imposter
  30782. * @param _scene The Babylon scene
  30783. */
  30784. constructor(
  30785. /**
  30786. * The physics-enabled object used as the physics imposter
  30787. */
  30788. object: IPhysicsEnabledObject,
  30789. /**
  30790. * The type of the physics imposter
  30791. */
  30792. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  30793. /**
  30794. * This function will completly initialize this impostor.
  30795. * It will create a new body - but only if this mesh has no parent.
  30796. * If it has, this impostor will not be used other than to define the impostor
  30797. * of the child mesh.
  30798. * @hidden
  30799. */
  30800. _init(): void;
  30801. private _getPhysicsParent;
  30802. /**
  30803. * Should a new body be generated.
  30804. * @returns boolean specifying if body initialization is required
  30805. */
  30806. isBodyInitRequired(): boolean;
  30807. /**
  30808. * Sets the updated scaling
  30809. * @param updated Specifies if the scaling is updated
  30810. */
  30811. setScalingUpdated(updated: boolean): void;
  30812. /**
  30813. * Force a regeneration of this or the parent's impostor's body.
  30814. * Use under cautious - This will remove all joints already implemented.
  30815. */
  30816. forceUpdate(): void;
  30817. /**
  30818. * Gets the body that holds this impostor. Either its own, or its parent.
  30819. */
  30820. /**
  30821. * Set the physics body. Used mainly by the physics engine/plugin
  30822. */
  30823. physicsBody: any;
  30824. /**
  30825. * Get the parent of the physics imposter
  30826. * @returns Physics imposter or null
  30827. */
  30828. /**
  30829. * Sets the parent of the physics imposter
  30830. */
  30831. parent: Nullable<PhysicsImpostor>;
  30832. /**
  30833. * Resets the update flags
  30834. */
  30835. resetUpdateFlags(): void;
  30836. /**
  30837. * Gets the object extend size
  30838. * @returns the object extend size
  30839. */
  30840. getObjectExtendSize(): Vector3;
  30841. /**
  30842. * Gets the object center
  30843. * @returns The object center
  30844. */
  30845. getObjectCenter(): Vector3;
  30846. /**
  30847. * Get a specific parametes from the options parameter
  30848. * @param paramName The object parameter name
  30849. * @returns The object parameter
  30850. */
  30851. getParam(paramName: string): any;
  30852. /**
  30853. * Sets a specific parameter in the options given to the physics plugin
  30854. * @param paramName The parameter name
  30855. * @param value The value of the parameter
  30856. */
  30857. setParam(paramName: string, value: number): void;
  30858. /**
  30859. * Specifically change the body's mass option. Won't recreate the physics body object
  30860. * @param mass The mass of the physics imposter
  30861. */
  30862. setMass(mass: number): void;
  30863. /**
  30864. * Gets the linear velocity
  30865. * @returns linear velocity or null
  30866. */
  30867. getLinearVelocity(): Nullable<Vector3>;
  30868. /**
  30869. * Sets the linear velocity
  30870. * @param velocity linear velocity or null
  30871. */
  30872. setLinearVelocity(velocity: Nullable<Vector3>): void;
  30873. /**
  30874. * Gets the angular velocity
  30875. * @returns angular velocity or null
  30876. */
  30877. getAngularVelocity(): Nullable<Vector3>;
  30878. /**
  30879. * Sets the angular velocity
  30880. * @param velocity The velocity or null
  30881. */
  30882. setAngularVelocity(velocity: Nullable<Vector3>): void;
  30883. /**
  30884. * Execute a function with the physics plugin native code
  30885. * Provide a function the will have two variables - the world object and the physics body object
  30886. * @param func The function to execute with the physics plugin native code
  30887. */
  30888. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  30889. /**
  30890. * Register a function that will be executed before the physics world is stepping forward
  30891. * @param func The function to execute before the physics world is stepped forward
  30892. */
  30893. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30894. /**
  30895. * Unregister a function that will be executed before the physics world is stepping forward
  30896. * @param func The function to execute before the physics world is stepped forward
  30897. */
  30898. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30899. /**
  30900. * Register a function that will be executed after the physics step
  30901. * @param func The function to execute after physics step
  30902. */
  30903. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30904. /**
  30905. * Unregisters a function that will be executed after the physics step
  30906. * @param func The function to execute after physics step
  30907. */
  30908. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30909. /**
  30910. * register a function that will be executed when this impostor collides against a different body
  30911. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  30912. * @param func Callback that is executed on collision
  30913. */
  30914. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  30915. /**
  30916. * Unregisters the physics imposter on contact
  30917. * @param collideAgainst The physics object to collide against
  30918. * @param func Callback to execute on collision
  30919. */
  30920. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  30921. private _tmpQuat;
  30922. private _tmpQuat2;
  30923. /**
  30924. * Get the parent rotation
  30925. * @returns The parent rotation
  30926. */
  30927. getParentsRotation(): Quaternion;
  30928. /**
  30929. * this function is executed by the physics engine.
  30930. */
  30931. beforeStep: () => void;
  30932. /**
  30933. * this function is executed by the physics engine
  30934. */
  30935. afterStep: () => void;
  30936. /**
  30937. * Legacy collision detection event support
  30938. */
  30939. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  30940. /**
  30941. * event and body object due to cannon's event-based architecture.
  30942. */
  30943. onCollide: (e: {
  30944. body: any;
  30945. }) => void;
  30946. /**
  30947. * Apply a force
  30948. * @param force The force to apply
  30949. * @param contactPoint The contact point for the force
  30950. * @returns The physics imposter
  30951. */
  30952. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30953. /**
  30954. * Apply an impulse
  30955. * @param force The impulse force
  30956. * @param contactPoint The contact point for the impulse force
  30957. * @returns The physics imposter
  30958. */
  30959. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30960. /**
  30961. * A help function to create a joint
  30962. * @param otherImpostor A physics imposter used to create a joint
  30963. * @param jointType The type of joint
  30964. * @param jointData The data for the joint
  30965. * @returns The physics imposter
  30966. */
  30967. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  30968. /**
  30969. * Add a joint to this impostor with a different impostor
  30970. * @param otherImpostor A physics imposter used to add a joint
  30971. * @param joint The joint to add
  30972. * @returns The physics imposter
  30973. */
  30974. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  30975. /**
  30976. * Will keep this body still, in a sleep mode.
  30977. * @returns the physics imposter
  30978. */
  30979. sleep(): PhysicsImpostor;
  30980. /**
  30981. * Wake the body up.
  30982. * @returns The physics imposter
  30983. */
  30984. wakeUp(): PhysicsImpostor;
  30985. /**
  30986. * Clones the physics imposter
  30987. * @param newObject The physics imposter clones to this physics-enabled object
  30988. * @returns A nullable physics imposter
  30989. */
  30990. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30991. /**
  30992. * Disposes the physics imposter
  30993. */
  30994. dispose(): void;
  30995. /**
  30996. * Sets the delta position
  30997. * @param position The delta position amount
  30998. */
  30999. setDeltaPosition(position: Vector3): void;
  31000. /**
  31001. * Sets the delta rotation
  31002. * @param rotation The delta rotation amount
  31003. */
  31004. setDeltaRotation(rotation: Quaternion): void;
  31005. /**
  31006. * Gets the box size of the physics imposter and stores the result in the input parameter
  31007. * @param result Stores the box size
  31008. * @returns The physics imposter
  31009. */
  31010. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  31011. /**
  31012. * Gets the radius of the physics imposter
  31013. * @returns Radius of the physics imposter
  31014. */
  31015. getRadius(): number;
  31016. /**
  31017. * Sync a bone with this impostor
  31018. * @param bone The bone to sync to the impostor.
  31019. * @param boneMesh The mesh that the bone is influencing.
  31020. * @param jointPivot The pivot of the joint / bone in local space.
  31021. * @param distToJoint Optional distance from the impostor to the joint.
  31022. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31023. */
  31024. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  31025. /**
  31026. * Sync impostor to a bone
  31027. * @param bone The bone that the impostor will be synced to.
  31028. * @param boneMesh The mesh that the bone is influencing.
  31029. * @param jointPivot The pivot of the joint / bone in local space.
  31030. * @param distToJoint Optional distance from the impostor to the joint.
  31031. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  31032. * @param boneAxis Optional vector3 axis the bone is aligned with
  31033. */
  31034. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  31035. /**
  31036. * No-Imposter type
  31037. */
  31038. static NoImpostor: number;
  31039. /**
  31040. * Sphere-Imposter type
  31041. */
  31042. static SphereImpostor: number;
  31043. /**
  31044. * Box-Imposter type
  31045. */
  31046. static BoxImpostor: number;
  31047. /**
  31048. * Plane-Imposter type
  31049. */
  31050. static PlaneImpostor: number;
  31051. /**
  31052. * Mesh-imposter type
  31053. */
  31054. static MeshImpostor: number;
  31055. /**
  31056. * Cylinder-Imposter type
  31057. */
  31058. static CylinderImpostor: number;
  31059. /**
  31060. * Particle-Imposter type
  31061. */
  31062. static ParticleImpostor: number;
  31063. /**
  31064. * Heightmap-Imposter type
  31065. */
  31066. static HeightmapImpostor: number;
  31067. }
  31068. }
  31069. declare module BABYLON {
  31070. /**
  31071. * Interface for Physics-Joint data
  31072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31073. */
  31074. interface PhysicsJointData {
  31075. /**
  31076. * The main pivot of the joint
  31077. */
  31078. mainPivot?: Vector3;
  31079. /**
  31080. * The connected pivot of the joint
  31081. */
  31082. connectedPivot?: Vector3;
  31083. /**
  31084. * The main axis of the joint
  31085. */
  31086. mainAxis?: Vector3;
  31087. /**
  31088. * The connected axis of the joint
  31089. */
  31090. connectedAxis?: Vector3;
  31091. /**
  31092. * The collision of the joint
  31093. */
  31094. collision?: boolean;
  31095. /**
  31096. * Native Oimo/Cannon/Energy data
  31097. */
  31098. nativeParams?: any;
  31099. }
  31100. /**
  31101. * This is a holder class for the physics joint created by the physics plugin
  31102. * It holds a set of functions to control the underlying joint
  31103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31104. */
  31105. class PhysicsJoint {
  31106. /**
  31107. * The type of the physics joint
  31108. */
  31109. type: number;
  31110. /**
  31111. * The data for the physics joint
  31112. */
  31113. jointData: PhysicsJointData;
  31114. private _physicsJoint;
  31115. protected _physicsPlugin: IPhysicsEnginePlugin;
  31116. /**
  31117. * Initializes the physics joint
  31118. * @param type The type of the physics joint
  31119. * @param jointData The data for the physics joint
  31120. */
  31121. constructor(
  31122. /**
  31123. * The type of the physics joint
  31124. */
  31125. type: number,
  31126. /**
  31127. * The data for the physics joint
  31128. */
  31129. jointData: PhysicsJointData);
  31130. /**
  31131. * Gets the physics joint
  31132. */
  31133. /**
  31134. * Sets the physics joint
  31135. */
  31136. physicsJoint: any;
  31137. /**
  31138. * Sets the physics plugin
  31139. */
  31140. physicsPlugin: IPhysicsEnginePlugin;
  31141. /**
  31142. * Execute a function that is physics-plugin specific.
  31143. * @param {Function} func the function that will be executed.
  31144. * It accepts two parameters: the physics world and the physics joint
  31145. */
  31146. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31147. /**
  31148. * Distance-Joint type
  31149. */
  31150. static DistanceJoint: number;
  31151. /**
  31152. * Hinge-Joint type
  31153. */
  31154. static HingeJoint: number;
  31155. /**
  31156. * Ball-and-Socket joint type
  31157. */
  31158. static BallAndSocketJoint: number;
  31159. /**
  31160. * Wheel-Joint type
  31161. */
  31162. static WheelJoint: number;
  31163. /**
  31164. * Slider-Joint type
  31165. */
  31166. static SliderJoint: number;
  31167. /**
  31168. * Prismatic-Joint type
  31169. */
  31170. static PrismaticJoint: number;
  31171. /**
  31172. * Universal-Joint type
  31173. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31174. */
  31175. static UniversalJoint: number;
  31176. /**
  31177. * Hinge-Joint 2 type
  31178. */
  31179. static Hinge2Joint: number;
  31180. /**
  31181. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31182. */
  31183. static PointToPointJoint: number;
  31184. /**
  31185. * Spring-Joint type
  31186. */
  31187. static SpringJoint: number;
  31188. /**
  31189. * Lock-Joint type
  31190. */
  31191. static LockJoint: number;
  31192. }
  31193. /**
  31194. * A class representing a physics distance joint
  31195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31196. */
  31197. class DistanceJoint extends PhysicsJoint {
  31198. /**
  31199. *
  31200. * @param jointData The data for the Distance-Joint
  31201. */
  31202. constructor(jointData: DistanceJointData);
  31203. /**
  31204. * Update the predefined distance.
  31205. * @param maxDistance The maximum preferred distance
  31206. * @param minDistance The minimum preferred distance
  31207. */
  31208. updateDistance(maxDistance: number, minDistance?: number): void;
  31209. }
  31210. /**
  31211. * Represents a Motor-Enabled Joint
  31212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31213. */
  31214. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31215. /**
  31216. * Initializes the Motor-Enabled Joint
  31217. * @param type The type of the joint
  31218. * @param jointData The physica joint data for the joint
  31219. */
  31220. constructor(type: number, jointData: PhysicsJointData);
  31221. /**
  31222. * Set the motor values.
  31223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31224. * @param force the force to apply
  31225. * @param maxForce max force for this motor.
  31226. */
  31227. setMotor(force?: number, maxForce?: number): void;
  31228. /**
  31229. * Set the motor's limits.
  31230. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31231. * @param upperLimit The upper limit of the motor
  31232. * @param lowerLimit The lower limit of the motor
  31233. */
  31234. setLimit(upperLimit: number, lowerLimit?: number): void;
  31235. }
  31236. /**
  31237. * This class represents a single physics Hinge-Joint
  31238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31239. */
  31240. class HingeJoint extends MotorEnabledJoint {
  31241. /**
  31242. * Initializes the Hinge-Joint
  31243. * @param jointData The joint data for the Hinge-Joint
  31244. */
  31245. constructor(jointData: PhysicsJointData);
  31246. /**
  31247. * Set the motor values.
  31248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31249. * @param {number} force the force to apply
  31250. * @param {number} maxForce max force for this motor.
  31251. */
  31252. setMotor(force?: number, maxForce?: number): void;
  31253. /**
  31254. * Set the motor's limits.
  31255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31256. * @param upperLimit The upper limit of the motor
  31257. * @param lowerLimit The lower limit of the motor
  31258. */
  31259. setLimit(upperLimit: number, lowerLimit?: number): void;
  31260. }
  31261. /**
  31262. * This class represents a dual hinge physics joint (same as wheel joint)
  31263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31264. */
  31265. class Hinge2Joint extends MotorEnabledJoint {
  31266. /**
  31267. * Initializes the Hinge2-Joint
  31268. * @param jointData The joint data for the Hinge2-Joint
  31269. */
  31270. constructor(jointData: PhysicsJointData);
  31271. /**
  31272. * Set the motor values.
  31273. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31274. * @param {number} force the force to apply
  31275. * @param {number} maxForce max force for this motor.
  31276. * @param {motorIndex} the motor's index, 0 or 1.
  31277. */
  31278. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31279. /**
  31280. * Set the motor limits.
  31281. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31282. * @param {number} upperLimit the upper limit
  31283. * @param {number} lowerLimit lower limit
  31284. * @param {motorIndex} the motor's index, 0 or 1.
  31285. */
  31286. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31287. }
  31288. /**
  31289. * Interface for a motor enabled joint
  31290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31291. */
  31292. interface IMotorEnabledJoint {
  31293. /**
  31294. * Physics joint
  31295. */
  31296. physicsJoint: any;
  31297. /**
  31298. * Sets the motor of the motor-enabled joint
  31299. * @param force The force of the motor
  31300. * @param maxForce The maximum force of the motor
  31301. * @param motorIndex The index of the motor
  31302. */
  31303. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31304. /**
  31305. * Sets the limit of the motor
  31306. * @param upperLimit The upper limit of the motor
  31307. * @param lowerLimit The lower limit of the motor
  31308. * @param motorIndex The index of the motor
  31309. */
  31310. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31311. }
  31312. /**
  31313. * Joint data for a Distance-Joint
  31314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31315. */
  31316. interface DistanceJointData extends PhysicsJointData {
  31317. /**
  31318. * Max distance the 2 joint objects can be apart
  31319. */
  31320. maxDistance: number;
  31321. }
  31322. /**
  31323. * Joint data from a spring joint
  31324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31325. */
  31326. interface SpringJointData extends PhysicsJointData {
  31327. /**
  31328. * Length of the spring
  31329. */
  31330. length: number;
  31331. /**
  31332. * Stiffness of the spring
  31333. */
  31334. stiffness: number;
  31335. /**
  31336. * Damping of the spring
  31337. */
  31338. damping: number;
  31339. /** this callback will be called when applying the force to the impostors. */
  31340. forceApplicationCallback: () => void;
  31341. }
  31342. }
  31343. declare module BABYLON {
  31344. /**
  31345. * This represents the base class for particle system in Babylon.
  31346. * 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.
  31347. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31348. * @example https://doc.babylonjs.com/babylon101/particles
  31349. */
  31350. class BaseParticleSystem {
  31351. /**
  31352. * Source color is added to the destination color without alpha affecting the result
  31353. */
  31354. static BLENDMODE_ONEONE: number;
  31355. /**
  31356. * Blend current color and particle color using particle’s alpha
  31357. */
  31358. static BLENDMODE_STANDARD: number;
  31359. /**
  31360. * Add current color and particle color multiplied by particle’s alpha
  31361. */
  31362. static BLENDMODE_ADD: number;
  31363. /**
  31364. * Multiply current color with particle color
  31365. */
  31366. static BLENDMODE_MULTIPLY: number;
  31367. /**
  31368. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31369. */
  31370. static BLENDMODE_MULTIPLYADD: number;
  31371. /**
  31372. * List of animations used by the particle system.
  31373. */
  31374. animations: Animation[];
  31375. /**
  31376. * The id of the Particle system.
  31377. */
  31378. id: string;
  31379. /**
  31380. * The friendly name of the Particle system.
  31381. */
  31382. name: string;
  31383. /**
  31384. * The rendering group used by the Particle system to chose when to render.
  31385. */
  31386. renderingGroupId: number;
  31387. /**
  31388. * The emitter represents the Mesh or position we are attaching the particle system to.
  31389. */
  31390. emitter: Nullable<AbstractMesh | Vector3>;
  31391. /**
  31392. * The maximum number of particles to emit per frame
  31393. */
  31394. emitRate: number;
  31395. /**
  31396. * If you want to launch only a few particles at once, that can be done, as well.
  31397. */
  31398. manualEmitCount: number;
  31399. /**
  31400. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31401. */
  31402. updateSpeed: number;
  31403. /**
  31404. * The amount of time the particle system is running (depends of the overall update speed).
  31405. */
  31406. targetStopDuration: number;
  31407. /**
  31408. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31409. */
  31410. disposeOnStop: boolean;
  31411. /**
  31412. * Minimum power of emitting particles.
  31413. */
  31414. minEmitPower: number;
  31415. /**
  31416. * Maximum power of emitting particles.
  31417. */
  31418. maxEmitPower: number;
  31419. /**
  31420. * Minimum life time of emitting particles.
  31421. */
  31422. minLifeTime: number;
  31423. /**
  31424. * Maximum life time of emitting particles.
  31425. */
  31426. maxLifeTime: number;
  31427. /**
  31428. * Minimum Size of emitting particles.
  31429. */
  31430. minSize: number;
  31431. /**
  31432. * Maximum Size of emitting particles.
  31433. */
  31434. maxSize: number;
  31435. /**
  31436. * Minimum scale of emitting particles on X axis.
  31437. */
  31438. minScaleX: number;
  31439. /**
  31440. * Maximum scale of emitting particles on X axis.
  31441. */
  31442. maxScaleX: number;
  31443. /**
  31444. * Minimum scale of emitting particles on Y axis.
  31445. */
  31446. minScaleY: number;
  31447. /**
  31448. * Maximum scale of emitting particles on Y axis.
  31449. */
  31450. maxScaleY: number;
  31451. /**
  31452. * Gets or sets the minimal initial rotation in radians.
  31453. */
  31454. minInitialRotation: number;
  31455. /**
  31456. * Gets or sets the maximal initial rotation in radians.
  31457. */
  31458. maxInitialRotation: number;
  31459. /**
  31460. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31461. */
  31462. minAngularSpeed: number;
  31463. /**
  31464. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31465. */
  31466. maxAngularSpeed: number;
  31467. /**
  31468. * The texture used to render each particle. (this can be a spritesheet)
  31469. */
  31470. particleTexture: Nullable<Texture>;
  31471. /**
  31472. * The layer mask we are rendering the particles through.
  31473. */
  31474. layerMask: number;
  31475. /**
  31476. * This can help using your own shader to render the particle system.
  31477. * The according effect will be created
  31478. */
  31479. customShader: any;
  31480. /**
  31481. * By default particle system starts as soon as they are created. This prevents the
  31482. * automatic start to happen and let you decide when to start emitting particles.
  31483. */
  31484. preventAutoStart: boolean;
  31485. /**
  31486. * Gets or sets a texture used to add random noise to particle positions
  31487. */
  31488. noiseTexture: Nullable<ProceduralTexture>;
  31489. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31490. noiseStrength: Vector3;
  31491. /**
  31492. * Callback triggered when the particle animation is ending.
  31493. */
  31494. onAnimationEnd: Nullable<() => void>;
  31495. /**
  31496. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  31497. */
  31498. blendMode: number;
  31499. /**
  31500. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31501. * to override the particles.
  31502. */
  31503. forceDepthWrite: boolean;
  31504. /** 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 */
  31505. preWarmCycles: number;
  31506. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  31507. preWarmStepOffset: number;
  31508. /**
  31509. * 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)
  31510. */
  31511. spriteCellChangeSpeed: number;
  31512. /**
  31513. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31514. */
  31515. startSpriteCellID: number;
  31516. /**
  31517. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31518. */
  31519. endSpriteCellID: number;
  31520. /**
  31521. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31522. */
  31523. spriteCellWidth: number;
  31524. /**
  31525. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31526. */
  31527. spriteCellHeight: number;
  31528. /**
  31529. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31530. */
  31531. spriteRandomStartCell: boolean;
  31532. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31533. translationPivot: Vector2;
  31534. /** @hidden */
  31535. protected _isAnimationSheetEnabled: boolean;
  31536. /**
  31537. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31538. */
  31539. beginAnimationOnStart: boolean;
  31540. /**
  31541. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31542. */
  31543. beginAnimationFrom: number;
  31544. /**
  31545. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31546. */
  31547. beginAnimationTo: number;
  31548. /**
  31549. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31550. */
  31551. beginAnimationLoop: boolean;
  31552. /**
  31553. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  31554. */
  31555. isAnimationSheetEnabled: boolean;
  31556. /**
  31557. * Get hosting scene
  31558. * @returns the scene
  31559. */
  31560. getScene(): Scene;
  31561. /**
  31562. * You can use gravity if you want to give an orientation to your particles.
  31563. */
  31564. gravity: Vector3;
  31565. protected _colorGradients: Nullable<Array<ColorGradient>>;
  31566. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  31567. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  31568. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  31569. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  31570. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  31571. protected _dragGradients: Nullable<Array<FactorGradient>>;
  31572. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  31573. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  31574. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  31575. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  31576. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  31577. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  31578. /**
  31579. * Defines the delay in milliseconds before starting the system (0 by default)
  31580. */
  31581. startDelay: number;
  31582. /**
  31583. * Gets the current list of drag gradients.
  31584. * You must use addDragGradient and removeDragGradient to udpate this list
  31585. * @returns the list of drag gradients
  31586. */
  31587. getDragGradients(): Nullable<Array<FactorGradient>>;
  31588. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31589. limitVelocityDamping: number;
  31590. /**
  31591. * Gets the current list of limit velocity gradients.
  31592. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31593. * @returns the list of limit velocity gradients
  31594. */
  31595. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31596. /**
  31597. * Gets the current list of color gradients.
  31598. * You must use addColorGradient and removeColorGradient to udpate this list
  31599. * @returns the list of color gradients
  31600. */
  31601. getColorGradients(): Nullable<Array<ColorGradient>>;
  31602. /**
  31603. * Gets the current list of size gradients.
  31604. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31605. * @returns the list of size gradients
  31606. */
  31607. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31608. /**
  31609. * Gets the current list of color remap gradients.
  31610. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31611. * @returns the list of color remap gradients
  31612. */
  31613. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31614. /**
  31615. * Gets the current list of alpha remap gradients.
  31616. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31617. * @returns the list of alpha remap gradients
  31618. */
  31619. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31620. /**
  31621. * Gets the current list of life time gradients.
  31622. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31623. * @returns the list of life time gradients
  31624. */
  31625. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31626. /**
  31627. * Gets the current list of angular speed gradients.
  31628. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31629. * @returns the list of angular speed gradients
  31630. */
  31631. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31632. /**
  31633. * Gets the current list of velocity gradients.
  31634. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31635. * @returns the list of velocity gradients
  31636. */
  31637. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31638. /**
  31639. * Gets the current list of start size gradients.
  31640. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31641. * @returns the list of start size gradients
  31642. */
  31643. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31644. /**
  31645. * Gets the current list of emit rate gradients.
  31646. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31647. * @returns the list of emit rate gradients
  31648. */
  31649. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31650. /**
  31651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31652. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31653. */
  31654. direction1: Vector3;
  31655. /**
  31656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31657. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31658. */
  31659. direction2: Vector3;
  31660. /**
  31661. * 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.
  31662. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31663. */
  31664. minEmitBox: Vector3;
  31665. /**
  31666. * 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.
  31667. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31668. */
  31669. maxEmitBox: Vector3;
  31670. /**
  31671. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31672. */
  31673. color1: Color4;
  31674. /**
  31675. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31676. */
  31677. color2: Color4;
  31678. /**
  31679. * Color the particle will have at the end of its lifetime
  31680. */
  31681. colorDead: Color4;
  31682. /**
  31683. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  31684. */
  31685. textureMask: Color4;
  31686. /**
  31687. * The particle emitter type defines the emitter used by the particle system.
  31688. * It can be for example box, sphere, or cone...
  31689. */
  31690. particleEmitterType: IParticleEmitterType;
  31691. /** @hidden */
  31692. _isSubEmitter: boolean;
  31693. /**
  31694. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31695. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31696. */
  31697. billboardMode: number;
  31698. protected _isBillboardBased: boolean;
  31699. /**
  31700. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31701. */
  31702. isBillboardBased: boolean;
  31703. /**
  31704. * The scene the particle system belongs to.
  31705. */
  31706. protected _scene: Scene;
  31707. /**
  31708. * Local cache of defines for image processing.
  31709. */
  31710. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  31711. /**
  31712. * Default configuration related to image processing available in the standard Material.
  31713. */
  31714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31715. /**
  31716. * Gets the image processing configuration used either in this material.
  31717. */
  31718. /**
  31719. * Sets the Default image processing configuration used either in the this material.
  31720. *
  31721. * If sets to null, the scene one is in use.
  31722. */
  31723. imageProcessingConfiguration: ImageProcessingConfiguration;
  31724. /**
  31725. * Attaches a new image processing configuration to the Standard Material.
  31726. * @param configuration
  31727. */
  31728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31729. /** @hidden */
  31730. protected _reset(): void;
  31731. /** @hidden */
  31732. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  31733. /**
  31734. * Instantiates a particle system.
  31735. * 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.
  31736. * @param name The name of the particle system
  31737. */
  31738. constructor(name: string);
  31739. /**
  31740. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31743. * @returns the emitter
  31744. */
  31745. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31746. /**
  31747. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31748. * @param radius The radius of the hemisphere to emit from
  31749. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31750. * @returns the emitter
  31751. */
  31752. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  31753. /**
  31754. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31755. * @param radius The radius of the sphere to emit from
  31756. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31757. * @returns the emitter
  31758. */
  31759. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  31760. /**
  31761. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31762. * @param radius The radius of the sphere to emit from
  31763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31765. * @returns the emitter
  31766. */
  31767. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  31768. /**
  31769. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31770. * @param radius The radius of the emission cylinder
  31771. * @param height The height of the emission cylinder
  31772. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31773. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31774. * @returns the emitter
  31775. */
  31776. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  31777. /**
  31778. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31779. * @param radius The radius of the cylinder to emit from
  31780. * @param height The height of the emission cylinder
  31781. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31782. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31783. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31784. * @returns the emitter
  31785. */
  31786. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  31787. /**
  31788. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31789. * @param radius The radius of the cone to emit from
  31790. * @param angle The base angle of the cone
  31791. * @returns the emitter
  31792. */
  31793. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  31794. /**
  31795. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31798. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31799. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31800. * @returns the emitter
  31801. */
  31802. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31803. }
  31804. }
  31805. declare module BABYLON {
  31806. /**
  31807. * This represents a GPU particle system in Babylon
  31808. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  31809. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  31810. */
  31811. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  31812. /**
  31813. * The layer mask we are rendering the particles through.
  31814. */
  31815. layerMask: number;
  31816. private _capacity;
  31817. private _activeCount;
  31818. private _currentActiveCount;
  31819. private _accumulatedCount;
  31820. private _renderEffect;
  31821. private _updateEffect;
  31822. private _buffer0;
  31823. private _buffer1;
  31824. private _spriteBuffer;
  31825. private _updateVAO;
  31826. private _renderVAO;
  31827. private _targetIndex;
  31828. private _sourceBuffer;
  31829. private _targetBuffer;
  31830. private _engine;
  31831. private _currentRenderId;
  31832. private _started;
  31833. private _stopped;
  31834. private _timeDelta;
  31835. private _randomTexture;
  31836. private _randomTexture2;
  31837. private _attributesStrideSize;
  31838. private _updateEffectOptions;
  31839. private _randomTextureSize;
  31840. private _actualFrame;
  31841. private readonly _rawTextureWidth;
  31842. /**
  31843. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  31844. */
  31845. static readonly IsSupported: boolean;
  31846. /**
  31847. * An event triggered when the system is disposed.
  31848. */
  31849. onDisposeObservable: Observable<GPUParticleSystem>;
  31850. /**
  31851. * Gets the maximum number of particles active at the same time.
  31852. * @returns The max number of active particles.
  31853. */
  31854. getCapacity(): number;
  31855. /**
  31856. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31857. * to override the particles.
  31858. */
  31859. forceDepthWrite: boolean;
  31860. /**
  31861. * Gets or set the number of active particles
  31862. */
  31863. activeParticleCount: number;
  31864. private _preWarmDone;
  31865. /**
  31866. * Is this system ready to be used/rendered
  31867. * @return true if the system is ready
  31868. */
  31869. isReady(): boolean;
  31870. /**
  31871. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31872. * @returns True if it has been started, otherwise false.
  31873. */
  31874. isStarted(): boolean;
  31875. /**
  31876. * Starts the particle system and begins to emit
  31877. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31878. */
  31879. start(delay?: number): void;
  31880. /**
  31881. * Stops the particle system.
  31882. */
  31883. stop(): void;
  31884. /**
  31885. * Remove all active particles
  31886. */
  31887. reset(): void;
  31888. /**
  31889. * Returns the string "GPUParticleSystem"
  31890. * @returns a string containing the class name
  31891. */
  31892. getClassName(): string;
  31893. private _colorGradientsTexture;
  31894. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  31895. /**
  31896. * Adds a new color gradient
  31897. * @param gradient defines the gradient to use (between 0 and 1)
  31898. * @param color1 defines the color to affect to the specified gradient
  31899. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31900. * @returns the current particle system
  31901. */
  31902. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  31903. /**
  31904. * Remove a specific color gradient
  31905. * @param gradient defines the gradient to remove
  31906. * @returns the current particle system
  31907. */
  31908. removeColorGradient(gradient: number): GPUParticleSystem;
  31909. private _angularSpeedGradientsTexture;
  31910. private _sizeGradientsTexture;
  31911. private _velocityGradientsTexture;
  31912. private _limitVelocityGradientsTexture;
  31913. private _dragGradientsTexture;
  31914. private _addFactorGradient;
  31915. /**
  31916. * Adds a new size gradient
  31917. * @param gradient defines the gradient to use (between 0 and 1)
  31918. * @param factor defines the size factor to affect to the specified gradient
  31919. * @returns the current particle system
  31920. */
  31921. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  31922. /**
  31923. * Remove a specific size gradient
  31924. * @param gradient defines the gradient to remove
  31925. * @returns the current particle system
  31926. */
  31927. removeSizeGradient(gradient: number): GPUParticleSystem;
  31928. /**
  31929. * Adds a new angular speed gradient
  31930. * @param gradient defines the gradient to use (between 0 and 1)
  31931. * @param factor defines the angular speed to affect to the specified gradient
  31932. * @returns the current particle system
  31933. */
  31934. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  31935. /**
  31936. * Remove a specific angular speed gradient
  31937. * @param gradient defines the gradient to remove
  31938. * @returns the current particle system
  31939. */
  31940. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  31941. /**
  31942. * Adds a new velocity gradient
  31943. * @param gradient defines the gradient to use (between 0 and 1)
  31944. * @param factor defines the velocity to affect to the specified gradient
  31945. * @returns the current particle system
  31946. */
  31947. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31948. /**
  31949. * Remove a specific velocity gradient
  31950. * @param gradient defines the gradient to remove
  31951. * @returns the current particle system
  31952. */
  31953. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31954. /**
  31955. * Adds a new limit velocity gradient
  31956. * @param gradient defines the gradient to use (between 0 and 1)
  31957. * @param factor defines the limit velocity value to affect to the specified gradient
  31958. * @returns the current particle system
  31959. */
  31960. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31961. /**
  31962. * Remove a specific limit velocity gradient
  31963. * @param gradient defines the gradient to remove
  31964. * @returns the current particle system
  31965. */
  31966. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31967. /**
  31968. * Adds a new drag gradient
  31969. * @param gradient defines the gradient to use (between 0 and 1)
  31970. * @param factor defines the drag value to affect to the specified gradient
  31971. * @returns the current particle system
  31972. */
  31973. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31974. /**
  31975. * Remove a specific drag gradient
  31976. * @param gradient defines the gradient to remove
  31977. * @returns the current particle system
  31978. */
  31979. removeDragGradient(gradient: number): GPUParticleSystem;
  31980. /**
  31981. * Not supported by GPUParticleSystem
  31982. * @param gradient defines the gradient to use (between 0 and 1)
  31983. * @param factor defines the emit rate value to affect to the specified gradient
  31984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31985. * @returns the current particle system
  31986. */
  31987. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31988. /**
  31989. * Not supported by GPUParticleSystem
  31990. * @param gradient defines the gradient to remove
  31991. * @returns the current particle system
  31992. */
  31993. removeEmitRateGradient(gradient: number): IParticleSystem;
  31994. /**
  31995. * Not supported by GPUParticleSystem
  31996. * @param gradient defines the gradient to use (between 0 and 1)
  31997. * @param factor defines the start size value to affect to the specified gradient
  31998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31999. * @returns the current particle system
  32000. */
  32001. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32002. /**
  32003. * Not supported by GPUParticleSystem
  32004. * @param gradient defines the gradient to remove
  32005. * @returns the current particle system
  32006. */
  32007. removeStartSizeGradient(gradient: number): IParticleSystem;
  32008. /**
  32009. * Not supported by GPUParticleSystem
  32010. * @param gradient defines the gradient to use (between 0 and 1)
  32011. * @param min defines the color remap minimal range
  32012. * @param max defines the color remap maximal range
  32013. * @returns the current particle system
  32014. */
  32015. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32016. /**
  32017. * Not supported by GPUParticleSystem
  32018. * @param gradient defines the gradient to remove
  32019. * @returns the current particle system
  32020. */
  32021. removeColorRemapGradient(gradient: number): IParticleSystem;
  32022. /**
  32023. * Not supported by GPUParticleSystem
  32024. * @param gradient defines the gradient to use (between 0 and 1)
  32025. * @param min defines the alpha remap minimal range
  32026. * @param max defines the alpha remap maximal range
  32027. * @returns the current particle system
  32028. */
  32029. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32030. /**
  32031. * Not supported by GPUParticleSystem
  32032. * @param gradient defines the gradient to remove
  32033. * @returns the current particle system
  32034. */
  32035. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32036. /**
  32037. * Not supported by GPUParticleSystem
  32038. * @param gradient defines the gradient to use (between 0 and 1)
  32039. * @param color defines the color to affect to the specified gradient
  32040. * @returns the current particle system
  32041. */
  32042. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32043. /**
  32044. * Not supported by GPUParticleSystem
  32045. * @param gradient defines the gradient to remove
  32046. * @returns the current particle system
  32047. */
  32048. removeRampGradient(gradient: number): IParticleSystem;
  32049. /**
  32050. * Not supported by GPUParticleSystem
  32051. * @returns the list of ramp gradients
  32052. */
  32053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32054. /**
  32055. * Not supported by GPUParticleSystem
  32056. * Gets or sets a boolean indicating that ramp gradients must be used
  32057. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32058. */
  32059. useRampGradients: boolean;
  32060. /**
  32061. * Not supported by GPUParticleSystem
  32062. * @param gradient defines the gradient to use (between 0 and 1)
  32063. * @param factor defines the life time factor to affect to the specified gradient
  32064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32065. * @returns the current particle system
  32066. */
  32067. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32068. /**
  32069. * Not supported by GPUParticleSystem
  32070. * @param gradient defines the gradient to remove
  32071. * @returns the current particle system
  32072. */
  32073. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32074. /**
  32075. * Instantiates a GPU particle system.
  32076. * 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.
  32077. * @param name The name of the particle system
  32078. * @param options The options used to create the system
  32079. * @param scene The scene the particle system belongs to
  32080. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32081. */
  32082. constructor(name: string, options: Partial<{
  32083. capacity: number;
  32084. randomTextureSize: number;
  32085. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  32086. protected _reset(): void;
  32087. private _createUpdateVAO;
  32088. private _createRenderVAO;
  32089. private _initialize;
  32090. /** @hidden */
  32091. _recreateUpdateEffect(): void;
  32092. /** @hidden */
  32093. _recreateRenderEffect(): void;
  32094. /**
  32095. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32096. * @param preWarm defines if we are in the pre-warmimg phase
  32097. */
  32098. animate(preWarm?: boolean): void;
  32099. private _createFactorGradientTexture;
  32100. private _createSizeGradientTexture;
  32101. private _createAngularSpeedGradientTexture;
  32102. private _createVelocityGradientTexture;
  32103. private _createLimitVelocityGradientTexture;
  32104. private _createDragGradientTexture;
  32105. private _createColorGradientTexture;
  32106. /**
  32107. * Renders the particle system in its current state
  32108. * @param preWarm defines if the system should only update the particles but not render them
  32109. * @returns the current number of particles
  32110. */
  32111. render(preWarm?: boolean): number;
  32112. /**
  32113. * Rebuilds the particle system
  32114. */
  32115. rebuild(): void;
  32116. private _releaseBuffers;
  32117. private _releaseVAOs;
  32118. /**
  32119. * Disposes the particle system and free the associated resources
  32120. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32121. */
  32122. dispose(disposeTexture?: boolean): void;
  32123. /**
  32124. * Clones the particle system.
  32125. * @param name The name of the cloned object
  32126. * @param newEmitter The new emitter to use
  32127. * @returns the cloned particle system
  32128. */
  32129. clone(name: string, newEmitter: any): GPUParticleSystem;
  32130. /**
  32131. * Serializes the particle system to a JSON object.
  32132. * @returns the JSON object
  32133. */
  32134. serialize(): any;
  32135. /**
  32136. * Parses a JSON object to create a GPU particle system.
  32137. * @param parsedParticleSystem The JSON object to parse
  32138. * @param scene The scene to create the particle system in
  32139. * @param rootUrl The root url to use to load external dependencies like texture
  32140. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32141. * @returns the parsed GPU particle system
  32142. */
  32143. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  32144. }
  32145. }
  32146. declare module BABYLON {
  32147. /**
  32148. * Interface representing a particle system in Babylon.js.
  32149. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  32150. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  32151. */
  32152. interface IParticleSystem {
  32153. /**
  32154. * List of animations used by the particle system.
  32155. */
  32156. animations: Animation[];
  32157. /**
  32158. * The id of the Particle system.
  32159. */
  32160. id: string;
  32161. /**
  32162. * The name of the Particle system.
  32163. */
  32164. name: string;
  32165. /**
  32166. * The emitter represents the Mesh or position we are attaching the particle system to.
  32167. */
  32168. emitter: Nullable<AbstractMesh | Vector3>;
  32169. /**
  32170. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32171. */
  32172. isBillboardBased: boolean;
  32173. /**
  32174. * The rendering group used by the Particle system to chose when to render.
  32175. */
  32176. renderingGroupId: number;
  32177. /**
  32178. * The layer mask we are rendering the particles through.
  32179. */
  32180. layerMask: number;
  32181. /**
  32182. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  32183. */
  32184. updateSpeed: number;
  32185. /**
  32186. * The amount of time the particle system is running (depends of the overall update speed).
  32187. */
  32188. targetStopDuration: number;
  32189. /**
  32190. * The texture used to render each particle. (this can be a spritesheet)
  32191. */
  32192. particleTexture: Nullable<Texture>;
  32193. /**
  32194. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  32195. */
  32196. blendMode: number;
  32197. /**
  32198. * Minimum life time of emitting particles.
  32199. */
  32200. minLifeTime: number;
  32201. /**
  32202. * Maximum life time of emitting particles.
  32203. */
  32204. maxLifeTime: number;
  32205. /**
  32206. * Minimum Size of emitting particles.
  32207. */
  32208. minSize: number;
  32209. /**
  32210. * Maximum Size of emitting particles.
  32211. */
  32212. maxSize: number;
  32213. /**
  32214. * Minimum scale of emitting particles on X axis.
  32215. */
  32216. minScaleX: number;
  32217. /**
  32218. * Maximum scale of emitting particles on X axis.
  32219. */
  32220. maxScaleX: number;
  32221. /**
  32222. * Minimum scale of emitting particles on Y axis.
  32223. */
  32224. minScaleY: number;
  32225. /**
  32226. * Maximum scale of emitting particles on Y axis.
  32227. */
  32228. maxScaleY: number;
  32229. /**
  32230. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32231. */
  32232. color1: Color4;
  32233. /**
  32234. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32235. */
  32236. color2: Color4;
  32237. /**
  32238. * Color the particle will have at the end of its lifetime.
  32239. */
  32240. colorDead: Color4;
  32241. /**
  32242. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  32243. */
  32244. emitRate: number;
  32245. /**
  32246. * You can use gravity if you want to give an orientation to your particles.
  32247. */
  32248. gravity: Vector3;
  32249. /**
  32250. * Minimum power of emitting particles.
  32251. */
  32252. minEmitPower: number;
  32253. /**
  32254. * Maximum power of emitting particles.
  32255. */
  32256. maxEmitPower: number;
  32257. /**
  32258. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32259. */
  32260. minAngularSpeed: number;
  32261. /**
  32262. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32263. */
  32264. maxAngularSpeed: number;
  32265. /**
  32266. * Gets or sets the minimal initial rotation in radians.
  32267. */
  32268. minInitialRotation: number;
  32269. /**
  32270. * Gets or sets the maximal initial rotation in radians.
  32271. */
  32272. maxInitialRotation: number;
  32273. /**
  32274. * The particle emitter type defines the emitter used by the particle system.
  32275. * It can be for example box, sphere, or cone...
  32276. */
  32277. particleEmitterType: Nullable<IParticleEmitterType>;
  32278. /**
  32279. * Defines the delay in milliseconds before starting the system (0 by default)
  32280. */
  32281. startDelay: number;
  32282. /**
  32283. * 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
  32284. */
  32285. preWarmCycles: number;
  32286. /**
  32287. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32288. */
  32289. preWarmStepOffset: number;
  32290. /**
  32291. * 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)
  32292. */
  32293. spriteCellChangeSpeed: number;
  32294. /**
  32295. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32296. */
  32297. startSpriteCellID: number;
  32298. /**
  32299. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32300. */
  32301. endSpriteCellID: number;
  32302. /**
  32303. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32304. */
  32305. spriteCellWidth: number;
  32306. /**
  32307. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32308. */
  32309. spriteCellHeight: number;
  32310. /**
  32311. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32312. */
  32313. spriteRandomStartCell: boolean;
  32314. /**
  32315. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32316. */
  32317. isAnimationSheetEnabled: boolean;
  32318. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32319. translationPivot: Vector2;
  32320. /**
  32321. * Gets or sets a texture used to add random noise to particle positions
  32322. */
  32323. noiseTexture: Nullable<BaseTexture>;
  32324. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32325. noiseStrength: Vector3;
  32326. /**
  32327. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32328. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32329. */
  32330. billboardMode: number;
  32331. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32332. limitVelocityDamping: number;
  32333. /**
  32334. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32335. */
  32336. beginAnimationOnStart: boolean;
  32337. /**
  32338. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32339. */
  32340. beginAnimationFrom: number;
  32341. /**
  32342. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32343. */
  32344. beginAnimationTo: number;
  32345. /**
  32346. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32347. */
  32348. beginAnimationLoop: boolean;
  32349. /**
  32350. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32351. */
  32352. disposeOnStop: boolean;
  32353. /**
  32354. * Gets the maximum number of particles active at the same time.
  32355. * @returns The max number of active particles.
  32356. */
  32357. getCapacity(): number;
  32358. /**
  32359. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32360. * @returns True if it has been started, otherwise false.
  32361. */
  32362. isStarted(): boolean;
  32363. /**
  32364. * Animates the particle system for this frame.
  32365. */
  32366. animate(): void;
  32367. /**
  32368. * Renders the particle system in its current state.
  32369. * @returns the current number of particles
  32370. */
  32371. render(): number;
  32372. /**
  32373. * Dispose the particle system and frees its associated resources.
  32374. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32375. */
  32376. dispose(disposeTexture?: boolean): void;
  32377. /**
  32378. * Clones the particle system.
  32379. * @param name The name of the cloned object
  32380. * @param newEmitter The new emitter to use
  32381. * @returns the cloned particle system
  32382. */
  32383. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32384. /**
  32385. * Serializes the particle system to a JSON object.
  32386. * @returns the JSON object
  32387. */
  32388. serialize(): any;
  32389. /**
  32390. * Rebuild the particle system
  32391. */
  32392. rebuild(): void;
  32393. /**
  32394. * Starts the particle system and begins to emit
  32395. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32396. */
  32397. start(delay?: number): void;
  32398. /**
  32399. * Stops the particle system.
  32400. */
  32401. stop(): void;
  32402. /**
  32403. * Remove all active particles
  32404. */
  32405. reset(): void;
  32406. /**
  32407. * Is this system ready to be used/rendered
  32408. * @return true if the system is ready
  32409. */
  32410. isReady(): boolean;
  32411. /**
  32412. * Adds a new color gradient
  32413. * @param gradient defines the gradient to use (between 0 and 1)
  32414. * @param color1 defines the color to affect to the specified gradient
  32415. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32416. * @returns the current particle system
  32417. */
  32418. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32419. /**
  32420. * Remove a specific color gradient
  32421. * @param gradient defines the gradient to remove
  32422. * @returns the current particle system
  32423. */
  32424. removeColorGradient(gradient: number): IParticleSystem;
  32425. /**
  32426. * Adds a new size gradient
  32427. * @param gradient defines the gradient to use (between 0 and 1)
  32428. * @param factor defines the size factor to affect to the specified gradient
  32429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32430. * @returns the current particle system
  32431. */
  32432. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32433. /**
  32434. * Remove a specific size gradient
  32435. * @param gradient defines the gradient to remove
  32436. * @returns the current particle system
  32437. */
  32438. removeSizeGradient(gradient: number): IParticleSystem;
  32439. /**
  32440. * Gets the current list of color gradients.
  32441. * You must use addColorGradient and removeColorGradient to udpate this list
  32442. * @returns the list of color gradients
  32443. */
  32444. getColorGradients(): Nullable<Array<ColorGradient>>;
  32445. /**
  32446. * Gets the current list of size gradients.
  32447. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32448. * @returns the list of size gradients
  32449. */
  32450. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32451. /**
  32452. * Gets the current list of angular speed gradients.
  32453. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32454. * @returns the list of angular speed gradients
  32455. */
  32456. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32457. /**
  32458. * Adds a new angular speed gradient
  32459. * @param gradient defines the gradient to use (between 0 and 1)
  32460. * @param factor defines the angular speed to affect to the specified gradient
  32461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32462. * @returns the current particle system
  32463. */
  32464. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32465. /**
  32466. * Remove a specific angular speed gradient
  32467. * @param gradient defines the gradient to remove
  32468. * @returns the current particle system
  32469. */
  32470. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32471. /**
  32472. * Gets the current list of velocity gradients.
  32473. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32474. * @returns the list of velocity gradients
  32475. */
  32476. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32477. /**
  32478. * Adds a new velocity gradient
  32479. * @param gradient defines the gradient to use (between 0 and 1)
  32480. * @param factor defines the velocity to affect to the specified gradient
  32481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32482. * @returns the current particle system
  32483. */
  32484. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32485. /**
  32486. * Remove a specific velocity gradient
  32487. * @param gradient defines the gradient to remove
  32488. * @returns the current particle system
  32489. */
  32490. removeVelocityGradient(gradient: number): IParticleSystem;
  32491. /**
  32492. * Gets the current list of limit velocity gradients.
  32493. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32494. * @returns the list of limit velocity gradients
  32495. */
  32496. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32497. /**
  32498. * Adds a new limit velocity gradient
  32499. * @param gradient defines the gradient to use (between 0 and 1)
  32500. * @param factor defines the limit velocity to affect to the specified gradient
  32501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32502. * @returns the current particle system
  32503. */
  32504. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32505. /**
  32506. * Remove a specific limit velocity gradient
  32507. * @param gradient defines the gradient to remove
  32508. * @returns the current particle system
  32509. */
  32510. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32511. /**
  32512. * Adds a new drag gradient
  32513. * @param gradient defines the gradient to use (between 0 and 1)
  32514. * @param factor defines the drag to affect to the specified gradient
  32515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32516. * @returns the current particle system
  32517. */
  32518. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32519. /**
  32520. * Remove a specific drag gradient
  32521. * @param gradient defines the gradient to remove
  32522. * @returns the current particle system
  32523. */
  32524. removeDragGradient(gradient: number): IParticleSystem;
  32525. /**
  32526. * Gets the current list of drag gradients.
  32527. * You must use addDragGradient and removeDragGradient to udpate this list
  32528. * @returns the list of drag gradients
  32529. */
  32530. getDragGradients(): Nullable<Array<FactorGradient>>;
  32531. /**
  32532. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32533. * @param gradient defines the gradient to use (between 0 and 1)
  32534. * @param factor defines the emit rate to affect to the specified gradient
  32535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32536. * @returns the current particle system
  32537. */
  32538. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32539. /**
  32540. * Remove a specific emit rate gradient
  32541. * @param gradient defines the gradient to remove
  32542. * @returns the current particle system
  32543. */
  32544. removeEmitRateGradient(gradient: number): IParticleSystem;
  32545. /**
  32546. * Gets the current list of emit rate gradients.
  32547. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32548. * @returns the list of emit rate gradients
  32549. */
  32550. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32551. /**
  32552. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32553. * @param gradient defines the gradient to use (between 0 and 1)
  32554. * @param factor defines the start size to affect to the specified gradient
  32555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32556. * @returns the current particle system
  32557. */
  32558. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32559. /**
  32560. * Remove a specific start size gradient
  32561. * @param gradient defines the gradient to remove
  32562. * @returns the current particle system
  32563. */
  32564. removeStartSizeGradient(gradient: number): IParticleSystem;
  32565. /**
  32566. * Gets the current list of start size gradients.
  32567. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32568. * @returns the list of start size gradients
  32569. */
  32570. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32571. /**
  32572. * Adds a new life time gradient
  32573. * @param gradient defines the gradient to use (between 0 and 1)
  32574. * @param factor defines the life time factor to affect to the specified gradient
  32575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32576. * @returns the current particle system
  32577. */
  32578. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32579. /**
  32580. * Remove a specific life time gradient
  32581. * @param gradient defines the gradient to remove
  32582. * @returns the current particle system
  32583. */
  32584. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32585. /**
  32586. * Gets the current list of life time gradients.
  32587. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32588. * @returns the list of life time gradients
  32589. */
  32590. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32591. /**
  32592. * Gets the current list of color gradients.
  32593. * You must use addColorGradient and removeColorGradient to udpate this list
  32594. * @returns the list of color gradients
  32595. */
  32596. getColorGradients(): Nullable<Array<ColorGradient>>;
  32597. /**
  32598. * Adds a new ramp gradient used to remap particle colors
  32599. * @param gradient defines the gradient to use (between 0 and 1)
  32600. * @param color defines the color to affect to the specified gradient
  32601. * @returns the current particle system
  32602. */
  32603. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32604. /**
  32605. * Gets the current list of ramp gradients.
  32606. * You must use addRampGradient and removeRampGradient to udpate this list
  32607. * @returns the list of ramp gradients
  32608. */
  32609. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32610. /** Gets or sets a boolean indicating that ramp gradients must be used
  32611. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32612. */
  32613. useRampGradients: boolean;
  32614. /**
  32615. * Adds a new color remap gradient
  32616. * @param gradient defines the gradient to use (between 0 and 1)
  32617. * @param min defines the color remap minimal range
  32618. * @param max defines the color remap maximal range
  32619. * @returns the current particle system
  32620. */
  32621. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32622. /**
  32623. * Gets the current list of color remap gradients.
  32624. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32625. * @returns the list of color remap gradients
  32626. */
  32627. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32628. /**
  32629. * Adds a new alpha remap gradient
  32630. * @param gradient defines the gradient to use (between 0 and 1)
  32631. * @param min defines the alpha remap minimal range
  32632. * @param max defines the alpha remap maximal range
  32633. * @returns the current particle system
  32634. */
  32635. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32636. /**
  32637. * Gets the current list of alpha remap gradients.
  32638. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32639. * @returns the list of alpha remap gradients
  32640. */
  32641. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32642. /**
  32643. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32644. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32645. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32646. * @returns the emitter
  32647. */
  32648. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32649. /**
  32650. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32651. * @param radius The radius of the hemisphere to emit from
  32652. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32653. * @returns the emitter
  32654. */
  32655. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  32656. /**
  32657. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32658. * @param radius The radius of the sphere to emit from
  32659. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32660. * @returns the emitter
  32661. */
  32662. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  32663. /**
  32664. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32665. * @param radius The radius of the sphere to emit from
  32666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32668. * @returns the emitter
  32669. */
  32670. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32671. /**
  32672. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32673. * @param radius The radius of the emission cylinder
  32674. * @param height The height of the emission cylinder
  32675. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32676. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32677. * @returns the emitter
  32678. */
  32679. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  32680. /**
  32681. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32682. * @param radius The radius of the cylinder to emit from
  32683. * @param height The height of the emission cylinder
  32684. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32687. * @returns the emitter
  32688. */
  32689. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32690. /**
  32691. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32692. * @param radius The radius of the cone to emit from
  32693. * @param angle The base angle of the cone
  32694. * @returns the emitter
  32695. */
  32696. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  32697. /**
  32698. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32701. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32702. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32703. * @returns the emitter
  32704. */
  32705. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32706. /**
  32707. * Get hosting scene
  32708. * @returns the scene
  32709. */
  32710. getScene(): Scene;
  32711. }
  32712. }
  32713. declare module BABYLON {
  32714. /**
  32715. * A particle represents one of the element emitted by a particle system.
  32716. * This is mainly define by its coordinates, direction, velocity and age.
  32717. */
  32718. class Particle {
  32719. /**
  32720. * The particle system the particle belongs to.
  32721. */
  32722. particleSystem: ParticleSystem;
  32723. private static _Count;
  32724. /**
  32725. * Unique ID of the particle
  32726. */
  32727. id: number;
  32728. /**
  32729. * The world position of the particle in the scene.
  32730. */
  32731. position: Vector3;
  32732. /**
  32733. * The world direction of the particle in the scene.
  32734. */
  32735. direction: Vector3;
  32736. /**
  32737. * The color of the particle.
  32738. */
  32739. color: Color4;
  32740. /**
  32741. * The color change of the particle per step.
  32742. */
  32743. colorStep: Color4;
  32744. /**
  32745. * Defines how long will the life of the particle be.
  32746. */
  32747. lifeTime: number;
  32748. /**
  32749. * The current age of the particle.
  32750. */
  32751. age: number;
  32752. /**
  32753. * The current size of the particle.
  32754. */
  32755. size: number;
  32756. /**
  32757. * The current scale of the particle.
  32758. */
  32759. scale: Vector2;
  32760. /**
  32761. * The current angle of the particle.
  32762. */
  32763. angle: number;
  32764. /**
  32765. * Defines how fast is the angle changing.
  32766. */
  32767. angularSpeed: number;
  32768. /**
  32769. * Defines the cell index used by the particle to be rendered from a sprite.
  32770. */
  32771. cellIndex: number;
  32772. /**
  32773. * The information required to support color remapping
  32774. */
  32775. remapData: Vector4;
  32776. /** @hidden */
  32777. _randomCellOffset?: number;
  32778. /** @hidden */
  32779. _initialDirection: Nullable<Vector3>;
  32780. /** @hidden */
  32781. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  32782. /** @hidden */
  32783. _initialStartSpriteCellID: number;
  32784. /** @hidden */
  32785. _initialEndSpriteCellID: number;
  32786. /** @hidden */
  32787. _currentColorGradient: Nullable<ColorGradient>;
  32788. /** @hidden */
  32789. _currentColor1: Color4;
  32790. /** @hidden */
  32791. _currentColor2: Color4;
  32792. /** @hidden */
  32793. _currentSizeGradient: Nullable<FactorGradient>;
  32794. /** @hidden */
  32795. _currentSize1: number;
  32796. /** @hidden */
  32797. _currentSize2: number;
  32798. /** @hidden */
  32799. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  32800. /** @hidden */
  32801. _currentAngularSpeed1: number;
  32802. /** @hidden */
  32803. _currentAngularSpeed2: number;
  32804. /** @hidden */
  32805. _currentVelocityGradient: Nullable<FactorGradient>;
  32806. /** @hidden */
  32807. _currentVelocity1: number;
  32808. /** @hidden */
  32809. _currentVelocity2: number;
  32810. /** @hidden */
  32811. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  32812. /** @hidden */
  32813. _currentLimitVelocity1: number;
  32814. /** @hidden */
  32815. _currentLimitVelocity2: number;
  32816. /** @hidden */
  32817. _currentDragGradient: Nullable<FactorGradient>;
  32818. /** @hidden */
  32819. _currentDrag1: number;
  32820. /** @hidden */
  32821. _currentDrag2: number;
  32822. /** @hidden */
  32823. _randomNoiseCoordinates1: Vector3;
  32824. /** @hidden */
  32825. _randomNoiseCoordinates2: Vector3;
  32826. /**
  32827. * Creates a new instance Particle
  32828. * @param particleSystem the particle system the particle belongs to
  32829. */
  32830. constructor(
  32831. /**
  32832. * The particle system the particle belongs to.
  32833. */
  32834. particleSystem: ParticleSystem);
  32835. private updateCellInfoFromSystem;
  32836. /**
  32837. * Defines how the sprite cell index is updated for the particle
  32838. */
  32839. updateCellIndex(): void;
  32840. /** @hidden */
  32841. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  32842. /** @hidden */
  32843. _inheritParticleInfoToSubEmitters(): void;
  32844. /** @hidden */
  32845. _reset(): void;
  32846. /**
  32847. * Copy the properties of particle to another one.
  32848. * @param other the particle to copy the information to.
  32849. */
  32850. copyTo(other: Particle): void;
  32851. }
  32852. }
  32853. declare module BABYLON {
  32854. /**
  32855. * This class is made for on one-liner static method to help creating particle system set.
  32856. */
  32857. class ParticleHelper {
  32858. /**
  32859. * Gets or sets base Assets URL
  32860. */
  32861. static BaseAssetsUrl: string;
  32862. /**
  32863. * Create a default particle system that you can tweak
  32864. * @param emitter defines the emitter to use
  32865. * @param capacity defines the system capacity (default is 500 particles)
  32866. * @param scene defines the hosting scene
  32867. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  32868. * @returns the new Particle system
  32869. */
  32870. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  32871. /**
  32872. * This is the main static method (one-liner) of this helper to create different particle systems
  32873. * @param type This string represents the type to the particle system to create
  32874. * @param scene The scene where the particle system should live
  32875. * @param gpu If the system will use gpu
  32876. * @returns the ParticleSystemSet created
  32877. */
  32878. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  32879. /**
  32880. * Static function used to export a particle system to a ParticleSystemSet variable.
  32881. * Please note that the emitter shape is not exported
  32882. * @param systems defines the particle systems to export
  32883. * @returns the created particle system set
  32884. */
  32885. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  32886. }
  32887. }
  32888. declare module BABYLON {
  32889. /**
  32890. * This represents a particle system in Babylon.
  32891. * 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.
  32892. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  32893. * @example https://doc.babylonjs.com/babylon101/particles
  32894. */
  32895. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  32896. /**
  32897. * Billboard mode will only apply to Y axis
  32898. */
  32899. static readonly BILLBOARDMODE_Y: number;
  32900. /**
  32901. * Billboard mode will apply to all axes
  32902. */
  32903. static readonly BILLBOARDMODE_ALL: number;
  32904. /**
  32905. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  32906. */
  32907. static readonly BILLBOARDMODE_STRETCHED: number;
  32908. /**
  32909. * This function can be defined to provide custom update for active particles.
  32910. * This function will be called instead of regular update (age, position, color, etc.).
  32911. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  32912. */
  32913. updateFunction: (particles: Particle[]) => void;
  32914. private _emitterWorldMatrix;
  32915. /**
  32916. * This function can be defined to specify initial direction for every new particle.
  32917. * It by default use the emitterType defined function
  32918. */
  32919. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  32920. /**
  32921. * This function can be defined to specify initial position for every new particle.
  32922. * It by default use the emitterType defined function
  32923. */
  32924. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  32925. /**
  32926. * @hidden
  32927. */
  32928. _inheritedVelocityOffset: Vector3;
  32929. /**
  32930. * An event triggered when the system is disposed
  32931. */
  32932. onDisposeObservable: Observable<ParticleSystem>;
  32933. private _onDisposeObserver;
  32934. /**
  32935. * Sets a callback that will be triggered when the system is disposed
  32936. */
  32937. onDispose: () => void;
  32938. private _particles;
  32939. private _epsilon;
  32940. private _capacity;
  32941. private _stockParticles;
  32942. private _newPartsExcess;
  32943. private _vertexData;
  32944. private _vertexBuffer;
  32945. private _vertexBuffers;
  32946. private _spriteBuffer;
  32947. private _indexBuffer;
  32948. private _effect;
  32949. private _customEffect;
  32950. private _cachedDefines;
  32951. private _scaledColorStep;
  32952. private _colorDiff;
  32953. private _scaledDirection;
  32954. private _scaledGravity;
  32955. private _currentRenderId;
  32956. private _alive;
  32957. private _useInstancing;
  32958. private _started;
  32959. private _stopped;
  32960. private _actualFrame;
  32961. private _scaledUpdateSpeed;
  32962. private _vertexBufferSize;
  32963. /** @hidden */
  32964. _currentEmitRateGradient: Nullable<FactorGradient>;
  32965. /** @hidden */
  32966. _currentEmitRate1: number;
  32967. /** @hidden */
  32968. _currentEmitRate2: number;
  32969. /** @hidden */
  32970. _currentStartSizeGradient: Nullable<FactorGradient>;
  32971. /** @hidden */
  32972. _currentStartSize1: number;
  32973. /** @hidden */
  32974. _currentStartSize2: number;
  32975. private readonly _rawTextureWidth;
  32976. private _rampGradientsTexture;
  32977. private _useRampGradients;
  32978. /** Gets or sets a boolean indicating that ramp gradients must be used
  32979. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32980. */
  32981. useRampGradients: boolean;
  32982. /**
  32983. * 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.
  32984. * 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: [])
  32985. */
  32986. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32987. private _subEmitters;
  32988. /**
  32989. * @hidden
  32990. * If the particle systems emitter should be disposed when the particle system is disposed
  32991. */
  32992. _disposeEmitterOnDispose: boolean;
  32993. /**
  32994. * The current active Sub-systems, this property is used by the root particle system only.
  32995. */
  32996. activeSubSystems: Array<ParticleSystem>;
  32997. private _rootParticleSystem;
  32998. /**
  32999. * Gets the current list of active particles
  33000. */
  33001. readonly particles: Particle[];
  33002. /**
  33003. * Returns the string "ParticleSystem"
  33004. * @returns a string containing the class name
  33005. */
  33006. getClassName(): string;
  33007. /**
  33008. * Instantiates a particle system.
  33009. * 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.
  33010. * @param name The name of the particle system
  33011. * @param capacity The max number of particles alive at the same time
  33012. * @param scene The scene the particle system belongs to
  33013. * @param customEffect a custom effect used to change the way particles are rendered by default
  33014. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  33015. * @param epsilon Offset used to render the particles
  33016. */
  33017. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  33018. private _addFactorGradient;
  33019. private _removeFactorGradient;
  33020. /**
  33021. * Adds a new life time gradient
  33022. * @param gradient defines the gradient to use (between 0 and 1)
  33023. * @param factor defines the life time factor to affect to the specified gradient
  33024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33025. * @returns the current particle system
  33026. */
  33027. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33028. /**
  33029. * Remove a specific life time gradient
  33030. * @param gradient defines the gradient to remove
  33031. * @returns the current particle system
  33032. */
  33033. removeLifeTimeGradient(gradient: number): IParticleSystem;
  33034. /**
  33035. * Adds a new size gradient
  33036. * @param gradient defines the gradient to use (between 0 and 1)
  33037. * @param factor defines the size factor to affect to the specified gradient
  33038. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33039. * @returns the current particle system
  33040. */
  33041. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33042. /**
  33043. * Remove a specific size gradient
  33044. * @param gradient defines the gradient to remove
  33045. * @returns the current particle system
  33046. */
  33047. removeSizeGradient(gradient: number): IParticleSystem;
  33048. /**
  33049. * Adds a new color remap gradient
  33050. * @param gradient defines the gradient to use (between 0 and 1)
  33051. * @param min defines the color remap minimal range
  33052. * @param max defines the color remap maximal range
  33053. * @returns the current particle system
  33054. */
  33055. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33056. /**
  33057. * Remove a specific color remap gradient
  33058. * @param gradient defines the gradient to remove
  33059. * @returns the current particle system
  33060. */
  33061. removeColorRemapGradient(gradient: number): IParticleSystem;
  33062. /**
  33063. * Adds a new alpha remap gradient
  33064. * @param gradient defines the gradient to use (between 0 and 1)
  33065. * @param min defines the alpha remap minimal range
  33066. * @param max defines the alpha remap maximal range
  33067. * @returns the current particle system
  33068. */
  33069. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  33070. /**
  33071. * Remove a specific alpha remap gradient
  33072. * @param gradient defines the gradient to remove
  33073. * @returns the current particle system
  33074. */
  33075. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  33076. /**
  33077. * Adds a new angular speed gradient
  33078. * @param gradient defines the gradient to use (between 0 and 1)
  33079. * @param factor defines the angular speed to affect to the specified gradient
  33080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33081. * @returns the current particle system
  33082. */
  33083. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33084. /**
  33085. * Remove a specific angular speed gradient
  33086. * @param gradient defines the gradient to remove
  33087. * @returns the current particle system
  33088. */
  33089. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  33090. /**
  33091. * Adds a new velocity gradient
  33092. * @param gradient defines the gradient to use (between 0 and 1)
  33093. * @param factor defines the velocity to affect to the specified gradient
  33094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33095. * @returns the current particle system
  33096. */
  33097. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33098. /**
  33099. * Remove a specific velocity gradient
  33100. * @param gradient defines the gradient to remove
  33101. * @returns the current particle system
  33102. */
  33103. removeVelocityGradient(gradient: number): IParticleSystem;
  33104. /**
  33105. * Adds a new limit velocity gradient
  33106. * @param gradient defines the gradient to use (between 0 and 1)
  33107. * @param factor defines the limit velocity value to affect to the specified gradient
  33108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33109. * @returns the current particle system
  33110. */
  33111. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33112. /**
  33113. * Remove a specific limit velocity gradient
  33114. * @param gradient defines the gradient to remove
  33115. * @returns the current particle system
  33116. */
  33117. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33118. /**
  33119. * Adds a new drag gradient
  33120. * @param gradient defines the gradient to use (between 0 and 1)
  33121. * @param factor defines the drag value to affect to the specified gradient
  33122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33123. * @returns the current particle system
  33124. */
  33125. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33126. /**
  33127. * Remove a specific drag gradient
  33128. * @param gradient defines the gradient to remove
  33129. * @returns the current particle system
  33130. */
  33131. removeDragGradient(gradient: number): IParticleSystem;
  33132. /**
  33133. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33134. * @param gradient defines the gradient to use (between 0 and 1)
  33135. * @param factor defines the emit rate value to affect to the specified gradient
  33136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33137. * @returns the current particle system
  33138. */
  33139. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33140. /**
  33141. * Remove a specific emit rate gradient
  33142. * @param gradient defines the gradient to remove
  33143. * @returns the current particle system
  33144. */
  33145. removeEmitRateGradient(gradient: number): IParticleSystem;
  33146. /**
  33147. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33148. * @param gradient defines the gradient to use (between 0 and 1)
  33149. * @param factor defines the start size value to affect to the specified gradient
  33150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33151. * @returns the current particle system
  33152. */
  33153. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33154. /**
  33155. * Remove a specific start size gradient
  33156. * @param gradient defines the gradient to remove
  33157. * @returns the current particle system
  33158. */
  33159. removeStartSizeGradient(gradient: number): IParticleSystem;
  33160. private _createRampGradientTexture;
  33161. /**
  33162. * Gets the current list of ramp gradients.
  33163. * You must use addRampGradient and removeRampGradient to udpate this list
  33164. * @returns the list of ramp gradients
  33165. */
  33166. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33167. /**
  33168. * Adds a new ramp gradient used to remap particle colors
  33169. * @param gradient defines the gradient to use (between 0 and 1)
  33170. * @param color defines the color to affect to the specified gradient
  33171. * @returns the current particle system
  33172. */
  33173. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  33174. /**
  33175. * Remove a specific ramp gradient
  33176. * @param gradient defines the gradient to remove
  33177. * @returns the current particle system
  33178. */
  33179. removeRampGradient(gradient: number): ParticleSystem;
  33180. /**
  33181. * Adds a new color gradient
  33182. * @param gradient defines the gradient to use (between 0 and 1)
  33183. * @param color1 defines the color to affect to the specified gradient
  33184. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33185. * @returns this particle system
  33186. */
  33187. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33188. /**
  33189. * Remove a specific color gradient
  33190. * @param gradient defines the gradient to remove
  33191. * @returns this particle system
  33192. */
  33193. removeColorGradient(gradient: number): IParticleSystem;
  33194. private _fetchR;
  33195. protected _reset(): void;
  33196. private _resetEffect;
  33197. private _createVertexBuffers;
  33198. private _createIndexBuffer;
  33199. /**
  33200. * Gets the maximum number of particles active at the same time.
  33201. * @returns The max number of active particles.
  33202. */
  33203. getCapacity(): number;
  33204. /**
  33205. * Gets whether there are still active particles in the system.
  33206. * @returns True if it is alive, otherwise false.
  33207. */
  33208. isAlive(): boolean;
  33209. /**
  33210. * Gets if the system has been started. (Note: this will still be true after stop is called)
  33211. * @returns True if it has been started, otherwise false.
  33212. */
  33213. isStarted(): boolean;
  33214. private _prepareSubEmitterInternalArray;
  33215. /**
  33216. * Starts the particle system and begins to emit
  33217. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  33218. */
  33219. start(delay?: number): void;
  33220. /**
  33221. * Stops the particle system.
  33222. * @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.
  33223. */
  33224. stop(stopSubEmitters?: boolean): void;
  33225. /**
  33226. * Remove all active particles
  33227. */
  33228. reset(): void;
  33229. /**
  33230. * @hidden (for internal use only)
  33231. */
  33232. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  33233. /**
  33234. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  33235. * Its lifetime will start back at 0.
  33236. */
  33237. recycleParticle: (particle: Particle) => void;
  33238. private _stopSubEmitters;
  33239. private _createParticle;
  33240. private _removeFromRoot;
  33241. private _emitFromParticle;
  33242. private _update;
  33243. /** @hidden */
  33244. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  33245. /** @hidden */
  33246. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  33247. /** @hidden */
  33248. private _getEffect;
  33249. /**
  33250. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  33251. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  33252. */
  33253. animate(preWarmOnly?: boolean): void;
  33254. private _appendParticleVertices;
  33255. /**
  33256. * Rebuilds the particle system.
  33257. */
  33258. rebuild(): void;
  33259. /**
  33260. * Is this system ready to be used/rendered
  33261. * @return true if the system is ready
  33262. */
  33263. isReady(): boolean;
  33264. private _render;
  33265. /**
  33266. * Renders the particle system in its current state.
  33267. * @returns the current number of particles
  33268. */
  33269. render(): number;
  33270. /**
  33271. * Disposes the particle system and free the associated resources
  33272. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  33273. */
  33274. dispose(disposeTexture?: boolean): void;
  33275. /**
  33276. * Clones the particle system.
  33277. * @param name The name of the cloned object
  33278. * @param newEmitter The new emitter to use
  33279. * @returns the cloned particle system
  33280. */
  33281. clone(name: string, newEmitter: any): ParticleSystem;
  33282. /**
  33283. * Serializes the particle system to a JSON object.
  33284. * @returns the JSON object
  33285. */
  33286. serialize(): any;
  33287. /** @hidden */
  33288. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33289. /** @hidden */
  33290. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33291. /**
  33292. * Parses a JSON object to create a particle system.
  33293. * @param parsedParticleSystem The JSON object to parse
  33294. * @param scene The scene to create the particle system in
  33295. * @param rootUrl The root url to use to load external dependencies like texture
  33296. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33297. * @returns the Parsed particle system
  33298. */
  33299. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33300. }
  33301. }
  33302. declare module BABYLON {
  33303. interface Engine {
  33304. /**
  33305. * Create an effect to use with particle systems.
  33306. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33307. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33308. * @param uniformsNames defines a list of attribute names
  33309. * @param samplers defines an array of string used to represent textures
  33310. * @param defines defines the string containing the defines to use to compile the shaders
  33311. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33312. * @param onCompiled defines a function to call when the effect creation is successful
  33313. * @param onError defines a function to call when the effect creation has failed
  33314. * @returns the new Effect
  33315. */
  33316. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33317. }
  33318. interface Mesh {
  33319. /**
  33320. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33321. * @returns an array of IParticleSystem
  33322. */
  33323. getEmittedParticleSystems(): IParticleSystem[];
  33324. /**
  33325. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33326. * @returns an array of IParticleSystem
  33327. */
  33328. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33329. }
  33330. }
  33331. declare module BABYLON {
  33332. /**
  33333. * Represents a set of particle systems working together to create a specific effect
  33334. */
  33335. class ParticleSystemSet implements IDisposable {
  33336. private _emitterCreationOptions;
  33337. private _emitterNode;
  33338. /**
  33339. * Gets the particle system list
  33340. */
  33341. systems: IParticleSystem[];
  33342. /**
  33343. * Gets the emitter node used with this set
  33344. */
  33345. readonly emitterNode: Nullable<TransformNode>;
  33346. /**
  33347. * Creates a new emitter mesh as a sphere
  33348. * @param options defines the options used to create the sphere
  33349. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33350. * @param scene defines the hosting scene
  33351. */
  33352. setEmitterAsSphere(options: {
  33353. diameter: number;
  33354. segments: number;
  33355. color: Color3;
  33356. }, renderingGroupId: number, scene: Scene): void;
  33357. /**
  33358. * Starts all particle systems of the set
  33359. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33360. */
  33361. start(emitter?: AbstractMesh): void;
  33362. /**
  33363. * Release all associated resources
  33364. */
  33365. dispose(): void;
  33366. /**
  33367. * Serialize the set into a JSON compatible object
  33368. * @returns a JSON compatible representation of the set
  33369. */
  33370. serialize(): any;
  33371. /**
  33372. * Parse a new ParticleSystemSet from a serialized source
  33373. * @param data defines a JSON compatible representation of the set
  33374. * @param scene defines the hosting scene
  33375. * @param gpu defines if we want GPU particles or CPU particles
  33376. * @returns a new ParticleSystemSet
  33377. */
  33378. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33379. }
  33380. }
  33381. declare module BABYLON {
  33382. /**
  33383. * Represents one particle of a solid particle system.
  33384. */
  33385. class SolidParticle {
  33386. /**
  33387. * particle global index
  33388. */
  33389. idx: number;
  33390. /**
  33391. * The color of the particle
  33392. */
  33393. color: Nullable<Color4>;
  33394. /**
  33395. * The world space position of the particle.
  33396. */
  33397. position: Vector3;
  33398. /**
  33399. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33400. */
  33401. rotation: Vector3;
  33402. /**
  33403. * The world space rotation quaternion of the particle.
  33404. */
  33405. rotationQuaternion: Nullable<Quaternion>;
  33406. /**
  33407. * The scaling of the particle.
  33408. */
  33409. scaling: Vector3;
  33410. /**
  33411. * The uvs of the particle.
  33412. */
  33413. uvs: Vector4;
  33414. /**
  33415. * The current speed of the particle.
  33416. */
  33417. velocity: Vector3;
  33418. /**
  33419. * The pivot point in the particle local space.
  33420. */
  33421. pivot: Vector3;
  33422. /**
  33423. * Must the particle be translated from its pivot point in its local space ?
  33424. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  33425. * Default : false
  33426. */
  33427. translateFromPivot: boolean;
  33428. /**
  33429. * Is the particle active or not ?
  33430. */
  33431. alive: boolean;
  33432. /**
  33433. * Is the particle visible or not ?
  33434. */
  33435. isVisible: boolean;
  33436. /**
  33437. * Index of this particle in the global "positions" array (Internal use)
  33438. * @hidden
  33439. */
  33440. _pos: number;
  33441. /**
  33442. * @hidden Index of this particle in the global "indices" array (Internal use)
  33443. */
  33444. _ind: number;
  33445. /**
  33446. * @hidden ModelShape of this particle (Internal use)
  33447. */
  33448. _model: ModelShape;
  33449. /**
  33450. * ModelShape id of this particle
  33451. */
  33452. shapeId: number;
  33453. /**
  33454. * Index of the particle in its shape id (Internal use)
  33455. */
  33456. idxInShape: number;
  33457. /**
  33458. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  33459. */
  33460. _modelBoundingInfo: BoundingInfo;
  33461. /**
  33462. * @hidden Particle BoundingInfo object (Internal use)
  33463. */
  33464. _boundingInfo: BoundingInfo;
  33465. /**
  33466. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  33467. */
  33468. _sps: SolidParticleSystem;
  33469. /**
  33470. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33471. */
  33472. _stillInvisible: boolean;
  33473. /**
  33474. * @hidden Last computed particle rotation matrix
  33475. */
  33476. _rotationMatrix: number[];
  33477. /**
  33478. * Parent particle Id, if any.
  33479. * Default null.
  33480. */
  33481. parentId: Nullable<number>;
  33482. /**
  33483. * @hidden Internal global position in the SPS.
  33484. */
  33485. _globalPosition: Vector3;
  33486. /**
  33487. * Creates a Solid Particle object.
  33488. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33489. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  33490. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33491. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33492. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33493. * @param shapeId (integer) is the model shape identifier in the SPS.
  33494. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33495. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33496. */
  33497. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  33498. /**
  33499. * Legacy support, changed scale to scaling
  33500. */
  33501. /**
  33502. * Legacy support, changed scale to scaling
  33503. */
  33504. scale: Vector3;
  33505. /**
  33506. * Legacy support, changed quaternion to rotationQuaternion
  33507. */
  33508. /**
  33509. * Legacy support, changed quaternion to rotationQuaternion
  33510. */
  33511. quaternion: Nullable<Quaternion>;
  33512. /**
  33513. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33514. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33515. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33516. * @returns true if it intersects
  33517. */
  33518. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33519. /**
  33520. * get the rotation matrix of the particle
  33521. * @hidden
  33522. */
  33523. getRotationMatrix(m: Matrix): void;
  33524. }
  33525. /**
  33526. * Represents the shape of the model used by one particle of a solid particle system.
  33527. * SPS internal tool, don't use it manually.
  33528. */
  33529. class ModelShape {
  33530. /**
  33531. * The shape id
  33532. * @hidden
  33533. */
  33534. shapeID: number;
  33535. /**
  33536. * flat array of model positions (internal use)
  33537. * @hidden
  33538. */
  33539. _shape: Vector3[];
  33540. /**
  33541. * flat array of model UVs (internal use)
  33542. * @hidden
  33543. */
  33544. _shapeUV: number[];
  33545. /**
  33546. * length of the shape in the model indices array (internal use)
  33547. * @hidden
  33548. */
  33549. _indicesLength: number;
  33550. /**
  33551. * Custom position function (internal use)
  33552. * @hidden
  33553. */
  33554. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33555. /**
  33556. * Custom vertex function (internal use)
  33557. * @hidden
  33558. */
  33559. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33560. /**
  33561. * 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.
  33562. * SPS internal tool, don't use it manually.
  33563. * @hidden
  33564. */
  33565. 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>);
  33566. }
  33567. /**
  33568. * Represents a Depth Sorted Particle in the solid particle system.
  33569. */
  33570. class DepthSortedParticle {
  33571. /**
  33572. * Index of the particle in the "indices" array
  33573. */
  33574. ind: number;
  33575. /**
  33576. * Length of the particle shape in the "indices" array
  33577. */
  33578. indicesLength: number;
  33579. /**
  33580. * Squared distance from the particle to the camera
  33581. */
  33582. sqDistance: number;
  33583. }
  33584. }
  33585. declare module BABYLON {
  33586. /**
  33587. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  33588. *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.
  33589. * The SPS is also a particle system. It provides some methods to manage the particles.
  33590. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  33591. *
  33592. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  33593. */
  33594. class SolidParticleSystem implements IDisposable {
  33595. /**
  33596. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  33597. * Example : var p = SPS.particles[i];
  33598. */
  33599. particles: SolidParticle[];
  33600. /**
  33601. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  33602. */
  33603. nbParticles: number;
  33604. /**
  33605. * If the particles must ever face the camera (default false). Useful for planar particles.
  33606. */
  33607. billboard: boolean;
  33608. /**
  33609. * Recompute normals when adding a shape
  33610. */
  33611. recomputeNormals: boolean;
  33612. /**
  33613. * This a counter ofr your own usage. It's not set by any SPS functions.
  33614. */
  33615. counter: number;
  33616. /**
  33617. * The SPS name. This name is also given to the underlying mesh.
  33618. */
  33619. name: string;
  33620. /**
  33621. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  33622. */
  33623. mesh: Mesh;
  33624. /**
  33625. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  33626. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  33627. */
  33628. vars: any;
  33629. /**
  33630. * This array is populated when the SPS is set as 'pickable'.
  33631. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  33632. * Each element of this array is an object `{idx: int, faceId: int}`.
  33633. * `idx` is the picked particle index in the `SPS.particles` array
  33634. * `faceId` is the picked face index counted within this particle.
  33635. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  33636. */
  33637. pickedParticles: {
  33638. idx: number;
  33639. faceId: number;
  33640. }[];
  33641. /**
  33642. * This array is populated when `enableDepthSort` is set to true.
  33643. * Each element of this array is an instance of the class DepthSortedParticle.
  33644. */
  33645. depthSortedParticles: DepthSortedParticle[];
  33646. /**
  33647. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  33648. * @hidden
  33649. */
  33650. _bSphereOnly: boolean;
  33651. /**
  33652. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  33653. * @hidden
  33654. */
  33655. _bSphereRadiusFactor: number;
  33656. private _scene;
  33657. private _positions;
  33658. private _indices;
  33659. private _normals;
  33660. private _colors;
  33661. private _uvs;
  33662. private _indices32;
  33663. private _positions32;
  33664. private _normals32;
  33665. private _fixedNormal32;
  33666. private _colors32;
  33667. private _uvs32;
  33668. private _index;
  33669. private _updatable;
  33670. private _pickable;
  33671. private _isVisibilityBoxLocked;
  33672. private _alwaysVisible;
  33673. private _depthSort;
  33674. private _shapeCounter;
  33675. private _copy;
  33676. private _color;
  33677. private _computeParticleColor;
  33678. private _computeParticleTexture;
  33679. private _computeParticleRotation;
  33680. private _computeParticleVertex;
  33681. private _computeBoundingBox;
  33682. private _depthSortParticles;
  33683. private _camera;
  33684. private _mustUnrotateFixedNormals;
  33685. private _particlesIntersect;
  33686. private _needs32Bits;
  33687. /**
  33688. * Creates a SPS (Solid Particle System) object.
  33689. * @param name (String) is the SPS name, this will be the underlying mesh name.
  33690. * @param scene (Scene) is the scene in which the SPS is added.
  33691. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  33692. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  33693. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  33694. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  33695. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  33696. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  33697. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  33698. */
  33699. constructor(name: string, scene: Scene, options?: {
  33700. updatable?: boolean;
  33701. isPickable?: boolean;
  33702. enableDepthSort?: boolean;
  33703. particleIntersection?: boolean;
  33704. boundingSphereOnly?: boolean;
  33705. bSphereRadiusFactor?: number;
  33706. });
  33707. /**
  33708. * Builds the SPS underlying mesh. Returns a standard Mesh.
  33709. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  33710. * @returns the created mesh
  33711. */
  33712. buildMesh(): Mesh;
  33713. /**
  33714. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  33715. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  33716. * Thus the particles generated from `digest()` have their property `position` set yet.
  33717. * @param mesh ( Mesh ) is the mesh to be digested
  33718. * @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
  33719. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  33720. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  33721. * @returns the current SPS
  33722. */
  33723. digest(mesh: Mesh, options?: {
  33724. facetNb?: number;
  33725. number?: number;
  33726. delta?: number;
  33727. }): SolidParticleSystem;
  33728. private _unrotateFixedNormals;
  33729. private _resetCopy;
  33730. private _meshBuilder;
  33731. private _posToShape;
  33732. private _uvsToShapeUV;
  33733. private _addParticle;
  33734. /**
  33735. * Adds some particles to the SPS from the model shape. Returns the shape id.
  33736. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  33737. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  33738. * @param nb (positive integer) the number of particles to be created from this model
  33739. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  33740. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  33741. * @returns the number of shapes in the system
  33742. */
  33743. addShape(mesh: Mesh, nb: number, options?: {
  33744. positionFunction?: any;
  33745. vertexFunction?: any;
  33746. }): number;
  33747. private _rebuildParticle;
  33748. /**
  33749. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  33750. * @returns the SPS.
  33751. */
  33752. rebuildMesh(): SolidParticleSystem;
  33753. /**
  33754. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  33755. * This method calls `updateParticle()` for each particle of the SPS.
  33756. * For an animated SPS, it is usually called within the render loop.
  33757. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  33758. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  33759. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  33760. * @returns the SPS.
  33761. */
  33762. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  33763. /**
  33764. * Disposes the SPS.
  33765. */
  33766. dispose(): void;
  33767. /**
  33768. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  33769. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33770. * @returns the SPS.
  33771. */
  33772. refreshVisibleSize(): SolidParticleSystem;
  33773. /**
  33774. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  33775. * @param size the size (float) of the visibility box
  33776. * note : this doesn't lock the SPS mesh bounding box.
  33777. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33778. */
  33779. setVisibilityBox(size: number): void;
  33780. /**
  33781. * Gets whether the SPS as always visible or not
  33782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33783. */
  33784. /**
  33785. * Sets the SPS as always visible or not
  33786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33787. */
  33788. isAlwaysVisible: boolean;
  33789. /**
  33790. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33792. */
  33793. /**
  33794. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33796. */
  33797. isVisibilityBoxLocked: boolean;
  33798. /**
  33799. * Tells to `setParticles()` to compute the particle rotations or not.
  33800. * Default value : true. The SPS is faster when it's set to false.
  33801. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33802. */
  33803. /**
  33804. * Gets if `setParticles()` computes the particle rotations or not.
  33805. * Default value : true. The SPS is faster when it's set to false.
  33806. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33807. */
  33808. computeParticleRotation: boolean;
  33809. /**
  33810. * Tells to `setParticles()` to compute the particle colors or not.
  33811. * Default value : true. The SPS is faster when it's set to false.
  33812. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33813. */
  33814. /**
  33815. * Gets if `setParticles()` computes the particle colors or not.
  33816. * Default value : true. The SPS is faster when it's set to false.
  33817. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33818. */
  33819. computeParticleColor: boolean;
  33820. /**
  33821. * Gets if `setParticles()` computes the particle textures or not.
  33822. * Default value : true. The SPS is faster when it's set to false.
  33823. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  33824. */
  33825. computeParticleTexture: boolean;
  33826. /**
  33827. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  33828. * Default value : false. The SPS is faster when it's set to false.
  33829. * Note : the particle custom vertex positions aren't stored values.
  33830. */
  33831. /**
  33832. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  33833. * Default value : false. The SPS is faster when it's set to false.
  33834. * Note : the particle custom vertex positions aren't stored values.
  33835. */
  33836. computeParticleVertex: boolean;
  33837. /**
  33838. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  33839. */
  33840. /**
  33841. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  33842. */
  33843. computeBoundingBox: boolean;
  33844. /**
  33845. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  33846. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33847. * Default : `true`
  33848. */
  33849. /**
  33850. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  33851. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33852. * Default : `true`
  33853. */
  33854. depthSortParticles: boolean;
  33855. /**
  33856. * This function does nothing. It may be overwritten to set all the particle first values.
  33857. * The SPS doesn't call this function, you may have to call it by your own.
  33858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33859. */
  33860. initParticles(): void;
  33861. /**
  33862. * This function does nothing. It may be overwritten to recycle a particle.
  33863. * The SPS doesn't call this function, you may have to call it by your own.
  33864. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33865. * @param particle The particle to recycle
  33866. * @returns the recycled particle
  33867. */
  33868. recycleParticle(particle: SolidParticle): SolidParticle;
  33869. /**
  33870. * Updates a particle : this function should be overwritten by the user.
  33871. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  33872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33873. * @example : just set a particle position or velocity and recycle conditions
  33874. * @param particle The particle to update
  33875. * @returns the updated particle
  33876. */
  33877. updateParticle(particle: SolidParticle): SolidParticle;
  33878. /**
  33879. * Updates a vertex of a particle : it can be overwritten by the user.
  33880. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  33881. * @param particle the current particle
  33882. * @param vertex the current index of the current particle
  33883. * @param pt the index of the current vertex in the particle shape
  33884. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  33885. * @example : just set a vertex particle position
  33886. * @returns the updated vertex
  33887. */
  33888. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  33889. /**
  33890. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  33891. * This does nothing and may be overwritten by the user.
  33892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33894. * @param update the boolean update value actually passed to setParticles()
  33895. */
  33896. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33897. /**
  33898. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  33899. * This will be passed three parameters.
  33900. * This does nothing and may be overwritten by the user.
  33901. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33903. * @param update the boolean update value actually passed to setParticles()
  33904. */
  33905. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Type of sub emitter
  33911. */
  33912. enum SubEmitterType {
  33913. /**
  33914. * Attached to the particle over it's lifetime
  33915. */
  33916. ATTACHED = 0,
  33917. /**
  33918. * Created when the particle dies
  33919. */
  33920. END = 1
  33921. }
  33922. /**
  33923. * Sub emitter class used to emit particles from an existing particle
  33924. */
  33925. class SubEmitter {
  33926. /**
  33927. * the particle system to be used by the sub emitter
  33928. */
  33929. particleSystem: ParticleSystem;
  33930. /**
  33931. * Type of the submitter (Default: END)
  33932. */
  33933. type: SubEmitterType;
  33934. /**
  33935. * 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)
  33936. * Note: This only is supported when using an emitter of type Mesh
  33937. */
  33938. inheritDirection: boolean;
  33939. /**
  33940. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  33941. */
  33942. inheritedVelocityAmount: number;
  33943. /**
  33944. * Creates a sub emitter
  33945. * @param particleSystem the particle system to be used by the sub emitter
  33946. */
  33947. constructor(
  33948. /**
  33949. * the particle system to be used by the sub emitter
  33950. */
  33951. particleSystem: ParticleSystem);
  33952. /**
  33953. * Clones the sub emitter
  33954. * @returns the cloned sub emitter
  33955. */
  33956. clone(): SubEmitter;
  33957. /**
  33958. * Serialize current object to a JSON object
  33959. * @returns the serialized object
  33960. */
  33961. serialize(): any;
  33962. /**
  33963. * Creates a new SubEmitter from a serialized JSON version
  33964. * @param serializationObject defines the JSON object to read from
  33965. * @param scene defines the hosting scene
  33966. * @param rootUrl defines the rootUrl for data loading
  33967. * @returns a new SubEmitter
  33968. */
  33969. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33970. /** Release associated resources */
  33971. dispose(): void;
  33972. }
  33973. }
  33974. declare module BABYLON {
  33975. interface Scene {
  33976. /**
  33977. * The list of reflection probes added to the scene
  33978. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33979. */
  33980. reflectionProbes: Array<ReflectionProbe>;
  33981. }
  33982. /**
  33983. * Class used to generate realtime reflection / refraction cube textures
  33984. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33985. */
  33986. class ReflectionProbe {
  33987. /** defines the name of the probe */
  33988. name: string;
  33989. private _scene;
  33990. private _renderTargetTexture;
  33991. private _projectionMatrix;
  33992. private _viewMatrix;
  33993. private _target;
  33994. private _add;
  33995. private _attachedMesh;
  33996. private _invertYAxis;
  33997. /** Gets or sets probe position (center of the cube map) */
  33998. position: Vector3;
  33999. /**
  34000. * Creates a new reflection probe
  34001. * @param name defines the name of the probe
  34002. * @param size defines the texture resolution (for each face)
  34003. * @param scene defines the hosting scene
  34004. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34005. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34006. */
  34007. constructor(
  34008. /** defines the name of the probe */
  34009. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34010. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34011. samples: number;
  34012. /** Gets or sets the refresh rate to use (on every frame by default) */
  34013. refreshRate: number;
  34014. /**
  34015. * Gets the hosting scene
  34016. * @returns a Scene
  34017. */
  34018. getScene(): Scene;
  34019. /** Gets the internal CubeTexture used to render to */
  34020. readonly cubeTexture: RenderTargetTexture;
  34021. /** Gets the list of meshes to render */
  34022. readonly renderList: Nullable<AbstractMesh[]>;
  34023. /**
  34024. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34025. * @param mesh defines the mesh to attach to
  34026. */
  34027. attachToMesh(mesh: AbstractMesh): void;
  34028. /**
  34029. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34030. * @param renderingGroupId The rendering group id corresponding to its index
  34031. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34032. */
  34033. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34034. /**
  34035. * Clean all associated resources
  34036. */
  34037. dispose(): void;
  34038. }
  34039. }
  34040. declare module BABYLON {
  34041. /**
  34042. * Postprocess used to generate anaglyphic rendering
  34043. */
  34044. class AnaglyphPostProcess extends PostProcess {
  34045. private _passedProcess;
  34046. /**
  34047. * Creates a new AnaglyphPostProcess
  34048. * @param name defines postprocess name
  34049. * @param options defines creation options or target ratio scale
  34050. * @param rigCameras defines cameras using this postprocess
  34051. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34052. * @param engine defines hosting engine
  34053. * @param reusable defines if the postprocess will be reused multiple times per frame
  34054. */
  34055. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34056. }
  34057. }
  34058. declare module BABYLON {
  34059. /**
  34060. * Post process used to render in black and white
  34061. */
  34062. class BlackAndWhitePostProcess extends PostProcess {
  34063. /**
  34064. * Linear about to convert he result to black and white (default: 1)
  34065. */
  34066. degree: number;
  34067. /**
  34068. * Creates a black and white post process
  34069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34070. * @param name The name of the effect.
  34071. * @param options The required width/height ratio to downsize to before computing the render pass.
  34072. * @param camera The camera to apply the render pass to.
  34073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34074. * @param engine The engine which the post process will be applied. (default: current engine)
  34075. * @param reusable If the post process can be reused on the same frame. (default: false)
  34076. */
  34077. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34078. }
  34079. }
  34080. declare module BABYLON {
  34081. /**
  34082. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34083. */
  34084. class BloomEffect extends PostProcessRenderEffect {
  34085. private bloomScale;
  34086. /**
  34087. * @hidden Internal
  34088. */
  34089. _effects: Array<PostProcess>;
  34090. /**
  34091. * @hidden Internal
  34092. */
  34093. _downscale: ExtractHighlightsPostProcess;
  34094. private _blurX;
  34095. private _blurY;
  34096. private _merge;
  34097. /**
  34098. * The luminance threshold to find bright areas of the image to bloom.
  34099. */
  34100. threshold: number;
  34101. /**
  34102. * The strength of the bloom.
  34103. */
  34104. weight: number;
  34105. /**
  34106. * Specifies the size of the bloom blur kernel, relative to the final output size
  34107. */
  34108. kernel: number;
  34109. /**
  34110. * Creates a new instance of @see BloomEffect
  34111. * @param scene The scene the effect belongs to.
  34112. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34113. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34114. * @param bloomWeight The the strength of bloom.
  34115. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34116. * @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)
  34117. */
  34118. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34119. /**
  34120. * Disposes each of the internal effects for a given camera.
  34121. * @param camera The camera to dispose the effect on.
  34122. */
  34123. disposeEffects(camera: Camera): void;
  34124. /**
  34125. * @hidden Internal
  34126. */
  34127. _updateEffects(): void;
  34128. /**
  34129. * Internal
  34130. * @returns if all the contained post processes are ready.
  34131. * @hidden
  34132. */
  34133. _isReady(): boolean;
  34134. }
  34135. }
  34136. declare module BABYLON {
  34137. /**
  34138. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34139. */
  34140. class BloomMergePostProcess extends PostProcess {
  34141. /** Weight of the bloom to be added to the original input. */
  34142. weight: number;
  34143. /**
  34144. * Creates a new instance of @see BloomMergePostProcess
  34145. * @param name The name of the effect.
  34146. * @param originalFromInput Post process which's input will be used for the merge.
  34147. * @param blurred Blurred highlights post process which's output will be used.
  34148. * @param weight Weight of the bloom to be added to the original input.
  34149. * @param options The required width/height ratio to downsize to before computing the render pass.
  34150. * @param camera The camera to apply the render pass to.
  34151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34152. * @param engine The engine which the post process will be applied. (default: current engine)
  34153. * @param reusable If the post process can be reused on the same frame. (default: false)
  34154. * @param textureType Type of textures used when performing the post process. (default: 0)
  34155. * @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)
  34156. */
  34157. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34158. /** Weight of the bloom to be added to the original input. */
  34159. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34160. }
  34161. }
  34162. declare module BABYLON {
  34163. /**
  34164. * The Blur Post Process which blurs an image based on a kernel and direction.
  34165. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34166. */
  34167. class BlurPostProcess extends PostProcess {
  34168. /** The direction in which to blur the image. */
  34169. direction: Vector2;
  34170. private blockCompilation;
  34171. protected _kernel: number;
  34172. protected _idealKernel: number;
  34173. protected _packedFloat: boolean;
  34174. private _staticDefines;
  34175. /**
  34176. * Sets the length in pixels of the blur sample region
  34177. */
  34178. /**
  34179. * Gets the length in pixels of the blur sample region
  34180. */
  34181. kernel: number;
  34182. /**
  34183. * Sets wether or not the blur needs to unpack/repack floats
  34184. */
  34185. /**
  34186. * Gets wether or not the blur is unpacking/repacking floats
  34187. */
  34188. packedFloat: boolean;
  34189. /**
  34190. * Creates a new instance BlurPostProcess
  34191. * @param name The name of the effect.
  34192. * @param direction The direction in which to blur the image.
  34193. * @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.
  34194. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  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. * @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)
  34201. */
  34202. constructor(name: string,
  34203. /** The direction in which to blur the image. */
  34204. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34205. /**
  34206. * Updates the effect with the current post process compile time values and recompiles the shader.
  34207. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34208. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34209. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34210. * @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
  34211. * @param onCompiled Called when the shader has been compiled.
  34212. * @param onError Called if there is an error when compiling a shader.
  34213. */
  34214. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34215. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34216. /**
  34217. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34218. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34219. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34220. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34221. * The gaps between physical kernels are compensated for in the weighting of the samples
  34222. * @param idealKernel Ideal blur kernel.
  34223. * @return Nearest best kernel.
  34224. */
  34225. protected _nearestBestKernel(idealKernel: number): number;
  34226. /**
  34227. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34228. * @param x The point on the Gaussian distribution to sample.
  34229. * @return the value of the Gaussian function at x.
  34230. */
  34231. protected _gaussianWeight(x: number): number;
  34232. /**
  34233. * Generates a string that can be used as a floating point number in GLSL.
  34234. * @param x Value to print.
  34235. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34236. * @return GLSL float string.
  34237. */
  34238. protected _glslFloat(x: number, decimalFigures?: number): string;
  34239. }
  34240. }
  34241. declare module BABYLON {
  34242. /**
  34243. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34244. */
  34245. class ChromaticAberrationPostProcess extends PostProcess {
  34246. /**
  34247. * The amount of seperation of rgb channels (default: 30)
  34248. */
  34249. aberrationAmount: number;
  34250. /**
  34251. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34252. */
  34253. radialIntensity: number;
  34254. /**
  34255. * 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))
  34256. */
  34257. direction: Vector2;
  34258. /**
  34259. * 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))
  34260. */
  34261. centerPosition: Vector2;
  34262. /**
  34263. * Creates a new instance ChromaticAberrationPostProcess
  34264. * @param name The name of the effect.
  34265. * @param screenWidth The width of the screen to apply the effect on.
  34266. * @param screenHeight The height of the screen to apply the effect on.
  34267. * @param options The required width/height ratio to downsize to before computing the render pass.
  34268. * @param camera The camera to apply the render pass to.
  34269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34270. * @param engine The engine which the post process will be applied. (default: current engine)
  34271. * @param reusable If the post process can be reused on the same frame. (default: false)
  34272. * @param textureType Type of textures used when performing the post process. (default: 0)
  34273. * @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)
  34274. */
  34275. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34276. }
  34277. }
  34278. declare module BABYLON {
  34279. /**
  34280. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34281. */
  34282. class CircleOfConfusionPostProcess extends PostProcess {
  34283. /**
  34284. * 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.
  34285. */
  34286. lensSize: number;
  34287. /**
  34288. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34289. */
  34290. fStop: number;
  34291. /**
  34292. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34293. */
  34294. focusDistance: number;
  34295. /**
  34296. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34297. */
  34298. focalLength: number;
  34299. private _depthTexture;
  34300. /**
  34301. * Creates a new instance CircleOfConfusionPostProcess
  34302. * @param name The name of the effect.
  34303. * @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.
  34304. * @param options The required width/height ratio to downsize to before computing the render pass.
  34305. * @param camera The camera to apply the render pass to.
  34306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34307. * @param engine The engine which the post process will be applied. (default: current engine)
  34308. * @param reusable If the post process can be reused on the same frame. (default: false)
  34309. * @param textureType Type of textures used when performing the post process. (default: 0)
  34310. * @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)
  34311. */
  34312. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34313. /**
  34314. * 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.
  34315. */
  34316. depthTexture: RenderTargetTexture;
  34317. }
  34318. }
  34319. declare module BABYLON {
  34320. /**
  34321. *
  34322. * This post-process allows the modification of rendered colors by using
  34323. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34324. *
  34325. * The object needs to be provided an url to a texture containing the color
  34326. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34327. * Use an image editing software to tweak the LUT to match your needs.
  34328. *
  34329. * For an example of a color LUT, see here:
  34330. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34331. * For explanations on color grading, see here:
  34332. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34333. *
  34334. */
  34335. class ColorCorrectionPostProcess extends PostProcess {
  34336. private _colorTableTexture;
  34337. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34338. }
  34339. }
  34340. declare module BABYLON {
  34341. /**
  34342. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34343. * input texture to perform effects such as edge detection or sharpening
  34344. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34345. */
  34346. class ConvolutionPostProcess extends PostProcess {
  34347. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34348. kernel: number[];
  34349. /**
  34350. * Creates a new instance ConvolutionPostProcess
  34351. * @param name The name of the effect.
  34352. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34353. * @param options The required width/height ratio to downsize to before computing the render pass.
  34354. * @param camera The camera to apply the render pass to.
  34355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34356. * @param engine The engine which the post process will be applied. (default: current engine)
  34357. * @param reusable If the post process can be reused on the same frame. (default: false)
  34358. * @param textureType Type of textures used when performing the post process. (default: 0)
  34359. */
  34360. constructor(name: string,
  34361. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34362. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34363. /**
  34364. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34365. */
  34366. static EdgeDetect0Kernel: number[];
  34367. /**
  34368. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34369. */
  34370. static EdgeDetect1Kernel: number[];
  34371. /**
  34372. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34373. */
  34374. static EdgeDetect2Kernel: number[];
  34375. /**
  34376. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34377. */
  34378. static SharpenKernel: number[];
  34379. /**
  34380. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34381. */
  34382. static EmbossKernel: number[];
  34383. /**
  34384. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34385. */
  34386. static GaussianKernel: number[];
  34387. }
  34388. }
  34389. declare module BABYLON {
  34390. /**
  34391. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34392. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34393. * based on samples that have a large difference in distance than the center pixel.
  34394. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34395. */
  34396. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34397. direction: Vector2;
  34398. /**
  34399. * Creates a new instance CircleOfConfusionPostProcess
  34400. * @param name The name of the effect.
  34401. * @param scene The scene the effect belongs to.
  34402. * @param direction The direction the blur should be applied.
  34403. * @param kernel The size of the kernel used to blur.
  34404. * @param options The required width/height ratio to downsize to before computing the render pass.
  34405. * @param camera The camera to apply the render pass to.
  34406. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34407. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34409. * @param engine The engine which the post process will be applied. (default: current engine)
  34410. * @param reusable If the post process can be reused on the same frame. (default: false)
  34411. * @param textureType Type of textures used when performing the post process. (default: 0)
  34412. * @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)
  34413. */
  34414. 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);
  34415. }
  34416. }
  34417. declare module BABYLON {
  34418. /**
  34419. * Specifies the level of max blur that should be applied when using the depth of field effect
  34420. */
  34421. enum DepthOfFieldEffectBlurLevel {
  34422. /**
  34423. * Subtle blur
  34424. */
  34425. Low = 0,
  34426. /**
  34427. * Medium blur
  34428. */
  34429. Medium = 1,
  34430. /**
  34431. * Large blur
  34432. */
  34433. High = 2
  34434. }
  34435. /**
  34436. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34437. */
  34438. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34439. private _circleOfConfusion;
  34440. /**
  34441. * @hidden Internal, blurs from high to low
  34442. */
  34443. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34444. private _depthOfFieldBlurY;
  34445. private _dofMerge;
  34446. /**
  34447. * @hidden Internal post processes in depth of field effect
  34448. */
  34449. _effects: Array<PostProcess>;
  34450. /**
  34451. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34452. */
  34453. focalLength: number;
  34454. /**
  34455. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34456. */
  34457. fStop: number;
  34458. /**
  34459. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34460. */
  34461. focusDistance: number;
  34462. /**
  34463. * 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.
  34464. */
  34465. lensSize: number;
  34466. /**
  34467. * Creates a new instance DepthOfFieldEffect
  34468. * @param scene The scene the effect belongs to.
  34469. * @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.
  34470. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34471. * @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)
  34472. */
  34473. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34474. /**
  34475. * 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.
  34476. */
  34477. depthTexture: RenderTargetTexture;
  34478. /**
  34479. * Disposes each of the internal effects for a given camera.
  34480. * @param camera The camera to dispose the effect on.
  34481. */
  34482. disposeEffects(camera: Camera): void;
  34483. /**
  34484. * @hidden Internal
  34485. */
  34486. _updateEffects(): void;
  34487. /**
  34488. * Internal
  34489. * @returns if all the contained post processes are ready.
  34490. * @hidden
  34491. */
  34492. _isReady(): boolean;
  34493. }
  34494. }
  34495. declare module BABYLON {
  34496. /**
  34497. * Options to be set when merging outputs from the default pipeline.
  34498. */
  34499. class DepthOfFieldMergePostProcessOptions {
  34500. /**
  34501. * The original image to merge on top of
  34502. */
  34503. originalFromInput: PostProcess;
  34504. /**
  34505. * Parameters to perform the merge of the depth of field effect
  34506. */
  34507. depthOfField?: {
  34508. circleOfConfusion: PostProcess;
  34509. blurSteps: Array<PostProcess>;
  34510. };
  34511. /**
  34512. * Parameters to perform the merge of bloom effect
  34513. */
  34514. bloom?: {
  34515. blurred: PostProcess;
  34516. weight: number;
  34517. };
  34518. }
  34519. /**
  34520. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34521. */
  34522. class DepthOfFieldMergePostProcess extends PostProcess {
  34523. private blurSteps;
  34524. /**
  34525. * Creates a new instance of DepthOfFieldMergePostProcess
  34526. * @param name The name of the effect.
  34527. * @param originalFromInput Post process which's input will be used for the merge.
  34528. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34529. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34530. * @param options The required width/height ratio to downsize to before computing the render pass.
  34531. * @param camera The camera to apply the render pass to.
  34532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34533. * @param engine The engine which the post process will be applied. (default: current engine)
  34534. * @param reusable If the post process can be reused on the same frame. (default: false)
  34535. * @param textureType Type of textures used when performing the post process. (default: 0)
  34536. * @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)
  34537. */
  34538. 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);
  34539. /**
  34540. * Updates the effect with the current post process compile time values and recompiles the shader.
  34541. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34542. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34543. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34544. * @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
  34545. * @param onCompiled Called when the shader has been compiled.
  34546. * @param onError Called if there is an error when compiling a shader.
  34547. */
  34548. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34549. }
  34550. }
  34551. declare module BABYLON {
  34552. /**
  34553. * DisplayPassPostProcess which produces an output the same as it's input
  34554. */
  34555. class DisplayPassPostProcess extends PostProcess {
  34556. /**
  34557. * Creates the DisplayPassPostProcess
  34558. * @param name The name of the effect.
  34559. * @param options The required width/height ratio to downsize to before computing the render pass.
  34560. * @param camera The camera to apply the render pass to.
  34561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34562. * @param engine The engine which the post process will be applied. (default: current engine)
  34563. * @param reusable If the post process can be reused on the same frame. (default: false)
  34564. */
  34565. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. /**
  34570. * 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.
  34571. */
  34572. class ExtractHighlightsPostProcess extends PostProcess {
  34573. /**
  34574. * The luminance threshold, pixels below this value will be set to black.
  34575. */
  34576. threshold: number;
  34577. /** @hidden */
  34578. _exposure: number;
  34579. /**
  34580. * Post process which has the input texture to be used when performing highlight extraction
  34581. * @hidden
  34582. */
  34583. _inputPostProcess: Nullable<PostProcess>;
  34584. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34585. }
  34586. }
  34587. declare module BABYLON {
  34588. /**
  34589. * Applies a kernel filter to the image
  34590. */
  34591. class FilterPostProcess extends PostProcess {
  34592. /** The matrix to be applied to the image */
  34593. kernelMatrix: Matrix;
  34594. /**
  34595. *
  34596. * @param name The name of the effect.
  34597. * @param kernelMatrix The matrix to be applied to the image
  34598. * @param options The required width/height ratio to downsize to before computing the render pass.
  34599. * @param camera The camera to apply the render pass to.
  34600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34601. * @param engine The engine which the post process will be applied. (default: current engine)
  34602. * @param reusable If the post process can be reused on the same frame. (default: false)
  34603. */
  34604. constructor(name: string,
  34605. /** The matrix to be applied to the image */
  34606. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34607. }
  34608. }
  34609. declare module BABYLON {
  34610. /**
  34611. * Fxaa post process
  34612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34613. */
  34614. class FxaaPostProcess extends PostProcess {
  34615. /** @hidden */
  34616. texelWidth: number;
  34617. /** @hidden */
  34618. texelHeight: number;
  34619. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34620. private _getDefines;
  34621. }
  34622. }
  34623. declare module BABYLON {
  34624. /**
  34625. * The GrainPostProcess adds noise to the image at mid luminance levels
  34626. */
  34627. class GrainPostProcess extends PostProcess {
  34628. /**
  34629. * The intensity of the grain added (default: 30)
  34630. */
  34631. intensity: number;
  34632. /**
  34633. * If the grain should be randomized on every frame
  34634. */
  34635. animated: boolean;
  34636. /**
  34637. * Creates a new instance of @see GrainPostProcess
  34638. * @param name The name of the effect.
  34639. * @param options The required width/height ratio to downsize to before computing the render pass.
  34640. * @param camera The camera to apply the render pass to.
  34641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34642. * @param engine The engine which the post process will be applied. (default: current engine)
  34643. * @param reusable If the post process can be reused on the same frame. (default: false)
  34644. * @param textureType Type of textures used when performing the post process. (default: 0)
  34645. * @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)
  34646. */
  34647. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34648. }
  34649. }
  34650. declare module BABYLON {
  34651. /**
  34652. * Extracts highlights from the image
  34653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34654. */
  34655. class HighlightsPostProcess extends PostProcess {
  34656. /**
  34657. * Extracts highlights from the image
  34658. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34659. * @param name The name of the effect.
  34660. * @param options The required width/height ratio to downsize to before computing the render pass.
  34661. * @param camera The camera to apply the render pass to.
  34662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34663. * @param engine The engine which the post process will be applied. (default: current engine)
  34664. * @param reusable If the post process can be reused on the same frame. (default: false)
  34665. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34666. */
  34667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34668. }
  34669. }
  34670. declare module BABYLON {
  34671. /**
  34672. * ImageProcessingPostProcess
  34673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34674. */
  34675. class ImageProcessingPostProcess extends PostProcess {
  34676. /**
  34677. * Default configuration related to image processing available in the PBR Material.
  34678. */
  34679. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34680. /**
  34681. * Gets the image processing configuration used either in this material.
  34682. */
  34683. /**
  34684. * Sets the Default image processing configuration used either in the this material.
  34685. *
  34686. * If sets to null, the scene one is in use.
  34687. */
  34688. imageProcessingConfiguration: ImageProcessingConfiguration;
  34689. /**
  34690. * Keep track of the image processing observer to allow dispose and replace.
  34691. */
  34692. private _imageProcessingObserver;
  34693. /**
  34694. * Attaches a new image processing configuration to the PBR Material.
  34695. * @param configuration
  34696. */
  34697. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34698. /**
  34699. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34700. */
  34701. /**
  34702. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34703. */
  34704. colorCurves: Nullable<ColorCurves>;
  34705. /**
  34706. * Gets wether the color curves effect is enabled.
  34707. */
  34708. /**
  34709. * Sets wether the color curves effect is enabled.
  34710. */
  34711. colorCurvesEnabled: boolean;
  34712. /**
  34713. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34714. */
  34715. /**
  34716. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34717. */
  34718. colorGradingTexture: Nullable<BaseTexture>;
  34719. /**
  34720. * Gets wether the color grading effect is enabled.
  34721. */
  34722. /**
  34723. * Gets wether the color grading effect is enabled.
  34724. */
  34725. colorGradingEnabled: boolean;
  34726. /**
  34727. * Gets exposure used in the effect.
  34728. */
  34729. /**
  34730. * Sets exposure used in the effect.
  34731. */
  34732. exposure: number;
  34733. /**
  34734. * Gets wether tonemapping is enabled or not.
  34735. */
  34736. /**
  34737. * Sets wether tonemapping is enabled or not
  34738. */
  34739. toneMappingEnabled: boolean;
  34740. /**
  34741. * Gets contrast used in the effect.
  34742. */
  34743. /**
  34744. * Sets contrast used in the effect.
  34745. */
  34746. contrast: number;
  34747. /**
  34748. * Gets Vignette stretch size.
  34749. */
  34750. /**
  34751. * Sets Vignette stretch size.
  34752. */
  34753. vignetteStretch: number;
  34754. /**
  34755. * Gets Vignette centre X Offset.
  34756. */
  34757. /**
  34758. * Sets Vignette centre X Offset.
  34759. */
  34760. vignetteCentreX: number;
  34761. /**
  34762. * Gets Vignette centre Y Offset.
  34763. */
  34764. /**
  34765. * Sets Vignette centre Y Offset.
  34766. */
  34767. vignetteCentreY: number;
  34768. /**
  34769. * Gets Vignette weight or intensity of the vignette effect.
  34770. */
  34771. /**
  34772. * Sets Vignette weight or intensity of the vignette effect.
  34773. */
  34774. vignetteWeight: number;
  34775. /**
  34776. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34777. * if vignetteEnabled is set to true.
  34778. */
  34779. /**
  34780. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34781. * if vignetteEnabled is set to true.
  34782. */
  34783. vignetteColor: Color4;
  34784. /**
  34785. * Gets Camera field of view used by the Vignette effect.
  34786. */
  34787. /**
  34788. * Sets Camera field of view used by the Vignette effect.
  34789. */
  34790. vignetteCameraFov: number;
  34791. /**
  34792. * Gets the vignette blend mode allowing different kind of effect.
  34793. */
  34794. /**
  34795. * Sets the vignette blend mode allowing different kind of effect.
  34796. */
  34797. vignetteBlendMode: number;
  34798. /**
  34799. * Gets wether the vignette effect is enabled.
  34800. */
  34801. /**
  34802. * Sets wether the vignette effect is enabled.
  34803. */
  34804. vignetteEnabled: boolean;
  34805. private _fromLinearSpace;
  34806. /**
  34807. * Gets wether the input of the processing is in Gamma or Linear Space.
  34808. */
  34809. /**
  34810. * Sets wether the input of the processing is in Gamma or Linear Space.
  34811. */
  34812. fromLinearSpace: boolean;
  34813. /**
  34814. * Defines cache preventing GC.
  34815. */
  34816. private _defines;
  34817. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34818. /**
  34819. * "ImageProcessingPostProcess"
  34820. * @returns "ImageProcessingPostProcess"
  34821. */
  34822. getClassName(): string;
  34823. protected _updateParameters(): void;
  34824. dispose(camera?: Camera): void;
  34825. }
  34826. }
  34827. declare module BABYLON {
  34828. /**
  34829. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  34830. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  34831. * As an example, all you have to do is to create the post-process:
  34832. * var mb = new BABYLON.MotionBlurPostProcess(
  34833. * 'mb', // The name of the effect.
  34834. * scene, // The scene containing the objects to blur according to their velocity.
  34835. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  34836. * camera // The camera to apply the render pass to.
  34837. * );
  34838. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  34839. */
  34840. class MotionBlurPostProcess extends PostProcess {
  34841. /**
  34842. * Defines how much the image is blurred by the movement. Default value is equal to 1
  34843. */
  34844. motionStrength: number;
  34845. /**
  34846. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  34847. */
  34848. /**
  34849. * Sets the number of iterations to be used for motion blur quality
  34850. */
  34851. motionBlurSamples: number;
  34852. private _motionBlurSamples;
  34853. private _geometryBufferRenderer;
  34854. /**
  34855. * Creates a new instance MotionBlurPostProcess
  34856. * @param name The name of the effect.
  34857. * @param scene The scene containing the objects to blur according to their velocity.
  34858. * @param options The required width/height ratio to downsize to before computing the render pass.
  34859. * @param camera The camera to apply the render pass to.
  34860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34861. * @param engine The engine which the post process will be applied. (default: current engine)
  34862. * @param reusable If the post process can be reused on the same frame. (default: false)
  34863. * @param textureType Type of textures used when performing the post process. (default: 0)
  34864. * @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)
  34865. */
  34866. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34867. /**
  34868. * Disposes the post process.
  34869. * @param camera The camera to dispose the post process on.
  34870. */
  34871. dispose(camera?: Camera): void;
  34872. }
  34873. }
  34874. declare module BABYLON {
  34875. /**
  34876. * PassPostProcess which produces an output the same as it's input
  34877. */
  34878. class PassPostProcess extends PostProcess {
  34879. /**
  34880. * Creates the PassPostProcess
  34881. * @param name The name of the effect.
  34882. * @param options The required width/height ratio to downsize to before computing the render pass.
  34883. * @param camera The camera to apply the render pass to.
  34884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34885. * @param engine The engine which the post process will be applied. (default: current engine)
  34886. * @param reusable If the post process can be reused on the same frame. (default: false)
  34887. * @param textureType The type of texture to be used when performing the post processing.
  34888. * @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)
  34889. */
  34890. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34891. }
  34892. }
  34893. declare module BABYLON {
  34894. /**
  34895. * Size options for a post process
  34896. */
  34897. type PostProcessOptions = {
  34898. width: number;
  34899. height: number;
  34900. };
  34901. /**
  34902. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34903. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34904. */
  34905. class PostProcess {
  34906. /** Name of the PostProcess. */
  34907. name: string;
  34908. /**
  34909. * Width of the texture to apply the post process on
  34910. */
  34911. width: number;
  34912. /**
  34913. * Height of the texture to apply the post process on
  34914. */
  34915. height: number;
  34916. /**
  34917. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34918. * @hidden
  34919. */
  34920. _outputTexture: Nullable<InternalTexture>;
  34921. /**
  34922. * Sampling mode used by the shader
  34923. * See https://doc.babylonjs.com/classes/3.1/texture
  34924. */
  34925. renderTargetSamplingMode: number;
  34926. /**
  34927. * Clear color to use when screen clearing
  34928. */
  34929. clearColor: Color4;
  34930. /**
  34931. * If the buffer needs to be cleared before applying the post process. (default: true)
  34932. * Should be set to false if shader will overwrite all previous pixels.
  34933. */
  34934. autoClear: boolean;
  34935. /**
  34936. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34937. */
  34938. alphaMode: number;
  34939. /**
  34940. * Sets the setAlphaBlendConstants of the babylon engine
  34941. */
  34942. alphaConstants: Color4;
  34943. /**
  34944. * Animations to be used for the post processing
  34945. */
  34946. animations: Animation[];
  34947. /**
  34948. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34949. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34950. */
  34951. enablePixelPerfectMode: boolean;
  34952. /**
  34953. * Force the postprocess to be applied without taking in account viewport
  34954. */
  34955. forceFullscreenViewport: boolean;
  34956. /**
  34957. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34958. *
  34959. * | Value | Type | Description |
  34960. * | ----- | ----------------------------------- | ----------- |
  34961. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34962. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34963. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34964. *
  34965. */
  34966. scaleMode: number;
  34967. /**
  34968. * Force textures to be a power of two (default: false)
  34969. */
  34970. alwaysForcePOT: boolean;
  34971. private _samples;
  34972. /**
  34973. * Number of sample textures (default: 1)
  34974. */
  34975. samples: number;
  34976. /**
  34977. * Modify the scale of the post process to be the same as the viewport (default: false)
  34978. */
  34979. adaptScaleToCurrentViewport: boolean;
  34980. private _camera;
  34981. private _scene;
  34982. private _engine;
  34983. private _options;
  34984. private _reusable;
  34985. private _textureType;
  34986. /**
  34987. * Smart array of input and output textures for the post process.
  34988. * @hidden
  34989. */
  34990. _textures: SmartArray<InternalTexture>;
  34991. /**
  34992. * The index in _textures that corresponds to the output texture.
  34993. * @hidden
  34994. */
  34995. _currentRenderTextureInd: number;
  34996. private _effect;
  34997. private _samplers;
  34998. private _fragmentUrl;
  34999. private _vertexUrl;
  35000. private _parameters;
  35001. private _scaleRatio;
  35002. protected _indexParameters: any;
  35003. private _shareOutputWithPostProcess;
  35004. private _texelSize;
  35005. private _forcedOutputTexture;
  35006. /**
  35007. * An event triggered when the postprocess is activated.
  35008. */
  35009. onActivateObservable: Observable<Camera>;
  35010. private _onActivateObserver;
  35011. /**
  35012. * A function that is added to the onActivateObservable
  35013. */
  35014. onActivate: Nullable<(camera: Camera) => void>;
  35015. /**
  35016. * An event triggered when the postprocess changes its size.
  35017. */
  35018. onSizeChangedObservable: Observable<PostProcess>;
  35019. private _onSizeChangedObserver;
  35020. /**
  35021. * A function that is added to the onSizeChangedObservable
  35022. */
  35023. onSizeChanged: (postProcess: PostProcess) => void;
  35024. /**
  35025. * An event triggered when the postprocess applies its effect.
  35026. */
  35027. onApplyObservable: Observable<Effect>;
  35028. private _onApplyObserver;
  35029. /**
  35030. * A function that is added to the onApplyObservable
  35031. */
  35032. onApply: (effect: Effect) => void;
  35033. /**
  35034. * An event triggered before rendering the postprocess
  35035. */
  35036. onBeforeRenderObservable: Observable<Effect>;
  35037. private _onBeforeRenderObserver;
  35038. /**
  35039. * A function that is added to the onBeforeRenderObservable
  35040. */
  35041. onBeforeRender: (effect: Effect) => void;
  35042. /**
  35043. * An event triggered after rendering the postprocess
  35044. */
  35045. onAfterRenderObservable: Observable<Effect>;
  35046. private _onAfterRenderObserver;
  35047. /**
  35048. * A function that is added to the onAfterRenderObservable
  35049. */
  35050. onAfterRender: (efect: Effect) => void;
  35051. /**
  35052. * 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
  35053. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35054. */
  35055. inputTexture: InternalTexture;
  35056. /**
  35057. * Gets the camera which post process is applied to.
  35058. * @returns The camera the post process is applied to.
  35059. */
  35060. getCamera(): Camera;
  35061. /**
  35062. * Gets the texel size of the postprocess.
  35063. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35064. */
  35065. readonly texelSize: Vector2;
  35066. /**
  35067. * Creates a new instance PostProcess
  35068. * @param name The name of the PostProcess.
  35069. * @param fragmentUrl The url of the fragment shader to be used.
  35070. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35071. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35072. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35073. * @param camera The camera to apply the render pass to.
  35074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35075. * @param engine The engine which the post process will be applied. (default: current engine)
  35076. * @param reusable If the post process can be reused on the same frame. (default: false)
  35077. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35078. * @param textureType Type of textures used when performing the post process. (default: 0)
  35079. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35080. * @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
  35081. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35082. */
  35083. constructor(
  35084. /** Name of the PostProcess. */
  35085. 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);
  35086. /**
  35087. * Gets the engine which this post process belongs to.
  35088. * @returns The engine the post process was enabled with.
  35089. */
  35090. getEngine(): Engine;
  35091. /**
  35092. * The effect that is created when initializing the post process.
  35093. * @returns The created effect corrisponding the the postprocess.
  35094. */
  35095. getEffect(): Effect;
  35096. /**
  35097. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35098. * @param postProcess The post process to share the output with.
  35099. * @returns This post process.
  35100. */
  35101. shareOutputWith(postProcess: PostProcess): PostProcess;
  35102. /**
  35103. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35104. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35105. */
  35106. useOwnOutput(): void;
  35107. /**
  35108. * Updates the effect with the current post process compile time values and recompiles the shader.
  35109. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35110. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35111. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35112. * @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
  35113. * @param onCompiled Called when the shader has been compiled.
  35114. * @param onError Called if there is an error when compiling a shader.
  35115. */
  35116. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35117. /**
  35118. * The post process is reusable if it can be used multiple times within one frame.
  35119. * @returns If the post process is reusable
  35120. */
  35121. isReusable(): boolean;
  35122. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35123. markTextureDirty(): void;
  35124. /**
  35125. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35126. * 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.
  35127. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35128. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35129. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35130. * @returns The target texture that was bound to be written to.
  35131. */
  35132. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35133. /**
  35134. * If the post process is supported.
  35135. */
  35136. readonly isSupported: boolean;
  35137. /**
  35138. * The aspect ratio of the output texture.
  35139. */
  35140. readonly aspectRatio: number;
  35141. /**
  35142. * Get a value indicating if the post-process is ready to be used
  35143. * @returns true if the post-process is ready (shader is compiled)
  35144. */
  35145. isReady(): boolean;
  35146. /**
  35147. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35148. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35149. */
  35150. apply(): Nullable<Effect>;
  35151. private _disposeTextures;
  35152. /**
  35153. * Disposes the post process.
  35154. * @param camera The camera to dispose the post process on.
  35155. */
  35156. dispose(camera?: Camera): void;
  35157. }
  35158. }
  35159. declare module BABYLON {
  35160. /**
  35161. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35162. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35163. */
  35164. class PostProcessManager {
  35165. private _scene;
  35166. private _indexBuffer;
  35167. private _vertexBuffers;
  35168. /**
  35169. * Creates a new instance PostProcess
  35170. * @param scene The scene that the post process is associated with.
  35171. */
  35172. constructor(scene: Scene);
  35173. private _prepareBuffers;
  35174. private _buildIndexBuffer;
  35175. /**
  35176. * Rebuilds the vertex buffers of the manager.
  35177. * @hidden
  35178. */
  35179. _rebuild(): void;
  35180. /**
  35181. * Prepares a frame to be run through a post process.
  35182. * @param sourceTexture The input texture to the post procesess. (default: null)
  35183. * @param postProcesses An array of post processes to be run. (default: null)
  35184. * @returns True if the post processes were able to be run.
  35185. * @hidden
  35186. */
  35187. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35188. /**
  35189. * Manually render a set of post processes to a texture.
  35190. * @param postProcesses An array of post processes to be run.
  35191. * @param targetTexture The target texture to render to.
  35192. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35193. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35194. * @param lodLevel defines which lod of the texture to render to
  35195. */
  35196. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35197. /**
  35198. * Finalize the result of the output of the postprocesses.
  35199. * @param doNotPresent If true the result will not be displayed to the screen.
  35200. * @param targetTexture The target texture to render to.
  35201. * @param faceIndex The index of the face to bind the target texture to.
  35202. * @param postProcesses The array of post processes to render.
  35203. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35204. * @hidden
  35205. */
  35206. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35207. /**
  35208. * Disposes of the post process manager.
  35209. */
  35210. dispose(): void;
  35211. }
  35212. }
  35213. declare module BABYLON {
  35214. /**
  35215. * Post process which applies a refractin texture
  35216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35217. */
  35218. class RefractionPostProcess extends PostProcess {
  35219. /** the base color of the refraction (used to taint the rendering) */
  35220. color: Color3;
  35221. /** simulated refraction depth */
  35222. depth: number;
  35223. /** the coefficient of the base color (0 to remove base color tainting) */
  35224. colorLevel: number;
  35225. private _refTexture;
  35226. private _ownRefractionTexture;
  35227. /**
  35228. * Gets or sets the refraction texture
  35229. * Please note that you are responsible for disposing the texture if you set it manually
  35230. */
  35231. refractionTexture: Texture;
  35232. /**
  35233. * Initializes the RefractionPostProcess
  35234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35235. * @param name The name of the effect.
  35236. * @param refractionTextureUrl Url of the refraction texture to use
  35237. * @param color the base color of the refraction (used to taint the rendering)
  35238. * @param depth simulated refraction depth
  35239. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35240. * @param camera The camera to apply the render pass to.
  35241. * @param options The required width/height ratio to downsize to before computing the render pass.
  35242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35243. * @param engine The engine which the post process will be applied. (default: current engine)
  35244. * @param reusable If the post process can be reused on the same frame. (default: false)
  35245. */
  35246. constructor(name: string, refractionTextureUrl: string,
  35247. /** the base color of the refraction (used to taint the rendering) */
  35248. color: Color3,
  35249. /** simulated refraction depth */
  35250. depth: number,
  35251. /** the coefficient of the base color (0 to remove base color tainting) */
  35252. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35253. /**
  35254. * Disposes of the post process
  35255. * @param camera Camera to dispose post process on
  35256. */
  35257. dispose(camera: Camera): void;
  35258. }
  35259. }
  35260. declare module BABYLON {
  35261. /**
  35262. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35263. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35264. */
  35265. class SharpenPostProcess extends PostProcess {
  35266. /**
  35267. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35268. */
  35269. colorAmount: number;
  35270. /**
  35271. * How much sharpness should be applied (default: 0.3)
  35272. */
  35273. edgeAmount: number;
  35274. /**
  35275. * Creates a new instance ConvolutionPostProcess
  35276. * @param name The name of the effect.
  35277. * @param options The required width/height ratio to downsize to before computing the render pass.
  35278. * @param camera The camera to apply the render pass to.
  35279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35280. * @param engine The engine which the post process will be applied. (default: current engine)
  35281. * @param reusable If the post process can be reused on the same frame. (default: false)
  35282. * @param textureType Type of textures used when performing the post process. (default: 0)
  35283. * @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)
  35284. */
  35285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35286. }
  35287. }
  35288. declare module BABYLON {
  35289. /**
  35290. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35291. */
  35292. class StereoscopicInterlacePostProcess extends PostProcess {
  35293. private _stepSize;
  35294. private _passedProcess;
  35295. /**
  35296. * Initializes a StereoscopicInterlacePostProcess
  35297. * @param name The name of the effect.
  35298. * @param rigCameras The rig cameras to be appled to the post process
  35299. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35301. * @param engine The engine which the post process will be applied. (default: current engine)
  35302. * @param reusable If the post process can be reused on the same frame. (default: false)
  35303. */
  35304. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35305. }
  35306. }
  35307. declare module BABYLON {
  35308. /** Defines operator used for tonemapping */
  35309. enum TonemappingOperator {
  35310. /** Hable */
  35311. Hable = 0,
  35312. /** Reinhard */
  35313. Reinhard = 1,
  35314. /** HejiDawson */
  35315. HejiDawson = 2,
  35316. /** Photographic */
  35317. Photographic = 3
  35318. }
  35319. /**
  35320. * Defines a post process to apply tone mapping
  35321. */
  35322. class TonemapPostProcess extends PostProcess {
  35323. private _operator;
  35324. /** Defines the required exposure adjustement */
  35325. exposureAdjustment: number;
  35326. /**
  35327. * Creates a new TonemapPostProcess
  35328. * @param name defines the name of the postprocess
  35329. * @param _operator defines the operator to use
  35330. * @param exposureAdjustment defines the required exposure adjustement
  35331. * @param camera defines the camera to use (can be null)
  35332. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35333. * @param engine defines the hosting engine (can be ignore if camera is set)
  35334. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35335. */
  35336. constructor(name: string, _operator: TonemappingOperator,
  35337. /** Defines the required exposure adjustement */
  35338. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35339. }
  35340. }
  35341. declare module BABYLON {
  35342. /**
  35343. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35344. */
  35345. class VolumetricLightScatteringPostProcess extends PostProcess {
  35346. private _volumetricLightScatteringPass;
  35347. private _volumetricLightScatteringRTT;
  35348. private _viewPort;
  35349. private _screenCoordinates;
  35350. private _cachedDefines;
  35351. /**
  35352. * If not undefined, the mesh position is computed from the attached node position
  35353. */
  35354. attachedNode: {
  35355. position: Vector3;
  35356. };
  35357. /**
  35358. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35359. */
  35360. customMeshPosition: Vector3;
  35361. /**
  35362. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35363. */
  35364. useCustomMeshPosition: boolean;
  35365. /**
  35366. * If the post-process should inverse the light scattering direction
  35367. */
  35368. invert: boolean;
  35369. /**
  35370. * The internal mesh used by the post-process
  35371. */
  35372. mesh: Mesh;
  35373. /**
  35374. * @hidden
  35375. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35376. */
  35377. useDiffuseColor: boolean;
  35378. /**
  35379. * Array containing the excluded meshes not rendered in the internal pass
  35380. */
  35381. excludedMeshes: AbstractMesh[];
  35382. /**
  35383. * Controls the overall intensity of the post-process
  35384. */
  35385. exposure: number;
  35386. /**
  35387. * Dissipates each sample's contribution in range [0, 1]
  35388. */
  35389. decay: number;
  35390. /**
  35391. * Controls the overall intensity of each sample
  35392. */
  35393. weight: number;
  35394. /**
  35395. * Controls the density of each sample
  35396. */
  35397. density: number;
  35398. /**
  35399. * @constructor
  35400. * @param name The post-process name
  35401. * @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)
  35402. * @param camera The camera that the post-process will be attached to
  35403. * @param mesh The mesh used to create the light scattering
  35404. * @param samples The post-process quality, default 100
  35405. * @param samplingModeThe post-process filtering mode
  35406. * @param engine The babylon engine
  35407. * @param reusable If the post-process is reusable
  35408. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35409. */
  35410. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35411. /**
  35412. * Returns the string "VolumetricLightScatteringPostProcess"
  35413. * @returns "VolumetricLightScatteringPostProcess"
  35414. */
  35415. getClassName(): string;
  35416. private _isReady;
  35417. /**
  35418. * Sets the new light position for light scattering effect
  35419. * @param position The new custom light position
  35420. */
  35421. setCustomMeshPosition(position: Vector3): void;
  35422. /**
  35423. * Returns the light position for light scattering effect
  35424. * @return Vector3 The custom light position
  35425. */
  35426. getCustomMeshPosition(): Vector3;
  35427. /**
  35428. * Disposes the internal assets and detaches the post-process from the camera
  35429. */
  35430. dispose(camera: Camera): void;
  35431. /**
  35432. * Returns the render target texture used by the post-process
  35433. * @return the render target texture used by the post-process
  35434. */
  35435. getPass(): RenderTargetTexture;
  35436. private _meshExcluded;
  35437. private _createPass;
  35438. private _updateMeshScreenCoordinates;
  35439. /**
  35440. * Creates a default mesh for the Volumeric Light Scattering post-process
  35441. * @param name The mesh name
  35442. * @param scene The scene where to create the mesh
  35443. * @return the default mesh
  35444. */
  35445. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35446. }
  35447. }
  35448. declare module BABYLON {
  35449. /**
  35450. * VRDistortionCorrectionPostProcess used for mobile VR
  35451. */
  35452. class VRDistortionCorrectionPostProcess extends PostProcess {
  35453. private _isRightEye;
  35454. private _distortionFactors;
  35455. private _postProcessScaleFactor;
  35456. private _lensCenterOffset;
  35457. private _scaleIn;
  35458. private _scaleFactor;
  35459. private _lensCenter;
  35460. /**
  35461. * Initializes the VRDistortionCorrectionPostProcess
  35462. * @param name The name of the effect.
  35463. * @param camera The camera to apply the render pass to.
  35464. * @param isRightEye If this is for the right eye distortion
  35465. * @param vrMetrics All the required metrics for the VR camera
  35466. */
  35467. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35468. }
  35469. }
  35470. declare module BABYLON {
  35471. interface Scene {
  35472. /** @hidden (Backing field) */
  35473. _boundingBoxRenderer: BoundingBoxRenderer;
  35474. /** @hidden (Backing field) */
  35475. _forceShowBoundingBoxes: boolean;
  35476. /**
  35477. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35478. */
  35479. forceShowBoundingBoxes: boolean;
  35480. /**
  35481. * Gets the bounding box renderer associated with the scene
  35482. * @returns a BoundingBoxRenderer
  35483. */
  35484. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35485. }
  35486. interface AbstractMesh {
  35487. /** @hidden (Backing field) */
  35488. _showBoundingBox: boolean;
  35489. /**
  35490. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35491. */
  35492. showBoundingBox: boolean;
  35493. }
  35494. /**
  35495. * Component responsible of rendering the bounding box of the meshes in a scene.
  35496. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35497. */
  35498. class BoundingBoxRenderer implements ISceneComponent {
  35499. /**
  35500. * The component name helpfull to identify the component in the list of scene components.
  35501. */
  35502. readonly name: string;
  35503. /**
  35504. * The scene the component belongs to.
  35505. */
  35506. scene: Scene;
  35507. /**
  35508. * Color of the bounding box lines placed in front of an object
  35509. */
  35510. frontColor: Color3;
  35511. /**
  35512. * Color of the bounding box lines placed behind an object
  35513. */
  35514. backColor: Color3;
  35515. /**
  35516. * Defines if the renderer should show the back lines or not
  35517. */
  35518. showBackLines: boolean;
  35519. /**
  35520. * @hidden
  35521. */
  35522. renderList: SmartArray<BoundingBox>;
  35523. private _colorShader;
  35524. private _vertexBuffers;
  35525. private _indexBuffer;
  35526. /**
  35527. * Instantiates a new bounding box renderer in a scene.
  35528. * @param scene the scene the renderer renders in
  35529. */
  35530. constructor(scene: Scene);
  35531. /**
  35532. * Registers the component in a given scene
  35533. */
  35534. register(): void;
  35535. private _evaluateSubMesh;
  35536. private _activeMesh;
  35537. private _prepareRessources;
  35538. private _createIndexBuffer;
  35539. /**
  35540. * Rebuilds the elements related to this component in case of
  35541. * context lost for instance.
  35542. */
  35543. rebuild(): void;
  35544. /**
  35545. * @hidden
  35546. */
  35547. reset(): void;
  35548. /**
  35549. * Render the bounding boxes of a specific rendering group
  35550. * @param renderingGroupId defines the rendering group to render
  35551. */
  35552. render(renderingGroupId: number): void;
  35553. /**
  35554. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35555. * @param mesh Define the mesh to render the occlusion bounding box for
  35556. */
  35557. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35558. /**
  35559. * Dispose and release the resources attached to this renderer.
  35560. */
  35561. dispose(): void;
  35562. }
  35563. }
  35564. declare module BABYLON {
  35565. /**
  35566. * This represents a depth renderer in Babylon.
  35567. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35568. */
  35569. class DepthRenderer {
  35570. private _scene;
  35571. private _depthMap;
  35572. private _effect;
  35573. private _cachedDefines;
  35574. private _camera;
  35575. /**
  35576. * Specifiess that the depth renderer will only be used within
  35577. * the camera it is created for.
  35578. * This can help forcing its rendering during the camera processing.
  35579. */
  35580. useOnlyInActiveCamera: boolean;
  35581. /**
  35582. * Instantiates a depth renderer
  35583. * @param scene The scene the renderer belongs to
  35584. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35585. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35586. */
  35587. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35588. /**
  35589. * Creates the depth rendering effect and checks if the effect is ready.
  35590. * @param subMesh The submesh to be used to render the depth map of
  35591. * @param useInstances If multiple world instances should be used
  35592. * @returns if the depth renderer is ready to render the depth map
  35593. */
  35594. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35595. /**
  35596. * Gets the texture which the depth map will be written to.
  35597. * @returns The depth map texture
  35598. */
  35599. getDepthMap(): RenderTargetTexture;
  35600. /**
  35601. * Disposes of the depth renderer.
  35602. */
  35603. dispose(): void;
  35604. }
  35605. }
  35606. declare module BABYLON {
  35607. interface Scene {
  35608. /** @hidden (Backing field) */
  35609. _depthRenderer: {
  35610. [id: string]: DepthRenderer;
  35611. };
  35612. /**
  35613. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35614. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35615. * @returns the created depth renderer
  35616. */
  35617. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35618. /**
  35619. * Disables a depth renderer for a given camera
  35620. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35621. */
  35622. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35623. }
  35624. /**
  35625. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35626. * in several rendering techniques.
  35627. */
  35628. class DepthRendererSceneComponent implements ISceneComponent {
  35629. /**
  35630. * The component name helpfull to identify the component in the list of scene components.
  35631. */
  35632. readonly name: string;
  35633. /**
  35634. * The scene the component belongs to.
  35635. */
  35636. scene: Scene;
  35637. /**
  35638. * Creates a new instance of the component for the given scene
  35639. * @param scene Defines the scene to register the component in
  35640. */
  35641. constructor(scene: Scene);
  35642. /**
  35643. * Registers the component in a given scene
  35644. */
  35645. register(): void;
  35646. /**
  35647. * Rebuilds the elements related to this component in case of
  35648. * context lost for instance.
  35649. */
  35650. rebuild(): void;
  35651. /**
  35652. * Disposes the component and the associated ressources
  35653. */
  35654. dispose(): void;
  35655. private _gatherRenderTargets;
  35656. private _gatherActiveCameraRenderTargets;
  35657. }
  35658. }
  35659. declare module BABYLON {
  35660. interface AbstractMesh {
  35661. /**
  35662. * Disables the mesh edge rendering mode
  35663. * @returns the currentAbstractMesh
  35664. */
  35665. disableEdgesRendering(): AbstractMesh;
  35666. /**
  35667. * Enables the edge rendering mode on the mesh.
  35668. * This mode makes the mesh edges visible
  35669. * @param epsilon defines the maximal distance between two angles to detect a face
  35670. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35671. * @returns the currentAbstractMesh
  35672. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35673. */
  35674. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35675. /**
  35676. * Gets the edgesRenderer associated with the mesh
  35677. */
  35678. edgesRenderer: Nullable<EdgesRenderer>;
  35679. }
  35680. interface LinesMesh {
  35681. /**
  35682. * Enables the edge rendering mode on the mesh.
  35683. * This mode makes the mesh edges visible
  35684. * @param epsilon defines the maximal distance between two angles to detect a face
  35685. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35686. * @returns the currentAbstractMesh
  35687. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35688. */
  35689. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35690. }
  35691. interface InstancedMesh {
  35692. /**
  35693. * Enables the edge rendering mode on the mesh.
  35694. * This mode makes the mesh edges visible
  35695. * @param epsilon defines the maximal distance between two angles to detect a face
  35696. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35697. * @returns the currentInstancedMesh
  35698. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35699. */
  35700. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedMesh;
  35701. }
  35702. /**
  35703. * Defines the minimum contract an Edges renderer should follow.
  35704. */
  35705. interface IEdgesRenderer extends IDisposable {
  35706. /**
  35707. * Gets or sets a boolean indicating if the edgesRenderer is active
  35708. */
  35709. isEnabled: boolean;
  35710. /**
  35711. * Renders the edges of the attached mesh,
  35712. */
  35713. render(): void;
  35714. /**
  35715. * Checks wether or not the edges renderer is ready to render.
  35716. * @return true if ready, otherwise false.
  35717. */
  35718. isReady(): boolean;
  35719. }
  35720. /**
  35721. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35722. */
  35723. class EdgesRenderer implements IEdgesRenderer {
  35724. /**
  35725. * Define the size of the edges with an orthographic camera
  35726. */
  35727. edgesWidthScalerForOrthographic: number;
  35728. /**
  35729. * Define the size of the edges with a perspective camera
  35730. */
  35731. edgesWidthScalerForPerspective: number;
  35732. protected _source: AbstractMesh;
  35733. protected _linesPositions: number[];
  35734. protected _linesNormals: number[];
  35735. protected _linesIndices: number[];
  35736. protected _epsilon: number;
  35737. protected _indicesCount: number;
  35738. protected _lineShader: ShaderMaterial;
  35739. protected _ib: WebGLBuffer;
  35740. protected _buffers: {
  35741. [key: string]: Nullable<VertexBuffer>;
  35742. };
  35743. protected _checkVerticesInsteadOfIndices: boolean;
  35744. private _meshRebuildObserver;
  35745. private _meshDisposeObserver;
  35746. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35747. isEnabled: boolean;
  35748. /**
  35749. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35750. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35751. * @param source Mesh used to create edges
  35752. * @param epsilon sum of angles in adjacency to check for edge
  35753. * @param checkVerticesInsteadOfIndices
  35754. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35755. */
  35756. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35757. protected _prepareRessources(): void;
  35758. /** @hidden */
  35759. _rebuild(): void;
  35760. /**
  35761. * Releases the required resources for the edges renderer
  35762. */
  35763. dispose(): void;
  35764. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35765. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35766. /**
  35767. * Checks if the pair of p0 and p1 is en edge
  35768. * @param faceIndex
  35769. * @param edge
  35770. * @param faceNormals
  35771. * @param p0
  35772. * @param p1
  35773. * @private
  35774. */
  35775. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35776. /**
  35777. * push line into the position, normal and index buffer
  35778. * @protected
  35779. */
  35780. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  35781. /**
  35782. * Generates lines edges from adjacencjes
  35783. * @private
  35784. */
  35785. _generateEdgesLines(): void;
  35786. /**
  35787. * Checks wether or not the edges renderer is ready to render.
  35788. * @return true if ready, otherwise false.
  35789. */
  35790. isReady(): boolean;
  35791. /**
  35792. * Renders the edges of the attached mesh,
  35793. */
  35794. render(): void;
  35795. }
  35796. }
  35797. declare module BABYLON {
  35798. /**
  35799. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35800. */
  35801. class GeometryBufferRenderer {
  35802. /**
  35803. * Constant used to retrieve the position texture index in the G-Buffer textures array
  35804. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  35805. */
  35806. static readonly POSITION_TEXTURE_TYPE: number;
  35807. /**
  35808. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  35809. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  35810. */
  35811. static readonly VELOCITY_TEXTURE_TYPE: number;
  35812. /**
  35813. * Dictionary used to store the previous transformation matrices of each rendered mesh
  35814. * in order to compute objects velocities when enableVelocity is set to "true"
  35815. * @hidden
  35816. */
  35817. _previousTransformationMatrices: {
  35818. [index: number]: Matrix;
  35819. };
  35820. private _scene;
  35821. private _multiRenderTarget;
  35822. private _ratio;
  35823. private _enablePosition;
  35824. private _enableVelocity;
  35825. private _positionIndex;
  35826. private _velocityIndex;
  35827. protected _effect: Effect;
  35828. protected _cachedDefines: string;
  35829. /**
  35830. * Set the render list (meshes to be rendered) used in the G buffer.
  35831. */
  35832. renderList: Mesh[];
  35833. /**
  35834. * Gets wether or not G buffer are supported by the running hardware.
  35835. * This requires draw buffer supports
  35836. */
  35837. readonly isSupported: boolean;
  35838. /**
  35839. * Returns the index of the given texture type in the G-Buffer textures array
  35840. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  35841. * @returns the index of the given texture type in the G-Buffer textures array
  35842. */
  35843. getTextureIndex(textureType: number): number;
  35844. /**
  35845. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  35846. */
  35847. /**
  35848. * Sets whether or not objects positions are enabled for the G buffer.
  35849. */
  35850. enablePosition: boolean;
  35851. /**
  35852. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  35853. */
  35854. /**
  35855. * Sets wether or not objects velocities are enabled for the G buffer.
  35856. */
  35857. enableVelocity: boolean;
  35858. /**
  35859. * Gets the scene associated with the buffer.
  35860. */
  35861. readonly scene: Scene;
  35862. /**
  35863. * Gets the ratio used by the buffer during its creation.
  35864. * How big is the buffer related to the main canvas.
  35865. */
  35866. readonly ratio: number;
  35867. /**
  35868. * Creates a new G Buffer for the scene
  35869. * @param scene The scene the buffer belongs to
  35870. * @param ratio How big is the buffer related to the main canvas.
  35871. */
  35872. constructor(scene: Scene, ratio?: number);
  35873. /**
  35874. * Checks wether everything is ready to render a submesh to the G buffer.
  35875. * @param subMesh the submesh to check readiness for
  35876. * @param useInstances is the mesh drawn using instance or not
  35877. * @returns true if ready otherwise false
  35878. */
  35879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35880. /**
  35881. * Gets the current underlying G Buffer.
  35882. * @returns the buffer
  35883. */
  35884. getGBuffer(): MultiRenderTarget;
  35885. /**
  35886. * Gets the number of samples used to render the buffer (anti aliasing).
  35887. */
  35888. /**
  35889. * Sets the number of samples used to render the buffer (anti aliasing).
  35890. */
  35891. samples: number;
  35892. /**
  35893. * Disposes the renderer and frees up associated resources.
  35894. */
  35895. dispose(): void;
  35896. protected _createRenderTargets(): void;
  35897. }
  35898. }
  35899. declare module BABYLON {
  35900. interface Scene {
  35901. /** @hidden (Backing field) */
  35902. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35903. /**
  35904. * Gets or Sets the current geometry buffer associated to the scene.
  35905. */
  35906. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35907. /**
  35908. * Enables a GeometryBufferRender and associates it with the scene
  35909. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35910. * @returns the GeometryBufferRenderer
  35911. */
  35912. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35913. /**
  35914. * Disables the GeometryBufferRender associated with the scene
  35915. */
  35916. disableGeometryBufferRenderer(): void;
  35917. }
  35918. /**
  35919. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35920. * in several rendering techniques.
  35921. */
  35922. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35923. /**
  35924. * The component name helpful to identify the component in the list of scene components.
  35925. */
  35926. readonly name: string;
  35927. /**
  35928. * The scene the component belongs to.
  35929. */
  35930. scene: Scene;
  35931. /**
  35932. * Creates a new instance of the component for the given scene
  35933. * @param scene Defines the scene to register the component in
  35934. */
  35935. constructor(scene: Scene);
  35936. /**
  35937. * Registers the component in a given scene
  35938. */
  35939. register(): void;
  35940. /**
  35941. * Rebuilds the elements related to this component in case of
  35942. * context lost for instance.
  35943. */
  35944. rebuild(): void;
  35945. /**
  35946. * Disposes the component and the associated ressources
  35947. */
  35948. dispose(): void;
  35949. private _gatherRenderTargets;
  35950. }
  35951. }
  35952. declare module BABYLON {
  35953. /**
  35954. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35955. */
  35956. class LineEdgesRenderer extends EdgesRenderer {
  35957. /**
  35958. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35959. * @param source LineMesh used to generate edges
  35960. * @param epsilon not important (specified angle for edge detection)
  35961. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35962. */
  35963. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35964. /**
  35965. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35966. */
  35967. _generateEdgesLines(): void;
  35968. }
  35969. }
  35970. declare module BABYLON {
  35971. interface Scene {
  35972. /** @hidden */
  35973. _outlineRenderer: OutlineRenderer;
  35974. /**
  35975. * Gets the outline renderer associated with the scene
  35976. * @returns a OutlineRenderer
  35977. */
  35978. getOutlineRenderer(): OutlineRenderer;
  35979. }
  35980. interface AbstractMesh {
  35981. /** @hidden (Backing field) */
  35982. _renderOutline: boolean;
  35983. /**
  35984. * Gets or sets a boolean indicating if the outline must be rendered as well
  35985. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35986. */
  35987. renderOutline: boolean;
  35988. /** @hidden (Backing field) */
  35989. _renderOverlay: boolean;
  35990. /**
  35991. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35992. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35993. */
  35994. renderOverlay: boolean;
  35995. }
  35996. /**
  35997. * This class is responsible to draw bothe outline/overlay of meshes.
  35998. * It should not be used directly but through the available method on mesh.
  35999. */
  36000. class OutlineRenderer implements ISceneComponent {
  36001. /**
  36002. * The name of the component. Each component must have a unique name.
  36003. */
  36004. name: string;
  36005. /**
  36006. * The scene the component belongs to.
  36007. */
  36008. scene: Scene;
  36009. /**
  36010. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36011. */
  36012. zOffset: number;
  36013. private _engine;
  36014. private _effect;
  36015. private _cachedDefines;
  36016. private _savedDepthWrite;
  36017. /**
  36018. * Instantiates a new outline renderer. (There could be only one per scene).
  36019. * @param scene Defines the scene it belongs to
  36020. */
  36021. constructor(scene: Scene);
  36022. /**
  36023. * Register the component to one instance of a scene.
  36024. */
  36025. register(): void;
  36026. /**
  36027. * Rebuilds the elements related to this component in case of
  36028. * context lost for instance.
  36029. */
  36030. rebuild(): void;
  36031. /**
  36032. * Disposes the component and the associated ressources.
  36033. */
  36034. dispose(): void;
  36035. /**
  36036. * Renders the outline in the canvas.
  36037. * @param subMesh Defines the sumesh to render
  36038. * @param batch Defines the batch of meshes in case of instances
  36039. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36040. */
  36041. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36042. /**
  36043. * Returns whether or not the outline renderer is ready for a given submesh.
  36044. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36045. * @param subMesh Defines the submesh to check readyness for
  36046. * @param useInstances Defines wheter wee are trying to render instances or not
  36047. * @returns true if ready otherwise false
  36048. */
  36049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36050. private _beforeRenderingMesh;
  36051. private _afterRenderingMesh;
  36052. }
  36053. }
  36054. declare module BABYLON {
  36055. /**
  36056. * This represents the object necessary to create a rendering group.
  36057. * This is exclusively used and created by the rendering manager.
  36058. * To modify the behavior, you use the available helpers in your scene or meshes.
  36059. * @hidden
  36060. */
  36061. class RenderingGroup {
  36062. index: number;
  36063. private _scene;
  36064. private _opaqueSubMeshes;
  36065. private _transparentSubMeshes;
  36066. private _alphaTestSubMeshes;
  36067. private _depthOnlySubMeshes;
  36068. private _particleSystems;
  36069. private _spriteManagers;
  36070. private _opaqueSortCompareFn;
  36071. private _alphaTestSortCompareFn;
  36072. private _transparentSortCompareFn;
  36073. private _renderOpaque;
  36074. private _renderAlphaTest;
  36075. private _renderTransparent;
  36076. private _edgesRenderers;
  36077. onBeforeTransparentRendering: () => void;
  36078. /**
  36079. * Set the opaque sort comparison function.
  36080. * If null the sub meshes will be render in the order they were created
  36081. */
  36082. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36083. /**
  36084. * Set the alpha test sort comparison function.
  36085. * If null the sub meshes will be render in the order they were created
  36086. */
  36087. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36088. /**
  36089. * Set the transparent sort comparison function.
  36090. * If null the sub meshes will be render in the order they were created
  36091. */
  36092. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36093. /**
  36094. * Creates a new rendering group.
  36095. * @param index The rendering group index
  36096. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36097. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36098. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36099. */
  36100. 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>);
  36101. /**
  36102. * Render all the sub meshes contained in the group.
  36103. * @param customRenderFunction Used to override the default render behaviour of the group.
  36104. * @returns true if rendered some submeshes.
  36105. */
  36106. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36107. /**
  36108. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36109. * @param subMeshes The submeshes to render
  36110. */
  36111. private renderOpaqueSorted;
  36112. /**
  36113. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36114. * @param subMeshes The submeshes to render
  36115. */
  36116. private renderAlphaTestSorted;
  36117. /**
  36118. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36119. * @param subMeshes The submeshes to render
  36120. */
  36121. private renderTransparentSorted;
  36122. /**
  36123. * Renders the submeshes in a specified order.
  36124. * @param subMeshes The submeshes to sort before render
  36125. * @param sortCompareFn The comparison function use to sort
  36126. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36127. * @param transparent Specifies to activate blending if true
  36128. */
  36129. private static renderSorted;
  36130. /**
  36131. * Renders the submeshes in the order they were dispatched (no sort applied).
  36132. * @param subMeshes The submeshes to render
  36133. */
  36134. private static renderUnsorted;
  36135. /**
  36136. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36137. * are rendered back to front if in the same alpha index.
  36138. *
  36139. * @param a The first submesh
  36140. * @param b The second submesh
  36141. * @returns The result of the comparison
  36142. */
  36143. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36144. /**
  36145. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36146. * are rendered back to front.
  36147. *
  36148. * @param a The first submesh
  36149. * @param b The second submesh
  36150. * @returns The result of the comparison
  36151. */
  36152. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36153. /**
  36154. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36155. * are rendered front to back (prevent overdraw).
  36156. *
  36157. * @param a The first submesh
  36158. * @param b The second submesh
  36159. * @returns The result of the comparison
  36160. */
  36161. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36162. /**
  36163. * Resets the different lists of submeshes to prepare a new frame.
  36164. */
  36165. prepare(): void;
  36166. dispose(): void;
  36167. /**
  36168. * Inserts the submesh in its correct queue depending on its material.
  36169. * @param subMesh The submesh to dispatch
  36170. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36171. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36172. */
  36173. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36174. dispatchSprites(spriteManager: ISpriteManager): void;
  36175. dispatchParticles(particleSystem: IParticleSystem): void;
  36176. private _renderParticles;
  36177. private _renderSprites;
  36178. }
  36179. }
  36180. declare module BABYLON {
  36181. /**
  36182. * Interface describing the different options available in the rendering manager
  36183. * regarding Auto Clear between groups.
  36184. */
  36185. interface IRenderingManagerAutoClearSetup {
  36186. /**
  36187. * Defines whether or not autoclear is enable.
  36188. */
  36189. autoClear: boolean;
  36190. /**
  36191. * Defines whether or not to autoclear the depth buffer.
  36192. */
  36193. depth: boolean;
  36194. /**
  36195. * Defines whether or not to autoclear the stencil buffer.
  36196. */
  36197. stencil: boolean;
  36198. }
  36199. /**
  36200. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36201. * It is enable to manage the different groups as well as the different necessary sort functions.
  36202. * This should not be used directly aside of the few static configurations
  36203. */
  36204. class RenderingManager {
  36205. /**
  36206. * The max id used for rendering groups (not included)
  36207. */
  36208. static MAX_RENDERINGGROUPS: number;
  36209. /**
  36210. * The min id used for rendering groups (included)
  36211. */
  36212. static MIN_RENDERINGGROUPS: number;
  36213. /**
  36214. * Used to globally prevent autoclearing scenes.
  36215. */
  36216. static AUTOCLEAR: boolean;
  36217. /**
  36218. * @hidden
  36219. */
  36220. _useSceneAutoClearSetup: boolean;
  36221. private _scene;
  36222. private _renderingGroups;
  36223. private _depthStencilBufferAlreadyCleaned;
  36224. private _autoClearDepthStencil;
  36225. private _customOpaqueSortCompareFn;
  36226. private _customAlphaTestSortCompareFn;
  36227. private _customTransparentSortCompareFn;
  36228. private _renderingGroupInfo;
  36229. /**
  36230. * Instantiates a new rendering group for a particular scene
  36231. * @param scene Defines the scene the groups belongs to
  36232. */
  36233. constructor(scene: Scene);
  36234. private _clearDepthStencilBuffer;
  36235. /**
  36236. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36237. * @hidden
  36238. */
  36239. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36240. /**
  36241. * Resets the different information of the group to prepare a new frame
  36242. * @hidden
  36243. */
  36244. reset(): void;
  36245. /**
  36246. * Dispose and release the group and its associated resources.
  36247. * @hidden
  36248. */
  36249. dispose(): void;
  36250. /**
  36251. * Clear the info related to rendering groups preventing retention points during dispose.
  36252. */
  36253. freeRenderingGroups(): void;
  36254. private _prepareRenderingGroup;
  36255. /**
  36256. * Add a sprite manager to the rendering manager in order to render it this frame.
  36257. * @param spriteManager Define the sprite manager to render
  36258. */
  36259. dispatchSprites(spriteManager: ISpriteManager): void;
  36260. /**
  36261. * Add a particle system to the rendering manager in order to render it this frame.
  36262. * @param particleSystem Define the particle system to render
  36263. */
  36264. dispatchParticles(particleSystem: IParticleSystem): void;
  36265. /**
  36266. * Add a submesh to the manager in order to render it this frame
  36267. * @param subMesh The submesh to dispatch
  36268. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36269. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36270. */
  36271. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36272. /**
  36273. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36274. * This allowed control for front to back rendering or reversly depending of the special needs.
  36275. *
  36276. * @param renderingGroupId The rendering group id corresponding to its index
  36277. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36278. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36279. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36280. */
  36281. 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;
  36282. /**
  36283. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36284. *
  36285. * @param renderingGroupId The rendering group id corresponding to its index
  36286. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36287. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36288. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36289. */
  36290. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36291. /**
  36292. * Gets the current auto clear configuration for one rendering group of the rendering
  36293. * manager.
  36294. * @param index the rendering group index to get the information for
  36295. * @returns The auto clear setup for the requested rendering group
  36296. */
  36297. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36298. }
  36299. }
  36300. declare module BABYLON {
  36301. /**
  36302. * Renders a layer on top of an existing scene
  36303. */
  36304. class UtilityLayerRenderer implements IDisposable {
  36305. /** the original scene that will be rendered on top of */
  36306. originalScene: Scene;
  36307. private _pointerCaptures;
  36308. private _lastPointerEvents;
  36309. private static _DefaultUtilityLayer;
  36310. private static _DefaultKeepDepthUtilityLayer;
  36311. /**
  36312. * 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)
  36313. */
  36314. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36315. /**
  36316. * 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)
  36317. */
  36318. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36319. /**
  36320. * The scene that is rendered on top of the original scene
  36321. */
  36322. utilityLayerScene: Scene;
  36323. /**
  36324. * If the utility layer should automatically be rendered on top of existing scene
  36325. */
  36326. shouldRender: boolean;
  36327. /**
  36328. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36329. */
  36330. onlyCheckPointerDownEvents: boolean;
  36331. /**
  36332. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36333. */
  36334. processAllEvents: boolean;
  36335. /**
  36336. * Observable raised when the pointer move from the utility layer scene to the main scene
  36337. */
  36338. onPointerOutObservable: Observable<number>;
  36339. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36340. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36341. private _afterRenderObserver;
  36342. private _sceneDisposeObserver;
  36343. private _originalPointerObserver;
  36344. /**
  36345. * Instantiates a UtilityLayerRenderer
  36346. * @param originalScene the original scene that will be rendered on top of
  36347. */
  36348. constructor(
  36349. /** the original scene that will be rendered on top of */
  36350. originalScene: Scene);
  36351. private _notifyObservers;
  36352. /**
  36353. * Renders the utility layers scene on top of the original scene
  36354. */
  36355. render(): void;
  36356. /**
  36357. * Disposes of the renderer
  36358. */
  36359. dispose(): void;
  36360. private _updateCamera;
  36361. }
  36362. }
  36363. declare module BABYLON {
  36364. /**
  36365. * Class used to represent a sprite
  36366. * @see http://doc.babylonjs.com/babylon101/sprites
  36367. */
  36368. class Sprite {
  36369. /** defines the name */
  36370. name: string;
  36371. /** Gets or sets the current world position */
  36372. position: Vector3;
  36373. /** Gets or sets the main color */
  36374. color: Color4;
  36375. /** Gets or sets the width */
  36376. width: number;
  36377. /** Gets or sets the height */
  36378. height: number;
  36379. /** Gets or sets rotation angle */
  36380. angle: number;
  36381. /** Gets or sets the cell index in the sprite sheet */
  36382. cellIndex: number;
  36383. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36384. invertU: number;
  36385. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36386. invertV: number;
  36387. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36388. disposeWhenFinishedAnimating: boolean;
  36389. /** Gets the list of attached animations */
  36390. animations: Animation[];
  36391. /** Gets or sets a boolean indicating if the sprite can be picked */
  36392. isPickable: boolean;
  36393. /**
  36394. * Gets or sets the associated action manager
  36395. */
  36396. actionManager: Nullable<ActionManager>;
  36397. private _animationStarted;
  36398. private _loopAnimation;
  36399. private _fromIndex;
  36400. private _toIndex;
  36401. private _delay;
  36402. private _direction;
  36403. private _manager;
  36404. private _time;
  36405. private _onAnimationEnd;
  36406. /**
  36407. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36408. */
  36409. isVisible: boolean;
  36410. /**
  36411. * Gets or sets the sprite size
  36412. */
  36413. size: number;
  36414. /**
  36415. * Creates a new Sprite
  36416. * @param name defines the name
  36417. * @param manager defines the manager
  36418. */
  36419. constructor(
  36420. /** defines the name */
  36421. name: string, manager: ISpriteManager);
  36422. /**
  36423. * Starts an animation
  36424. * @param from defines the initial key
  36425. * @param to defines the end key
  36426. * @param loop defines if the animation must loop
  36427. * @param delay defines the start delay (in ms)
  36428. * @param onAnimationEnd defines a callback to call when animation ends
  36429. */
  36430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36431. /** Stops current animation (if any) */
  36432. stopAnimation(): void;
  36433. /** @hidden */
  36434. _animate(deltaTime: number): void;
  36435. /** Release associated resources */
  36436. dispose(): void;
  36437. }
  36438. }
  36439. declare module BABYLON {
  36440. /**
  36441. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36442. */
  36443. interface ISpriteManager extends IDisposable {
  36444. /**
  36445. * Restricts the camera to viewing objects with the same layerMask.
  36446. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36447. */
  36448. layerMask: number;
  36449. /**
  36450. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36451. */
  36452. isPickable: boolean;
  36453. /**
  36454. * Specifies the rendering group id for this mesh (0 by default)
  36455. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36456. */
  36457. renderingGroupId: number;
  36458. /**
  36459. * Defines the list of sprites managed by the manager.
  36460. */
  36461. sprites: Array<Sprite>;
  36462. /**
  36463. * Tests the intersection of a sprite with a specific ray.
  36464. * @param ray The ray we are sending to test the collision
  36465. * @param camera The camera space we are sending rays in
  36466. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36467. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36468. * @returns picking info or null.
  36469. */
  36470. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36471. /**
  36472. * Renders the list of sprites on screen.
  36473. */
  36474. render(): void;
  36475. }
  36476. /**
  36477. * Class used to manage multiple sprites on the same spritesheet
  36478. * @see http://doc.babylonjs.com/babylon101/sprites
  36479. */
  36480. class SpriteManager implements ISpriteManager {
  36481. /** defines the manager's name */
  36482. name: string;
  36483. /** Gets the list of sprites */
  36484. sprites: Sprite[];
  36485. /** Gets or sets the rendering group id (0 by default) */
  36486. renderingGroupId: number;
  36487. /** Gets or sets camera layer mask */
  36488. layerMask: number;
  36489. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36490. fogEnabled: boolean;
  36491. /** Gets or sets a boolean indicating if the sprites are pickable */
  36492. isPickable: boolean;
  36493. /** Defines the default width of a cell in the spritesheet */
  36494. cellWidth: number;
  36495. /** Defines the default height of a cell in the spritesheet */
  36496. cellHeight: number;
  36497. /**
  36498. * An event triggered when the manager is disposed.
  36499. */
  36500. onDisposeObservable: Observable<SpriteManager>;
  36501. private _onDisposeObserver;
  36502. /**
  36503. * Callback called when the manager is disposed
  36504. */
  36505. onDispose: () => void;
  36506. private _capacity;
  36507. private _spriteTexture;
  36508. private _epsilon;
  36509. private _scene;
  36510. private _vertexData;
  36511. private _buffer;
  36512. private _vertexBuffers;
  36513. private _indexBuffer;
  36514. private _effectBase;
  36515. private _effectFog;
  36516. /**
  36517. * Gets or sets the spritesheet texture
  36518. */
  36519. texture: Texture;
  36520. /**
  36521. * Creates a new sprite manager
  36522. * @param name defines the manager's name
  36523. * @param imgUrl defines the sprite sheet url
  36524. * @param capacity defines the maximum allowed number of sprites
  36525. * @param cellSize defines the size of a sprite cell
  36526. * @param scene defines the hosting scene
  36527. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36528. * @param samplingMode defines the smapling mode to use with spritesheet
  36529. */
  36530. constructor(
  36531. /** defines the manager's name */
  36532. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36533. private _appendSpriteVertex;
  36534. /**
  36535. * Intersects the sprites with a ray
  36536. * @param ray defines the ray to intersect with
  36537. * @param camera defines the current active camera
  36538. * @param predicate defines a predicate used to select candidate sprites
  36539. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36540. * @returns null if no hit or a PickingInfo
  36541. */
  36542. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36543. /**
  36544. * Render all child sprites
  36545. */
  36546. render(): void;
  36547. /**
  36548. * Release associated resources
  36549. */
  36550. dispose(): void;
  36551. }
  36552. }
  36553. declare module BABYLON {
  36554. interface Scene {
  36555. /** @hidden */
  36556. _pointerOverSprite: Nullable<Sprite>;
  36557. /** @hidden */
  36558. _pickedDownSprite: Nullable<Sprite>;
  36559. /** @hidden */
  36560. _tempSpritePickingRay: Nullable<Ray>;
  36561. /**
  36562. * All of the sprite managers added to this scene
  36563. * @see http://doc.babylonjs.com/babylon101/sprites
  36564. */
  36565. spriteManagers: Array<ISpriteManager>;
  36566. /**
  36567. * An event triggered when sprites rendering is about to start
  36568. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36569. */
  36570. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36571. /**
  36572. * An event triggered when sprites rendering is done
  36573. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36574. */
  36575. onAfterSpritesRenderingObservable: Observable<Scene>;
  36576. /** @hidden */
  36577. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36578. /** Launch a ray to try to pick a sprite in the scene
  36579. * @param x position on screen
  36580. * @param y position on screen
  36581. * @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
  36582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36583. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36584. * @returns a PickingInfo
  36585. */
  36586. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36587. /** Use the given ray to pick a sprite in the scene
  36588. * @param ray The ray (in world space) to use to pick meshes
  36589. * @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
  36590. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36591. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36592. * @returns a PickingInfo
  36593. */
  36594. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36595. /**
  36596. * Force the sprite under the pointer
  36597. * @param sprite defines the sprite to use
  36598. */
  36599. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36600. /**
  36601. * Gets the sprite under the pointer
  36602. * @returns a Sprite or null if no sprite is under the pointer
  36603. */
  36604. getPointerOverSprite(): Nullable<Sprite>;
  36605. }
  36606. /**
  36607. * Defines the sprite scene component responsible to manage sprites
  36608. * in a given scene.
  36609. */
  36610. class SpriteSceneComponent implements ISceneComponent {
  36611. /**
  36612. * The component name helpfull to identify the component in the list of scene components.
  36613. */
  36614. readonly name: string;
  36615. /**
  36616. * The scene the component belongs to.
  36617. */
  36618. scene: Scene;
  36619. /** @hidden */
  36620. private _spritePredicate;
  36621. /**
  36622. * Creates a new instance of the component for the given scene
  36623. * @param scene Defines the scene to register the component in
  36624. */
  36625. constructor(scene: Scene);
  36626. /**
  36627. * Registers the component in a given scene
  36628. */
  36629. register(): void;
  36630. /**
  36631. * Rebuilds the elements related to this component in case of
  36632. * context lost for instance.
  36633. */
  36634. rebuild(): void;
  36635. /**
  36636. * Disposes the component and the associated ressources.
  36637. */
  36638. dispose(): void;
  36639. private _pickSpriteButKeepRay;
  36640. private _pointerMove;
  36641. private _pointerDown;
  36642. private _pointerUp;
  36643. }
  36644. }
  36645. declare module BABYLON {
  36646. /**
  36647. * @hidden
  36648. **/
  36649. class _AlphaState {
  36650. private _isAlphaBlendDirty;
  36651. private _isBlendFunctionParametersDirty;
  36652. private _isBlendEquationParametersDirty;
  36653. private _isBlendConstantsDirty;
  36654. private _alphaBlend;
  36655. private _blendFunctionParameters;
  36656. private _blendEquationParameters;
  36657. private _blendConstants;
  36658. /**
  36659. * Initializes the state.
  36660. */
  36661. constructor();
  36662. readonly isDirty: boolean;
  36663. alphaBlend: boolean;
  36664. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36665. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36666. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36667. reset(): void;
  36668. apply(gl: WebGLRenderingContext): void;
  36669. }
  36670. }
  36671. declare module BABYLON {
  36672. /**
  36673. * @hidden
  36674. **/
  36675. class _DepthCullingState {
  36676. private _isDepthTestDirty;
  36677. private _isDepthMaskDirty;
  36678. private _isDepthFuncDirty;
  36679. private _isCullFaceDirty;
  36680. private _isCullDirty;
  36681. private _isZOffsetDirty;
  36682. private _isFrontFaceDirty;
  36683. private _depthTest;
  36684. private _depthMask;
  36685. private _depthFunc;
  36686. private _cull;
  36687. private _cullFace;
  36688. private _zOffset;
  36689. private _frontFace;
  36690. /**
  36691. * Initializes the state.
  36692. */
  36693. constructor();
  36694. readonly isDirty: boolean;
  36695. zOffset: number;
  36696. cullFace: Nullable<number>;
  36697. cull: Nullable<boolean>;
  36698. depthFunc: Nullable<number>;
  36699. depthMask: boolean;
  36700. depthTest: boolean;
  36701. frontFace: Nullable<number>;
  36702. reset(): void;
  36703. apply(gl: WebGLRenderingContext): void;
  36704. }
  36705. }
  36706. declare module BABYLON {
  36707. /**
  36708. * @hidden
  36709. **/
  36710. class _StencilState {
  36711. private _isStencilTestDirty;
  36712. private _isStencilMaskDirty;
  36713. private _isStencilFuncDirty;
  36714. private _isStencilOpDirty;
  36715. private _stencilTest;
  36716. private _stencilMask;
  36717. private _stencilFunc;
  36718. private _stencilFuncRef;
  36719. private _stencilFuncMask;
  36720. private _stencilOpStencilFail;
  36721. private _stencilOpDepthFail;
  36722. private _stencilOpStencilDepthPass;
  36723. readonly isDirty: boolean;
  36724. stencilFunc: number;
  36725. stencilFuncRef: number;
  36726. stencilFuncMask: number;
  36727. stencilOpStencilFail: number;
  36728. stencilOpDepthFail: number;
  36729. stencilOpStencilDepthPass: number;
  36730. stencilMask: number;
  36731. stencilTest: boolean;
  36732. constructor();
  36733. reset(): void;
  36734. apply(gl: WebGLRenderingContext): void;
  36735. }
  36736. }
  36737. declare module BABYLON {
  36738. /**
  36739. * Class used to evalaute queries containing `and` and `or` operators
  36740. */
  36741. class AndOrNotEvaluator {
  36742. /**
  36743. * Evaluate a query
  36744. * @param query defines the query to evaluate
  36745. * @param evaluateCallback defines the callback used to filter result
  36746. * @returns true if the query matches
  36747. */
  36748. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36749. private static _HandleParenthesisContent;
  36750. private static _SimplifyNegation;
  36751. }
  36752. }
  36753. declare module BABYLON {
  36754. /**
  36755. * Defines the list of states available for a task inside a AssetsManager
  36756. */
  36757. enum AssetTaskState {
  36758. /**
  36759. * Initialization
  36760. */
  36761. INIT = 0,
  36762. /**
  36763. * Running
  36764. */
  36765. RUNNING = 1,
  36766. /**
  36767. * Done
  36768. */
  36769. DONE = 2,
  36770. /**
  36771. * Error
  36772. */
  36773. ERROR = 3
  36774. }
  36775. /**
  36776. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36777. */
  36778. abstract class AbstractAssetTask {
  36779. /**
  36780. * Task name
  36781. */ name: string;
  36782. /**
  36783. * Callback called when the task is successful
  36784. */
  36785. onSuccess: (task: any) => void;
  36786. /**
  36787. * Callback called when the task is not successful
  36788. */
  36789. onError: (task: any, message?: string, exception?: any) => void;
  36790. /**
  36791. * Creates a new AssetsManager
  36792. * @param name defines the name of the task
  36793. */
  36794. constructor(
  36795. /**
  36796. * Task name
  36797. */ name: string);
  36798. private _isCompleted;
  36799. private _taskState;
  36800. private _errorObject;
  36801. /**
  36802. * Get if the task is completed
  36803. */
  36804. readonly isCompleted: boolean;
  36805. /**
  36806. * Gets the current state of the task
  36807. */
  36808. readonly taskState: AssetTaskState;
  36809. /**
  36810. * Gets the current error object (if task is in error)
  36811. */
  36812. readonly errorObject: {
  36813. message?: string;
  36814. exception?: any;
  36815. };
  36816. /**
  36817. * Internal only
  36818. * @hidden
  36819. */
  36820. _setErrorObject(message?: string, exception?: any): void;
  36821. /**
  36822. * Execute the current task
  36823. * @param scene defines the scene where you want your assets to be loaded
  36824. * @param onSuccess is a callback called when the task is successfully executed
  36825. * @param onError is a callback called if an error occurs
  36826. */
  36827. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36828. /**
  36829. * Execute the current task
  36830. * @param scene defines the scene where you want your assets to be loaded
  36831. * @param onSuccess is a callback called when the task is successfully executed
  36832. * @param onError is a callback called if an error occurs
  36833. */
  36834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36835. /**
  36836. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36837. * This can be used with failed tasks that have the reason for failure fixed.
  36838. */
  36839. reset(): void;
  36840. private onErrorCallback;
  36841. private onDoneCallback;
  36842. }
  36843. /**
  36844. * Define the interface used by progress events raised during assets loading
  36845. */
  36846. interface IAssetsProgressEvent {
  36847. /**
  36848. * Defines the number of remaining tasks to process
  36849. */
  36850. remainingCount: number;
  36851. /**
  36852. * Defines the total number of tasks
  36853. */
  36854. totalCount: number;
  36855. /**
  36856. * Defines the task that was just processed
  36857. */
  36858. task: AbstractAssetTask;
  36859. }
  36860. /**
  36861. * Class used to share progress information about assets loading
  36862. */
  36863. class AssetsProgressEvent implements IAssetsProgressEvent {
  36864. /**
  36865. * Defines the number of remaining tasks to process
  36866. */
  36867. remainingCount: number;
  36868. /**
  36869. * Defines the total number of tasks
  36870. */
  36871. totalCount: number;
  36872. /**
  36873. * Defines the task that was just processed
  36874. */
  36875. task: AbstractAssetTask;
  36876. /**
  36877. * Creates a AssetsProgressEvent
  36878. * @param remainingCount defines the number of remaining tasks to process
  36879. * @param totalCount defines the total number of tasks
  36880. * @param task defines the task that was just processed
  36881. */
  36882. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36883. }
  36884. /**
  36885. * Define a task used by AssetsManager to load meshes
  36886. */
  36887. class MeshAssetTask extends AbstractAssetTask {
  36888. /**
  36889. * Defines the name of the task
  36890. */
  36891. name: string;
  36892. /**
  36893. * Defines the list of mesh's names you want to load
  36894. */
  36895. meshesNames: any;
  36896. /**
  36897. * Defines the root url to use as a base to load your meshes and associated resources
  36898. */
  36899. rootUrl: string;
  36900. /**
  36901. * Defines the filename of the scene to load from
  36902. */
  36903. sceneFilename: string;
  36904. /**
  36905. * Gets the list of loaded meshes
  36906. */
  36907. loadedMeshes: Array<AbstractMesh>;
  36908. /**
  36909. * Gets the list of loaded particle systems
  36910. */
  36911. loadedParticleSystems: Array<IParticleSystem>;
  36912. /**
  36913. * Gets the list of loaded skeletons
  36914. */
  36915. loadedSkeletons: Array<Skeleton>;
  36916. /**
  36917. * Callback called when the task is successful
  36918. */
  36919. onSuccess: (task: MeshAssetTask) => void;
  36920. /**
  36921. * Callback called when the task is successful
  36922. */
  36923. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36924. /**
  36925. * Creates a new MeshAssetTask
  36926. * @param name defines the name of the task
  36927. * @param meshesNames defines the list of mesh's names you want to load
  36928. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36929. * @param sceneFilename defines the filename of the scene to load from
  36930. */
  36931. constructor(
  36932. /**
  36933. * Defines the name of the task
  36934. */
  36935. name: string,
  36936. /**
  36937. * Defines the list of mesh's names you want to load
  36938. */
  36939. meshesNames: any,
  36940. /**
  36941. * Defines the root url to use as a base to load your meshes and associated resources
  36942. */
  36943. rootUrl: string,
  36944. /**
  36945. * Defines the filename of the scene to load from
  36946. */
  36947. sceneFilename: string);
  36948. /**
  36949. * Execute the current task
  36950. * @param scene defines the scene where you want your assets to be loaded
  36951. * @param onSuccess is a callback called when the task is successfully executed
  36952. * @param onError is a callback called if an error occurs
  36953. */
  36954. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36955. }
  36956. /**
  36957. * Define a task used by AssetsManager to load text content
  36958. */
  36959. class TextFileAssetTask extends AbstractAssetTask {
  36960. /**
  36961. * Defines the name of the task
  36962. */
  36963. name: string;
  36964. /**
  36965. * Defines the location of the file to load
  36966. */
  36967. url: string;
  36968. /**
  36969. * Gets the loaded text string
  36970. */
  36971. text: string;
  36972. /**
  36973. * Callback called when the task is successful
  36974. */
  36975. onSuccess: (task: TextFileAssetTask) => void;
  36976. /**
  36977. * Callback called when the task is successful
  36978. */
  36979. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36980. /**
  36981. * Creates a new TextFileAssetTask object
  36982. * @param name defines the name of the task
  36983. * @param url defines the location of the file to load
  36984. */
  36985. constructor(
  36986. /**
  36987. * Defines the name of the task
  36988. */
  36989. name: string,
  36990. /**
  36991. * Defines the location of the file to load
  36992. */
  36993. url: string);
  36994. /**
  36995. * Execute the current task
  36996. * @param scene defines the scene where you want your assets to be loaded
  36997. * @param onSuccess is a callback called when the task is successfully executed
  36998. * @param onError is a callback called if an error occurs
  36999. */
  37000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37001. }
  37002. /**
  37003. * Define a task used by AssetsManager to load binary data
  37004. */
  37005. class BinaryFileAssetTask extends AbstractAssetTask {
  37006. /**
  37007. * Defines the name of the task
  37008. */
  37009. name: string;
  37010. /**
  37011. * Defines the location of the file to load
  37012. */
  37013. url: string;
  37014. /**
  37015. * Gets the lodaded data (as an array buffer)
  37016. */
  37017. data: ArrayBuffer;
  37018. /**
  37019. * Callback called when the task is successful
  37020. */
  37021. onSuccess: (task: BinaryFileAssetTask) => void;
  37022. /**
  37023. * Callback called when the task is successful
  37024. */
  37025. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37026. /**
  37027. * Creates a new BinaryFileAssetTask object
  37028. * @param name defines the name of the new task
  37029. * @param url defines the location of the file to load
  37030. */
  37031. constructor(
  37032. /**
  37033. * Defines the name of the task
  37034. */
  37035. name: string,
  37036. /**
  37037. * Defines the location of the file to load
  37038. */
  37039. url: string);
  37040. /**
  37041. * Execute the current task
  37042. * @param scene defines the scene where you want your assets to be loaded
  37043. * @param onSuccess is a callback called when the task is successfully executed
  37044. * @param onError is a callback called if an error occurs
  37045. */
  37046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37047. }
  37048. /**
  37049. * Define a task used by AssetsManager to load images
  37050. */
  37051. class ImageAssetTask extends AbstractAssetTask {
  37052. /**
  37053. * Defines the name of the task
  37054. */
  37055. name: string;
  37056. /**
  37057. * Defines the location of the image to load
  37058. */
  37059. url: string;
  37060. /**
  37061. * Gets the loaded images
  37062. */
  37063. image: HTMLImageElement;
  37064. /**
  37065. * Callback called when the task is successful
  37066. */
  37067. onSuccess: (task: ImageAssetTask) => void;
  37068. /**
  37069. * Callback called when the task is successful
  37070. */
  37071. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37072. /**
  37073. * Creates a new ImageAssetTask
  37074. * @param name defines the name of the task
  37075. * @param url defines the location of the image to load
  37076. */
  37077. constructor(
  37078. /**
  37079. * Defines the name of the task
  37080. */
  37081. name: string,
  37082. /**
  37083. * Defines the location of the image to load
  37084. */
  37085. url: string);
  37086. /**
  37087. * Execute the current task
  37088. * @param scene defines the scene where you want your assets to be loaded
  37089. * @param onSuccess is a callback called when the task is successfully executed
  37090. * @param onError is a callback called if an error occurs
  37091. */
  37092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37093. }
  37094. /**
  37095. * Defines the interface used by texture loading tasks
  37096. */
  37097. interface ITextureAssetTask<TEX extends BaseTexture> {
  37098. /**
  37099. * Gets the loaded texture
  37100. */
  37101. texture: TEX;
  37102. }
  37103. /**
  37104. * Define a task used by AssetsManager to load 2D textures
  37105. */
  37106. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37107. /**
  37108. * Defines the name of the task
  37109. */
  37110. name: string;
  37111. /**
  37112. * Defines the location of the file to load
  37113. */
  37114. url: string;
  37115. /**
  37116. * Defines if mipmap should not be generated (default is false)
  37117. */
  37118. noMipmap?: boolean | undefined;
  37119. /**
  37120. * Defines if texture must be inverted on Y axis (default is false)
  37121. */
  37122. invertY?: boolean | undefined;
  37123. /**
  37124. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37125. */
  37126. samplingMode: number;
  37127. /**
  37128. * Gets the loaded texture
  37129. */
  37130. texture: Texture;
  37131. /**
  37132. * Callback called when the task is successful
  37133. */
  37134. onSuccess: (task: TextureAssetTask) => void;
  37135. /**
  37136. * Callback called when the task is successful
  37137. */
  37138. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37139. /**
  37140. * Creates a new TextureAssetTask object
  37141. * @param name defines the name of the task
  37142. * @param url defines the location of the file to load
  37143. * @param noMipmap defines if mipmap should not be generated (default is false)
  37144. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37145. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37146. */
  37147. constructor(
  37148. /**
  37149. * Defines the name of the task
  37150. */
  37151. name: string,
  37152. /**
  37153. * Defines the location of the file to load
  37154. */
  37155. url: string,
  37156. /**
  37157. * Defines if mipmap should not be generated (default is false)
  37158. */
  37159. noMipmap?: boolean | undefined,
  37160. /**
  37161. * Defines if texture must be inverted on Y axis (default is false)
  37162. */
  37163. invertY?: boolean | undefined,
  37164. /**
  37165. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37166. */
  37167. samplingMode?: number);
  37168. /**
  37169. * Execute the current task
  37170. * @param scene defines the scene where you want your assets to be loaded
  37171. * @param onSuccess is a callback called when the task is successfully executed
  37172. * @param onError is a callback called if an error occurs
  37173. */
  37174. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37175. }
  37176. /**
  37177. * Define a task used by AssetsManager to load cube textures
  37178. */
  37179. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37180. /**
  37181. * Defines the name of the task
  37182. */
  37183. name: string;
  37184. /**
  37185. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37186. */
  37187. url: string;
  37188. /**
  37189. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37190. */
  37191. extensions?: string[] | undefined;
  37192. /**
  37193. * Defines if mipmaps should not be generated (default is false)
  37194. */
  37195. noMipmap?: boolean | undefined;
  37196. /**
  37197. * Defines the explicit list of files (undefined by default)
  37198. */
  37199. files?: string[] | undefined;
  37200. /**
  37201. * Gets the loaded texture
  37202. */
  37203. texture: CubeTexture;
  37204. /**
  37205. * Callback called when the task is successful
  37206. */
  37207. onSuccess: (task: CubeTextureAssetTask) => void;
  37208. /**
  37209. * Callback called when the task is successful
  37210. */
  37211. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37212. /**
  37213. * Creates a new CubeTextureAssetTask
  37214. * @param name defines the name of the task
  37215. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37216. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37217. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37218. * @param files defines the explicit list of files (undefined by default)
  37219. */
  37220. constructor(
  37221. /**
  37222. * Defines the name of the task
  37223. */
  37224. name: string,
  37225. /**
  37226. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37227. */
  37228. url: string,
  37229. /**
  37230. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37231. */
  37232. extensions?: string[] | undefined,
  37233. /**
  37234. * Defines if mipmaps should not be generated (default is false)
  37235. */
  37236. noMipmap?: boolean | undefined,
  37237. /**
  37238. * Defines the explicit list of files (undefined by default)
  37239. */
  37240. files?: string[] | undefined);
  37241. /**
  37242. * Execute the current task
  37243. * @param scene defines the scene where you want your assets to be loaded
  37244. * @param onSuccess is a callback called when the task is successfully executed
  37245. * @param onError is a callback called if an error occurs
  37246. */
  37247. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37248. }
  37249. /**
  37250. * Define a task used by AssetsManager to load HDR cube textures
  37251. */
  37252. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37253. /**
  37254. * Defines the name of the task
  37255. */
  37256. name: string;
  37257. /**
  37258. * Defines the location of the file to load
  37259. */
  37260. url: string;
  37261. /**
  37262. * Defines the desired size (the more it increases the longer the generation will be)
  37263. */
  37264. size: number;
  37265. /**
  37266. * Defines if mipmaps should not be generated (default is false)
  37267. */
  37268. noMipmap: boolean;
  37269. /**
  37270. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37271. */
  37272. generateHarmonics: boolean;
  37273. /**
  37274. * 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)
  37275. */
  37276. gammaSpace: boolean;
  37277. /**
  37278. * Internal Use Only
  37279. */
  37280. reserved: boolean;
  37281. /**
  37282. * Gets the loaded texture
  37283. */
  37284. texture: HDRCubeTexture;
  37285. /**
  37286. * Callback called when the task is successful
  37287. */
  37288. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37289. /**
  37290. * Callback called when the task is successful
  37291. */
  37292. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37293. /**
  37294. * Creates a new HDRCubeTextureAssetTask object
  37295. * @param name defines the name of the task
  37296. * @param url defines the location of the file to load
  37297. * @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.
  37298. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37299. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37300. * @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)
  37301. * @param reserved Internal use only
  37302. */
  37303. constructor(
  37304. /**
  37305. * Defines the name of the task
  37306. */
  37307. name: string,
  37308. /**
  37309. * Defines the location of the file to load
  37310. */
  37311. url: string,
  37312. /**
  37313. * Defines the desired size (the more it increases the longer the generation will be)
  37314. */
  37315. size: number,
  37316. /**
  37317. * Defines if mipmaps should not be generated (default is false)
  37318. */
  37319. noMipmap?: boolean,
  37320. /**
  37321. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37322. */
  37323. generateHarmonics?: boolean,
  37324. /**
  37325. * 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)
  37326. */
  37327. gammaSpace?: boolean,
  37328. /**
  37329. * Internal Use Only
  37330. */
  37331. reserved?: boolean);
  37332. /**
  37333. * Execute the current task
  37334. * @param scene defines the scene where you want your assets to be loaded
  37335. * @param onSuccess is a callback called when the task is successfully executed
  37336. * @param onError is a callback called if an error occurs
  37337. */
  37338. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37339. }
  37340. /**
  37341. * This class can be used to easily import assets into a scene
  37342. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37343. */
  37344. class AssetsManager {
  37345. private _scene;
  37346. private _isLoading;
  37347. protected _tasks: AbstractAssetTask[];
  37348. protected _waitingTasksCount: number;
  37349. protected _totalTasksCount: number;
  37350. /**
  37351. * Callback called when all tasks are processed
  37352. */
  37353. onFinish: (tasks: AbstractAssetTask[]) => void;
  37354. /**
  37355. * Callback called when a task is successful
  37356. */
  37357. onTaskSuccess: (task: AbstractAssetTask) => void;
  37358. /**
  37359. * Callback called when a task had an error
  37360. */
  37361. onTaskError: (task: AbstractAssetTask) => void;
  37362. /**
  37363. * Callback called when a task is done (whatever the result is)
  37364. */
  37365. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37366. /**
  37367. * Observable called when all tasks are processed
  37368. */
  37369. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37370. /**
  37371. * Observable called when a task had an error
  37372. */
  37373. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37374. /**
  37375. * Observable called when a task is successful
  37376. */
  37377. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37378. /**
  37379. * Observable called when a task is done (whatever the result is)
  37380. */
  37381. onProgressObservable: Observable<IAssetsProgressEvent>;
  37382. /**
  37383. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37384. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37385. */
  37386. useDefaultLoadingScreen: boolean;
  37387. /**
  37388. * Creates a new AssetsManager
  37389. * @param scene defines the scene to work on
  37390. */
  37391. constructor(scene: Scene);
  37392. /**
  37393. * Add a MeshAssetTask to the list of active tasks
  37394. * @param taskName defines the name of the new task
  37395. * @param meshesNames defines the name of meshes to load
  37396. * @param rootUrl defines the root url to use to locate files
  37397. * @param sceneFilename defines the filename of the scene file
  37398. * @returns a new MeshAssetTask object
  37399. */
  37400. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37401. /**
  37402. * Add a TextFileAssetTask to the list of active tasks
  37403. * @param taskName defines the name of the new task
  37404. * @param url defines the url of the file to load
  37405. * @returns a new TextFileAssetTask object
  37406. */
  37407. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37408. /**
  37409. * Add a BinaryFileAssetTask to the list of active tasks
  37410. * @param taskName defines the name of the new task
  37411. * @param url defines the url of the file to load
  37412. * @returns a new BinaryFileAssetTask object
  37413. */
  37414. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37415. /**
  37416. * Add a ImageAssetTask to the list of active tasks
  37417. * @param taskName defines the name of the new task
  37418. * @param url defines the url of the file to load
  37419. * @returns a new ImageAssetTask object
  37420. */
  37421. addImageTask(taskName: string, url: string): ImageAssetTask;
  37422. /**
  37423. * Add a TextureAssetTask to the list of active tasks
  37424. * @param taskName defines the name of the new task
  37425. * @param url defines the url of the file to load
  37426. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37427. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37428. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37429. * @returns a new TextureAssetTask object
  37430. */
  37431. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37432. /**
  37433. * Add a CubeTextureAssetTask to the list of active tasks
  37434. * @param taskName defines the name of the new task
  37435. * @param url defines the url of the file to load
  37436. * @param extensions defines the extension to use to load the cube map (can be null)
  37437. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37438. * @param files defines the list of files to load (can be null)
  37439. * @returns a new CubeTextureAssetTask object
  37440. */
  37441. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37442. /**
  37443. *
  37444. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37445. * @param taskName defines the name of the new task
  37446. * @param url defines the url of the file to load
  37447. * @param size defines the size you want for the cubemap (can be null)
  37448. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37449. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37450. * @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)
  37451. * @param reserved Internal use only
  37452. * @returns a new HDRCubeTextureAssetTask object
  37453. */
  37454. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37455. /**
  37456. * Remove a task from the assets manager.
  37457. * @param task the task to remove
  37458. */
  37459. removeTask(task: AbstractAssetTask): void;
  37460. private _decreaseWaitingTasksCount;
  37461. private _runTask;
  37462. /**
  37463. * Reset the AssetsManager and remove all tasks
  37464. * @return the current instance of the AssetsManager
  37465. */
  37466. reset(): AssetsManager;
  37467. /**
  37468. * Start the loading process
  37469. * @return the current instance of the AssetsManager
  37470. */
  37471. load(): AssetsManager;
  37472. }
  37473. }
  37474. declare module BABYLON {
  37475. /**
  37476. * Direct draw surface info
  37477. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37478. */
  37479. interface DDSInfo {
  37480. /**
  37481. * Width of the texture
  37482. */
  37483. width: number;
  37484. /**
  37485. * Width of the texture
  37486. */
  37487. height: number;
  37488. /**
  37489. * Number of Mipmaps for the texture
  37490. * @see https://en.wikipedia.org/wiki/Mipmap
  37491. */
  37492. mipmapCount: number;
  37493. /**
  37494. * If the textures format is a known fourCC format
  37495. * @see https://www.fourcc.org/
  37496. */
  37497. isFourCC: boolean;
  37498. /**
  37499. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37500. */
  37501. isRGB: boolean;
  37502. /**
  37503. * If the texture is a lumincance format
  37504. */
  37505. isLuminance: boolean;
  37506. /**
  37507. * If this is a cube texture
  37508. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37509. */
  37510. isCube: boolean;
  37511. /**
  37512. * If the texture is a compressed format eg. FOURCC_DXT1
  37513. */
  37514. isCompressed: boolean;
  37515. /**
  37516. * The dxgiFormat of the texture
  37517. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37518. */
  37519. dxgiFormat: number;
  37520. /**
  37521. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37522. */
  37523. textureType: number;
  37524. /**
  37525. * Sphericle polynomial created for the dds texture
  37526. */
  37527. sphericalPolynomial?: SphericalPolynomial;
  37528. }
  37529. /**
  37530. * Class used to provide DDS decompression tools
  37531. */
  37532. class DDSTools {
  37533. /**
  37534. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37535. */
  37536. static StoreLODInAlphaChannel: boolean;
  37537. /**
  37538. * Gets DDS information from an array buffer
  37539. * @param arrayBuffer defines the array buffer to read data from
  37540. * @returns the DDS information
  37541. */
  37542. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37543. private static _FloatView;
  37544. private static _Int32View;
  37545. private static _ToHalfFloat;
  37546. private static _FromHalfFloat;
  37547. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37548. private static _GetHalfFloatRGBAArrayBuffer;
  37549. private static _GetFloatRGBAArrayBuffer;
  37550. private static _GetFloatAsUIntRGBAArrayBuffer;
  37551. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37552. private static _GetRGBAArrayBuffer;
  37553. private static _ExtractLongWordOrder;
  37554. private static _GetRGBArrayBuffer;
  37555. private static _GetLuminanceArrayBuffer;
  37556. /**
  37557. * Uploads DDS Levels to a Babylon Texture
  37558. * @hidden
  37559. */
  37560. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37561. }
  37562. }
  37563. declare module BABYLON {
  37564. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37565. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37566. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37567. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37568. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37569. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37570. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37571. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37572. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37573. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37574. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37575. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37576. /**
  37577. * Decorator used to define property that can be serialized as reference to a camera
  37578. * @param sourceName defines the name of the property to decorate
  37579. */
  37580. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37581. /**
  37582. * Class used to help serialization objects
  37583. */
  37584. class SerializationHelper {
  37585. /**
  37586. * Static function used to serialized a specific entity
  37587. * @param entity defines the entity to serialize
  37588. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37589. * @returns a JSON compatible object representing the serialization of the entity
  37590. */
  37591. static Serialize<T>(entity: T, serializationObject?: any): any;
  37592. /**
  37593. * Creates a new entity from a serialization data object
  37594. * @param creationFunction defines a function used to instanciated the new entity
  37595. * @param source defines the source serialization data
  37596. * @param scene defines the hosting scene
  37597. * @param rootUrl defines the root url for resources
  37598. * @returns a new entity
  37599. */
  37600. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37601. /**
  37602. * Clones an object
  37603. * @param creationFunction defines the function used to instanciate the new object
  37604. * @param source defines the source object
  37605. * @returns the cloned object
  37606. */
  37607. static Clone<T>(creationFunction: () => T, source: T): T;
  37608. /**
  37609. * Instanciates a new object based on a source one (some data will be shared between both object)
  37610. * @param creationFunction defines the function used to instanciate the new object
  37611. * @param source defines the source object
  37612. * @returns the new object
  37613. */
  37614. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37615. }
  37616. }
  37617. declare module BABYLON {
  37618. /**
  37619. * Wrapper class for promise with external resolve and reject.
  37620. */
  37621. class Deferred<T> {
  37622. /**
  37623. * The promise associated with this deferred object.
  37624. */
  37625. readonly promise: Promise<T>;
  37626. private _resolve;
  37627. private _reject;
  37628. /**
  37629. * The resolve method of the promise associated with this deferred object.
  37630. */
  37631. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37632. /**
  37633. * The reject method of the promise associated with this deferred object.
  37634. */
  37635. readonly reject: (reason?: any) => void;
  37636. /**
  37637. * Constructor for this deferred object.
  37638. */
  37639. constructor();
  37640. }
  37641. }
  37642. declare module BABYLON {
  37643. /**
  37644. * Raw texture data and descriptor sufficient for WebGL texture upload
  37645. */
  37646. interface EnvironmentTextureInfo {
  37647. /**
  37648. * Version of the environment map
  37649. */
  37650. version: number;
  37651. /**
  37652. * Width of image
  37653. */
  37654. width: number;
  37655. /**
  37656. * Irradiance information stored in the file.
  37657. */
  37658. irradiance: any;
  37659. /**
  37660. * Specular information stored in the file.
  37661. */
  37662. specular: any;
  37663. }
  37664. /**
  37665. * Sets of helpers addressing the serialization and deserialization of environment texture
  37666. * stored in a BabylonJS env file.
  37667. * Those files are usually stored as .env files.
  37668. */
  37669. class EnvironmentTextureTools {
  37670. /**
  37671. * Magic number identifying the env file.
  37672. */
  37673. private static _MagicBytes;
  37674. /**
  37675. * Gets the environment info from an env file.
  37676. * @param data The array buffer containing the .env bytes.
  37677. * @returns the environment file info (the json header) if successfully parsed.
  37678. */
  37679. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37680. /**
  37681. * Creates an environment texture from a loaded cube texture.
  37682. * @param texture defines the cube texture to convert in env file
  37683. * @return a promise containing the environment data if succesfull.
  37684. */
  37685. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37686. /**
  37687. * Creates a JSON representation of the spherical data.
  37688. * @param texture defines the texture containing the polynomials
  37689. * @return the JSON representation of the spherical info
  37690. */
  37691. private static _CreateEnvTextureIrradiance;
  37692. /**
  37693. * Uploads the texture info contained in the env file to the GPU.
  37694. * @param texture defines the internal texture to upload to
  37695. * @param arrayBuffer defines the buffer cotaining the data to load
  37696. * @param info defines the texture info retrieved through the GetEnvInfo method
  37697. * @returns a promise
  37698. */
  37699. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37700. /**
  37701. * Uploads the levels of image data to the GPU.
  37702. * @param texture defines the internal texture to upload to
  37703. * @param imageData defines the array buffer views of image data [mipmap][face]
  37704. * @returns a promise
  37705. */
  37706. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37707. /**
  37708. * Uploads spherical polynomials information to the texture.
  37709. * @param texture defines the texture we are trying to upload the information to
  37710. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37711. */
  37712. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37713. }
  37714. }
  37715. declare module BABYLON {
  37716. /**
  37717. * Class used to help managing file picking and drag'n'drop
  37718. */
  37719. class FilesInput {
  37720. /**
  37721. * List of files ready to be loaded
  37722. */
  37723. static FilesToLoad: {
  37724. [key: string]: File;
  37725. };
  37726. /**
  37727. * Callback called when a file is processed
  37728. */
  37729. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37730. private _engine;
  37731. private _currentScene;
  37732. private _sceneLoadedCallback;
  37733. private _progressCallback;
  37734. private _additionalRenderLoopLogicCallback;
  37735. private _textureLoadingCallback;
  37736. private _startingProcessingFilesCallback;
  37737. private _onReloadCallback;
  37738. private _errorCallback;
  37739. private _elementToMonitor;
  37740. private _sceneFileToLoad;
  37741. private _filesToLoad;
  37742. /**
  37743. * Creates a new FilesInput
  37744. * @param engine defines the rendering engine
  37745. * @param scene defines the hosting scene
  37746. * @param sceneLoadedCallback callback called when scene is loaded
  37747. * @param progressCallback callback called to track progress
  37748. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37749. * @param textureLoadingCallback callback called when a texture is loading
  37750. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37751. * @param onReloadCallback callback called when a reload is requested
  37752. * @param errorCallback callback call if an error occurs
  37753. */
  37754. 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);
  37755. private _dragEnterHandler;
  37756. private _dragOverHandler;
  37757. private _dropHandler;
  37758. /**
  37759. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37760. * @param elementToMonitor defines the DOM element to track
  37761. */
  37762. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37763. /**
  37764. * Release all associated resources
  37765. */
  37766. dispose(): void;
  37767. private renderFunction;
  37768. private drag;
  37769. private drop;
  37770. private _traverseFolder;
  37771. private _processFiles;
  37772. /**
  37773. * Load files from a drop event
  37774. * @param event defines the drop event to use as source
  37775. */
  37776. loadFiles(event: any): void;
  37777. private _processReload;
  37778. /**
  37779. * Reload the current scene from the loaded files
  37780. */
  37781. reload(): void;
  37782. }
  37783. }
  37784. declare module BABYLON {
  37785. /**
  37786. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37787. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37788. */
  37789. class KhronosTextureContainer {
  37790. /** contents of the KTX container file */
  37791. arrayBuffer: any;
  37792. private static HEADER_LEN;
  37793. private static COMPRESSED_2D;
  37794. private static COMPRESSED_3D;
  37795. private static TEX_2D;
  37796. private static TEX_3D;
  37797. /**
  37798. * Gets the openGL type
  37799. */
  37800. glType: number;
  37801. /**
  37802. * Gets the openGL type size
  37803. */
  37804. glTypeSize: number;
  37805. /**
  37806. * Gets the openGL format
  37807. */
  37808. glFormat: number;
  37809. /**
  37810. * Gets the openGL internal format
  37811. */
  37812. glInternalFormat: number;
  37813. /**
  37814. * Gets the base internal format
  37815. */
  37816. glBaseInternalFormat: number;
  37817. /**
  37818. * Gets image width in pixel
  37819. */
  37820. pixelWidth: number;
  37821. /**
  37822. * Gets image height in pixel
  37823. */
  37824. pixelHeight: number;
  37825. /**
  37826. * Gets image depth in pixels
  37827. */
  37828. pixelDepth: number;
  37829. /**
  37830. * Gets the number of array elements
  37831. */
  37832. numberOfArrayElements: number;
  37833. /**
  37834. * Gets the number of faces
  37835. */
  37836. numberOfFaces: number;
  37837. /**
  37838. * Gets the number of mipmap levels
  37839. */
  37840. numberOfMipmapLevels: number;
  37841. /**
  37842. * Gets the bytes of key value data
  37843. */
  37844. bytesOfKeyValueData: number;
  37845. /**
  37846. * Gets the load type
  37847. */
  37848. loadType: number;
  37849. /**
  37850. * Creates a new KhronosTextureContainer
  37851. * @param arrayBuffer contents of the KTX container file
  37852. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37853. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37854. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37855. */
  37856. constructor(
  37857. /** contents of the KTX container file */
  37858. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37859. /**
  37860. * Revert the endianness of a value.
  37861. * Not as fast hardware based, but will probably never need to use
  37862. * @param val defines the value to convert
  37863. * @returns the new value
  37864. */
  37865. switchEndianness(val: number): number;
  37866. /**
  37867. * Uploads KTX content to a Babylon Texture.
  37868. * It is assumed that the texture has already been created & is currently bound
  37869. * @hidden
  37870. */
  37871. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37872. private _upload2DCompressedLevels;
  37873. }
  37874. }
  37875. declare module BABYLON {
  37876. /**
  37877. * A class serves as a medium between the observable and its observers
  37878. */
  37879. class EventState {
  37880. /**
  37881. * Create a new EventState
  37882. * @param mask defines the mask associated with this state
  37883. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37884. * @param target defines the original target of the state
  37885. * @param currentTarget defines the current target of the state
  37886. */
  37887. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37888. /**
  37889. * Initialize the current event state
  37890. * @param mask defines the mask associated with this state
  37891. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37892. * @param target defines the original target of the state
  37893. * @param currentTarget defines the current target of the state
  37894. * @returns the current event state
  37895. */
  37896. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37897. /**
  37898. * An Observer can set this property to true to prevent subsequent observers of being notified
  37899. */
  37900. skipNextObservers: boolean;
  37901. /**
  37902. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37903. */
  37904. mask: number;
  37905. /**
  37906. * The object that originally notified the event
  37907. */
  37908. target?: any;
  37909. /**
  37910. * The current object in the bubbling phase
  37911. */
  37912. currentTarget?: any;
  37913. /**
  37914. * This will be populated with the return value of the last function that was executed.
  37915. * If it is the first function in the callback chain it will be the event data.
  37916. */
  37917. lastReturnValue?: any;
  37918. }
  37919. /**
  37920. * Represent an Observer registered to a given Observable object.
  37921. */
  37922. class Observer<T> {
  37923. /**
  37924. * Defines the callback to call when the observer is notified
  37925. */
  37926. callback: (eventData: T, eventState: EventState) => void;
  37927. /**
  37928. * Defines the mask of the observer (used to filter notifications)
  37929. */
  37930. mask: number;
  37931. /**
  37932. * Defines the current scope used to restore the JS context
  37933. */
  37934. scope: any;
  37935. /** @hidden */
  37936. _willBeUnregistered: boolean;
  37937. /**
  37938. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37939. */
  37940. unregisterOnNextCall: boolean;
  37941. /**
  37942. * Creates a new observer
  37943. * @param callback defines the callback to call when the observer is notified
  37944. * @param mask defines the mask of the observer (used to filter notifications)
  37945. * @param scope defines the current scope used to restore the JS context
  37946. */
  37947. constructor(
  37948. /**
  37949. * Defines the callback to call when the observer is notified
  37950. */
  37951. callback: (eventData: T, eventState: EventState) => void,
  37952. /**
  37953. * Defines the mask of the observer (used to filter notifications)
  37954. */
  37955. mask: number,
  37956. /**
  37957. * Defines the current scope used to restore the JS context
  37958. */
  37959. scope?: any);
  37960. }
  37961. /**
  37962. * Represent a list of observers registered to multiple Observables object.
  37963. */
  37964. class MultiObserver<T> {
  37965. private _observers;
  37966. private _observables;
  37967. /**
  37968. * Release associated resources
  37969. */
  37970. dispose(): void;
  37971. /**
  37972. * Raise a callback when one of the observable will notify
  37973. * @param observables defines a list of observables to watch
  37974. * @param callback defines the callback to call on notification
  37975. * @param mask defines the mask used to filter notifications
  37976. * @param scope defines the current scope used to restore the JS context
  37977. * @returns the new MultiObserver
  37978. */
  37979. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37980. }
  37981. /**
  37982. * The Observable class is a simple implementation of the Observable pattern.
  37983. *
  37984. * 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.
  37985. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37986. * 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).
  37987. * 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.
  37988. */
  37989. class Observable<T> {
  37990. private _observers;
  37991. private _eventState;
  37992. private _onObserverAdded;
  37993. /**
  37994. * Creates a new observable
  37995. * @param onObserverAdded defines a callback to call when a new observer is added
  37996. */
  37997. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37998. /**
  37999. * Create a new Observer with the specified callback
  38000. * @param callback the callback that will be executed for that Observer
  38001. * @param mask the mask used to filter observers
  38002. * @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.
  38003. * @param scope optional scope for the callback to be called from
  38004. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38005. * @returns the new observer created for the callback
  38006. */
  38007. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38008. /**
  38009. * Create a new Observer with the specified callback and unregisters after the next notification
  38010. * @param callback the callback that will be executed for that Observer
  38011. * @returns the new observer created for the callback
  38012. */
  38013. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38014. /**
  38015. * Remove an Observer from the Observable object
  38016. * @param observer the instance of the Observer to remove
  38017. * @returns false if it doesn't belong to this Observable
  38018. */
  38019. remove(observer: Nullable<Observer<T>>): boolean;
  38020. /**
  38021. * Remove a callback from the Observable object
  38022. * @param callback the callback to remove
  38023. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38024. * @returns false if it doesn't belong to this Observable
  38025. */
  38026. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38027. private _deferUnregister;
  38028. private _remove;
  38029. /**
  38030. * Notify all Observers by calling their respective callback with the given data
  38031. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38032. * @param eventData defines the data to send to all observers
  38033. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38034. * @param target defines the original target of the state
  38035. * @param currentTarget defines the current target of the state
  38036. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38037. */
  38038. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38039. /**
  38040. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38041. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38042. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38043. * and it is crucial that all callbacks will be executed.
  38044. * The order of the callbacks is kept, callbacks are not executed parallel.
  38045. *
  38046. * @param eventData The data to be sent to each callback
  38047. * @param mask is used to filter observers defaults to -1
  38048. * @param target defines the callback target (see EventState)
  38049. * @param currentTarget defines he current object in the bubbling phase
  38050. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38051. */
  38052. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38053. /**
  38054. * Notify a specific observer
  38055. * @param observer defines the observer to notify
  38056. * @param eventData defines the data to be sent to each callback
  38057. * @param mask is used to filter observers defaults to -1
  38058. */
  38059. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38060. /**
  38061. * Gets a boolean indicating if the observable has at least one observer
  38062. * @returns true is the Observable has at least one Observer registered
  38063. */
  38064. hasObservers(): boolean;
  38065. /**
  38066. * Clear the list of observers
  38067. */
  38068. clear(): void;
  38069. /**
  38070. * Clone the current observable
  38071. * @returns a new observable
  38072. */
  38073. clone(): Observable<T>;
  38074. /**
  38075. * Does this observable handles observer registered with a given mask
  38076. * @param mask defines the mask to be tested
  38077. * @return whether or not one observer registered with the given mask is handeled
  38078. **/
  38079. hasSpecificMask(mask?: number): boolean;
  38080. }
  38081. }
  38082. declare module BABYLON {
  38083. /**
  38084. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38085. */
  38086. class PerformanceMonitor {
  38087. private _enabled;
  38088. private _rollingFrameTime;
  38089. private _lastFrameTimeMs;
  38090. /**
  38091. * constructor
  38092. * @param frameSampleSize The number of samples required to saturate the sliding window
  38093. */
  38094. constructor(frameSampleSize?: number);
  38095. /**
  38096. * Samples current frame
  38097. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38098. */
  38099. sampleFrame(timeMs?: number): void;
  38100. /**
  38101. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38102. */
  38103. readonly averageFrameTime: number;
  38104. /**
  38105. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38106. */
  38107. readonly averageFrameTimeVariance: number;
  38108. /**
  38109. * Returns the frame time of the most recent frame
  38110. */
  38111. readonly instantaneousFrameTime: number;
  38112. /**
  38113. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38114. */
  38115. readonly averageFPS: number;
  38116. /**
  38117. * Returns the average framerate in frames per second using the most recent frame time
  38118. */
  38119. readonly instantaneousFPS: number;
  38120. /**
  38121. * Returns true if enough samples have been taken to completely fill the sliding window
  38122. */
  38123. readonly isSaturated: boolean;
  38124. /**
  38125. * Enables contributions to the sliding window sample set
  38126. */
  38127. enable(): void;
  38128. /**
  38129. * Disables contributions to the sliding window sample set
  38130. * Samples will not be interpolated over the disabled period
  38131. */
  38132. disable(): void;
  38133. /**
  38134. * Returns true if sampling is enabled
  38135. */
  38136. readonly isEnabled: boolean;
  38137. /**
  38138. * Resets performance monitor
  38139. */
  38140. reset(): void;
  38141. }
  38142. /**
  38143. * RollingAverage
  38144. *
  38145. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38146. */
  38147. class RollingAverage {
  38148. /**
  38149. * Current average
  38150. */
  38151. average: number;
  38152. /**
  38153. * Current variance
  38154. */
  38155. variance: number;
  38156. protected _samples: Array<number>;
  38157. protected _sampleCount: number;
  38158. protected _pos: number;
  38159. protected _m2: number;
  38160. /**
  38161. * constructor
  38162. * @param length The number of samples required to saturate the sliding window
  38163. */
  38164. constructor(length: number);
  38165. /**
  38166. * Adds a sample to the sample set
  38167. * @param v The sample value
  38168. */
  38169. add(v: number): void;
  38170. /**
  38171. * Returns previously added values or null if outside of history or outside the sliding window domain
  38172. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38173. * @return Value previously recorded with add() or null if outside of range
  38174. */
  38175. history(i: number): number;
  38176. /**
  38177. * Returns true if enough samples have been taken to completely fill the sliding window
  38178. * @return true if sample-set saturated
  38179. */
  38180. isSaturated(): boolean;
  38181. /**
  38182. * Resets the rolling average (equivalent to 0 samples taken so far)
  38183. */
  38184. reset(): void;
  38185. /**
  38186. * Wraps a value around the sample range boundaries
  38187. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38188. * @return Wrapped position in sample range
  38189. */
  38190. protected _wrapPosition(i: number): number;
  38191. }
  38192. }
  38193. declare module BABYLON {
  38194. /**
  38195. * Helper class that provides a small promise polyfill
  38196. */
  38197. class PromisePolyfill {
  38198. /**
  38199. * Static function used to check if the polyfill is required
  38200. * If this is the case then the function will inject the polyfill to window.Promise
  38201. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38202. */
  38203. static Apply(force?: boolean): void;
  38204. }
  38205. }
  38206. declare module BABYLON {
  38207. /**
  38208. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38210. */
  38211. class SceneOptimization {
  38212. /**
  38213. * Defines the priority of this optimization (0 by default which means first in the list)
  38214. */
  38215. priority: number;
  38216. /**
  38217. * Gets a string describing the action executed by the current optimization
  38218. * @returns description string
  38219. */
  38220. getDescription(): string;
  38221. /**
  38222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38223. * @param scene defines the current scene where to apply this optimization
  38224. * @param optimizer defines the current optimizer
  38225. * @returns true if everything that can be done was applied
  38226. */
  38227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38228. /**
  38229. * Creates the SceneOptimization object
  38230. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38231. * @param desc defines the description associated with the optimization
  38232. */
  38233. constructor(
  38234. /**
  38235. * Defines the priority of this optimization (0 by default which means first in the list)
  38236. */
  38237. priority?: number);
  38238. }
  38239. /**
  38240. * Defines an optimization used to reduce the size of render target textures
  38241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38242. */
  38243. class TextureOptimization extends SceneOptimization {
  38244. /**
  38245. * Defines the priority of this optimization (0 by default which means first in the list)
  38246. */
  38247. priority: number;
  38248. /**
  38249. * 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
  38250. */
  38251. maximumSize: number;
  38252. /**
  38253. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38254. */
  38255. step: number;
  38256. /**
  38257. * Gets a string describing the action executed by the current optimization
  38258. * @returns description string
  38259. */
  38260. getDescription(): string;
  38261. /**
  38262. * Creates the TextureOptimization object
  38263. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38264. * @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
  38265. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38266. */
  38267. constructor(
  38268. /**
  38269. * Defines the priority of this optimization (0 by default which means first in the list)
  38270. */
  38271. priority?: number,
  38272. /**
  38273. * 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
  38274. */
  38275. maximumSize?: number,
  38276. /**
  38277. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38278. */
  38279. step?: number);
  38280. /**
  38281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38282. * @param scene defines the current scene where to apply this optimization
  38283. * @param optimizer defines the current optimizer
  38284. * @returns true if everything that can be done was applied
  38285. */
  38286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38287. }
  38288. /**
  38289. * Defines an optimization used to increase or decrease the rendering resolution
  38290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38291. */
  38292. class HardwareScalingOptimization extends SceneOptimization {
  38293. /**
  38294. * Defines the priority of this optimization (0 by default which means first in the list)
  38295. */
  38296. priority: number;
  38297. /**
  38298. * Defines the maximum scale to use (2 by default)
  38299. */
  38300. maximumScale: number;
  38301. /**
  38302. * Defines the step to use between two passes (0.5 by default)
  38303. */
  38304. step: number;
  38305. private _currentScale;
  38306. private _directionOffset;
  38307. /**
  38308. * Gets a string describing the action executed by the current optimization
  38309. * @return description string
  38310. */
  38311. getDescription(): string;
  38312. /**
  38313. * Creates the HardwareScalingOptimization object
  38314. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38315. * @param maximumScale defines the maximum scale to use (2 by default)
  38316. * @param step defines the step to use between two passes (0.5 by default)
  38317. */
  38318. constructor(
  38319. /**
  38320. * Defines the priority of this optimization (0 by default which means first in the list)
  38321. */
  38322. priority?: number,
  38323. /**
  38324. * Defines the maximum scale to use (2 by default)
  38325. */
  38326. maximumScale?: number,
  38327. /**
  38328. * Defines the step to use between two passes (0.5 by default)
  38329. */
  38330. step?: number);
  38331. /**
  38332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38333. * @param scene defines the current scene where to apply this optimization
  38334. * @param optimizer defines the current optimizer
  38335. * @returns true if everything that can be done was applied
  38336. */
  38337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38338. }
  38339. /**
  38340. * Defines an optimization used to remove shadows
  38341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38342. */
  38343. class ShadowsOptimization extends SceneOptimization {
  38344. /**
  38345. * Gets a string describing the action executed by the current optimization
  38346. * @return description string
  38347. */
  38348. getDescription(): string;
  38349. /**
  38350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38351. * @param scene defines the current scene where to apply this optimization
  38352. * @param optimizer defines the current optimizer
  38353. * @returns true if everything that can be done was applied
  38354. */
  38355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38356. }
  38357. /**
  38358. * Defines an optimization used to turn post-processes off
  38359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38360. */
  38361. class PostProcessesOptimization extends SceneOptimization {
  38362. /**
  38363. * Gets a string describing the action executed by the current optimization
  38364. * @return description string
  38365. */
  38366. getDescription(): string;
  38367. /**
  38368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38369. * @param scene defines the current scene where to apply this optimization
  38370. * @param optimizer defines the current optimizer
  38371. * @returns true if everything that can be done was applied
  38372. */
  38373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38374. }
  38375. /**
  38376. * Defines an optimization used to turn lens flares off
  38377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38378. */
  38379. class LensFlaresOptimization extends SceneOptimization {
  38380. /**
  38381. * Gets a string describing the action executed by the current optimization
  38382. * @return description string
  38383. */
  38384. getDescription(): string;
  38385. /**
  38386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38387. * @param scene defines the current scene where to apply this optimization
  38388. * @param optimizer defines the current optimizer
  38389. * @returns true if everything that can be done was applied
  38390. */
  38391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38392. }
  38393. /**
  38394. * Defines an optimization based on user defined callback.
  38395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38396. */
  38397. class CustomOptimization extends SceneOptimization {
  38398. /**
  38399. * Callback called to apply the custom optimization.
  38400. */
  38401. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38402. /**
  38403. * Callback called to get custom description
  38404. */
  38405. onGetDescription: () => string;
  38406. /**
  38407. * Gets a string describing the action executed by the current optimization
  38408. * @returns description string
  38409. */
  38410. getDescription(): string;
  38411. /**
  38412. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38413. * @param scene defines the current scene where to apply this optimization
  38414. * @param optimizer defines the current optimizer
  38415. * @returns true if everything that can be done was applied
  38416. */
  38417. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38418. }
  38419. /**
  38420. * Defines an optimization used to turn particles off
  38421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38422. */
  38423. class ParticlesOptimization extends SceneOptimization {
  38424. /**
  38425. * Gets a string describing the action executed by the current optimization
  38426. * @return description string
  38427. */
  38428. getDescription(): string;
  38429. /**
  38430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38431. * @param scene defines the current scene where to apply this optimization
  38432. * @param optimizer defines the current optimizer
  38433. * @returns true if everything that can be done was applied
  38434. */
  38435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38436. }
  38437. /**
  38438. * Defines an optimization used to turn render targets off
  38439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38440. */
  38441. class RenderTargetsOptimization extends SceneOptimization {
  38442. /**
  38443. * Gets a string describing the action executed by the current optimization
  38444. * @return description string
  38445. */
  38446. getDescription(): string;
  38447. /**
  38448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38449. * @param scene defines the current scene where to apply this optimization
  38450. * @param optimizer defines the current optimizer
  38451. * @returns true if everything that can be done was applied
  38452. */
  38453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38454. }
  38455. /**
  38456. * Defines an optimization used to merge meshes with compatible materials
  38457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38458. */
  38459. class MergeMeshesOptimization extends SceneOptimization {
  38460. private static _UpdateSelectionTree;
  38461. /**
  38462. * Gets or sets a boolean which defines if optimization octree has to be updated
  38463. */
  38464. /**
  38465. * Gets or sets a boolean which defines if optimization octree has to be updated
  38466. */
  38467. static UpdateSelectionTree: boolean;
  38468. /**
  38469. * Gets a string describing the action executed by the current optimization
  38470. * @return description string
  38471. */
  38472. getDescription(): string;
  38473. private _canBeMerged;
  38474. /**
  38475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38476. * @param scene defines the current scene where to apply this optimization
  38477. * @param optimizer defines the current optimizer
  38478. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38479. * @returns true if everything that can be done was applied
  38480. */
  38481. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38482. }
  38483. /**
  38484. * Defines a list of options used by SceneOptimizer
  38485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38486. */
  38487. class SceneOptimizerOptions {
  38488. /**
  38489. * Defines the target frame rate to reach (60 by default)
  38490. */
  38491. targetFrameRate: number;
  38492. /**
  38493. * Defines the interval between two checkes (2000ms by default)
  38494. */
  38495. trackerDuration: number;
  38496. /**
  38497. * Gets the list of optimizations to apply
  38498. */
  38499. optimizations: SceneOptimization[];
  38500. /**
  38501. * Creates a new list of options used by SceneOptimizer
  38502. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38503. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38504. */
  38505. constructor(
  38506. /**
  38507. * Defines the target frame rate to reach (60 by default)
  38508. */
  38509. targetFrameRate?: number,
  38510. /**
  38511. * Defines the interval between two checkes (2000ms by default)
  38512. */
  38513. trackerDuration?: number);
  38514. /**
  38515. * Add a new optimization
  38516. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38517. * @returns the current SceneOptimizerOptions
  38518. */
  38519. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38520. /**
  38521. * Add a new custom optimization
  38522. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38523. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38524. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38525. * @returns the current SceneOptimizerOptions
  38526. */
  38527. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38528. /**
  38529. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38530. * @param targetFrameRate defines the target frame rate (60 by default)
  38531. * @returns a SceneOptimizerOptions object
  38532. */
  38533. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38534. /**
  38535. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38536. * @param targetFrameRate defines the target frame rate (60 by default)
  38537. * @returns a SceneOptimizerOptions object
  38538. */
  38539. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38540. /**
  38541. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38542. * @param targetFrameRate defines the target frame rate (60 by default)
  38543. * @returns a SceneOptimizerOptions object
  38544. */
  38545. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38546. }
  38547. /**
  38548. * Class used to run optimizations in order to reach a target frame rate
  38549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38550. */
  38551. class SceneOptimizer implements IDisposable {
  38552. private _isRunning;
  38553. private _options;
  38554. private _scene;
  38555. private _currentPriorityLevel;
  38556. private _targetFrameRate;
  38557. private _trackerDuration;
  38558. private _currentFrameRate;
  38559. private _sceneDisposeObserver;
  38560. private _improvementMode;
  38561. /**
  38562. * Defines an observable called when the optimizer reaches the target frame rate
  38563. */
  38564. onSuccessObservable: Observable<SceneOptimizer>;
  38565. /**
  38566. * Defines an observable called when the optimizer enables an optimization
  38567. */
  38568. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38569. /**
  38570. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38571. */
  38572. onFailureObservable: Observable<SceneOptimizer>;
  38573. /**
  38574. * Gets a boolean indicating if the optimizer is in improvement mode
  38575. */
  38576. readonly isInImprovementMode: boolean;
  38577. /**
  38578. * Gets the current priority level (0 at start)
  38579. */
  38580. readonly currentPriorityLevel: number;
  38581. /**
  38582. * Gets the current frame rate checked by the SceneOptimizer
  38583. */
  38584. readonly currentFrameRate: number;
  38585. /**
  38586. * Gets or sets the current target frame rate (60 by default)
  38587. */
  38588. /**
  38589. * Gets or sets the current target frame rate (60 by default)
  38590. */
  38591. targetFrameRate: number;
  38592. /**
  38593. * Gets or sets the current interval between two checks (every 2000ms by default)
  38594. */
  38595. /**
  38596. * Gets or sets the current interval between two checks (every 2000ms by default)
  38597. */
  38598. trackerDuration: number;
  38599. /**
  38600. * Gets the list of active optimizations
  38601. */
  38602. readonly optimizations: SceneOptimization[];
  38603. /**
  38604. * Creates a new SceneOptimizer
  38605. * @param scene defines the scene to work on
  38606. * @param options defines the options to use with the SceneOptimizer
  38607. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38608. * @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)
  38609. */
  38610. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38611. /**
  38612. * Stops the current optimizer
  38613. */
  38614. stop(): void;
  38615. /**
  38616. * Reset the optimizer to initial step (current priority level = 0)
  38617. */
  38618. reset(): void;
  38619. /**
  38620. * Start the optimizer. By default it will try to reach a specific framerate
  38621. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38622. */
  38623. start(): void;
  38624. private _checkCurrentState;
  38625. /**
  38626. * Release all resources
  38627. */
  38628. dispose(): void;
  38629. /**
  38630. * Helper function to create a SceneOptimizer with one single line of code
  38631. * @param scene defines the scene to work on
  38632. * @param options defines the options to use with the SceneOptimizer
  38633. * @param onSuccess defines a callback to call on success
  38634. * @param onFailure defines a callback to call on failure
  38635. * @returns the new SceneOptimizer object
  38636. */
  38637. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38638. }
  38639. }
  38640. declare module BABYLON {
  38641. /**
  38642. * Class used to serialize a scene into a string
  38643. */
  38644. class SceneSerializer {
  38645. /**
  38646. * Clear cache used by a previous serialization
  38647. */
  38648. static ClearCache(): void;
  38649. /**
  38650. * Serialize a scene into a JSON compatible object
  38651. * @param scene defines the scene to serialize
  38652. * @returns a JSON compatible object
  38653. */
  38654. static Serialize(scene: Scene): any;
  38655. /**
  38656. * Serialize a mesh into a JSON compatible object
  38657. * @param toSerialize defines the mesh to serialize
  38658. * @param withParents defines if parents must be serialized as well
  38659. * @param withChildren defines if children must be serialized as well
  38660. * @returns a JSON compatible object
  38661. */
  38662. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38663. }
  38664. }
  38665. declare module BABYLON {
  38666. /**
  38667. * Defines an array and its length.
  38668. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38669. */
  38670. interface ISmartArrayLike<T> {
  38671. /**
  38672. * The data of the array.
  38673. */
  38674. data: Array<T>;
  38675. /**
  38676. * The active length of the array.
  38677. */
  38678. length: number;
  38679. }
  38680. /**
  38681. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38682. */
  38683. class SmartArray<T> implements ISmartArrayLike<T> {
  38684. /**
  38685. * The full set of data from the array.
  38686. */
  38687. data: Array<T>;
  38688. /**
  38689. * The active length of the array.
  38690. */
  38691. length: number;
  38692. protected _id: number;
  38693. /**
  38694. * Instantiates a Smart Array.
  38695. * @param capacity defines the default capacity of the array.
  38696. */
  38697. constructor(capacity: number);
  38698. /**
  38699. * Pushes a value at the end of the active data.
  38700. * @param value defines the object to push in the array.
  38701. */
  38702. push(value: T): void;
  38703. /**
  38704. * Iterates over the active data and apply the lambda to them.
  38705. * @param func defines the action to apply on each value.
  38706. */
  38707. forEach(func: (content: T) => void): void;
  38708. /**
  38709. * Sorts the full sets of data.
  38710. * @param compareFn defines the comparison function to apply.
  38711. */
  38712. sort(compareFn: (a: T, b: T) => number): void;
  38713. /**
  38714. * Resets the active data to an empty array.
  38715. */
  38716. reset(): void;
  38717. /**
  38718. * Releases all the data from the array as well as the array.
  38719. */
  38720. dispose(): void;
  38721. /**
  38722. * Concats the active data with a given array.
  38723. * @param array defines the data to concatenate with.
  38724. */
  38725. concat(array: any): void;
  38726. /**
  38727. * Returns the position of a value in the active data.
  38728. * @param value defines the value to find the index for
  38729. * @returns the index if found in the active data otherwise -1
  38730. */
  38731. indexOf(value: T): number;
  38732. /**
  38733. * Returns whether an element is part of the active data.
  38734. * @param value defines the value to look for
  38735. * @returns true if found in the active data otherwise false
  38736. */
  38737. contains(value: T): boolean;
  38738. private static _GlobalId;
  38739. }
  38740. /**
  38741. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38742. * The data in this array can only be present once
  38743. */
  38744. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38745. private _duplicateId;
  38746. /**
  38747. * Pushes a value at the end of the active data.
  38748. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38749. * @param value defines the object to push in the array.
  38750. */
  38751. push(value: T): void;
  38752. /**
  38753. * Pushes a value at the end of the active data.
  38754. * If the data is already present, it won t be added again
  38755. * @param value defines the object to push in the array.
  38756. * @returns true if added false if it was already present
  38757. */
  38758. pushNoDuplicate(value: T): boolean;
  38759. /**
  38760. * Resets the active data to an empty array.
  38761. */
  38762. reset(): void;
  38763. /**
  38764. * Concats the active data with a given array.
  38765. * This ensures no dupplicate will be present in the result.
  38766. * @param array defines the data to concatenate with.
  38767. */
  38768. concatWithNoDuplicate(array: any): void;
  38769. }
  38770. }
  38771. declare module BABYLON {
  38772. /**
  38773. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38774. * The underlying implementation relies on an associative array to ensure the best performances.
  38775. * The value can be anything including 'null' but except 'undefined'
  38776. */
  38777. class StringDictionary<T> {
  38778. /**
  38779. * This will clear this dictionary and copy the content from the 'source' one.
  38780. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38781. * @param source the dictionary to take the content from and copy to this dictionary
  38782. */
  38783. copyFrom(source: StringDictionary<T>): void;
  38784. /**
  38785. * Get a value based from its key
  38786. * @param key the given key to get the matching value from
  38787. * @return the value if found, otherwise undefined is returned
  38788. */
  38789. get(key: string): T | undefined;
  38790. /**
  38791. * Get a value from its key or add it if it doesn't exist.
  38792. * This method will ensure you that a given key/data will be present in the dictionary.
  38793. * @param key the given key to get the matching value from
  38794. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38795. * The factory will only be invoked if there's no data for the given key.
  38796. * @return the value corresponding to the key.
  38797. */
  38798. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38799. /**
  38800. * Get a value from its key if present in the dictionary otherwise add it
  38801. * @param key the key to get the value from
  38802. * @param val if there's no such key/value pair in the dictionary add it with this value
  38803. * @return the value corresponding to the key
  38804. */
  38805. getOrAdd(key: string, val: T): T;
  38806. /**
  38807. * Check if there's a given key in the dictionary
  38808. * @param key the key to check for
  38809. * @return true if the key is present, false otherwise
  38810. */
  38811. contains(key: string): boolean;
  38812. /**
  38813. * Add a new key and its corresponding value
  38814. * @param key the key to add
  38815. * @param value the value corresponding to the key
  38816. * @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
  38817. */
  38818. add(key: string, value: T): boolean;
  38819. /**
  38820. * Update a specific value associated to a key
  38821. * @param key defines the key to use
  38822. * @param value defines the value to store
  38823. * @returns true if the value was updated (or false if the key was not found)
  38824. */
  38825. set(key: string, value: T): boolean;
  38826. /**
  38827. * Get the element of the given key and remove it from the dictionary
  38828. * @param key defines the key to search
  38829. * @returns the value associated with the key or null if not found
  38830. */
  38831. getAndRemove(key: string): Nullable<T>;
  38832. /**
  38833. * Remove a key/value from the dictionary.
  38834. * @param key the key to remove
  38835. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38836. */
  38837. remove(key: string): boolean;
  38838. /**
  38839. * Clear the whole content of the dictionary
  38840. */
  38841. clear(): void;
  38842. /**
  38843. * Gets the current count
  38844. */
  38845. readonly count: number;
  38846. /**
  38847. * Execute a callback on each key/val of the dictionary.
  38848. * Note that you can remove any element in this dictionary in the callback implementation
  38849. * @param callback the callback to execute on a given key/value pair
  38850. */
  38851. forEach(callback: (key: string, val: T) => void): void;
  38852. /**
  38853. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38854. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38855. * Note that you can remove any element in this dictionary in the callback implementation
  38856. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38857. * @returns the first item
  38858. */
  38859. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38860. private _count;
  38861. private _data;
  38862. }
  38863. }
  38864. declare module BABYLON {
  38865. /**
  38866. * Class used to store custom tags
  38867. */
  38868. class Tags {
  38869. /**
  38870. * Adds support for tags on the given object
  38871. * @param obj defines the object to use
  38872. */
  38873. static EnableFor(obj: any): void;
  38874. /**
  38875. * Removes tags support
  38876. * @param obj defines the object to use
  38877. */
  38878. static DisableFor(obj: any): void;
  38879. /**
  38880. * Gets a boolean indicating if the given object has tags
  38881. * @param obj defines the object to use
  38882. * @returns a boolean
  38883. */
  38884. static HasTags(obj: any): boolean;
  38885. /**
  38886. * Gets the tags available on a given object
  38887. * @param obj defines the object to use
  38888. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38889. * @returns the tags
  38890. */
  38891. static GetTags(obj: any, asString?: boolean): any;
  38892. /**
  38893. * Adds tags to an object
  38894. * @param obj defines the object to use
  38895. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38896. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38897. */
  38898. static AddTagsTo(obj: any, tagsString: string): void;
  38899. /**
  38900. * @hidden
  38901. */
  38902. static _AddTagTo(obj: any, tag: string): void;
  38903. /**
  38904. * Removes specific tags from a specific object
  38905. * @param obj defines the object to use
  38906. * @param tagsString defines the tags to remove
  38907. */
  38908. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38909. /**
  38910. * @hidden
  38911. */
  38912. static _RemoveTagFrom(obj: any, tag: string): void;
  38913. /**
  38914. * Defines if tags hosted on an object match a given query
  38915. * @param obj defines the object to use
  38916. * @param tagsQuery defines the tag query
  38917. * @returns a boolean
  38918. */
  38919. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38920. }
  38921. }
  38922. declare module BABYLON {
  38923. /**
  38924. * Class used to host texture specific utilities
  38925. */
  38926. class TextureTools {
  38927. /**
  38928. * Uses the GPU to create a copy texture rescaled at a given size
  38929. * @param texture Texture to copy from
  38930. * @param width defines the desired width
  38931. * @param height defines the desired height
  38932. * @param useBilinearMode defines if bilinear mode has to be used
  38933. * @return the generated texture
  38934. */
  38935. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38936. /**
  38937. * Gets an environment BRDF texture for a given scene
  38938. * @param scene defines the hosting scene
  38939. * @returns the environment BRDF texture
  38940. */
  38941. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38942. private static _environmentBRDFBase64Texture;
  38943. }
  38944. }
  38945. declare module BABYLON {
  38946. /**
  38947. * Based on jsTGALoader - Javascript loader for TGA file
  38948. * By Vincent Thibault
  38949. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38950. */
  38951. class TGATools {
  38952. private static _TYPE_INDEXED;
  38953. private static _TYPE_RGB;
  38954. private static _TYPE_GREY;
  38955. private static _TYPE_RLE_INDEXED;
  38956. private static _TYPE_RLE_RGB;
  38957. private static _TYPE_RLE_GREY;
  38958. private static _ORIGIN_MASK;
  38959. private static _ORIGIN_SHIFT;
  38960. private static _ORIGIN_BL;
  38961. private static _ORIGIN_BR;
  38962. private static _ORIGIN_UL;
  38963. private static _ORIGIN_UR;
  38964. /**
  38965. * Gets the header of a TGA file
  38966. * @param data defines the TGA data
  38967. * @returns the header
  38968. */
  38969. static GetTGAHeader(data: Uint8Array): any;
  38970. /**
  38971. * Uploads TGA content to a Babylon Texture
  38972. * @hidden
  38973. */
  38974. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38975. /** @hidden */
  38976. 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;
  38977. /** @hidden */
  38978. 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;
  38979. /** @hidden */
  38980. 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;
  38981. /** @hidden */
  38982. 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;
  38983. /** @hidden */
  38984. 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;
  38985. /** @hidden */
  38986. 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;
  38987. }
  38988. }
  38989. declare module BABYLON {
  38990. /**
  38991. * Interface for any object that can request an animation frame
  38992. */
  38993. interface ICustomAnimationFrameRequester {
  38994. /**
  38995. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38996. */
  38997. renderFunction?: Function;
  38998. /**
  38999. * Called to request the next frame to render to
  39000. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39001. */
  39002. requestAnimationFrame: Function;
  39003. /**
  39004. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39005. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39006. */
  39007. requestID?: number;
  39008. }
  39009. /**
  39010. * Interface containing an array of animations
  39011. */
  39012. interface IAnimatable {
  39013. /**
  39014. * Array of animations
  39015. */
  39016. animations: Array<Animation>;
  39017. }
  39018. /** Interface used by value gradients (color, factor, ...) */
  39019. interface IValueGradient {
  39020. /**
  39021. * Gets or sets the gradient value (between 0 and 1)
  39022. */
  39023. gradient: number;
  39024. }
  39025. /** Class used to store color4 gradient */
  39026. class ColorGradient implements IValueGradient {
  39027. /**
  39028. * Gets or sets the gradient value (between 0 and 1)
  39029. */
  39030. gradient: number;
  39031. /**
  39032. * Gets or sets first associated color
  39033. */
  39034. color1: Color4;
  39035. /**
  39036. * Gets or sets second associated color
  39037. */
  39038. color2?: Color4;
  39039. /**
  39040. * Will get a color picked randomly between color1 and color2.
  39041. * If color2 is undefined then color1 will be used
  39042. * @param result defines the target Color4 to store the result in
  39043. */
  39044. getColorToRef(result: Color4): void;
  39045. }
  39046. /** Class used to store color 3 gradient */
  39047. class Color3Gradient implements IValueGradient {
  39048. /**
  39049. * Gets or sets the gradient value (between 0 and 1)
  39050. */
  39051. gradient: number;
  39052. /**
  39053. * Gets or sets the associated color
  39054. */
  39055. color: Color3;
  39056. }
  39057. /** Class used to store factor gradient */
  39058. class FactorGradient implements IValueGradient {
  39059. /**
  39060. * Gets or sets the gradient value (between 0 and 1)
  39061. */
  39062. gradient: number;
  39063. /**
  39064. * Gets or sets first associated factor
  39065. */
  39066. factor1: number;
  39067. /**
  39068. * Gets or sets second associated factor
  39069. */
  39070. factor2?: number;
  39071. /**
  39072. * Will get a number picked randomly between factor1 and factor2.
  39073. * If factor2 is undefined then factor1 will be used
  39074. * @returns the picked number
  39075. */
  39076. getFactor(): number;
  39077. }
  39078. /**
  39079. * @ignore
  39080. * Application error to support additional information when loading a file
  39081. */
  39082. class LoadFileError extends Error {
  39083. /** defines the optional XHR request */
  39084. request?: XMLHttpRequest | undefined;
  39085. private static _setPrototypeOf;
  39086. /**
  39087. * Creates a new LoadFileError
  39088. * @param message defines the message of the error
  39089. * @param request defines the optional XHR request
  39090. */
  39091. constructor(message: string,
  39092. /** defines the optional XHR request */
  39093. request?: XMLHttpRequest | undefined);
  39094. }
  39095. /**
  39096. * Class used to define a retry strategy when error happens while loading assets
  39097. */
  39098. class RetryStrategy {
  39099. /**
  39100. * Function used to defines an exponential back off strategy
  39101. * @param maxRetries defines the maximum number of retries (3 by default)
  39102. * @param baseInterval defines the interval between retries
  39103. * @returns the strategy function to use
  39104. */
  39105. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39106. }
  39107. /**
  39108. * File request interface
  39109. */
  39110. interface IFileRequest {
  39111. /**
  39112. * Raised when the request is complete (success or error).
  39113. */
  39114. onCompleteObservable: Observable<IFileRequest>;
  39115. /**
  39116. * Aborts the request for a file.
  39117. */
  39118. abort: () => void;
  39119. }
  39120. /**
  39121. * Class containing a set of static utilities functions
  39122. */
  39123. class Tools {
  39124. /**
  39125. * Gets or sets the base URL to use to load assets
  39126. */
  39127. static BaseUrl: string;
  39128. /**
  39129. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39130. */
  39131. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39132. /**
  39133. * Default behaviour for cors in the application.
  39134. * It can be a string if the expected behavior is identical in the entire app.
  39135. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39136. */
  39137. static CorsBehavior: string | ((url: string | string[]) => string);
  39138. /**
  39139. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39140. * @ignorenaming
  39141. */
  39142. static UseFallbackTexture: boolean;
  39143. /**
  39144. * Use this object to register external classes like custom textures or material
  39145. * to allow the laoders to instantiate them
  39146. */
  39147. static RegisteredExternalClasses: {
  39148. [key: string]: Object;
  39149. };
  39150. /**
  39151. * Texture content used if a texture cannot loaded
  39152. * @ignorenaming
  39153. */
  39154. static fallbackTexture: string;
  39155. /**
  39156. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39157. * @param u defines the coordinate on X axis
  39158. * @param v defines the coordinate on Y axis
  39159. * @param width defines the width of the source data
  39160. * @param height defines the height of the source data
  39161. * @param pixels defines the source byte array
  39162. * @param color defines the output color
  39163. */
  39164. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39165. /**
  39166. * Interpolates between a and b via alpha
  39167. * @param a The lower value (returned when alpha = 0)
  39168. * @param b The upper value (returned when alpha = 1)
  39169. * @param alpha The interpolation-factor
  39170. * @return The mixed value
  39171. */
  39172. static Mix(a: number, b: number, alpha: number): number;
  39173. /**
  39174. * Tries to instantiate a new object from a given class name
  39175. * @param className defines the class name to instantiate
  39176. * @returns the new object or null if the system was not able to do the instantiation
  39177. */
  39178. static Instantiate(className: string): any;
  39179. /**
  39180. * Provides a slice function that will work even on IE
  39181. * @param data defines the array to slice
  39182. * @param start defines the start of the data (optional)
  39183. * @param end defines the end of the data (optional)
  39184. * @returns the new sliced array
  39185. */
  39186. static Slice<T>(data: T, start?: number, end?: number): T;
  39187. /**
  39188. * Polyfill for setImmediate
  39189. * @param action defines the action to execute after the current execution block
  39190. */
  39191. static SetImmediate(action: () => void): void;
  39192. /**
  39193. * Function indicating if a number is an exponent of 2
  39194. * @param value defines the value to test
  39195. * @returns true if the value is an exponent of 2
  39196. */
  39197. static IsExponentOfTwo(value: number): boolean;
  39198. private static _tmpFloatArray;
  39199. /**
  39200. * Returns the nearest 32-bit single precision float representation of a Number
  39201. * @param value A Number. If the parameter is of a different type, it will get converted
  39202. * to a number or to NaN if it cannot be converted
  39203. * @returns number
  39204. */
  39205. static FloatRound(value: number): number;
  39206. /**
  39207. * Find the next highest power of two.
  39208. * @param x Number to start search from.
  39209. * @return Next highest power of two.
  39210. */
  39211. static CeilingPOT(x: number): number;
  39212. /**
  39213. * Find the next lowest power of two.
  39214. * @param x Number to start search from.
  39215. * @return Next lowest power of two.
  39216. */
  39217. static FloorPOT(x: number): number;
  39218. /**
  39219. * Find the nearest power of two.
  39220. * @param x Number to start search from.
  39221. * @return Next nearest power of two.
  39222. */
  39223. static NearestPOT(x: number): number;
  39224. /**
  39225. * Get the closest exponent of two
  39226. * @param value defines the value to approximate
  39227. * @param max defines the maximum value to return
  39228. * @param mode defines how to define the closest value
  39229. * @returns closest exponent of two of the given value
  39230. */
  39231. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39232. /**
  39233. * Extracts the filename from a path
  39234. * @param path defines the path to use
  39235. * @returns the filename
  39236. */
  39237. static GetFilename(path: string): string;
  39238. /**
  39239. * Extracts the "folder" part of a path (everything before the filename).
  39240. * @param uri The URI to extract the info from
  39241. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39242. * @returns The "folder" part of the path
  39243. */
  39244. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39245. /**
  39246. * Extracts text content from a DOM element hierarchy
  39247. * @param element defines the root element
  39248. * @returns a string
  39249. */
  39250. static GetDOMTextContent(element: HTMLElement): string;
  39251. /**
  39252. * Convert an angle in radians to degrees
  39253. * @param angle defines the angle to convert
  39254. * @returns the angle in degrees
  39255. */
  39256. static ToDegrees(angle: number): number;
  39257. /**
  39258. * Convert an angle in degrees to radians
  39259. * @param angle defines the angle to convert
  39260. * @returns the angle in radians
  39261. */
  39262. static ToRadians(angle: number): number;
  39263. /**
  39264. * Encode a buffer to a base64 string
  39265. * @param buffer defines the buffer to encode
  39266. * @returns the encoded string
  39267. */
  39268. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39269. /**
  39270. * Extracts minimum and maximum values from a list of indexed positions
  39271. * @param positions defines the positions to use
  39272. * @param indices defines the indices to the positions
  39273. * @param indexStart defines the start index
  39274. * @param indexCount defines the end index
  39275. * @param bias defines bias value to add to the result
  39276. * @return minimum and maximum values
  39277. */
  39278. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39279. minimum: Vector3;
  39280. maximum: Vector3;
  39281. };
  39282. /**
  39283. * Extracts minimum and maximum values from a list of positions
  39284. * @param positions defines the positions to use
  39285. * @param start defines the start index in the positions array
  39286. * @param count defines the number of positions to handle
  39287. * @param bias defines bias value to add to the result
  39288. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39289. * @return minimum and maximum values
  39290. */
  39291. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39292. minimum: Vector3;
  39293. maximum: Vector3;
  39294. };
  39295. /**
  39296. * Returns an array if obj is not an array
  39297. * @param obj defines the object to evaluate as an array
  39298. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39299. * @returns either obj directly if obj is an array or a new array containing obj
  39300. */
  39301. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39302. /**
  39303. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39304. * @param size the number of element to construct and put in the array
  39305. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39306. * @returns a new array filled with new objects
  39307. */
  39308. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39309. /**
  39310. * Gets the pointer prefix to use
  39311. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39312. */
  39313. static GetPointerPrefix(): string;
  39314. /**
  39315. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39316. * @param func - the function to be called
  39317. * @param requester - the object that will request the next frame. Falls back to window.
  39318. * @returns frame number
  39319. */
  39320. static QueueNewFrame(func: () => void, requester?: any): number;
  39321. /**
  39322. * Ask the browser to promote the current element to fullscreen rendering mode
  39323. * @param element defines the DOM element to promote
  39324. */
  39325. static RequestFullscreen(element: HTMLElement): void;
  39326. /**
  39327. * Asks the browser to exit fullscreen mode
  39328. */
  39329. static ExitFullscreen(): void;
  39330. /**
  39331. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39332. * @param url define the url we are trying
  39333. * @param element define the dom element where to configure the cors policy
  39334. */
  39335. static SetCorsBehavior(url: string | string[], element: {
  39336. crossOrigin: string | null;
  39337. }): void;
  39338. /**
  39339. * Removes unwanted characters from an url
  39340. * @param url defines the url to clean
  39341. * @returns the cleaned url
  39342. */
  39343. static CleanUrl(url: string): string;
  39344. /**
  39345. * Gets or sets a function used to pre-process url before using them to load assets
  39346. */
  39347. static PreprocessUrl: (url: string) => string;
  39348. /**
  39349. * Loads an image as an HTMLImageElement.
  39350. * @param input url string, ArrayBuffer, or Blob to load
  39351. * @param onLoad callback called when the image successfully loads
  39352. * @param onError callback called when the image fails to load
  39353. * @param offlineProvider offline provider for caching
  39354. * @returns the HTMLImageElement of the loaded image
  39355. */
  39356. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39357. /**
  39358. * Loads a file
  39359. * @param url url string, ArrayBuffer, or Blob to load
  39360. * @param onSuccess callback called when the file successfully loads
  39361. * @param onProgress callback called while file is loading (if the server supports this mode)
  39362. * @param offlineProvider defines the offline provider for caching
  39363. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39364. * @param onError callback called when the file fails to load
  39365. * @returns a file request object
  39366. */
  39367. 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;
  39368. /**
  39369. * Load a script (identified by an url). When the url returns, the
  39370. * content of this file is added into a new script element, attached to the DOM (body element)
  39371. * @param scriptUrl defines the url of the script to laod
  39372. * @param onSuccess defines the callback called when the script is loaded
  39373. * @param onError defines the callback to call if an error occurs
  39374. */
  39375. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39376. /**
  39377. * Loads a file from a blob
  39378. * @param fileToLoad defines the blob to use
  39379. * @param callback defines the callback to call when data is loaded
  39380. * @param progressCallback defines the callback to call during loading process
  39381. * @returns a file request object
  39382. */
  39383. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39384. /**
  39385. * Loads a file
  39386. * @param fileToLoad defines the file to load
  39387. * @param callback defines the callback to call when data is loaded
  39388. * @param progressCallBack defines the callback to call during loading process
  39389. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39390. * @returns a file request object
  39391. */
  39392. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39393. /**
  39394. * Creates a data url from a given string content
  39395. * @param content defines the content to convert
  39396. * @returns the new data url link
  39397. */
  39398. static FileAsURL(content: string): string;
  39399. /**
  39400. * Format the given number to a specific decimal format
  39401. * @param value defines the number to format
  39402. * @param decimals defines the number of decimals to use
  39403. * @returns the formatted string
  39404. */
  39405. static Format(value: number, decimals?: number): string;
  39406. /**
  39407. * Checks if a given vector is inside a specific range
  39408. * @param v defines the vector to test
  39409. * @param min defines the minimum range
  39410. * @param max defines the maximum range
  39411. */
  39412. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39413. /**
  39414. * Tries to copy an object by duplicating every property
  39415. * @param source defines the source object
  39416. * @param destination defines the target object
  39417. * @param doNotCopyList defines a list of properties to avoid
  39418. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39419. */
  39420. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39421. /**
  39422. * Gets a boolean indicating if the given object has no own property
  39423. * @param obj defines the object to test
  39424. * @returns true if object has no own property
  39425. */
  39426. static IsEmpty(obj: any): boolean;
  39427. /**
  39428. * Function used to register events at window level
  39429. * @param events defines the events to register
  39430. */
  39431. static RegisterTopRootEvents(events: {
  39432. name: string;
  39433. handler: Nullable<(e: FocusEvent) => any>;
  39434. }[]): void;
  39435. /**
  39436. * Function used to unregister events from window level
  39437. * @param events defines the events to unregister
  39438. */
  39439. static UnregisterTopRootEvents(events: {
  39440. name: string;
  39441. handler: Nullable<(e: FocusEvent) => any>;
  39442. }[]): void;
  39443. /**
  39444. * Dumps the current bound framebuffer
  39445. * @param width defines the rendering width
  39446. * @param height defines the rendering height
  39447. * @param engine defines the hosting engine
  39448. * @param successCallback defines the callback triggered once the data are available
  39449. * @param mimeType defines the mime type of the result
  39450. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39451. */
  39452. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39453. /**
  39454. * Converts the canvas data to blob.
  39455. * This acts as a polyfill for browsers not supporting the to blob function.
  39456. * @param canvas Defines the canvas to extract the data from
  39457. * @param successCallback Defines the callback triggered once the data are available
  39458. * @param mimeType Defines the mime type of the result
  39459. */
  39460. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39461. /**
  39462. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39463. * @param successCallback defines the callback triggered once the data are available
  39464. * @param mimeType defines the mime type of the result
  39465. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39466. */
  39467. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39468. /**
  39469. * Downloads a blob in the browser
  39470. * @param blob defines the blob to download
  39471. * @param fileName defines the name of the downloaded file
  39472. */
  39473. static Download(blob: Blob, fileName: string): void;
  39474. /**
  39475. * Captures a screenshot of the current rendering
  39476. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39477. * @param engine defines the rendering engine
  39478. * @param camera defines the source camera
  39479. * @param size This parameter can be set to a single number or to an object with the
  39480. * following (optional) properties: precision, width, height. If a single number is passed,
  39481. * it will be used for both width and height. If an object is passed, the screenshot size
  39482. * will be derived from the parameters. The precision property is a multiplier allowing
  39483. * rendering at a higher or lower resolution
  39484. * @param successCallback defines the callback receives a single parameter which contains the
  39485. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39486. * src parameter of an <img> to display it
  39487. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39488. * Check your browser for supported MIME types
  39489. */
  39490. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39491. /**
  39492. * Generates an image screenshot from the specified camera.
  39493. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39494. * @param engine The engine to use for rendering
  39495. * @param camera The camera to use for rendering
  39496. * @param size This parameter can be set to a single number or to an object with the
  39497. * following (optional) properties: precision, width, height. If a single number is passed,
  39498. * it will be used for both width and height. If an object is passed, the screenshot size
  39499. * will be derived from the parameters. The precision property is a multiplier allowing
  39500. * rendering at a higher or lower resolution
  39501. * @param successCallback The callback receives a single parameter which contains the
  39502. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39503. * src parameter of an <img> to display it
  39504. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39505. * Check your browser for supported MIME types
  39506. * @param samples Texture samples (default: 1)
  39507. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39508. * @param fileName A name for for the downloaded file.
  39509. */
  39510. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39511. /**
  39512. * Validates if xhr data is correct
  39513. * @param xhr defines the request to validate
  39514. * @param dataType defines the expected data type
  39515. * @returns true if data is correct
  39516. */
  39517. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39518. /**
  39519. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39520. * Be aware Math.random() could cause collisions, but:
  39521. * "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"
  39522. * @returns a pseudo random id
  39523. */
  39524. static RandomId(): string;
  39525. /**
  39526. * Test if the given uri is a base64 string
  39527. * @param uri The uri to test
  39528. * @return True if the uri is a base64 string or false otherwise
  39529. */
  39530. static IsBase64(uri: string): boolean;
  39531. /**
  39532. * Decode the given base64 uri.
  39533. * @param uri The uri to decode
  39534. * @return The decoded base64 data.
  39535. */
  39536. static DecodeBase64(uri: string): ArrayBuffer;
  39537. /**
  39538. * No log
  39539. */
  39540. static readonly NoneLogLevel: number;
  39541. /**
  39542. * Only message logs
  39543. */
  39544. static readonly MessageLogLevel: number;
  39545. /**
  39546. * Only warning logs
  39547. */
  39548. static readonly WarningLogLevel: number;
  39549. /**
  39550. * Only error logs
  39551. */
  39552. static readonly ErrorLogLevel: number;
  39553. /**
  39554. * All logs
  39555. */
  39556. static readonly AllLogLevel: number;
  39557. private static _LogCache;
  39558. /**
  39559. * Gets a value indicating the number of loading errors
  39560. * @ignorenaming
  39561. */
  39562. static errorsCount: number;
  39563. /**
  39564. * Callback called when a new log is added
  39565. */
  39566. static OnNewCacheEntry: (entry: string) => void;
  39567. private static _AddLogEntry;
  39568. private static _FormatMessage;
  39569. private static _LogDisabled;
  39570. private static _LogEnabled;
  39571. private static _WarnDisabled;
  39572. private static _WarnEnabled;
  39573. private static _ErrorDisabled;
  39574. private static _ErrorEnabled;
  39575. /**
  39576. * Log a message to the console
  39577. */
  39578. static Log: (message: string) => void;
  39579. /**
  39580. * Write a warning message to the console
  39581. */
  39582. static Warn: (message: string) => void;
  39583. /**
  39584. * Write an error message to the console
  39585. */
  39586. static Error: (message: string) => void;
  39587. /**
  39588. * Gets current log cache (list of logs)
  39589. */
  39590. static readonly LogCache: string;
  39591. /**
  39592. * Clears the log cache
  39593. */
  39594. static ClearLogCache(): void;
  39595. /**
  39596. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39597. */
  39598. static LogLevels: number;
  39599. /**
  39600. * Checks if the loaded document was accessed via `file:`-Protocol.
  39601. * @returns boolean
  39602. */
  39603. static IsFileURL(): boolean;
  39604. /**
  39605. * Checks if the window object exists
  39606. * @returns true if the window object exists
  39607. */
  39608. static IsWindowObjectExist(): boolean;
  39609. /**
  39610. * No performance log
  39611. */
  39612. static readonly PerformanceNoneLogLevel: number;
  39613. /**
  39614. * Use user marks to log performance
  39615. */
  39616. static readonly PerformanceUserMarkLogLevel: number;
  39617. /**
  39618. * Log performance to the console
  39619. */
  39620. static readonly PerformanceConsoleLogLevel: number;
  39621. private static _performance;
  39622. /**
  39623. * Sets the current performance log level
  39624. */
  39625. static PerformanceLogLevel: number;
  39626. private static _StartPerformanceCounterDisabled;
  39627. private static _EndPerformanceCounterDisabled;
  39628. private static _StartUserMark;
  39629. private static _EndUserMark;
  39630. private static _StartPerformanceConsole;
  39631. private static _EndPerformanceConsole;
  39632. /**
  39633. * Starts a performance counter
  39634. */
  39635. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39636. /**
  39637. * Ends a specific performance coutner
  39638. */
  39639. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39640. /**
  39641. * Gets either window.performance.now() if supported or Date.now() else
  39642. */
  39643. static readonly Now: number;
  39644. /**
  39645. * This method will return the name of the class used to create the instance of the given object.
  39646. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39647. * @param object the object to get the class name from
  39648. * @param isType defines if the object is actually a type
  39649. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39650. */
  39651. static GetClassName(object: any, isType?: boolean): string;
  39652. /**
  39653. * Gets the first element of an array satisfying a given predicate
  39654. * @param array defines the array to browse
  39655. * @param predicate defines the predicate to use
  39656. * @returns null if not found or the element
  39657. */
  39658. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39659. /**
  39660. * This method will return the name of the full name of the class, including its owning module (if any).
  39661. * 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).
  39662. * @param object the object to get the class name from
  39663. * @param isType defines if the object is actually a type
  39664. * @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.
  39665. * @ignorenaming
  39666. */
  39667. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39668. /**
  39669. * Returns a promise that resolves after the given amount of time.
  39670. * @param delay Number of milliseconds to delay
  39671. * @returns Promise that resolves after the given amount of time
  39672. */
  39673. static DelayAsync(delay: number): Promise<void>;
  39674. /**
  39675. * Gets the current gradient from an array of IValueGradient
  39676. * @param ratio defines the current ratio to get
  39677. * @param gradients defines the array of IValueGradient
  39678. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39679. */
  39680. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39681. }
  39682. /**
  39683. * This class is used to track a performance counter which is number based.
  39684. * The user has access to many properties which give statistics of different nature.
  39685. *
  39686. * The implementer can track two kinds of Performance Counter: time and count.
  39687. * 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.
  39688. * 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.
  39689. */
  39690. class PerfCounter {
  39691. /**
  39692. * Gets or sets a global boolean to turn on and off all the counters
  39693. */
  39694. static Enabled: boolean;
  39695. /**
  39696. * Returns the smallest value ever
  39697. */
  39698. readonly min: number;
  39699. /**
  39700. * Returns the biggest value ever
  39701. */
  39702. readonly max: number;
  39703. /**
  39704. * Returns the average value since the performance counter is running
  39705. */
  39706. readonly average: number;
  39707. /**
  39708. * Returns the average value of the last second the counter was monitored
  39709. */
  39710. readonly lastSecAverage: number;
  39711. /**
  39712. * Returns the current value
  39713. */
  39714. readonly current: number;
  39715. /**
  39716. * Gets the accumulated total
  39717. */
  39718. readonly total: number;
  39719. /**
  39720. * Gets the total value count
  39721. */
  39722. readonly count: number;
  39723. /**
  39724. * Creates a new counter
  39725. */
  39726. constructor();
  39727. /**
  39728. * Call this method to start monitoring a new frame.
  39729. * 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.
  39730. */
  39731. fetchNewFrame(): void;
  39732. /**
  39733. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39734. * @param newCount the count value to add to the monitored count
  39735. * @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.
  39736. */
  39737. addCount(newCount: number, fetchResult: boolean): void;
  39738. /**
  39739. * Start monitoring this performance counter
  39740. */
  39741. beginMonitoring(): void;
  39742. /**
  39743. * Compute the time lapsed since the previous beginMonitoring() call.
  39744. * @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
  39745. */
  39746. endMonitoring(newFrame?: boolean): void;
  39747. private _fetchResult;
  39748. private _startMonitoringTime;
  39749. private _min;
  39750. private _max;
  39751. private _average;
  39752. private _current;
  39753. private _totalValueCount;
  39754. private _totalAccumulated;
  39755. private _lastSecAverage;
  39756. private _lastSecAccumulated;
  39757. private _lastSecTime;
  39758. private _lastSecValueCount;
  39759. }
  39760. /**
  39761. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39762. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39763. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39764. * @param name The name of the class, case should be preserved
  39765. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39766. */
  39767. function className(name: string, module?: string): (target: Object) => void;
  39768. /**
  39769. * An implementation of a loop for asynchronous functions.
  39770. */
  39771. class AsyncLoop {
  39772. /**
  39773. * Defines the number of iterations for the loop
  39774. */
  39775. iterations: number;
  39776. /**
  39777. * Defines the current index of the loop.
  39778. */
  39779. index: number;
  39780. private _done;
  39781. private _fn;
  39782. private _successCallback;
  39783. /**
  39784. * Constructor.
  39785. * @param iterations the number of iterations.
  39786. * @param func the function to run each iteration
  39787. * @param successCallback the callback that will be called upon succesful execution
  39788. * @param offset starting offset.
  39789. */
  39790. constructor(
  39791. /**
  39792. * Defines the number of iterations for the loop
  39793. */
  39794. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39795. /**
  39796. * Execute the next iteration. Must be called after the last iteration was finished.
  39797. */
  39798. executeNext(): void;
  39799. /**
  39800. * Break the loop and run the success callback.
  39801. */
  39802. breakLoop(): void;
  39803. /**
  39804. * Create and run an async loop.
  39805. * @param iterations the number of iterations.
  39806. * @param fn the function to run each iteration
  39807. * @param successCallback the callback that will be called upon succesful execution
  39808. * @param offset starting offset.
  39809. * @returns the created async loop object
  39810. */
  39811. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39812. /**
  39813. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39814. * @param iterations total number of iterations
  39815. * @param syncedIterations number of synchronous iterations in each async iteration.
  39816. * @param fn the function to call each iteration.
  39817. * @param callback a success call back that will be called when iterating stops.
  39818. * @param breakFunction a break condition (optional)
  39819. * @param timeout timeout settings for the setTimeout function. default - 0.
  39820. * @returns the created async loop object
  39821. */
  39822. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39823. }
  39824. }
  39825. interface HTMLCanvasElement {
  39826. /** Track wether a record is in progress */
  39827. isRecording: boolean;
  39828. /** Capture Stream method defined by some browsers */
  39829. captureStream(fps?: number): MediaStream;
  39830. }
  39831. interface MediaRecorder {
  39832. /** Starts recording */
  39833. start(timeSlice: number): void;
  39834. /** Stops recording */
  39835. stop(): void;
  39836. /** Event raised when an error arised. */
  39837. onerror: (event: ErrorEvent) => void;
  39838. /** Event raised when the recording stops. */
  39839. onstop: (event: Event) => void;
  39840. /** Event raised when a new chunk of data is available and should be tracked. */
  39841. ondataavailable: (event: Event) => void;
  39842. }
  39843. interface MediaRecorderOptions {
  39844. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39845. mimeType?: string;
  39846. /** The chosen bitrate for the audio component of the media. */
  39847. audioBitsPerSecond?: number;
  39848. /** The chosen bitrate for the video component of the media. */
  39849. videoBitsPerSecond?: number;
  39850. /** 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. */
  39851. bitsPerSecond?: number;
  39852. }
  39853. interface MediaRecorderConstructor {
  39854. /**
  39855. * A reference to the prototype.
  39856. */
  39857. readonly prototype: MediaRecorder;
  39858. /**
  39859. * Creates a new MediaRecorder.
  39860. * @param stream Defines the stream to record.
  39861. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39862. */
  39863. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39864. }
  39865. /**
  39866. * MediaRecoreder object available in some browsers.
  39867. */
  39868. declare var MediaRecorder: MediaRecorderConstructor;
  39869. declare module BABYLON {
  39870. /**
  39871. * This represents the different options avilable for the video capture.
  39872. */
  39873. interface VideoRecorderOptions {
  39874. /** Defines the mime type of the video */
  39875. mimeType: string;
  39876. /** Defines the video the video should be recorded at */
  39877. fps: number;
  39878. /** Defines the chunk size for the recording data */
  39879. recordChunckSize: number;
  39880. }
  39881. /**
  39882. * This can helps recording videos from BabylonJS.
  39883. * This is based on the available WebRTC functionalities of the browser.
  39884. *
  39885. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39886. */
  39887. class VideoRecorder {
  39888. private static readonly _defaultOptions;
  39889. /**
  39890. * Returns wehther or not the VideoRecorder is available in your browser.
  39891. * @param engine Defines the Babylon Engine to check the support for
  39892. * @returns true if supported otherwise false
  39893. */
  39894. static IsSupported(engine: Engine): boolean;
  39895. private readonly _options;
  39896. private _canvas;
  39897. private _mediaRecorder;
  39898. private _recordedChunks;
  39899. private _fileName;
  39900. private _resolve;
  39901. private _reject;
  39902. /**
  39903. * True wether a recording is already in progress.
  39904. */
  39905. readonly isRecording: boolean;
  39906. /**
  39907. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39908. * a video file.
  39909. * @param engine Defines the BabylonJS Engine you wish to record
  39910. * @param options Defines options that can be used to customized the capture
  39911. */
  39912. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39913. /**
  39914. * Stops the current recording before the default capture timeout passed in the startRecording
  39915. * functions.
  39916. */
  39917. stopRecording(): void;
  39918. /**
  39919. * Starts recording the canvas for a max duration specified in parameters.
  39920. * @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.
  39921. * @param maxDuration Defines the maximum recording time in seconds.
  39922. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39923. * @return a promise callback at the end of the recording with the video data in Blob.
  39924. */
  39925. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39926. /**
  39927. * Releases internal resources used during the recording.
  39928. */
  39929. dispose(): void;
  39930. private _handleDataAvailable;
  39931. private _handleError;
  39932. private _handleStop;
  39933. }
  39934. }
  39935. declare module BABYLON {
  39936. /**
  39937. * Defines the potential axis of a Joystick
  39938. */
  39939. enum JoystickAxis {
  39940. /** X axis */
  39941. X = 0,
  39942. /** Y axis */
  39943. Y = 1,
  39944. /** Z axis */
  39945. Z = 2
  39946. }
  39947. /**
  39948. * Class used to define virtual joystick (used in touch mode)
  39949. */
  39950. class VirtualJoystick {
  39951. /**
  39952. * Gets or sets a boolean indicating that left and right values must be inverted
  39953. */
  39954. reverseLeftRight: boolean;
  39955. /**
  39956. * Gets or sets a boolean indicating that up and down values must be inverted
  39957. */
  39958. reverseUpDown: boolean;
  39959. /**
  39960. * Gets the offset value for the position (ie. the change of the position value)
  39961. */
  39962. deltaPosition: Vector3;
  39963. /**
  39964. * Gets a boolean indicating if the virtual joystick was pressed
  39965. */
  39966. pressed: boolean;
  39967. private static _globalJoystickIndex;
  39968. private static vjCanvas;
  39969. private static vjCanvasContext;
  39970. private static vjCanvasWidth;
  39971. private static vjCanvasHeight;
  39972. private static halfWidth;
  39973. private _action;
  39974. private _axisTargetedByLeftAndRight;
  39975. private _axisTargetedByUpAndDown;
  39976. private _joystickSensibility;
  39977. private _inversedSensibility;
  39978. private _joystickPointerID;
  39979. private _joystickColor;
  39980. private _joystickPointerPos;
  39981. private _joystickPreviousPointerPos;
  39982. private _joystickPointerStartPos;
  39983. private _deltaJoystickVector;
  39984. private _leftJoystick;
  39985. private _touches;
  39986. private _onPointerDownHandlerRef;
  39987. private _onPointerMoveHandlerRef;
  39988. private _onPointerUpHandlerRef;
  39989. private _onResize;
  39990. /**
  39991. * Creates a new virtual joystick
  39992. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39993. */
  39994. constructor(leftJoystick?: boolean);
  39995. /**
  39996. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39997. * @param newJoystickSensibility defines the new sensibility
  39998. */
  39999. setJoystickSensibility(newJoystickSensibility: number): void;
  40000. private _onPointerDown;
  40001. private _onPointerMove;
  40002. private _onPointerUp;
  40003. /**
  40004. * Change the color of the virtual joystick
  40005. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40006. */
  40007. setJoystickColor(newColor: string): void;
  40008. /**
  40009. * Defines a callback to call when the joystick is touched
  40010. * @param action defines the callback
  40011. */
  40012. setActionOnTouch(action: () => any): void;
  40013. /**
  40014. * Defines which axis you'd like to control for left & right
  40015. * @param axis defines the axis to use
  40016. */
  40017. setAxisForLeftRight(axis: JoystickAxis): void;
  40018. /**
  40019. * Defines which axis you'd like to control for up & down
  40020. * @param axis defines the axis to use
  40021. */
  40022. setAxisForUpDown(axis: JoystickAxis): void;
  40023. private _drawVirtualJoystick;
  40024. /**
  40025. * Release internal HTML canvas
  40026. */
  40027. releaseCanvas(): void;
  40028. }
  40029. }
  40030. declare module BABYLON {
  40031. /**
  40032. * Helper class to push actions to a pool of workers.
  40033. */
  40034. class WorkerPool implements IDisposable {
  40035. private _workerInfos;
  40036. private _pendingActions;
  40037. /**
  40038. * Constructor
  40039. * @param workers Array of workers to use for actions
  40040. */
  40041. constructor(workers: Array<Worker>);
  40042. /**
  40043. * Terminates all workers and clears any pending actions.
  40044. */
  40045. dispose(): void;
  40046. /**
  40047. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40048. * pended until a worker has completed its action.
  40049. * @param action The action to perform. Call onComplete when the action is complete.
  40050. */
  40051. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40052. private _execute;
  40053. }
  40054. }
  40055. declare module BABYLON {
  40056. /**
  40057. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40058. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40059. */
  40060. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40061. /**
  40062. * Gets the name of the behavior.
  40063. */
  40064. readonly name: string;
  40065. private _zoomStopsAnimation;
  40066. private _idleRotationSpeed;
  40067. private _idleRotationWaitTime;
  40068. private _idleRotationSpinupTime;
  40069. /**
  40070. * Sets the flag that indicates if user zooming should stop animation.
  40071. */
  40072. /**
  40073. * Gets the flag that indicates if user zooming should stop animation.
  40074. */
  40075. zoomStopsAnimation: boolean;
  40076. /**
  40077. * Sets the default speed at which the camera rotates around the model.
  40078. */
  40079. /**
  40080. * Gets the default speed at which the camera rotates around the model.
  40081. */
  40082. idleRotationSpeed: number;
  40083. /**
  40084. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40085. */
  40086. /**
  40087. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40088. */
  40089. idleRotationWaitTime: number;
  40090. /**
  40091. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40092. */
  40093. /**
  40094. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40095. */
  40096. idleRotationSpinupTime: number;
  40097. /**
  40098. * Gets a value indicating if the camera is currently rotating because of this behavior
  40099. */
  40100. readonly rotationInProgress: boolean;
  40101. private _onPrePointerObservableObserver;
  40102. private _onAfterCheckInputsObserver;
  40103. private _attachedCamera;
  40104. private _isPointerDown;
  40105. private _lastFrameTime;
  40106. private _lastInteractionTime;
  40107. private _cameraRotationSpeed;
  40108. /**
  40109. * Initializes the behavior.
  40110. */
  40111. init(): void;
  40112. /**
  40113. * Attaches the behavior to its arc rotate camera.
  40114. * @param camera Defines the camera to attach the behavior to
  40115. */
  40116. attach(camera: ArcRotateCamera): void;
  40117. /**
  40118. * Detaches the behavior from its current arc rotate camera.
  40119. */
  40120. detach(): void;
  40121. /**
  40122. * Returns true if user is scrolling.
  40123. * @return true if user is scrolling.
  40124. */
  40125. private _userIsZooming;
  40126. private _lastFrameRadius;
  40127. private _shouldAnimationStopForInteraction;
  40128. /**
  40129. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40130. */
  40131. private _applyUserInteraction;
  40132. private _userIsMoving;
  40133. }
  40134. }
  40135. declare module BABYLON {
  40136. /**
  40137. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40139. */
  40140. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40141. /**
  40142. * Gets the name of the behavior.
  40143. */
  40144. readonly name: string;
  40145. /**
  40146. * The easing function used by animations
  40147. */
  40148. static EasingFunction: BackEase;
  40149. /**
  40150. * The easing mode used by animations
  40151. */
  40152. static EasingMode: number;
  40153. /**
  40154. * The duration of the animation, in milliseconds
  40155. */
  40156. transitionDuration: number;
  40157. /**
  40158. * Length of the distance animated by the transition when lower radius is reached
  40159. */
  40160. lowerRadiusTransitionRange: number;
  40161. /**
  40162. * Length of the distance animated by the transition when upper radius is reached
  40163. */
  40164. upperRadiusTransitionRange: number;
  40165. private _autoTransitionRange;
  40166. /**
  40167. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40168. */
  40169. /**
  40170. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40171. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40172. */
  40173. autoTransitionRange: boolean;
  40174. private _attachedCamera;
  40175. private _onAfterCheckInputsObserver;
  40176. private _onMeshTargetChangedObserver;
  40177. /**
  40178. * Initializes the behavior.
  40179. */
  40180. init(): void;
  40181. /**
  40182. * Attaches the behavior to its arc rotate camera.
  40183. * @param camera Defines the camera to attach the behavior to
  40184. */
  40185. attach(camera: ArcRotateCamera): void;
  40186. /**
  40187. * Detaches the behavior from its current arc rotate camera.
  40188. */
  40189. detach(): void;
  40190. private _radiusIsAnimating;
  40191. private _radiusBounceTransition;
  40192. private _animatables;
  40193. private _cachedWheelPrecision;
  40194. /**
  40195. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40196. * @param radiusLimit The limit to check against.
  40197. * @return Bool to indicate if at limit.
  40198. */
  40199. private _isRadiusAtLimit;
  40200. /**
  40201. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40202. * @param radiusDelta The delta by which to animate to. Can be negative.
  40203. */
  40204. private _applyBoundRadiusAnimation;
  40205. /**
  40206. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40207. */
  40208. protected _clearAnimationLocks(): void;
  40209. /**
  40210. * Stops and removes all animations that have been applied to the camera
  40211. */
  40212. stopAllAnimations(): void;
  40213. }
  40214. }
  40215. declare module BABYLON {
  40216. /**
  40217. * 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.
  40218. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40219. */
  40220. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40221. /**
  40222. * Gets the name of the behavior.
  40223. */
  40224. readonly name: string;
  40225. private _mode;
  40226. private _radiusScale;
  40227. private _positionScale;
  40228. private _defaultElevation;
  40229. private _elevationReturnTime;
  40230. private _elevationReturnWaitTime;
  40231. private _zoomStopsAnimation;
  40232. private _framingTime;
  40233. /**
  40234. * The easing function used by animations
  40235. */
  40236. static EasingFunction: ExponentialEase;
  40237. /**
  40238. * The easing mode used by animations
  40239. */
  40240. static EasingMode: number;
  40241. /**
  40242. * Sets the current mode used by the behavior
  40243. */
  40244. /**
  40245. * Gets current mode used by the behavior.
  40246. */
  40247. mode: number;
  40248. /**
  40249. * Sets the scale applied to the radius (1 by default)
  40250. */
  40251. /**
  40252. * Gets the scale applied to the radius
  40253. */
  40254. radiusScale: number;
  40255. /**
  40256. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40257. */
  40258. /**
  40259. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40260. */
  40261. positionScale: number;
  40262. /**
  40263. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40264. * behaviour is triggered, in radians.
  40265. */
  40266. /**
  40267. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40268. * behaviour is triggered, in radians.
  40269. */
  40270. defaultElevation: number;
  40271. /**
  40272. * Sets the time (in milliseconds) taken to return to the default beta position.
  40273. * Negative value indicates camera should not return to default.
  40274. */
  40275. /**
  40276. * Gets the time (in milliseconds) taken to return to the default beta position.
  40277. * Negative value indicates camera should not return to default.
  40278. */
  40279. elevationReturnTime: number;
  40280. /**
  40281. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40282. */
  40283. /**
  40284. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40285. */
  40286. elevationReturnWaitTime: number;
  40287. /**
  40288. * Sets the flag that indicates if user zooming should stop animation.
  40289. */
  40290. /**
  40291. * Gets the flag that indicates if user zooming should stop animation.
  40292. */
  40293. zoomStopsAnimation: boolean;
  40294. /**
  40295. * Sets the transition time when framing the mesh, in milliseconds
  40296. */
  40297. /**
  40298. * Gets the transition time when framing the mesh, in milliseconds
  40299. */
  40300. framingTime: number;
  40301. /**
  40302. * Define if the behavior should automatically change the configured
  40303. * camera limits and sensibilities.
  40304. */
  40305. autoCorrectCameraLimitsAndSensibility: boolean;
  40306. private _onPrePointerObservableObserver;
  40307. private _onAfterCheckInputsObserver;
  40308. private _onMeshTargetChangedObserver;
  40309. private _attachedCamera;
  40310. private _isPointerDown;
  40311. private _lastInteractionTime;
  40312. /**
  40313. * Initializes the behavior.
  40314. */
  40315. init(): void;
  40316. /**
  40317. * Attaches the behavior to its arc rotate camera.
  40318. * @param camera Defines the camera to attach the behavior to
  40319. */
  40320. attach(camera: ArcRotateCamera): void;
  40321. /**
  40322. * Detaches the behavior from its current arc rotate camera.
  40323. */
  40324. detach(): void;
  40325. private _animatables;
  40326. private _betaIsAnimating;
  40327. private _betaTransition;
  40328. private _radiusTransition;
  40329. private _vectorTransition;
  40330. /**
  40331. * Targets the given mesh and updates zoom level accordingly.
  40332. * @param mesh The mesh to target.
  40333. * @param radius Optional. If a cached radius position already exists, overrides default.
  40334. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40335. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40336. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40337. */
  40338. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40339. /**
  40340. * Targets the given mesh with its children and updates zoom level accordingly.
  40341. * @param mesh The mesh to target.
  40342. * @param radius Optional. If a cached radius position already exists, overrides default.
  40343. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40346. */
  40347. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40348. /**
  40349. * Targets the given meshes with their children and updates zoom level accordingly.
  40350. * @param meshes The mesh to target.
  40351. * @param radius Optional. If a cached radius position already exists, overrides default.
  40352. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40353. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40354. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40355. */
  40356. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40357. /**
  40358. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40359. * @param minimumWorld Determines the smaller position of the bounding box extend
  40360. * @param maximumWorld Determines the bigger position of the bounding box extend
  40361. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40362. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40363. */
  40364. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40365. /**
  40366. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40367. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40368. * frustum width.
  40369. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40370. * to fully enclose the mesh in the viewing frustum.
  40371. */
  40372. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40373. /**
  40374. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40375. * is automatically returned to its default position (expected to be above ground plane).
  40376. */
  40377. private _maintainCameraAboveGround;
  40378. /**
  40379. * Returns the frustum slope based on the canvas ratio and camera FOV
  40380. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40381. */
  40382. private _getFrustumSlope;
  40383. /**
  40384. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40385. */
  40386. private _clearAnimationLocks;
  40387. /**
  40388. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40389. */
  40390. private _applyUserInteraction;
  40391. /**
  40392. * Stops and removes all animations that have been applied to the camera
  40393. */
  40394. stopAllAnimations(): void;
  40395. /**
  40396. * Gets a value indicating if the user is moving the camera
  40397. */
  40398. readonly isUserIsMoving: boolean;
  40399. /**
  40400. * The camera can move all the way towards the mesh.
  40401. */
  40402. static IgnoreBoundsSizeMode: number;
  40403. /**
  40404. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40405. */
  40406. static FitFrustumSidesMode: number;
  40407. }
  40408. }
  40409. declare module BABYLON {
  40410. /**
  40411. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40412. */
  40413. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40414. private ui;
  40415. /**
  40416. * The name of the behavior
  40417. */
  40418. name: string;
  40419. /**
  40420. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40421. */
  40422. distanceAwayFromFace: number;
  40423. /**
  40424. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40425. */
  40426. distanceAwayFromBottomOfFace: number;
  40427. private _faceVectors;
  40428. private _target;
  40429. private _scene;
  40430. private _onRenderObserver;
  40431. private _tmpMatrix;
  40432. private _tmpVector;
  40433. /**
  40434. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40435. * @param ui The transform node that should be attched to the mesh
  40436. */
  40437. constructor(ui: BABYLON.TransformNode);
  40438. /**
  40439. * Initializes the behavior
  40440. */
  40441. init(): void;
  40442. private _closestFace;
  40443. private _zeroVector;
  40444. private _lookAtTmpMatrix;
  40445. private _lookAtToRef;
  40446. /**
  40447. * Attaches the AttachToBoxBehavior to the passed in mesh
  40448. * @param target The mesh that the specified node will be attached to
  40449. */
  40450. attach(target: BABYLON.Mesh): void;
  40451. /**
  40452. * Detaches the behavior from the mesh
  40453. */
  40454. detach(): void;
  40455. }
  40456. }
  40457. declare module BABYLON {
  40458. /**
  40459. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40460. */
  40461. class FadeInOutBehavior implements Behavior<Mesh> {
  40462. /**
  40463. * Time in milliseconds to delay before fading in (Default: 0)
  40464. */
  40465. delay: number;
  40466. /**
  40467. * Time in milliseconds for the mesh to fade in (Default: 300)
  40468. */
  40469. fadeInTime: number;
  40470. private _millisecondsPerFrame;
  40471. private _hovered;
  40472. private _hoverValue;
  40473. private _ownerNode;
  40474. /**
  40475. * Instatiates the FadeInOutBehavior
  40476. */
  40477. constructor();
  40478. /**
  40479. * The name of the behavior
  40480. */
  40481. readonly name: string;
  40482. /**
  40483. * Initializes the behavior
  40484. */
  40485. init(): void;
  40486. /**
  40487. * Attaches the fade behavior on the passed in mesh
  40488. * @param ownerNode The mesh that will be faded in/out once attached
  40489. */
  40490. attach(ownerNode: Mesh): void;
  40491. /**
  40492. * Detaches the behavior from the mesh
  40493. */
  40494. detach(): void;
  40495. /**
  40496. * Triggers the mesh to begin fading in or out
  40497. * @param value if the object should fade in or out (true to fade in)
  40498. */
  40499. fadeIn(value: boolean): void;
  40500. private _update;
  40501. private _setAllVisibility;
  40502. }
  40503. }
  40504. declare module BABYLON {
  40505. /**
  40506. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40507. */
  40508. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40509. private _dragBehaviorA;
  40510. private _dragBehaviorB;
  40511. private _startDistance;
  40512. private _initialScale;
  40513. private _targetScale;
  40514. private _ownerNode;
  40515. private _sceneRenderObserver;
  40516. /**
  40517. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40518. */
  40519. constructor();
  40520. /**
  40521. * The name of the behavior
  40522. */
  40523. readonly name: string;
  40524. /**
  40525. * Initializes the behavior
  40526. */
  40527. init(): void;
  40528. private _getCurrentDistance;
  40529. /**
  40530. * Attaches the scale behavior the passed in mesh
  40531. * @param ownerNode The mesh that will be scaled around once attached
  40532. */
  40533. attach(ownerNode: Mesh): void;
  40534. /**
  40535. * Detaches the behavior from the mesh
  40536. */
  40537. detach(): void;
  40538. }
  40539. }
  40540. declare module BABYLON {
  40541. /**
  40542. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40543. */
  40544. class PointerDragBehavior implements Behavior<Mesh> {
  40545. private static _AnyMouseID;
  40546. private _attachedNode;
  40547. private _dragPlane;
  40548. private _scene;
  40549. private _pointerObserver;
  40550. private _beforeRenderObserver;
  40551. private static _planeScene;
  40552. /**
  40553. * 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)
  40554. */
  40555. maxDragAngle: number;
  40556. /**
  40557. * @hidden
  40558. */
  40559. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40560. /**
  40561. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40562. */
  40563. currentDraggingPointerID: number;
  40564. /**
  40565. * The last position where the pointer hit the drag plane in world space
  40566. */
  40567. lastDragPosition: Vector3;
  40568. /**
  40569. * If the behavior is currently in a dragging state
  40570. */
  40571. dragging: boolean;
  40572. /**
  40573. * 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)
  40574. */
  40575. dragDeltaRatio: number;
  40576. /**
  40577. * If the drag plane orientation should be updated during the dragging (Default: true)
  40578. */
  40579. updateDragPlane: boolean;
  40580. private _debugMode;
  40581. private _moving;
  40582. /**
  40583. * Fires each time the attached mesh is dragged with the pointer
  40584. * * delta between last drag position and current drag position in world space
  40585. * * dragDistance along the drag axis
  40586. * * dragPlaneNormal normal of the current drag plane used during the drag
  40587. * * dragPlanePoint in world space where the drag intersects the drag plane
  40588. */
  40589. onDragObservable: Observable<{
  40590. delta: Vector3;
  40591. dragPlanePoint: Vector3;
  40592. dragPlaneNormal: Vector3;
  40593. dragDistance: number;
  40594. pointerId: number;
  40595. }>;
  40596. /**
  40597. * Fires each time a drag begins (eg. mouse down on mesh)
  40598. */
  40599. onDragStartObservable: Observable<{
  40600. dragPlanePoint: Vector3;
  40601. pointerId: number;
  40602. }>;
  40603. /**
  40604. * Fires each time a drag ends (eg. mouse release after drag)
  40605. */
  40606. onDragEndObservable: Observable<{
  40607. dragPlanePoint: Vector3;
  40608. pointerId: number;
  40609. }>;
  40610. /**
  40611. * If the attached mesh should be moved when dragged
  40612. */
  40613. moveAttached: boolean;
  40614. /**
  40615. * If the drag behavior will react to drag events (Default: true)
  40616. */
  40617. enabled: boolean;
  40618. /**
  40619. * If camera controls should be detached during the drag
  40620. */
  40621. detachCameraControls: boolean;
  40622. /**
  40623. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40624. */
  40625. useObjectOrienationForDragging: boolean;
  40626. private _options;
  40627. /**
  40628. * Creates a pointer drag behavior that can be attached to a mesh
  40629. * @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)
  40630. */
  40631. constructor(options?: {
  40632. dragAxis?: Vector3;
  40633. dragPlaneNormal?: Vector3;
  40634. });
  40635. /**
  40636. * The name of the behavior
  40637. */
  40638. readonly name: string;
  40639. /**
  40640. * Initializes the behavior
  40641. */
  40642. init(): void;
  40643. private _tmpVector;
  40644. private _alternatePickedPoint;
  40645. private _worldDragAxis;
  40646. private _targetPosition;
  40647. private _attachedElement;
  40648. /**
  40649. * Attaches the drag behavior the passed in mesh
  40650. * @param ownerNode The mesh that will be dragged around once attached
  40651. */
  40652. attach(ownerNode: Mesh): void;
  40653. /**
  40654. * Force relase the drag action by code.
  40655. */
  40656. releaseDrag(): void;
  40657. private _startDragRay;
  40658. private _lastPointerRay;
  40659. /**
  40660. * Simulates the start of a pointer drag event on the behavior
  40661. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40662. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40663. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40664. */
  40665. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40666. private _startDrag;
  40667. private _dragDelta;
  40668. private _moveDrag;
  40669. private _pickWithRayOnDragPlane;
  40670. private _pointA;
  40671. private _pointB;
  40672. private _pointC;
  40673. private _lineA;
  40674. private _lineB;
  40675. private _localAxis;
  40676. private _lookAt;
  40677. private _updateDragPlanePosition;
  40678. /**
  40679. * Detaches the behavior from the mesh
  40680. */
  40681. detach(): void;
  40682. }
  40683. }
  40684. declare module BABYLON {
  40685. /**
  40686. * 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
  40687. */
  40688. class SixDofDragBehavior implements Behavior<Mesh> {
  40689. private static _virtualScene;
  40690. private _ownerNode;
  40691. private _sceneRenderObserver;
  40692. private _scene;
  40693. private _targetPosition;
  40694. private _virtualOriginMesh;
  40695. private _virtualDragMesh;
  40696. private _pointerObserver;
  40697. private _moving;
  40698. private _startingOrientation;
  40699. /**
  40700. * 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)
  40701. */
  40702. private zDragFactor;
  40703. /**
  40704. * If the behavior is currently in a dragging state
  40705. */
  40706. dragging: boolean;
  40707. /**
  40708. * 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)
  40709. */
  40710. dragDeltaRatio: number;
  40711. /**
  40712. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40713. */
  40714. currentDraggingPointerID: number;
  40715. /**
  40716. * If camera controls should be detached during the drag
  40717. */
  40718. detachCameraControls: boolean;
  40719. /**
  40720. * Fires each time a drag starts
  40721. */
  40722. onDragStartObservable: Observable<{}>;
  40723. /**
  40724. * Fires each time a drag ends (eg. mouse release after drag)
  40725. */
  40726. onDragEndObservable: Observable<{}>;
  40727. /**
  40728. * 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
  40729. */
  40730. constructor();
  40731. /**
  40732. * The name of the behavior
  40733. */
  40734. readonly name: string;
  40735. /**
  40736. * Initializes the behavior
  40737. */
  40738. init(): void;
  40739. /**
  40740. * Attaches the scale behavior the passed in mesh
  40741. * @param ownerNode The mesh that will be scaled around once attached
  40742. */
  40743. attach(ownerNode: Mesh): void;
  40744. /**
  40745. * Detaches the behavior from the mesh
  40746. */
  40747. detach(): void;
  40748. }
  40749. }
  40750. declare module BABYLON {
  40751. /**
  40752. * Contains an array of blocks representing the octree
  40753. */
  40754. interface IOctreeContainer<T> {
  40755. /**
  40756. * Blocks within the octree
  40757. */
  40758. blocks: Array<OctreeBlock<T>>;
  40759. }
  40760. /**
  40761. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40762. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40763. */
  40764. class Octree<T> {
  40765. /** 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.) */
  40766. maxDepth: number;
  40767. /**
  40768. * Blocks within the octree containing objects
  40769. */
  40770. blocks: Array<OctreeBlock<T>>;
  40771. /**
  40772. * Content stored in the octree
  40773. */
  40774. dynamicContent: T[];
  40775. private _maxBlockCapacity;
  40776. private _selectionContent;
  40777. private _creationFunc;
  40778. /**
  40779. * Creates a octree
  40780. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40781. * @param creationFunc function to be used to instatiate the octree
  40782. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40783. * @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.)
  40784. */
  40785. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40786. /** 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.) */
  40787. maxDepth?: number);
  40788. /**
  40789. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40790. * @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);
  40791. * @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);
  40792. * @param entries meshes to be added to the octree blocks
  40793. */
  40794. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40795. /**
  40796. * Adds a mesh to the octree
  40797. * @param entry Mesh to add to the octree
  40798. */
  40799. addMesh(entry: T): void;
  40800. /**
  40801. * Selects an array of meshes within the frustum
  40802. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40803. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40804. * @returns array of meshes within the frustum
  40805. */
  40806. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40807. /**
  40808. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40809. * @param sphereCenter defines the bounding sphere center
  40810. * @param sphereRadius defines the bounding sphere radius
  40811. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40812. * @returns an array of objects that intersect the sphere
  40813. */
  40814. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40815. /**
  40816. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40817. * @param ray defines the ray to test with
  40818. * @returns array of intersected objects
  40819. */
  40820. intersectsRay(ray: Ray): SmartArray<T>;
  40821. /**
  40822. * @hidden
  40823. */
  40824. 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;
  40825. /**
  40826. * Adds a mesh into the octree block if it intersects the block
  40827. */
  40828. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40829. /**
  40830. * Adds a submesh into the octree block if it intersects the block
  40831. */
  40832. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40833. }
  40834. }
  40835. declare module BABYLON {
  40836. /**
  40837. * Class used to store a cell in an octree
  40838. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40839. */
  40840. class OctreeBlock<T> {
  40841. /**
  40842. * Gets the content of the current block
  40843. */
  40844. entries: T[];
  40845. /**
  40846. * Gets the list of block children
  40847. */
  40848. blocks: Array<OctreeBlock<T>>;
  40849. private _depth;
  40850. private _maxDepth;
  40851. private _capacity;
  40852. private _minPoint;
  40853. private _maxPoint;
  40854. private _boundingVectors;
  40855. private _creationFunc;
  40856. /**
  40857. * Creates a new block
  40858. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40859. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40860. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40861. * @param depth defines the current depth of this block in the octree
  40862. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40863. * @param creationFunc defines a callback to call when an element is added to the block
  40864. */
  40865. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40866. /**
  40867. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40868. */
  40869. readonly capacity: number;
  40870. /**
  40871. * Gets the minimum vector (in world space) of the block's bounding box
  40872. */
  40873. readonly minPoint: Vector3;
  40874. /**
  40875. * Gets the maximum vector (in world space) of the block's bounding box
  40876. */
  40877. readonly maxPoint: Vector3;
  40878. /**
  40879. * Add a new element to this block
  40880. * @param entry defines the element to add
  40881. */
  40882. addEntry(entry: T): void;
  40883. /**
  40884. * Add an array of elements to this block
  40885. * @param entries defines the array of elements to add
  40886. */
  40887. addEntries(entries: T[]): void;
  40888. /**
  40889. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40890. * @param frustumPlanes defines the frustum planes to test
  40891. * @param selection defines the array to store current content if selection is positive
  40892. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40893. */
  40894. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40895. /**
  40896. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40897. * @param sphereCenter defines the bounding sphere center
  40898. * @param sphereRadius defines the bounding sphere radius
  40899. * @param selection defines the array to store current content if selection is positive
  40900. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40901. */
  40902. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40903. /**
  40904. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40905. * @param ray defines the ray to test with
  40906. * @param selection defines the array to store current content if selection is positive
  40907. */
  40908. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40909. /**
  40910. * Subdivide the content into child blocks (this block will then be empty)
  40911. */
  40912. createInnerBlocks(): void;
  40913. }
  40914. }
  40915. declare module BABYLON {
  40916. interface Scene {
  40917. /**
  40918. * @hidden
  40919. * Backing Filed
  40920. */
  40921. _selectionOctree: Octree<AbstractMesh>;
  40922. /**
  40923. * Gets the octree used to boost mesh selection (picking)
  40924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40925. */
  40926. selectionOctree: Octree<AbstractMesh>;
  40927. /**
  40928. * Creates or updates the octree used to boost selection (picking)
  40929. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40930. * @param maxCapacity defines the maximum capacity per leaf
  40931. * @param maxDepth defines the maximum depth of the octree
  40932. * @returns an octree of AbstractMesh
  40933. */
  40934. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40935. }
  40936. interface AbstractMesh {
  40937. /**
  40938. * @hidden
  40939. * Backing Field
  40940. */
  40941. _submeshesOctree: Octree<SubMesh>;
  40942. /**
  40943. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40944. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40945. * @param maxCapacity defines the maximum size of each block (64 by default)
  40946. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40947. * @returns the new octree
  40948. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40950. */
  40951. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40952. }
  40953. /**
  40954. * Defines the octree scene component responsible to manage any octrees
  40955. * in a given scene.
  40956. */
  40957. class OctreeSceneComponent {
  40958. /**
  40959. * The component name helpfull to identify the component in the list of scene components.
  40960. */
  40961. readonly name: string;
  40962. /**
  40963. * The scene the component belongs to.
  40964. */
  40965. scene: Scene;
  40966. /**
  40967. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40968. */
  40969. readonly checksIsEnabled: boolean;
  40970. /**
  40971. * Creates a new instance of the component for the given scene
  40972. * @param scene Defines the scene to register the component in
  40973. */
  40974. constructor(scene: Scene);
  40975. /**
  40976. * Registers the component in a given scene
  40977. */
  40978. register(): void;
  40979. /**
  40980. * Return the list of active meshes
  40981. * @returns the list of active meshes
  40982. */
  40983. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40984. /**
  40985. * Return the list of active sub meshes
  40986. * @param mesh The mesh to get the candidates sub meshes from
  40987. * @returns the list of active sub meshes
  40988. */
  40989. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40990. private _tempRay;
  40991. /**
  40992. * Return the list of sub meshes intersecting with a given local ray
  40993. * @param mesh defines the mesh to find the submesh for
  40994. * @param localRay defines the ray in local space
  40995. * @returns the list of intersecting sub meshes
  40996. */
  40997. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40998. /**
  40999. * Return the list of sub meshes colliding with a collider
  41000. * @param mesh defines the mesh to find the submesh for
  41001. * @param collider defines the collider to evaluate the collision against
  41002. * @returns the list of colliding sub meshes
  41003. */
  41004. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41005. /**
  41006. * Rebuilds the elements related to this component in case of
  41007. * context lost for instance.
  41008. */
  41009. rebuild(): void;
  41010. /**
  41011. * Disposes the component and the associated ressources.
  41012. */
  41013. dispose(): void;
  41014. }
  41015. }
  41016. declare module BABYLON {
  41017. /**
  41018. * Manage the gamepad inputs to control an arc rotate camera.
  41019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41020. */
  41021. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41022. /**
  41023. * Defines the camera the input is attached to.
  41024. */
  41025. camera: ArcRotateCamera;
  41026. /**
  41027. * Defines the gamepad the input is gathering event from.
  41028. */
  41029. gamepad: Nullable<Gamepad>;
  41030. /**
  41031. * Defines the gamepad rotation sensiblity.
  41032. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41033. */
  41034. gamepadRotationSensibility: number;
  41035. /**
  41036. * Defines the gamepad move sensiblity.
  41037. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41038. */
  41039. gamepadMoveSensibility: number;
  41040. private _onGamepadConnectedObserver;
  41041. private _onGamepadDisconnectedObserver;
  41042. /**
  41043. * Attach the input controls to a specific dom element to get the input from.
  41044. * @param element Defines the element the controls should be listened from
  41045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41046. */
  41047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41048. /**
  41049. * Detach the current controls from the specified dom element.
  41050. * @param element Defines the element to stop listening the inputs from
  41051. */
  41052. detachControl(element: Nullable<HTMLElement>): void;
  41053. /**
  41054. * Update the current camera state depending on the inputs that have been used this frame.
  41055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41056. */
  41057. checkInputs(): void;
  41058. /**
  41059. * Gets the class name of the current intput.
  41060. * @returns the class name
  41061. */
  41062. getClassName(): string;
  41063. /**
  41064. * Get the friendly name associated with the input class.
  41065. * @returns the input friendly name
  41066. */
  41067. getSimpleName(): string;
  41068. }
  41069. }
  41070. declare module BABYLON {
  41071. /**
  41072. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41074. */
  41075. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41076. /**
  41077. * Defines the camera the input is attached to.
  41078. */
  41079. camera: ArcRotateCamera;
  41080. /**
  41081. * Defines the list of key codes associated with the up action (increase alpha)
  41082. */
  41083. keysUp: number[];
  41084. /**
  41085. * Defines the list of key codes associated with the down action (decrease alpha)
  41086. */
  41087. keysDown: number[];
  41088. /**
  41089. * Defines the list of key codes associated with the left action (increase beta)
  41090. */
  41091. keysLeft: number[];
  41092. /**
  41093. * Defines the list of key codes associated with the right action (decrease beta)
  41094. */
  41095. keysRight: number[];
  41096. /**
  41097. * Defines the list of key codes associated with the reset action.
  41098. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41099. */
  41100. keysReset: number[];
  41101. /**
  41102. * Defines the panning sensibility of the inputs.
  41103. * (How fast is the camera paning)
  41104. */
  41105. panningSensibility: number;
  41106. /**
  41107. * Defines the zooming sensibility of the inputs.
  41108. * (How fast is the camera zooming)
  41109. */
  41110. zoomingSensibility: number;
  41111. /**
  41112. * Defines wether maintaining the alt key down switch the movement mode from
  41113. * orientation to zoom.
  41114. */
  41115. useAltToZoom: boolean;
  41116. /**
  41117. * Rotation speed of the camera
  41118. */
  41119. angularSpeed: number;
  41120. private _keys;
  41121. private _ctrlPressed;
  41122. private _altPressed;
  41123. private _onCanvasBlurObserver;
  41124. private _onKeyboardObserver;
  41125. private _engine;
  41126. private _scene;
  41127. /**
  41128. * Attach the input controls to a specific dom element to get the input from.
  41129. * @param element Defines the element the controls should be listened from
  41130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41131. */
  41132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41133. /**
  41134. * Detach the current controls from the specified dom element.
  41135. * @param element Defines the element to stop listening the inputs from
  41136. */
  41137. detachControl(element: Nullable<HTMLElement>): void;
  41138. /**
  41139. * Update the current camera state depending on the inputs that have been used this frame.
  41140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41141. */
  41142. checkInputs(): void;
  41143. /**
  41144. * Gets the class name of the current intput.
  41145. * @returns the class name
  41146. */
  41147. getClassName(): string;
  41148. /**
  41149. * Get the friendly name associated with the input class.
  41150. * @returns the input friendly name
  41151. */
  41152. getSimpleName(): string;
  41153. }
  41154. }
  41155. declare module BABYLON {
  41156. /**
  41157. * Manage the mouse wheel inputs to control an arc rotate camera.
  41158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41159. */
  41160. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41161. /**
  41162. * Defines the camera the input is attached to.
  41163. */
  41164. camera: ArcRotateCamera;
  41165. /**
  41166. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41167. */
  41168. wheelPrecision: number;
  41169. /**
  41170. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41171. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41172. */
  41173. wheelDeltaPercentage: number;
  41174. private _wheel;
  41175. private _observer;
  41176. /**
  41177. * Attach the input controls to a specific dom element to get the input from.
  41178. * @param element Defines the element the controls should be listened from
  41179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41180. */
  41181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41182. /**
  41183. * Detach the current controls from the specified dom element.
  41184. * @param element Defines the element to stop listening the inputs from
  41185. */
  41186. detachControl(element: Nullable<HTMLElement>): void;
  41187. /**
  41188. * Gets the class name of the current intput.
  41189. * @returns the class name
  41190. */
  41191. getClassName(): string;
  41192. /**
  41193. * Get the friendly name associated with the input class.
  41194. * @returns the input friendly name
  41195. */
  41196. getSimpleName(): string;
  41197. }
  41198. }
  41199. declare module BABYLON {
  41200. /**
  41201. * Manage the pointers inputs to control an arc rotate camera.
  41202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41203. */
  41204. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41205. /**
  41206. * Defines the camera the input is attached to.
  41207. */
  41208. camera: ArcRotateCamera;
  41209. /**
  41210. * Defines the buttons associated with the input to handle camera move.
  41211. */
  41212. buttons: number[];
  41213. /**
  41214. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41215. */
  41216. angularSensibilityX: number;
  41217. /**
  41218. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41219. */
  41220. angularSensibilityY: number;
  41221. /**
  41222. * Defines the pointer pinch precision or how fast is the camera zooming.
  41223. */
  41224. pinchPrecision: number;
  41225. /**
  41226. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41227. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41228. */
  41229. pinchDeltaPercentage: number;
  41230. /**
  41231. * Defines the pointer panning sensibility or how fast is the camera moving.
  41232. */
  41233. panningSensibility: number;
  41234. /**
  41235. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41236. */
  41237. multiTouchPanning: boolean;
  41238. /**
  41239. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41240. */
  41241. multiTouchPanAndZoom: boolean;
  41242. /**
  41243. * Revers pinch action direction.
  41244. */
  41245. pinchInwards: boolean;
  41246. private _isPanClick;
  41247. private _pointerInput;
  41248. private _observer;
  41249. private _onMouseMove;
  41250. private _onGestureStart;
  41251. private _onGesture;
  41252. private _MSGestureHandler;
  41253. private _onLostFocus;
  41254. private _onContextMenu;
  41255. /**
  41256. * Attach the input controls to a specific dom element to get the input from.
  41257. * @param element Defines the element the controls should be listened from
  41258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41259. */
  41260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41261. /**
  41262. * Detach the current controls from the specified dom element.
  41263. * @param element Defines the element to stop listening the inputs from
  41264. */
  41265. detachControl(element: Nullable<HTMLElement>): void;
  41266. /**
  41267. * Gets the class name of the current intput.
  41268. * @returns the class name
  41269. */
  41270. getClassName(): string;
  41271. /**
  41272. * Get the friendly name associated with the input class.
  41273. * @returns the input friendly name
  41274. */
  41275. getSimpleName(): string;
  41276. }
  41277. }
  41278. declare module BABYLON {
  41279. /**
  41280. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41282. */
  41283. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41284. /**
  41285. * Defines the camera the input is attached to.
  41286. */
  41287. camera: ArcRotateCamera;
  41288. /**
  41289. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41290. */
  41291. alphaCorrection: number;
  41292. /**
  41293. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  41294. */
  41295. betaCorrection: number;
  41296. /**
  41297. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41298. */
  41299. gammaCorrection: number;
  41300. private _alpha;
  41301. private _gamma;
  41302. private _dirty;
  41303. private _deviceOrientationHandler;
  41304. /**
  41305. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41306. */
  41307. constructor();
  41308. /**
  41309. * Attach the input controls to a specific dom element to get the input from.
  41310. * @param element Defines the element the controls should be listened from
  41311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41312. */
  41313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41314. /** @hidden */
  41315. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41316. /**
  41317. * Update the current camera state depending on the inputs that have been used this frame.
  41318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41319. */
  41320. checkInputs(): void;
  41321. /**
  41322. * Detach the current controls from the specified dom element.
  41323. * @param element Defines the element to stop listening the inputs from
  41324. */
  41325. detachControl(element: Nullable<HTMLElement>): void;
  41326. /**
  41327. * Gets the class name of the current intput.
  41328. * @returns the class name
  41329. */
  41330. getClassName(): string;
  41331. /**
  41332. * Get the friendly name associated with the input class.
  41333. * @returns the input friendly name
  41334. */
  41335. getSimpleName(): string;
  41336. }
  41337. }
  41338. declare module BABYLON {
  41339. /**
  41340. * Listen to keyboard events to control the camera.
  41341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41342. */
  41343. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41344. /**
  41345. * Defines the camera the input is attached to.
  41346. */
  41347. camera: FlyCamera;
  41348. /**
  41349. * The list of keyboard keys used to control the forward move of the camera.
  41350. */
  41351. keysForward: number[];
  41352. /**
  41353. * The list of keyboard keys used to control the backward move of the camera.
  41354. */
  41355. keysBackward: number[];
  41356. /**
  41357. * The list of keyboard keys used to control the forward move of the camera.
  41358. */
  41359. keysUp: number[];
  41360. /**
  41361. * The list of keyboard keys used to control the backward move of the camera.
  41362. */
  41363. keysDown: number[];
  41364. /**
  41365. * The list of keyboard keys used to control the right strafe move of the camera.
  41366. */
  41367. keysRight: number[];
  41368. /**
  41369. * The list of keyboard keys used to control the left strafe move of the camera.
  41370. */
  41371. keysLeft: number[];
  41372. private _keys;
  41373. private _onCanvasBlurObserver;
  41374. private _onKeyboardObserver;
  41375. private _engine;
  41376. private _scene;
  41377. /**
  41378. * Attach the input controls to a specific dom element to get the input from.
  41379. * @param element Defines the element the controls should be listened from
  41380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41381. */
  41382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41383. /**
  41384. * Detach the current controls from the specified dom element.
  41385. * @param element Defines the element to stop listening the inputs from
  41386. */
  41387. detachControl(element: Nullable<HTMLElement>): void;
  41388. /**
  41389. * Gets the class name of the current intput.
  41390. * @returns the class name
  41391. */
  41392. getClassName(): string;
  41393. /** @hidden */
  41394. _onLostFocus(e: FocusEvent): void;
  41395. /**
  41396. * Get the friendly name associated with the input class.
  41397. * @returns the input friendly name
  41398. */
  41399. getSimpleName(): string;
  41400. /**
  41401. * Update the current camera state depending on the inputs that have been used this frame.
  41402. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41403. */
  41404. checkInputs(): void;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /**
  41409. * Listen to mouse events to control the camera.
  41410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41411. */
  41412. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41413. /**
  41414. * Defines the camera the input is attached to.
  41415. */
  41416. camera: FlyCamera;
  41417. /**
  41418. * Defines if touch is enabled. (Default is true.)
  41419. */
  41420. touchEnabled: boolean;
  41421. /**
  41422. * Defines the buttons associated with the input to handle camera rotation.
  41423. */
  41424. buttons: number[];
  41425. /**
  41426. * Assign buttons for Yaw control.
  41427. */
  41428. buttonsYaw: number[];
  41429. /**
  41430. * Assign buttons for Pitch control.
  41431. */
  41432. buttonsPitch: number[];
  41433. /**
  41434. * Assign buttons for Roll control.
  41435. */
  41436. buttonsRoll: number[];
  41437. /**
  41438. * Detect if any button is being pressed while mouse is moved.
  41439. * -1 = Mouse locked.
  41440. * 0 = Left button.
  41441. * 1 = Middle Button.
  41442. * 2 = Right Button.
  41443. */
  41444. activeButton: number;
  41445. /**
  41446. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41447. * Higher values reduce its sensitivity.
  41448. */
  41449. angularSensibility: number;
  41450. private _mousemoveCallback;
  41451. private _observer;
  41452. private _rollObserver;
  41453. private previousPosition;
  41454. private noPreventDefault;
  41455. private element;
  41456. /**
  41457. * Listen to mouse events to control the camera.
  41458. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41460. */
  41461. constructor(touchEnabled?: boolean);
  41462. /**
  41463. * Attach the mouse control to the HTML DOM element.
  41464. * @param element Defines the element that listens to the input events.
  41465. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41466. */
  41467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41468. /**
  41469. * Detach the current controls from the specified dom element.
  41470. * @param element Defines the element to stop listening the inputs from
  41471. */
  41472. detachControl(element: Nullable<HTMLElement>): void;
  41473. /**
  41474. * Gets the class name of the current input.
  41475. * @returns the class name.
  41476. */
  41477. getClassName(): string;
  41478. /**
  41479. * Get the friendly name associated with the input class.
  41480. * @returns the input's friendly name.
  41481. */
  41482. getSimpleName(): string;
  41483. private _pointerInput;
  41484. private _onMouseMove;
  41485. /**
  41486. * Rotate camera by mouse offset.
  41487. */
  41488. private rotateCamera;
  41489. }
  41490. }
  41491. declare module BABYLON {
  41492. /**
  41493. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41494. * Screen rotation is taken into account.
  41495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41496. */
  41497. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41498. private _camera;
  41499. private _screenOrientationAngle;
  41500. private _constantTranform;
  41501. private _screenQuaternion;
  41502. private _alpha;
  41503. private _beta;
  41504. private _gamma;
  41505. /**
  41506. * Instantiates a new input
  41507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41508. */
  41509. constructor();
  41510. /**
  41511. * Define the camera controlled by the input.
  41512. */
  41513. camera: FreeCamera;
  41514. /**
  41515. * Attach the input controls to a specific dom element to get the input from.
  41516. * @param element Defines the element the controls should be listened from
  41517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41518. */
  41519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41520. private _orientationChanged;
  41521. private _deviceOrientation;
  41522. /**
  41523. * Detach the current controls from the specified dom element.
  41524. * @param element Defines the element to stop listening the inputs from
  41525. */
  41526. detachControl(element: Nullable<HTMLElement>): void;
  41527. /**
  41528. * Update the current camera state depending on the inputs that have been used this frame.
  41529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41530. */
  41531. checkInputs(): void;
  41532. /**
  41533. * Gets the class name of the current intput.
  41534. * @returns the class name
  41535. */
  41536. getClassName(): string;
  41537. /**
  41538. * Get the friendly name associated with the input class.
  41539. * @returns the input friendly name
  41540. */
  41541. getSimpleName(): string;
  41542. }
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * Manage the gamepad inputs to control a free camera.
  41547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41548. */
  41549. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41550. /**
  41551. * Define the camera the input is attached to.
  41552. */
  41553. camera: FreeCamera;
  41554. /**
  41555. * Define the Gamepad controlling the input
  41556. */
  41557. gamepad: Nullable<Gamepad>;
  41558. /**
  41559. * Defines the gamepad rotation sensiblity.
  41560. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41561. */
  41562. gamepadAngularSensibility: number;
  41563. /**
  41564. * Defines the gamepad move sensiblity.
  41565. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41566. */
  41567. gamepadMoveSensibility: number;
  41568. private _onGamepadConnectedObserver;
  41569. private _onGamepadDisconnectedObserver;
  41570. private _cameraTransform;
  41571. private _deltaTransform;
  41572. private _vector3;
  41573. private _vector2;
  41574. /**
  41575. * Attach the input controls to a specific dom element to get the input from.
  41576. * @param element Defines the element the controls should be listened from
  41577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41578. */
  41579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41580. /**
  41581. * Detach the current controls from the specified dom element.
  41582. * @param element Defines the element to stop listening the inputs from
  41583. */
  41584. detachControl(element: Nullable<HTMLElement>): void;
  41585. /**
  41586. * Update the current camera state depending on the inputs that have been used this frame.
  41587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41588. */
  41589. checkInputs(): void;
  41590. /**
  41591. * Gets the class name of the current intput.
  41592. * @returns the class name
  41593. */
  41594. getClassName(): string;
  41595. /**
  41596. * Get the friendly name associated with the input class.
  41597. * @returns the input friendly name
  41598. */
  41599. getSimpleName(): string;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Manage the keyboard inputs to control the movement of a free camera.
  41605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41606. */
  41607. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41608. /**
  41609. * Defines the camera the input is attached to.
  41610. */
  41611. camera: FreeCamera;
  41612. /**
  41613. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41614. */
  41615. keysUp: number[];
  41616. /**
  41617. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41618. */
  41619. keysDown: number[];
  41620. /**
  41621. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41622. */
  41623. keysLeft: number[];
  41624. /**
  41625. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41626. */
  41627. keysRight: number[];
  41628. private _keys;
  41629. private _onCanvasBlurObserver;
  41630. private _onKeyboardObserver;
  41631. private _engine;
  41632. private _scene;
  41633. /**
  41634. * Attach the input controls to a specific dom element to get the input from.
  41635. * @param element Defines the element the controls should be listened from
  41636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41637. */
  41638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41639. /**
  41640. * Detach the current controls from the specified dom element.
  41641. * @param element Defines the element to stop listening the inputs from
  41642. */
  41643. detachControl(element: Nullable<HTMLElement>): void;
  41644. /**
  41645. * Update the current camera state depending on the inputs that have been used this frame.
  41646. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41647. */
  41648. checkInputs(): void;
  41649. /**
  41650. * Gets the class name of the current intput.
  41651. * @returns the class name
  41652. */
  41653. getClassName(): string;
  41654. /** @hidden */
  41655. _onLostFocus(e: FocusEvent): void;
  41656. /**
  41657. * Get the friendly name associated with the input class.
  41658. * @returns the input friendly name
  41659. */
  41660. getSimpleName(): string;
  41661. }
  41662. }
  41663. declare module BABYLON {
  41664. /**
  41665. * Manage the mouse inputs to control the movement of a free camera.
  41666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41667. */
  41668. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41669. /**
  41670. * Define if touch is enabled in the mouse input
  41671. */
  41672. touchEnabled: boolean;
  41673. /**
  41674. * Defines the camera the input is attached to.
  41675. */
  41676. camera: FreeCamera;
  41677. /**
  41678. * Defines the buttons associated with the input to handle camera move.
  41679. */
  41680. buttons: number[];
  41681. /**
  41682. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41683. */
  41684. angularSensibility: number;
  41685. private _pointerInput;
  41686. private _onMouseMove;
  41687. private _observer;
  41688. private previousPosition;
  41689. /**
  41690. * Manage the mouse inputs to control the movement of a free camera.
  41691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41692. * @param touchEnabled Defines if touch is enabled or not
  41693. */
  41694. constructor(
  41695. /**
  41696. * Define if touch is enabled in the mouse input
  41697. */
  41698. touchEnabled?: boolean);
  41699. /**
  41700. * Attach the input controls to a specific dom element to get the input from.
  41701. * @param element Defines the element the controls should be listened from
  41702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41703. */
  41704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41705. /**
  41706. * Detach the current controls from the specified dom element.
  41707. * @param element Defines the element to stop listening the inputs from
  41708. */
  41709. detachControl(element: Nullable<HTMLElement>): void;
  41710. /**
  41711. * Gets the class name of the current intput.
  41712. * @returns the class name
  41713. */
  41714. getClassName(): string;
  41715. /**
  41716. * Get the friendly name associated with the input class.
  41717. * @returns the input friendly name
  41718. */
  41719. getSimpleName(): string;
  41720. }
  41721. }
  41722. declare module BABYLON {
  41723. /**
  41724. * Manage the touch inputs to control the movement of a free camera.
  41725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41726. */
  41727. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41728. /**
  41729. * Defines the camera the input is attached to.
  41730. */
  41731. camera: FreeCamera;
  41732. /**
  41733. * Defines the touch sensibility for rotation.
  41734. * The higher the faster.
  41735. */
  41736. touchAngularSensibility: number;
  41737. /**
  41738. * Defines the touch sensibility for move.
  41739. * The higher the faster.
  41740. */
  41741. touchMoveSensibility: number;
  41742. private _offsetX;
  41743. private _offsetY;
  41744. private _pointerPressed;
  41745. private _pointerInput;
  41746. private _observer;
  41747. private _onLostFocus;
  41748. /**
  41749. * Attach the input controls to a specific dom element to get the input from.
  41750. * @param element Defines the element the controls should be listened from
  41751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41752. */
  41753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41754. /**
  41755. * Detach the current controls from the specified dom element.
  41756. * @param element Defines the element to stop listening the inputs from
  41757. */
  41758. detachControl(element: Nullable<HTMLElement>): void;
  41759. /**
  41760. * Update the current camera state depending on the inputs that have been used this frame.
  41761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41762. */
  41763. checkInputs(): void;
  41764. /**
  41765. * Gets the class name of the current intput.
  41766. * @returns the class name
  41767. */
  41768. getClassName(): string;
  41769. /**
  41770. * Get the friendly name associated with the input class.
  41771. * @returns the input friendly name
  41772. */
  41773. getSimpleName(): string;
  41774. }
  41775. }
  41776. declare module BABYLON {
  41777. /**
  41778. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41780. */
  41781. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41782. /**
  41783. * Defines the camera the input is attached to.
  41784. */
  41785. camera: FreeCamera;
  41786. private _leftjoystick;
  41787. private _rightjoystick;
  41788. /**
  41789. * Gets the left stick of the virtual joystick.
  41790. * @returns The virtual Joystick
  41791. */
  41792. getLeftJoystick(): VirtualJoystick;
  41793. /**
  41794. * Gets the right stick of the virtual joystick.
  41795. * @returns The virtual Joystick
  41796. */
  41797. getRightJoystick(): VirtualJoystick;
  41798. /**
  41799. * Update the current camera state depending on the inputs that have been used this frame.
  41800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41801. */
  41802. checkInputs(): void;
  41803. /**
  41804. * Attach the input controls to a specific dom element to get the input from.
  41805. * @param element Defines the element the controls should be listened from
  41806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41807. */
  41808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41809. /**
  41810. * Detach the current controls from the specified dom element.
  41811. * @param element Defines the element to stop listening the inputs from
  41812. */
  41813. detachControl(element: Nullable<HTMLElement>): void;
  41814. /**
  41815. * Gets the class name of the current intput.
  41816. * @returns the class name
  41817. */
  41818. getClassName(): string;
  41819. /**
  41820. * Get the friendly name associated with the input class.
  41821. * @returns the input friendly name
  41822. */
  41823. getSimpleName(): string;
  41824. }
  41825. }
  41826. declare module BABYLON {
  41827. /**
  41828. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41830. */
  41831. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41832. /**
  41833. * Creates a new AnaglyphArcRotateCamera
  41834. * @param name defines camera name
  41835. * @param alpha defines alpha angle (in radians)
  41836. * @param beta defines beta angle (in radians)
  41837. * @param radius defines radius
  41838. * @param target defines camera target
  41839. * @param interaxialDistance defines distance between each color axis
  41840. * @param scene defines the hosting scene
  41841. */
  41842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41843. /**
  41844. * Gets camera class name
  41845. * @returns AnaglyphArcRotateCamera
  41846. */
  41847. getClassName(): string;
  41848. }
  41849. }
  41850. declare module BABYLON {
  41851. /**
  41852. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41853. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41854. */
  41855. class AnaglyphFreeCamera extends FreeCamera {
  41856. /**
  41857. * Creates a new AnaglyphFreeCamera
  41858. * @param name defines camera name
  41859. * @param position defines initial position
  41860. * @param interaxialDistance defines distance between each color axis
  41861. * @param scene defines the hosting scene
  41862. */
  41863. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41864. /**
  41865. * Gets camera class name
  41866. * @returns AnaglyphFreeCamera
  41867. */
  41868. getClassName(): string;
  41869. }
  41870. }
  41871. declare module BABYLON {
  41872. /**
  41873. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41874. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41875. */
  41876. class AnaglyphGamepadCamera extends GamepadCamera {
  41877. /**
  41878. * Creates a new AnaglyphGamepadCamera
  41879. * @param name defines camera name
  41880. * @param position defines initial position
  41881. * @param interaxialDistance defines distance between each color axis
  41882. * @param scene defines the hosting scene
  41883. */
  41884. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41885. /**
  41886. * Gets camera class name
  41887. * @returns AnaglyphGamepadCamera
  41888. */
  41889. getClassName(): string;
  41890. }
  41891. }
  41892. declare module BABYLON {
  41893. /**
  41894. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41895. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41896. */
  41897. class AnaglyphUniversalCamera extends UniversalCamera {
  41898. /**
  41899. * Creates a new AnaglyphUniversalCamera
  41900. * @param name defines camera name
  41901. * @param position defines initial position
  41902. * @param interaxialDistance defines distance between each color axis
  41903. * @param scene defines the hosting scene
  41904. */
  41905. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41906. /**
  41907. * Gets camera class name
  41908. * @returns AnaglyphUniversalCamera
  41909. */
  41910. getClassName(): string;
  41911. }
  41912. }
  41913. declare module BABYLON {
  41914. /**
  41915. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41916. * @see http://doc.babylonjs.com/features/cameras
  41917. */
  41918. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41919. /**
  41920. * Creates a new StereoscopicArcRotateCamera
  41921. * @param name defines camera name
  41922. * @param alpha defines alpha angle (in radians)
  41923. * @param beta defines beta angle (in radians)
  41924. * @param radius defines radius
  41925. * @param target defines camera target
  41926. * @param interaxialDistance defines distance between each color axis
  41927. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41928. * @param scene defines the hosting scene
  41929. */
  41930. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41931. /**
  41932. * Gets camera class name
  41933. * @returns StereoscopicArcRotateCamera
  41934. */
  41935. getClassName(): string;
  41936. }
  41937. }
  41938. declare module BABYLON {
  41939. /**
  41940. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41941. * @see http://doc.babylonjs.com/features/cameras
  41942. */
  41943. class StereoscopicFreeCamera extends FreeCamera {
  41944. /**
  41945. * Creates a new StereoscopicFreeCamera
  41946. * @param name defines camera name
  41947. * @param position defines initial position
  41948. * @param interaxialDistance defines distance between each color axis
  41949. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41950. * @param scene defines the hosting scene
  41951. */
  41952. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41953. /**
  41954. * Gets camera class name
  41955. * @returns StereoscopicFreeCamera
  41956. */
  41957. getClassName(): string;
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /**
  41962. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41963. * @see http://doc.babylonjs.com/features/cameras
  41964. */
  41965. class StereoscopicGamepadCamera extends GamepadCamera {
  41966. /**
  41967. * Creates a new StereoscopicGamepadCamera
  41968. * @param name defines camera name
  41969. * @param position defines initial position
  41970. * @param interaxialDistance defines distance between each color axis
  41971. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41972. * @param scene defines the hosting scene
  41973. */
  41974. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41975. /**
  41976. * Gets camera class name
  41977. * @returns StereoscopicGamepadCamera
  41978. */
  41979. getClassName(): string;
  41980. }
  41981. }
  41982. declare module BABYLON {
  41983. /**
  41984. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41985. * @see http://doc.babylonjs.com/features/cameras
  41986. */
  41987. class StereoscopicUniversalCamera extends UniversalCamera {
  41988. /**
  41989. * Creates a new StereoscopicUniversalCamera
  41990. * @param name defines camera name
  41991. * @param position defines initial position
  41992. * @param interaxialDistance defines distance between each color axis
  41993. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41994. * @param scene defines the hosting scene
  41995. */
  41996. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41997. /**
  41998. * Gets camera class name
  41999. * @returns StereoscopicUniversalCamera
  42000. */
  42001. getClassName(): string;
  42002. }
  42003. }
  42004. declare module BABYLON {
  42005. /**
  42006. * This represents all the required metrics to create a VR camera.
  42007. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42008. */
  42009. class VRCameraMetrics {
  42010. /**
  42011. * Define the horizontal resolution off the screen.
  42012. */
  42013. hResolution: number;
  42014. /**
  42015. * Define the vertical resolution off the screen.
  42016. */
  42017. vResolution: number;
  42018. /**
  42019. * Define the horizontal screen size.
  42020. */
  42021. hScreenSize: number;
  42022. /**
  42023. * Define the vertical screen size.
  42024. */
  42025. vScreenSize: number;
  42026. /**
  42027. * Define the vertical screen center position.
  42028. */
  42029. vScreenCenter: number;
  42030. /**
  42031. * Define the distance of the eyes to the screen.
  42032. */
  42033. eyeToScreenDistance: number;
  42034. /**
  42035. * Define the distance between both lenses
  42036. */
  42037. lensSeparationDistance: number;
  42038. /**
  42039. * Define the distance between both viewer's eyes.
  42040. */
  42041. interpupillaryDistance: number;
  42042. /**
  42043. * Define the distortion factor of the VR postprocess.
  42044. * Please, touch with care.
  42045. */
  42046. distortionK: number[];
  42047. /**
  42048. * Define the chromatic aberration correction factors for the VR post process.
  42049. */
  42050. chromaAbCorrection: number[];
  42051. /**
  42052. * Define the scale factor of the post process.
  42053. * The smaller the better but the slower.
  42054. */
  42055. postProcessScaleFactor: number;
  42056. /**
  42057. * Define an offset for the lens center.
  42058. */
  42059. lensCenterOffset: number;
  42060. /**
  42061. * Define if the current vr camera should compensate the distortion of the lense or not.
  42062. */
  42063. compensateDistortion: boolean;
  42064. /**
  42065. * Gets the rendering aspect ratio based on the provided resolutions.
  42066. */
  42067. readonly aspectRatio: number;
  42068. /**
  42069. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42070. */
  42071. readonly aspectRatioFov: number;
  42072. /**
  42073. * @hidden
  42074. */
  42075. readonly leftHMatrix: Matrix;
  42076. /**
  42077. * @hidden
  42078. */
  42079. readonly rightHMatrix: Matrix;
  42080. /**
  42081. * @hidden
  42082. */
  42083. readonly leftPreViewMatrix: Matrix;
  42084. /**
  42085. * @hidden
  42086. */
  42087. readonly rightPreViewMatrix: Matrix;
  42088. /**
  42089. * Get the default VRMetrics based on the most generic setup.
  42090. * @returns the default vr metrics
  42091. */
  42092. static GetDefault(): VRCameraMetrics;
  42093. }
  42094. }
  42095. declare module BABYLON {
  42096. /**
  42097. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42099. */
  42100. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42101. /**
  42102. * Creates a new VRDeviceOrientationArcRotateCamera
  42103. * @param name defines camera name
  42104. * @param alpha defines the camera rotation along the logitudinal axis
  42105. * @param beta defines the camera rotation along the latitudinal axis
  42106. * @param radius defines the camera distance from its target
  42107. * @param target defines the camera target
  42108. * @param scene defines the scene the camera belongs to
  42109. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42110. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42111. */
  42112. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42113. /**
  42114. * Gets camera class name
  42115. * @returns VRDeviceOrientationArcRotateCamera
  42116. */
  42117. getClassName(): string;
  42118. }
  42119. }
  42120. declare module BABYLON {
  42121. /**
  42122. * Camera used to simulate VR rendering (based on FreeCamera)
  42123. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42124. */
  42125. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42126. /**
  42127. * Creates a new VRDeviceOrientationFreeCamera
  42128. * @param name defines camera name
  42129. * @param position defines the start position of the camera
  42130. * @param scene defines the scene the camera belongs to
  42131. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42132. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42133. */
  42134. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42135. /**
  42136. * Gets camera class name
  42137. * @returns VRDeviceOrientationFreeCamera
  42138. */
  42139. getClassName(): string;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42145. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42146. */
  42147. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42148. /**
  42149. * Creates a new VRDeviceOrientationGamepadCamera
  42150. * @param name defines camera name
  42151. * @param position defines the start position of the camera
  42152. * @param scene defines the scene the camera belongs to
  42153. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42154. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42155. */
  42156. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42157. /**
  42158. * Gets camera class name
  42159. * @returns VRDeviceOrientationGamepadCamera
  42160. */
  42161. getClassName(): string;
  42162. }
  42163. }
  42164. declare module BABYLON {
  42165. /**
  42166. * Options to modify the vr teleportation behavior.
  42167. */
  42168. interface VRTeleportationOptions {
  42169. /**
  42170. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42171. */
  42172. floorMeshName?: string;
  42173. /**
  42174. * A list of meshes to be used as the teleportation floor. (default: empty)
  42175. */
  42176. floorMeshes?: Mesh[];
  42177. }
  42178. /**
  42179. * Options to modify the vr experience helper's behavior.
  42180. */
  42181. interface VRExperienceHelperOptions extends WebVROptions {
  42182. /**
  42183. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42184. */
  42185. createDeviceOrientationCamera?: boolean;
  42186. /**
  42187. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42188. */
  42189. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42190. /**
  42191. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42192. */
  42193. laserToggle?: boolean;
  42194. /**
  42195. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42196. */
  42197. floorMeshes?: Mesh[];
  42198. }
  42199. /**
  42200. * Helps to quickly add VR support to an existing scene.
  42201. * See http://doc.babylonjs.com/how_to/webvr_helper
  42202. */
  42203. class VRExperienceHelper {
  42204. /** Options to modify the vr experience helper's behavior. */
  42205. webVROptions: VRExperienceHelperOptions;
  42206. private _scene;
  42207. private _position;
  42208. private _btnVR;
  42209. private _btnVRDisplayed;
  42210. private _webVRsupported;
  42211. private _webVRready;
  42212. private _webVRrequesting;
  42213. private _webVRpresenting;
  42214. private _hasEnteredVR;
  42215. private _fullscreenVRpresenting;
  42216. private _canvas;
  42217. private _webVRCamera;
  42218. private _vrDeviceOrientationCamera;
  42219. private _deviceOrientationCamera;
  42220. private _existingCamera;
  42221. private _onKeyDown;
  42222. private _onVrDisplayPresentChange;
  42223. private _onVRDisplayChanged;
  42224. private _onVRRequestPresentStart;
  42225. private _onVRRequestPresentComplete;
  42226. /**
  42227. * Observable raised when entering VR.
  42228. */
  42229. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42230. /**
  42231. * Observable raised when exiting VR.
  42232. */
  42233. onExitingVRObservable: Observable<VRExperienceHelper>;
  42234. /**
  42235. * Observable raised when controller mesh is loaded.
  42236. */
  42237. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42238. /** Return this.onEnteringVRObservable
  42239. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42240. */
  42241. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42242. /** Return this.onExitingVRObservable
  42243. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42244. */
  42245. readonly onExitingVR: Observable<VRExperienceHelper>;
  42246. /** Return this.onControllerMeshLoadedObservable
  42247. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42248. */
  42249. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42250. private _rayLength;
  42251. private _useCustomVRButton;
  42252. private _teleportationRequested;
  42253. private _teleportActive;
  42254. private _floorMeshName;
  42255. private _floorMeshesCollection;
  42256. private _rotationAllowed;
  42257. private _teleportBackwardsVector;
  42258. private _teleportationTarget;
  42259. private _isDefaultTeleportationTarget;
  42260. private _postProcessMove;
  42261. private _teleportationFillColor;
  42262. private _teleportationBorderColor;
  42263. private _rotationAngle;
  42264. private _haloCenter;
  42265. private _cameraGazer;
  42266. private _padSensibilityUp;
  42267. private _padSensibilityDown;
  42268. private _leftController;
  42269. private _rightController;
  42270. /**
  42271. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42272. */
  42273. onNewMeshSelected: Observable<AbstractMesh>;
  42274. /**
  42275. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42276. */
  42277. onNewMeshPicked: Observable<PickingInfo>;
  42278. private _circleEase;
  42279. /**
  42280. * Observable raised before camera teleportation
  42281. */
  42282. onBeforeCameraTeleport: Observable<Vector3>;
  42283. /**
  42284. * Observable raised after camera teleportation
  42285. */
  42286. onAfterCameraTeleport: Observable<Vector3>;
  42287. /**
  42288. * Observable raised when current selected mesh gets unselected
  42289. */
  42290. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42291. private _raySelectionPredicate;
  42292. /**
  42293. * To be optionaly changed by user to define custom ray selection
  42294. */
  42295. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42296. /**
  42297. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42298. */
  42299. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42300. /**
  42301. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42302. */
  42303. teleportationEnabled: boolean;
  42304. private _defaultHeight;
  42305. private _teleportationInitialized;
  42306. private _interactionsEnabled;
  42307. private _interactionsRequested;
  42308. private _displayGaze;
  42309. private _displayLaserPointer;
  42310. /**
  42311. * The mesh used to display where the user is going to teleport.
  42312. */
  42313. /**
  42314. * Sets the mesh to be used to display where the user is going to teleport.
  42315. */
  42316. teleportationTarget: Mesh;
  42317. /**
  42318. * 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
  42319. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42320. * See http://doc.babylonjs.com/resources/baking_transformations
  42321. */
  42322. gazeTrackerMesh: Mesh;
  42323. /**
  42324. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42325. */
  42326. updateGazeTrackerScale: boolean;
  42327. /**
  42328. * The gaze tracking mesh corresponding to the left controller
  42329. */
  42330. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42331. /**
  42332. * The gaze tracking mesh corresponding to the right controller
  42333. */
  42334. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42335. /**
  42336. * If the ray of the gaze should be displayed.
  42337. */
  42338. /**
  42339. * Sets if the ray of the gaze should be displayed.
  42340. */
  42341. displayGaze: boolean;
  42342. /**
  42343. * If the ray of the LaserPointer should be displayed.
  42344. */
  42345. /**
  42346. * Sets if the ray of the LaserPointer should be displayed.
  42347. */
  42348. displayLaserPointer: boolean;
  42349. /**
  42350. * The deviceOrientationCamera used as the camera when not in VR.
  42351. */
  42352. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42353. /**
  42354. * Based on the current WebVR support, returns the current VR camera used.
  42355. */
  42356. readonly currentVRCamera: Nullable<Camera>;
  42357. /**
  42358. * The webVRCamera which is used when in VR.
  42359. */
  42360. readonly webVRCamera: WebVRFreeCamera;
  42361. /**
  42362. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42363. */
  42364. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42365. private readonly _teleportationRequestInitiated;
  42366. /**
  42367. * Instantiates a VRExperienceHelper.
  42368. * Helps to quickly add VR support to an existing scene.
  42369. * @param scene The scene the VRExperienceHelper belongs to.
  42370. * @param webVROptions Options to modify the vr experience helper's behavior.
  42371. */
  42372. constructor(scene: Scene,
  42373. /** Options to modify the vr experience helper's behavior. */
  42374. webVROptions?: VRExperienceHelperOptions);
  42375. private _onDefaultMeshLoaded;
  42376. private _onResize;
  42377. private _onFullscreenChange;
  42378. /**
  42379. * Gets a value indicating if we are currently in VR mode.
  42380. */
  42381. readonly isInVRMode: boolean;
  42382. private onVrDisplayPresentChange;
  42383. private onVRDisplayChanged;
  42384. private moveButtonToBottomRight;
  42385. private displayVRButton;
  42386. private updateButtonVisibility;
  42387. /**
  42388. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42389. * Otherwise, will use the fullscreen API.
  42390. */
  42391. enterVR(): void;
  42392. /**
  42393. * Attempt to exit VR, or fullscreen.
  42394. */
  42395. exitVR(): void;
  42396. /**
  42397. * The position of the vr experience helper.
  42398. */
  42399. /**
  42400. * Sets the position of the vr experience helper.
  42401. */
  42402. position: Vector3;
  42403. /**
  42404. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42405. */
  42406. enableInteractions(): void;
  42407. private readonly _noControllerIsActive;
  42408. private beforeRender;
  42409. private _isTeleportationFloor;
  42410. /**
  42411. * Adds a floor mesh to be used for teleportation.
  42412. * @param floorMesh the mesh to be used for teleportation.
  42413. */
  42414. addFloorMesh(floorMesh: Mesh): void;
  42415. /**
  42416. * Removes a floor mesh from being used for teleportation.
  42417. * @param floorMesh the mesh to be removed.
  42418. */
  42419. removeFloorMesh(floorMesh: Mesh): void;
  42420. /**
  42421. * Enables interactions and teleportation using the VR controllers and gaze.
  42422. * @param vrTeleportationOptions options to modify teleportation behavior.
  42423. */
  42424. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42425. private _onNewGamepadConnected;
  42426. private _tryEnableInteractionOnController;
  42427. private _onNewGamepadDisconnected;
  42428. private _enableInteractionOnController;
  42429. private _checkTeleportWithRay;
  42430. private _checkRotate;
  42431. private _checkTeleportBackwards;
  42432. private _enableTeleportationOnController;
  42433. private _createTeleportationCircles;
  42434. private _displayTeleportationTarget;
  42435. private _hideTeleportationTarget;
  42436. private _rotateCamera;
  42437. private _moveTeleportationSelectorTo;
  42438. private _workingVector;
  42439. private _workingQuaternion;
  42440. private _workingMatrix;
  42441. /**
  42442. * Teleports the users feet to the desired location
  42443. * @param location The location where the user's feet should be placed
  42444. */
  42445. teleportCamera(location: Vector3): void;
  42446. private _convertNormalToDirectionOfRay;
  42447. private _castRayAndSelectObject;
  42448. private _notifySelectedMeshUnselected;
  42449. /**
  42450. * Sets the color of the laser ray from the vr controllers.
  42451. * @param color new color for the ray.
  42452. */
  42453. changeLaserColor(color: Color3): void;
  42454. /**
  42455. * Sets the color of the ray from the vr headsets gaze.
  42456. * @param color new color for the ray.
  42457. */
  42458. changeGazeColor(color: Color3): void;
  42459. /**
  42460. * Exits VR and disposes of the vr experience helper
  42461. */
  42462. dispose(): void;
  42463. /**
  42464. * Gets the name of the VRExperienceHelper class
  42465. * @returns "VRExperienceHelper"
  42466. */
  42467. getClassName(): string;
  42468. }
  42469. }
  42470. declare module BABYLON {
  42471. /**
  42472. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42473. * IMPORTANT!! The data is right-hand data.
  42474. * @export
  42475. * @interface DevicePose
  42476. */
  42477. interface DevicePose {
  42478. /**
  42479. * The position of the device, values in array are [x,y,z].
  42480. */
  42481. readonly position: Nullable<Float32Array>;
  42482. /**
  42483. * The linearVelocity of the device, values in array are [x,y,z].
  42484. */
  42485. readonly linearVelocity: Nullable<Float32Array>;
  42486. /**
  42487. * The linearAcceleration of the device, values in array are [x,y,z].
  42488. */
  42489. readonly linearAcceleration: Nullable<Float32Array>;
  42490. /**
  42491. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42492. */
  42493. readonly orientation: Nullable<Float32Array>;
  42494. /**
  42495. * The angularVelocity of the device, values in array are [x,y,z].
  42496. */
  42497. readonly angularVelocity: Nullable<Float32Array>;
  42498. /**
  42499. * The angularAcceleration of the device, values in array are [x,y,z].
  42500. */
  42501. readonly angularAcceleration: Nullable<Float32Array>;
  42502. }
  42503. /**
  42504. * Interface representing a pose controlled object in Babylon.
  42505. * A pose controlled object has both regular pose values as well as pose values
  42506. * from an external device such as a VR head mounted display
  42507. */
  42508. interface PoseControlled {
  42509. /**
  42510. * The position of the object in babylon space.
  42511. */
  42512. position: Vector3;
  42513. /**
  42514. * The rotation quaternion of the object in babylon space.
  42515. */
  42516. rotationQuaternion: Quaternion;
  42517. /**
  42518. * The position of the device in babylon space.
  42519. */
  42520. devicePosition?: Vector3;
  42521. /**
  42522. * The rotation quaternion of the device in babylon space.
  42523. */
  42524. deviceRotationQuaternion: Quaternion;
  42525. /**
  42526. * The raw pose coming from the device.
  42527. */
  42528. rawPose: Nullable<DevicePose>;
  42529. /**
  42530. * The scale of the device to be used when translating from device space to babylon space.
  42531. */
  42532. deviceScaleFactor: number;
  42533. /**
  42534. * Updates the poseControlled values based on the input device pose.
  42535. * @param poseData the pose data to update the object with
  42536. */
  42537. updateFromDevice(poseData: DevicePose): void;
  42538. }
  42539. /**
  42540. * Set of options to customize the webVRCamera
  42541. */
  42542. interface WebVROptions {
  42543. /**
  42544. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42545. */
  42546. trackPosition?: boolean;
  42547. /**
  42548. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42549. */
  42550. positionScale?: number;
  42551. /**
  42552. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42553. */
  42554. displayName?: string;
  42555. /**
  42556. * Should the native controller meshes be initialized. (default: true)
  42557. */
  42558. controllerMeshes?: boolean;
  42559. /**
  42560. * Creating a default HemiLight only on controllers. (default: true)
  42561. */
  42562. defaultLightingOnControllers?: boolean;
  42563. /**
  42564. * If you don't want to use the default VR button of the helper. (default: false)
  42565. */
  42566. useCustomVRButton?: boolean;
  42567. /**
  42568. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42569. */
  42570. customVRButton?: HTMLButtonElement;
  42571. /**
  42572. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42573. */
  42574. rayLength?: number;
  42575. /**
  42576. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42577. */
  42578. defaultHeight?: number;
  42579. }
  42580. /**
  42581. * This represents a WebVR camera.
  42582. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42583. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42584. */
  42585. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42586. private webVROptions;
  42587. /**
  42588. * @hidden
  42589. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42590. */
  42591. _vrDevice: any;
  42592. /**
  42593. * The rawPose of the vrDevice.
  42594. */
  42595. rawPose: Nullable<DevicePose>;
  42596. private _onVREnabled;
  42597. private _specsVersion;
  42598. private _attached;
  42599. private _frameData;
  42600. protected _descendants: Array<Node>;
  42601. private _deviceRoomPosition;
  42602. /** @hidden */
  42603. _deviceRoomRotationQuaternion: Quaternion;
  42604. private _standingMatrix;
  42605. /**
  42606. * Represents device position in babylon space.
  42607. */
  42608. devicePosition: Vector3;
  42609. /**
  42610. * Represents device rotation in babylon space.
  42611. */
  42612. deviceRotationQuaternion: Quaternion;
  42613. /**
  42614. * The scale of the device to be used when translating from device space to babylon space.
  42615. */
  42616. deviceScaleFactor: number;
  42617. private _deviceToWorld;
  42618. private _worldToDevice;
  42619. /**
  42620. * References to the webVR controllers for the vrDevice.
  42621. */
  42622. controllers: Array<WebVRController>;
  42623. /**
  42624. * Emits an event when a controller is attached.
  42625. */
  42626. onControllersAttachedObservable: Observable<WebVRController[]>;
  42627. /**
  42628. * Emits an event when a controller's mesh has been loaded;
  42629. */
  42630. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42631. /**
  42632. * Emits an event when the HMD's pose has been updated.
  42633. */
  42634. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42635. private _poseSet;
  42636. /**
  42637. * If the rig cameras be used as parent instead of this camera.
  42638. */
  42639. rigParenting: boolean;
  42640. private _lightOnControllers;
  42641. private _defaultHeight?;
  42642. /**
  42643. * Instantiates a WebVRFreeCamera.
  42644. * @param name The name of the WebVRFreeCamera
  42645. * @param position The starting anchor position for the camera
  42646. * @param scene The scene the camera belongs to
  42647. * @param webVROptions a set of customizable options for the webVRCamera
  42648. */
  42649. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42650. /**
  42651. * Gets the device distance from the ground in meters.
  42652. * @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.
  42653. */
  42654. deviceDistanceToRoomGround(): number;
  42655. /**
  42656. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42657. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42658. */
  42659. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42660. /**
  42661. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42662. * @returns A promise with a boolean set to if the standing matrix is supported.
  42663. */
  42664. useStandingMatrixAsync(): Promise<boolean>;
  42665. /**
  42666. * Disposes the camera
  42667. */
  42668. dispose(): void;
  42669. /**
  42670. * Gets a vrController by name.
  42671. * @param name The name of the controller to retreive
  42672. * @returns the controller matching the name specified or null if not found
  42673. */
  42674. getControllerByName(name: string): Nullable<WebVRController>;
  42675. private _leftController;
  42676. /**
  42677. * The controller corrisponding to the users left hand.
  42678. */
  42679. readonly leftController: Nullable<WebVRController>;
  42680. private _rightController;
  42681. /**
  42682. * The controller corrisponding to the users right hand.
  42683. */
  42684. readonly rightController: Nullable<WebVRController>;
  42685. /**
  42686. * Casts a ray forward from the vrCamera's gaze.
  42687. * @param length Length of the ray (default: 100)
  42688. * @returns the ray corrisponding to the gaze
  42689. */
  42690. getForwardRay(length?: number): Ray;
  42691. /**
  42692. * @hidden
  42693. * Updates the camera based on device's frame data
  42694. */
  42695. _checkInputs(): void;
  42696. /**
  42697. * Updates the poseControlled values based on the input device pose.
  42698. * @param poseData Pose coming from the device
  42699. */
  42700. updateFromDevice(poseData: DevicePose): void;
  42701. private _htmlElementAttached;
  42702. private _detachIfAttached;
  42703. /**
  42704. * WebVR's attach control will start broadcasting frames to the device.
  42705. * Note that in certain browsers (chrome for example) this function must be called
  42706. * within a user-interaction callback. Example:
  42707. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42708. *
  42709. * @param element html element to attach the vrDevice to
  42710. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42711. */
  42712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42713. /**
  42714. * Detaches the camera from the html element and disables VR
  42715. *
  42716. * @param element html element to detach from
  42717. */
  42718. detachControl(element: HTMLElement): void;
  42719. /**
  42720. * @returns the name of this class
  42721. */
  42722. getClassName(): string;
  42723. /**
  42724. * Calls resetPose on the vrDisplay
  42725. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42726. */
  42727. resetToCurrentRotation(): void;
  42728. /**
  42729. * @hidden
  42730. * Updates the rig cameras (left and right eye)
  42731. */
  42732. _updateRigCameras(): void;
  42733. private _workingVector;
  42734. private _oneVector;
  42735. private _workingMatrix;
  42736. private updateCacheCalled;
  42737. private _correctPositionIfNotTrackPosition;
  42738. /**
  42739. * @hidden
  42740. * Updates the cached values of the camera
  42741. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42742. */
  42743. _updateCache(ignoreParentClass?: boolean): void;
  42744. /**
  42745. * @hidden
  42746. * Get current device position in babylon world
  42747. */
  42748. _computeDevicePosition(): void;
  42749. /**
  42750. * Updates the current device position and rotation in the babylon world
  42751. */
  42752. update(): void;
  42753. /**
  42754. * @hidden
  42755. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42756. * @returns an identity matrix
  42757. */
  42758. _getViewMatrix(): Matrix;
  42759. private _tmpMatrix;
  42760. /**
  42761. * This function is called by the two RIG cameras.
  42762. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42763. */
  42764. protected _getWebVRViewMatrix(): Matrix;
  42765. protected _getWebVRProjectionMatrix(): Matrix;
  42766. private _onGamepadConnectedObserver;
  42767. private _onGamepadDisconnectedObserver;
  42768. private _updateCacheWhenTrackingDisabledObserver;
  42769. /**
  42770. * Initializes the controllers and their meshes
  42771. */
  42772. initControllers(): void;
  42773. }
  42774. }
  42775. declare module BABYLON {
  42776. /**
  42777. * WebXR Camera which holds the views for the xrSession
  42778. * @see https://doc.babylonjs.com/how_to/webxr
  42779. */
  42780. class WebXRCamera extends FreeCamera {
  42781. private static _TmpMatrix;
  42782. /**
  42783. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42784. * @param name the name of the camera
  42785. * @param scene the scene to add the camera to
  42786. */
  42787. constructor(name: string, scene: BABYLON.Scene);
  42788. private _updateNumberOfRigCameras;
  42789. /** @hidden */
  42790. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42791. /**
  42792. * Updates the cameras position from the current pose information of the XR session
  42793. * @param xrSessionManager the session containing pose information
  42794. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42795. */
  42796. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42797. }
  42798. }
  42799. declare module BABYLON {
  42800. /**
  42801. * States of the webXR experience
  42802. */
  42803. enum WebXRState {
  42804. /**
  42805. * Transitioning to/from being in XR mode
  42806. */
  42807. TRANSITION = 0,
  42808. /**
  42809. * In XR mode and presenting
  42810. */
  42811. IN_XR = 1,
  42812. /**
  42813. * Not entered XR mode
  42814. */
  42815. NOT_IN_XR = 2
  42816. }
  42817. /**
  42818. * Helper class used to enable XR
  42819. * @see https://doc.babylonjs.com/how_to/webxr
  42820. */
  42821. class WebXRExperienceHelper implements IDisposable {
  42822. private scene;
  42823. /**
  42824. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42825. */
  42826. container: AbstractMesh;
  42827. /**
  42828. * Camera used to render xr content
  42829. */
  42830. camera: WebXRCamera;
  42831. /**
  42832. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42833. */
  42834. state: WebXRState;
  42835. /**
  42836. * Fires when the state of the experience helper has changed
  42837. */
  42838. onStateChangedObservable: Observable<WebXRState>;
  42839. private _sessionManager;
  42840. private _nonVRCamera;
  42841. private _originalSceneAutoClear;
  42842. private _outputCanvas;
  42843. private _outputCanvasContext;
  42844. /**
  42845. * Creates a WebXRExperienceHelper
  42846. * @param scene The scene the helper should be created in
  42847. */
  42848. constructor(scene: BABYLON.Scene);
  42849. /**
  42850. * Exits XR mode and returns the scene to its original state
  42851. * @returns promise that resolves after xr mode has exited
  42852. */
  42853. exitXR(): Promise<void>;
  42854. /**
  42855. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42856. * @param sessionCreationOptions options for the XR session
  42857. * @param frameOfReference frame of reference of the XR session
  42858. * @returns promise that resolves after xr mode has entered
  42859. */
  42860. enterXR(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42861. /**
  42862. * Disposes of the experience helper
  42863. */
  42864. dispose(): void;
  42865. private _createCanvas;
  42866. private _removeCanvas;
  42867. }
  42868. }
  42869. declare module BABYLON {
  42870. /**
  42871. * Manages an XRSession
  42872. * @see https://doc.babylonjs.com/how_to/webxr
  42873. */
  42874. class WebXRSessionManager implements IDisposable {
  42875. private scene;
  42876. /**
  42877. * Fires every time a new xrFrame arrives which can be used to update the camera
  42878. */
  42879. onXRFrameObservable: Observable<any>;
  42880. /**
  42881. * Fires when the xr session is ended either by the device or manually done
  42882. */
  42883. onXRSessionEnded: Observable<any>;
  42884. /** @hidden */
  42885. _xrSession: XRSession;
  42886. /** @hidden */
  42887. _frameOfReference: XRFrameOfReference;
  42888. /** @hidden */
  42889. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42890. /** @hidden */
  42891. _currentXRFrame: Nullable<XRFrame>;
  42892. private _xrNavigator;
  42893. private _xrDevice;
  42894. private _tmpMatrix;
  42895. /**
  42896. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42897. * @param scene The scene which the session should be created for
  42898. */
  42899. constructor(scene: BABYLON.Scene);
  42900. /**
  42901. * Initializes the manager, this must be done with a user action (eg. button click event)
  42902. * After initialization enterXR can be called to start an XR session
  42903. * @returns Promise which resolves after it is initialized
  42904. */
  42905. initialize(): Promise<void>;
  42906. /**
  42907. * Enters XR with the desired XR session options
  42908. * @param sessionCreationOptions xr options to create the session with
  42909. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42910. * @returns Promise which resolves after it enters XR
  42911. */
  42912. enterXR(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42913. /**
  42914. * Stops the xrSession and restores the renderloop
  42915. * @returns Promise which resolves after it exits XR
  42916. */
  42917. exitXR(): Promise<void>;
  42918. /**
  42919. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42920. * @param ray ray to cast into the environment
  42921. * @returns Promise which resolves with a collision point in the environment if it exists
  42922. */
  42923. environmentPointHitTest(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42924. /**
  42925. * @hidden
  42926. * Converts the render layer of xrSession to a render target
  42927. * @param session session to create render target for
  42928. * @param scene scene the new render target should be created for
  42929. */
  42930. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42931. /**
  42932. * Disposes of the session manager
  42933. */
  42934. dispose(): void;
  42935. }
  42936. }
  42937. declare module BABYLON {
  42938. /** @hidden */
  42939. class _OcclusionDataStorage {
  42940. /** @hidden */
  42941. occlusionInternalRetryCounter: number;
  42942. /** @hidden */
  42943. isOcclusionQueryInProgress: boolean;
  42944. /** @hidden */
  42945. isOccluded: boolean;
  42946. /** @hidden */
  42947. occlusionRetryCount: number;
  42948. /** @hidden */
  42949. occlusionType: number;
  42950. /** @hidden */
  42951. occlusionQueryAlgorithmType: number;
  42952. }
  42953. interface Engine {
  42954. /**
  42955. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42956. * @return the new query
  42957. */
  42958. createQuery(): WebGLQuery;
  42959. /**
  42960. * Delete and release a webGL query
  42961. * @param query defines the query to delete
  42962. * @return the current engine
  42963. */
  42964. deleteQuery(query: WebGLQuery): Engine;
  42965. /**
  42966. * Check if a given query has resolved and got its value
  42967. * @param query defines the query to check
  42968. * @returns true if the query got its value
  42969. */
  42970. isQueryResultAvailable(query: WebGLQuery): boolean;
  42971. /**
  42972. * Gets the value of a given query
  42973. * @param query defines the query to check
  42974. * @returns the value of the query
  42975. */
  42976. getQueryResult(query: WebGLQuery): number;
  42977. /**
  42978. * Initiates an occlusion query
  42979. * @param algorithmType defines the algorithm to use
  42980. * @param query defines the query to use
  42981. * @returns the current engine
  42982. * @see http://doc.babylonjs.com/features/occlusionquery
  42983. */
  42984. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42985. /**
  42986. * Ends an occlusion query
  42987. * @see http://doc.babylonjs.com/features/occlusionquery
  42988. * @param algorithmType defines the algorithm to use
  42989. * @returns the current engine
  42990. */
  42991. endOcclusionQuery(algorithmType: number): Engine;
  42992. /**
  42993. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42994. * Please note that only one query can be issued at a time
  42995. * @returns a time token used to track the time span
  42996. */
  42997. startTimeQuery(): Nullable<_TimeToken>;
  42998. /**
  42999. * Ends a time query
  43000. * @param token defines the token used to measure the time span
  43001. * @returns the time spent (in ns)
  43002. */
  43003. endTimeQuery(token: _TimeToken): int;
  43004. /** @hidden */
  43005. _currentNonTimestampToken: Nullable<_TimeToken>;
  43006. /** @hidden */
  43007. _createTimeQuery(): WebGLQuery;
  43008. /** @hidden */
  43009. _deleteTimeQuery(query: WebGLQuery): void;
  43010. /** @hidden */
  43011. _getGlAlgorithmType(algorithmType: number): number;
  43012. /** @hidden */
  43013. _getTimeQueryResult(query: WebGLQuery): any;
  43014. /** @hidden */
  43015. _getTimeQueryAvailability(query: WebGLQuery): any;
  43016. }
  43017. interface AbstractMesh {
  43018. /**
  43019. * Backing filed
  43020. * @hidden
  43021. */
  43022. __occlusionDataStorage: _OcclusionDataStorage;
  43023. /**
  43024. * Access property
  43025. * @hidden
  43026. */
  43027. _occlusionDataStorage: _OcclusionDataStorage;
  43028. /**
  43029. * 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.
  43030. * The default value is -1 which means don't break the query and wait till the result
  43031. * @see http://doc.babylonjs.com/features/occlusionquery
  43032. */
  43033. occlusionRetryCount: number;
  43034. /**
  43035. * 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:
  43036. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43037. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43038. * * 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.
  43039. * @see http://doc.babylonjs.com/features/occlusionquery
  43040. */
  43041. occlusionType: number;
  43042. /**
  43043. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43044. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43045. * * 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.
  43046. * @see http://doc.babylonjs.com/features/occlusionquery
  43047. */
  43048. occlusionQueryAlgorithmType: number;
  43049. /**
  43050. * 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
  43051. * @see http://doc.babylonjs.com/features/occlusionquery
  43052. */
  43053. isOccluded: boolean;
  43054. /**
  43055. * Flag to check the progress status of the query
  43056. * @see http://doc.babylonjs.com/features/occlusionquery
  43057. */
  43058. isOcclusionQueryInProgress: boolean;
  43059. }
  43060. }
  43061. declare module BABYLON {
  43062. interface Engine {
  43063. /**
  43064. * Creates a webGL transform feedback object
  43065. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43066. * @returns the webGL transform feedback object
  43067. */
  43068. createTransformFeedback(): WebGLTransformFeedback;
  43069. /**
  43070. * Delete a webGL transform feedback object
  43071. * @param value defines the webGL transform feedback object to delete
  43072. */
  43073. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43074. /**
  43075. * Bind a webGL transform feedback object to the webgl context
  43076. * @param value defines the webGL transform feedback object to bind
  43077. */
  43078. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43079. /**
  43080. * Begins a transform feedback operation
  43081. * @param usePoints defines if points or triangles must be used
  43082. */
  43083. beginTransformFeedback(usePoints: boolean): void;
  43084. /**
  43085. * Ends a transform feedback operation
  43086. */
  43087. endTransformFeedback(): void;
  43088. /**
  43089. * Specify the varyings to use with transform feedback
  43090. * @param program defines the associated webGL program
  43091. * @param value defines the list of strings representing the varying names
  43092. */
  43093. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43094. /**
  43095. * Bind a webGL buffer for a transform feedback operation
  43096. * @param value defines the webGL buffer to bind
  43097. */
  43098. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43099. }
  43100. }
  43101. declare module BABYLON {
  43102. /**
  43103. * Google Daydream controller
  43104. */
  43105. class DaydreamController extends WebVRController {
  43106. /**
  43107. * Base Url for the controller model.
  43108. */
  43109. static MODEL_BASE_URL: string;
  43110. /**
  43111. * File name for the controller model.
  43112. */
  43113. static MODEL_FILENAME: string;
  43114. /**
  43115. * Gamepad Id prefix used to identify Daydream Controller.
  43116. */
  43117. static readonly GAMEPAD_ID_PREFIX: string;
  43118. /**
  43119. * Creates a new DaydreamController from a gamepad
  43120. * @param vrGamepad the gamepad that the controller should be created from
  43121. */
  43122. constructor(vrGamepad: any);
  43123. /**
  43124. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43125. * @param scene scene in which to add meshes
  43126. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43127. */
  43128. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43129. /**
  43130. * Called once for each button that changed state since the last frame
  43131. * @param buttonIdx Which button index changed
  43132. * @param state New state of the button
  43133. * @param changes Which properties on the state changed since last frame
  43134. */
  43135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43136. }
  43137. }
  43138. declare module BABYLON {
  43139. /**
  43140. * Gear VR Controller
  43141. */
  43142. class GearVRController extends WebVRController {
  43143. /**
  43144. * Base Url for the controller model.
  43145. */
  43146. static MODEL_BASE_URL: string;
  43147. /**
  43148. * File name for the controller model.
  43149. */
  43150. static MODEL_FILENAME: string;
  43151. /**
  43152. * Gamepad Id prefix used to identify this controller.
  43153. */
  43154. static readonly GAMEPAD_ID_PREFIX: string;
  43155. private readonly _buttonIndexToObservableNameMap;
  43156. /**
  43157. * Creates a new GearVRController from a gamepad
  43158. * @param vrGamepad the gamepad that the controller should be created from
  43159. */
  43160. constructor(vrGamepad: any);
  43161. /**
  43162. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43163. * @param scene scene in which to add meshes
  43164. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43165. */
  43166. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43167. /**
  43168. * Called once for each button that changed state since the last frame
  43169. * @param buttonIdx Which button index changed
  43170. * @param state New state of the button
  43171. * @param changes Which properties on the state changed since last frame
  43172. */
  43173. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43174. }
  43175. }
  43176. declare module BABYLON {
  43177. /**
  43178. * Generic Controller
  43179. */
  43180. class GenericController extends WebVRController {
  43181. /**
  43182. * Base Url for the controller model.
  43183. */
  43184. static readonly MODEL_BASE_URL: string;
  43185. /**
  43186. * File name for the controller model.
  43187. */
  43188. static readonly MODEL_FILENAME: string;
  43189. /**
  43190. * Creates a new GenericController from a gamepad
  43191. * @param vrGamepad the gamepad that the controller should be created from
  43192. */
  43193. constructor(vrGamepad: any);
  43194. /**
  43195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43196. * @param scene scene in which to add meshes
  43197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43198. */
  43199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43200. /**
  43201. * Called once for each button that changed state since the last frame
  43202. * @param buttonIdx Which button index changed
  43203. * @param state New state of the button
  43204. * @param changes Which properties on the state changed since last frame
  43205. */
  43206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43207. }
  43208. }
  43209. declare module BABYLON {
  43210. /**
  43211. * Oculus Touch Controller
  43212. */
  43213. class OculusTouchController extends WebVRController {
  43214. /**
  43215. * Base Url for the controller model.
  43216. */
  43217. static MODEL_BASE_URL: string;
  43218. /**
  43219. * File name for the left controller model.
  43220. */
  43221. static MODEL_LEFT_FILENAME: string;
  43222. /**
  43223. * File name for the right controller model.
  43224. */
  43225. static MODEL_RIGHT_FILENAME: string;
  43226. /**
  43227. * Fired when the secondary trigger on this controller is modified
  43228. */
  43229. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43230. /**
  43231. * Fired when the thumb rest on this controller is modified
  43232. */
  43233. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43234. /**
  43235. * Creates a new OculusTouchController from a gamepad
  43236. * @param vrGamepad the gamepad that the controller should be created from
  43237. */
  43238. constructor(vrGamepad: any);
  43239. /**
  43240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43241. * @param scene scene in which to add meshes
  43242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43243. */
  43244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43245. /**
  43246. * Fired when the A button on this controller is modified
  43247. */
  43248. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43249. /**
  43250. * Fired when the B button on this controller is modified
  43251. */
  43252. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43253. /**
  43254. * Fired when the X button on this controller is modified
  43255. */
  43256. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43257. /**
  43258. * Fired when the Y button on this controller is modified
  43259. */
  43260. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43261. /**
  43262. * Called once for each button that changed state since the last frame
  43263. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43264. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43265. * 2) secondary trigger (same)
  43266. * 3) A (right) X (left), touch, pressed = value
  43267. * 4) B / Y
  43268. * 5) thumb rest
  43269. * @param buttonIdx Which button index changed
  43270. * @param state New state of the button
  43271. * @param changes Which properties on the state changed since last frame
  43272. */
  43273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43274. }
  43275. }
  43276. declare module BABYLON {
  43277. /**
  43278. * Defines the types of pose enabled controllers that are supported
  43279. */
  43280. enum PoseEnabledControllerType {
  43281. /**
  43282. * HTC Vive
  43283. */
  43284. VIVE = 0,
  43285. /**
  43286. * Oculus Rift
  43287. */
  43288. OCULUS = 1,
  43289. /**
  43290. * Windows mixed reality
  43291. */
  43292. WINDOWS = 2,
  43293. /**
  43294. * Samsung gear VR
  43295. */
  43296. GEAR_VR = 3,
  43297. /**
  43298. * Google Daydream
  43299. */
  43300. DAYDREAM = 4,
  43301. /**
  43302. * Generic
  43303. */
  43304. GENERIC = 5
  43305. }
  43306. /**
  43307. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43308. */
  43309. interface MutableGamepadButton {
  43310. /**
  43311. * Value of the button/trigger
  43312. */
  43313. value: number;
  43314. /**
  43315. * If the button/trigger is currently touched
  43316. */
  43317. touched: boolean;
  43318. /**
  43319. * If the button/trigger is currently pressed
  43320. */
  43321. pressed: boolean;
  43322. }
  43323. /**
  43324. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43325. * @hidden
  43326. */
  43327. interface ExtendedGamepadButton extends GamepadButton {
  43328. /**
  43329. * If the button/trigger is currently pressed
  43330. */
  43331. readonly pressed: boolean;
  43332. /**
  43333. * If the button/trigger is currently touched
  43334. */
  43335. readonly touched: boolean;
  43336. /**
  43337. * Value of the button/trigger
  43338. */
  43339. readonly value: number;
  43340. }
  43341. /**
  43342. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43343. */
  43344. class PoseEnabledControllerHelper {
  43345. /**
  43346. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43347. * @param vrGamepad the gamepad to initialized
  43348. * @returns a vr controller of the type the gamepad identified as
  43349. */
  43350. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43351. }
  43352. /**
  43353. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43354. */
  43355. class PoseEnabledController extends Gamepad implements PoseControlled {
  43356. private _deviceRoomPosition;
  43357. private _deviceRoomRotationQuaternion;
  43358. /**
  43359. * The device position in babylon space
  43360. */
  43361. devicePosition: Vector3;
  43362. /**
  43363. * The device rotation in babylon space
  43364. */
  43365. deviceRotationQuaternion: Quaternion;
  43366. /**
  43367. * The scale factor of the device in babylon space
  43368. */
  43369. deviceScaleFactor: number;
  43370. /**
  43371. * (Likely devicePosition should be used instead) The device position in its room space
  43372. */
  43373. position: Vector3;
  43374. /**
  43375. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43376. */
  43377. rotationQuaternion: Quaternion;
  43378. /**
  43379. * The type of controller (Eg. Windows mixed reality)
  43380. */
  43381. controllerType: PoseEnabledControllerType;
  43382. protected _calculatedPosition: Vector3;
  43383. private _calculatedRotation;
  43384. /**
  43385. * The raw pose from the device
  43386. */
  43387. rawPose: DevicePose;
  43388. private _trackPosition;
  43389. private _maxRotationDistFromHeadset;
  43390. private _draggedRoomRotation;
  43391. /**
  43392. * @hidden
  43393. */
  43394. _disableTrackPosition(fixedPosition: Vector3): void;
  43395. /**
  43396. * Internal, the mesh attached to the controller
  43397. * @hidden
  43398. */
  43399. _mesh: Nullable<AbstractMesh>;
  43400. private _poseControlledCamera;
  43401. private _leftHandSystemQuaternion;
  43402. /**
  43403. * Internal, matrix used to convert room space to babylon space
  43404. * @hidden
  43405. */
  43406. _deviceToWorld: Matrix;
  43407. /**
  43408. * Node to be used when casting a ray from the controller
  43409. * @hidden
  43410. */
  43411. _pointingPoseNode: Nullable<AbstractMesh>;
  43412. /**
  43413. * Name of the child mesh that can be used to cast a ray from the controller
  43414. */
  43415. static readonly POINTING_POSE: string;
  43416. /**
  43417. * Creates a new PoseEnabledController from a gamepad
  43418. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43419. */
  43420. constructor(browserGamepad: any);
  43421. private _workingMatrix;
  43422. /**
  43423. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43424. */
  43425. update(): void;
  43426. /**
  43427. * Updates only the pose device and mesh without doing any button event checking
  43428. */
  43429. protected _updatePoseAndMesh(): void;
  43430. /**
  43431. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43432. * @param poseData raw pose fromthe device
  43433. */
  43434. updateFromDevice(poseData: DevicePose): void;
  43435. /**
  43436. * @hidden
  43437. */
  43438. _meshAttachedObservable: Observable<AbstractMesh>;
  43439. /**
  43440. * Attaches a mesh to the controller
  43441. * @param mesh the mesh to be attached
  43442. */
  43443. attachToMesh(mesh: AbstractMesh): void;
  43444. /**
  43445. * Attaches the controllers mesh to a camera
  43446. * @param camera the camera the mesh should be attached to
  43447. */
  43448. attachToPoseControlledCamera(camera: TargetCamera): void;
  43449. /**
  43450. * Disposes of the controller
  43451. */
  43452. dispose(): void;
  43453. /**
  43454. * The mesh that is attached to the controller
  43455. */
  43456. readonly mesh: Nullable<AbstractMesh>;
  43457. /**
  43458. * Gets the ray of the controller in the direction the controller is pointing
  43459. * @param length the length the resulting ray should be
  43460. * @returns a ray in the direction the controller is pointing
  43461. */
  43462. getForwardRay(length?: number): Ray;
  43463. }
  43464. }
  43465. declare module BABYLON {
  43466. /**
  43467. * Vive Controller
  43468. */
  43469. class ViveController extends WebVRController {
  43470. /**
  43471. * Base Url for the controller model.
  43472. */
  43473. static MODEL_BASE_URL: string;
  43474. /**
  43475. * File name for the controller model.
  43476. */
  43477. static MODEL_FILENAME: string;
  43478. /**
  43479. * Creates a new ViveController from a gamepad
  43480. * @param vrGamepad the gamepad that the controller should be created from
  43481. */
  43482. constructor(vrGamepad: any);
  43483. /**
  43484. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43485. * @param scene scene in which to add meshes
  43486. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43487. */
  43488. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43489. /**
  43490. * Fired when the left button on this controller is modified
  43491. */
  43492. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43493. /**
  43494. * Fired when the right button on this controller is modified
  43495. */
  43496. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43497. /**
  43498. * Fired when the menu button on this controller is modified
  43499. */
  43500. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43501. /**
  43502. * Called once for each button that changed state since the last frame
  43503. * Vive mapping:
  43504. * 0: touchpad
  43505. * 1: trigger
  43506. * 2: left AND right buttons
  43507. * 3: menu button
  43508. * @param buttonIdx Which button index changed
  43509. * @param state New state of the button
  43510. * @param changes Which properties on the state changed since last frame
  43511. */
  43512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43513. }
  43514. }
  43515. declare module BABYLON {
  43516. /**
  43517. * Defines the WebVRController object that represents controllers tracked in 3D space
  43518. */
  43519. abstract class WebVRController extends PoseEnabledController {
  43520. /**
  43521. * Internal, the default controller model for the controller
  43522. */
  43523. protected _defaultModel: AbstractMesh;
  43524. /**
  43525. * Fired when the trigger state has changed
  43526. */
  43527. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43528. /**
  43529. * Fired when the main button state has changed
  43530. */
  43531. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the secondary button state has changed
  43534. */
  43535. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the pad state has changed
  43538. */
  43539. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when controllers stick values have changed
  43542. */
  43543. onPadValuesChangedObservable: Observable<StickValues>;
  43544. /**
  43545. * Array of button availible on the controller
  43546. */
  43547. protected _buttons: Array<MutableGamepadButton>;
  43548. private _onButtonStateChange;
  43549. /**
  43550. * Fired when a controller button's state has changed
  43551. * @param callback the callback containing the button that was modified
  43552. */
  43553. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43554. /**
  43555. * X and Y axis corrisponding to the controllers joystick
  43556. */
  43557. pad: StickValues;
  43558. /**
  43559. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43560. */
  43561. hand: string;
  43562. /**
  43563. * The default controller model for the controller
  43564. */
  43565. readonly defaultModel: AbstractMesh;
  43566. /**
  43567. * Creates a new WebVRController from a gamepad
  43568. * @param vrGamepad the gamepad that the WebVRController should be created from
  43569. */
  43570. constructor(vrGamepad: any);
  43571. /**
  43572. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43573. */
  43574. update(): void;
  43575. /**
  43576. * Function to be called when a button is modified
  43577. */
  43578. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43579. /**
  43580. * Loads a mesh and attaches it to the controller
  43581. * @param scene the scene the mesh should be added to
  43582. * @param meshLoaded callback for when the mesh has been loaded
  43583. */
  43584. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43585. private _setButtonValue;
  43586. private _changes;
  43587. private _checkChanges;
  43588. /**
  43589. * Disposes of th webVRCOntroller
  43590. */
  43591. dispose(): void;
  43592. }
  43593. }
  43594. declare module BABYLON {
  43595. /**
  43596. * Defines the WindowsMotionController object that the state of the windows motion controller
  43597. */
  43598. class WindowsMotionController extends WebVRController {
  43599. /**
  43600. * The base url used to load the left and right controller models
  43601. */
  43602. static MODEL_BASE_URL: string;
  43603. /**
  43604. * The name of the left controller model file
  43605. */
  43606. static MODEL_LEFT_FILENAME: string;
  43607. /**
  43608. * The name of the right controller model file
  43609. */
  43610. static MODEL_RIGHT_FILENAME: string;
  43611. /**
  43612. * The controller name prefix for this controller type
  43613. */
  43614. static readonly GAMEPAD_ID_PREFIX: string;
  43615. /**
  43616. * The controller id pattern for this controller type
  43617. */
  43618. private static readonly GAMEPAD_ID_PATTERN;
  43619. private _loadedMeshInfo;
  43620. private readonly _mapping;
  43621. /**
  43622. * Fired when the trackpad on this controller is clicked
  43623. */
  43624. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43625. /**
  43626. * Fired when the trackpad on this controller is modified
  43627. */
  43628. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43629. /**
  43630. * The current x and y values of this controller's trackpad
  43631. */
  43632. trackpad: StickValues;
  43633. /**
  43634. * Creates a new WindowsMotionController from a gamepad
  43635. * @param vrGamepad the gamepad that the controller should be created from
  43636. */
  43637. constructor(vrGamepad: any);
  43638. /**
  43639. * Fired when the trigger on this controller is modified
  43640. */
  43641. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43642. /**
  43643. * Fired when the menu button on this controller is modified
  43644. */
  43645. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43646. /**
  43647. * Fired when the grip button on this controller is modified
  43648. */
  43649. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43650. /**
  43651. * Fired when the thumbstick button on this controller is modified
  43652. */
  43653. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43654. /**
  43655. * Fired when the touchpad button on this controller is modified
  43656. */
  43657. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43658. /**
  43659. * Fired when the touchpad values on this controller are modified
  43660. */
  43661. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43662. private _updateTrackpad;
  43663. /**
  43664. * Called once per frame by the engine.
  43665. */
  43666. update(): void;
  43667. /**
  43668. * Called once for each button that changed state since the last frame
  43669. * @param buttonIdx Which button index changed
  43670. * @param state New state of the button
  43671. * @param changes Which properties on the state changed since last frame
  43672. */
  43673. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43674. /**
  43675. * Moves the buttons on the controller mesh based on their current state
  43676. * @param buttonName the name of the button to move
  43677. * @param buttonValue the value of the button which determines the buttons new position
  43678. */
  43679. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43680. /**
  43681. * Moves the axis on the controller mesh based on its current state
  43682. * @param axis the index of the axis
  43683. * @param axisValue the value of the axis which determines the meshes new position
  43684. * @hidden
  43685. */
  43686. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43687. /**
  43688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43689. * @param scene scene in which to add meshes
  43690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43691. */
  43692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43693. /**
  43694. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43695. * can be transformed by button presses and axes values, based on this._mapping.
  43696. *
  43697. * @param scene scene in which the meshes exist
  43698. * @param meshes list of meshes that make up the controller model to process
  43699. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43700. */
  43701. private processModel;
  43702. private createMeshInfo;
  43703. /**
  43704. * Gets the ray of the controller in the direction the controller is pointing
  43705. * @param length the length the resulting ray should be
  43706. * @returns a ray in the direction the controller is pointing
  43707. */
  43708. getForwardRay(length?: number): Ray;
  43709. /**
  43710. * Disposes of the controller
  43711. */
  43712. dispose(): void;
  43713. }
  43714. }
  43715. declare module BABYLON {
  43716. /**
  43717. * Interface to implement to create a shadow generator compatible with BJS.
  43718. */
  43719. interface IShadowGenerator {
  43720. /**
  43721. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43722. * @returns The render target texture if present otherwise, null
  43723. */
  43724. getShadowMap(): Nullable<RenderTargetTexture>;
  43725. /**
  43726. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43727. * @returns The render target texture if the shadow map is present otherwise, null
  43728. */
  43729. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43730. /**
  43731. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43732. * @param subMesh The submesh we want to render in the shadow map
  43733. * @param useInstances Defines wether will draw in the map using instances
  43734. * @returns true if ready otherwise, false
  43735. */
  43736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43737. /**
  43738. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43739. * @param defines Defines of the material we want to update
  43740. * @param lightIndex Index of the light in the enabled light list of the material
  43741. */
  43742. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43743. /**
  43744. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43745. * defined in the generator but impacting the effect).
  43746. * It implies the unifroms available on the materials are the standard BJS ones.
  43747. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43748. * @param effect The effect we are binfing the information for
  43749. */
  43750. bindShadowLight(lightIndex: string, effect: Effect): void;
  43751. /**
  43752. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43753. * (eq to shadow prjection matrix * light transform matrix)
  43754. * @returns The transform matrix used to create the shadow map
  43755. */
  43756. getTransformMatrix(): Matrix;
  43757. /**
  43758. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43759. * Cube and 2D textures for instance.
  43760. */
  43761. recreateShadowMap(): void;
  43762. /**
  43763. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43764. * @param onCompiled Callback triggered at the and of the effects compilation
  43765. * @param options Sets of optional options forcing the compilation with different modes
  43766. */
  43767. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43768. useInstances: boolean;
  43769. }>): void;
  43770. /**
  43771. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43772. * @param options Sets of optional options forcing the compilation with different modes
  43773. * @returns A promise that resolves when the compilation completes
  43774. */
  43775. forceCompilationAsync(options?: Partial<{
  43776. useInstances: boolean;
  43777. }>): Promise<void>;
  43778. /**
  43779. * Serializes the shadow generator setup to a json object.
  43780. * @returns The serialized JSON object
  43781. */
  43782. serialize(): any;
  43783. /**
  43784. * Disposes the Shadow map and related Textures and effects.
  43785. */
  43786. dispose(): void;
  43787. }
  43788. /**
  43789. * Default implementation IShadowGenerator.
  43790. * This is the main object responsible of generating shadows in the framework.
  43791. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43792. */
  43793. class ShadowGenerator implements IShadowGenerator {
  43794. /**
  43795. * Shadow generator mode None: no filtering applied.
  43796. */
  43797. static readonly FILTER_NONE: number;
  43798. /**
  43799. * Shadow generator mode ESM: Exponential Shadow Mapping.
  43800. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43801. */
  43802. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  43803. /**
  43804. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  43805. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  43806. */
  43807. static readonly FILTER_POISSONSAMPLING: number;
  43808. /**
  43809. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  43810. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43811. */
  43812. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  43813. /**
  43814. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  43815. * edge artifacts on steep falloff.
  43816. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43817. */
  43818. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  43819. /**
  43820. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  43821. * edge artifacts on steep falloff.
  43822. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43823. */
  43824. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  43825. /**
  43826. * Shadow generator mode PCF: Percentage Closer Filtering
  43827. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43828. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  43829. */
  43830. static readonly FILTER_PCF: number;
  43831. /**
  43832. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  43833. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43834. * Contact Hardening
  43835. */
  43836. static readonly FILTER_PCSS: number;
  43837. /**
  43838. * Reserved for PCF and PCSS
  43839. * Highest Quality.
  43840. *
  43841. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  43842. *
  43843. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  43844. */
  43845. static readonly QUALITY_HIGH: number;
  43846. /**
  43847. * Reserved for PCF and PCSS
  43848. * Good tradeoff for quality/perf cross devices
  43849. *
  43850. * Execute PCF on a 3*3 kernel.
  43851. *
  43852. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  43853. */
  43854. static readonly QUALITY_MEDIUM: number;
  43855. /**
  43856. * Reserved for PCF and PCSS
  43857. * The lowest quality but the fastest.
  43858. *
  43859. * Execute PCF on a 1*1 kernel.
  43860. *
  43861. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  43862. */
  43863. static readonly QUALITY_LOW: number;
  43864. private _bias;
  43865. /**
  43866. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43867. */
  43868. /**
  43869. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43870. */
  43871. bias: number;
  43872. private _normalBias;
  43873. /**
  43874. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43875. */
  43876. /**
  43877. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43878. */
  43879. normalBias: number;
  43880. private _blurBoxOffset;
  43881. /**
  43882. * Gets the blur box offset: offset applied during the blur pass.
  43883. * Only usefull if useKernelBlur = false
  43884. */
  43885. /**
  43886. * Sets the blur box offset: offset applied during the blur pass.
  43887. * Only usefull if useKernelBlur = false
  43888. */
  43889. blurBoxOffset: number;
  43890. private _blurScale;
  43891. /**
  43892. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43893. * 2 means half of the size.
  43894. */
  43895. /**
  43896. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43897. * 2 means half of the size.
  43898. */
  43899. blurScale: number;
  43900. private _blurKernel;
  43901. /**
  43902. * Gets the blur kernel: kernel size of the blur pass.
  43903. * Only usefull if useKernelBlur = true
  43904. */
  43905. /**
  43906. * Sets the blur kernel: kernel size of the blur pass.
  43907. * Only usefull if useKernelBlur = true
  43908. */
  43909. blurKernel: number;
  43910. private _useKernelBlur;
  43911. /**
  43912. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43913. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43914. */
  43915. /**
  43916. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43917. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43918. */
  43919. useKernelBlur: boolean;
  43920. private _depthScale;
  43921. /**
  43922. * Gets the depth scale used in ESM mode.
  43923. */
  43924. /**
  43925. * Sets the depth scale used in ESM mode.
  43926. * This can override the scale stored on the light.
  43927. */
  43928. depthScale: number;
  43929. private _filter;
  43930. /**
  43931. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43932. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43933. */
  43934. /**
  43935. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43936. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43937. */
  43938. filter: number;
  43939. /**
  43940. * Gets if the current filter is set to Poisson Sampling.
  43941. */
  43942. /**
  43943. * Sets the current filter to Poisson Sampling.
  43944. */
  43945. usePoissonSampling: boolean;
  43946. /**
  43947. * Gets if the current filter is set to VSM.
  43948. * DEPRECATED. Should use useExponentialShadowMap instead.
  43949. */
  43950. /**
  43951. * Sets the current filter is to VSM.
  43952. * DEPRECATED. Should use useExponentialShadowMap instead.
  43953. */
  43954. useVarianceShadowMap: boolean;
  43955. /**
  43956. * Gets if the current filter is set to blurred VSM.
  43957. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43958. */
  43959. /**
  43960. * Sets the current filter is to blurred VSM.
  43961. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43962. */
  43963. useBlurVarianceShadowMap: boolean;
  43964. /**
  43965. * Gets if the current filter is set to ESM.
  43966. */
  43967. /**
  43968. * Sets the current filter is to ESM.
  43969. */
  43970. useExponentialShadowMap: boolean;
  43971. /**
  43972. * Gets if the current filter is set to filtered ESM.
  43973. */
  43974. /**
  43975. * Gets if the current filter is set to filtered ESM.
  43976. */
  43977. useBlurExponentialShadowMap: boolean;
  43978. /**
  43979. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43980. * exponential to prevent steep falloff artifacts).
  43981. */
  43982. /**
  43983. * Sets the current filter to "close ESM" (using the inverse of the
  43984. * exponential to prevent steep falloff artifacts).
  43985. */
  43986. useCloseExponentialShadowMap: boolean;
  43987. /**
  43988. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43989. * exponential to prevent steep falloff artifacts).
  43990. */
  43991. /**
  43992. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43993. * exponential to prevent steep falloff artifacts).
  43994. */
  43995. useBlurCloseExponentialShadowMap: boolean;
  43996. /**
  43997. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43998. */
  43999. /**
  44000. * Sets the current filter to "PCF" (percentage closer filtering).
  44001. */
  44002. usePercentageCloserFiltering: boolean;
  44003. private _filteringQuality;
  44004. /**
  44005. * Gets the PCF or PCSS Quality.
  44006. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44007. */
  44008. /**
  44009. * Sets the PCF or PCSS Quality.
  44010. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44011. */
  44012. filteringQuality: number;
  44013. /**
  44014. * Gets if the current filter is set to "PCSS" (contact hardening).
  44015. */
  44016. /**
  44017. * Sets the current filter to "PCSS" (contact hardening).
  44018. */
  44019. useContactHardeningShadow: boolean;
  44020. private _contactHardeningLightSizeUVRatio;
  44021. /**
  44022. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44023. * Using a ratio helps keeping shape stability independently of the map size.
  44024. *
  44025. * It does not account for the light projection as it was having too much
  44026. * instability during the light setup or during light position changes.
  44027. *
  44028. * Only valid if useContactHardeningShadow is true.
  44029. */
  44030. /**
  44031. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44032. * Using a ratio helps keeping shape stability independently of the map size.
  44033. *
  44034. * It does not account for the light projection as it was having too much
  44035. * instability during the light setup or during light position changes.
  44036. *
  44037. * Only valid if useContactHardeningShadow is true.
  44038. */
  44039. contactHardeningLightSizeUVRatio: number;
  44040. private _darkness;
  44041. /**
  44042. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44043. * 0 means strongest and 1 would means no shadow.
  44044. * @returns the darkness.
  44045. */
  44046. getDarkness(): number;
  44047. /**
  44048. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44049. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44050. * @returns the shadow generator allowing fluent coding.
  44051. */
  44052. setDarkness(darkness: number): ShadowGenerator;
  44053. private _transparencyShadow;
  44054. /**
  44055. * Sets the ability to have transparent shadow (boolean).
  44056. * @param transparent True if transparent else False
  44057. * @returns the shadow generator allowing fluent coding
  44058. */
  44059. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44060. private _shadowMap;
  44061. private _shadowMap2;
  44062. /**
  44063. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44064. * @returns The render target texture if present otherwise, null
  44065. */
  44066. getShadowMap(): Nullable<RenderTargetTexture>;
  44067. /**
  44068. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44069. * @returns The render target texture if the shadow map is present otherwise, null
  44070. */
  44071. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44072. /**
  44073. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44074. * @param mesh Mesh to add
  44075. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44076. * @returns the Shadow Generator itself
  44077. */
  44078. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44079. /**
  44080. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44081. * @param mesh Mesh to remove
  44082. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44083. * @returns the Shadow Generator itself
  44084. */
  44085. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44086. /**
  44087. * Controls the extent to which the shadows fade out at the edge of the frustum
  44088. * Used only by directionals and spots
  44089. */
  44090. frustumEdgeFalloff: number;
  44091. private _light;
  44092. /**
  44093. * Returns the associated light object.
  44094. * @returns the light generating the shadow
  44095. */
  44096. getLight(): IShadowLight;
  44097. /**
  44098. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44099. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44100. * It might on the other hand introduce peter panning.
  44101. */
  44102. forceBackFacesOnly: boolean;
  44103. private _scene;
  44104. private _lightDirection;
  44105. private _effect;
  44106. private _viewMatrix;
  44107. private _projectionMatrix;
  44108. private _transformMatrix;
  44109. private _cachedPosition;
  44110. private _cachedDirection;
  44111. private _cachedDefines;
  44112. private _currentRenderID;
  44113. private _boxBlurPostprocess;
  44114. private _kernelBlurXPostprocess;
  44115. private _kernelBlurYPostprocess;
  44116. private _blurPostProcesses;
  44117. private _mapSize;
  44118. private _currentFaceIndex;
  44119. private _currentFaceIndexCache;
  44120. private _textureType;
  44121. private _defaultTextureMatrix;
  44122. /**
  44123. * Creates a ShadowGenerator object.
  44124. * A ShadowGenerator is the required tool to use the shadows.
  44125. * Each light casting shadows needs to use its own ShadowGenerator.
  44126. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  44127. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44128. * @param light The light object generating the shadows.
  44129. * @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.
  44130. */
  44131. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44132. private _initializeGenerator;
  44133. private _initializeShadowMap;
  44134. private _initializeBlurRTTAndPostProcesses;
  44135. private _renderForShadowMap;
  44136. private _renderSubMeshForShadowMap;
  44137. private _applyFilterValues;
  44138. /**
  44139. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44140. * @param onCompiled Callback triggered at the and of the effects compilation
  44141. * @param options Sets of optional options forcing the compilation with different modes
  44142. */
  44143. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44144. useInstances: boolean;
  44145. }>): void;
  44146. /**
  44147. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44148. * @param options Sets of optional options forcing the compilation with different modes
  44149. * @returns A promise that resolves when the compilation completes
  44150. */
  44151. forceCompilationAsync(options?: Partial<{
  44152. useInstances: boolean;
  44153. }>): Promise<void>;
  44154. /**
  44155. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44156. * @param subMesh The submesh we want to render in the shadow map
  44157. * @param useInstances Defines wether will draw in the map using instances
  44158. * @returns true if ready otherwise, false
  44159. */
  44160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44161. /**
  44162. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44163. * @param defines Defines of the material we want to update
  44164. * @param lightIndex Index of the light in the enabled light list of the material
  44165. */
  44166. prepareDefines(defines: any, lightIndex: number): void;
  44167. /**
  44168. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44169. * defined in the generator but impacting the effect).
  44170. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44171. * @param effect The effect we are binfing the information for
  44172. */
  44173. bindShadowLight(lightIndex: string, effect: Effect): void;
  44174. /**
  44175. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44176. * (eq to shadow prjection matrix * light transform matrix)
  44177. * @returns The transform matrix used to create the shadow map
  44178. */
  44179. getTransformMatrix(): Matrix;
  44180. /**
  44181. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44182. * Cube and 2D textures for instance.
  44183. */
  44184. recreateShadowMap(): void;
  44185. private _disposeBlurPostProcesses;
  44186. private _disposeRTTandPostProcesses;
  44187. /**
  44188. * Disposes the ShadowGenerator.
  44189. * Returns nothing.
  44190. */
  44191. dispose(): void;
  44192. /**
  44193. * Serializes the shadow generator setup to a json object.
  44194. * @returns The serialized JSON object
  44195. */
  44196. serialize(): any;
  44197. /**
  44198. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44199. * @param parsedShadowGenerator The JSON object to parse
  44200. * @param scene The scene to create the shadow map for
  44201. * @returns The parsed shadow generator
  44202. */
  44203. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44204. }
  44205. }
  44206. declare module BABYLON {
  44207. /**
  44208. * Defines the shadow generator component responsible to manage any shadow generators
  44209. * in a given scene.
  44210. */
  44211. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44212. /**
  44213. * The component name helpfull to identify the component in the list of scene components.
  44214. */
  44215. readonly name: string;
  44216. /**
  44217. * The scene the component belongs to.
  44218. */
  44219. scene: Scene;
  44220. /**
  44221. * Creates a new instance of the component for the given scene
  44222. * @param scene Defines the scene to register the component in
  44223. */
  44224. constructor(scene: Scene);
  44225. /**
  44226. * Registers the component in a given scene
  44227. */
  44228. register(): void;
  44229. /**
  44230. * Rebuilds the elements related to this component in case of
  44231. * context lost for instance.
  44232. */
  44233. rebuild(): void;
  44234. /**
  44235. * Serializes the component data to the specified json object
  44236. * @param serializationObject The object to serialize to
  44237. */
  44238. serialize(serializationObject: any): void;
  44239. /**
  44240. * Adds all the element from the container to the scene
  44241. * @param container the container holding the elements
  44242. */
  44243. addFromContainer(container: AbstractScene): void;
  44244. /**
  44245. * Removes all the elements in the container from the scene
  44246. * @param container contains the elements to remove
  44247. */
  44248. removeFromContainer(container: AbstractScene): void;
  44249. /**
  44250. * Rebuilds the elements related to this component in case of
  44251. * context lost for instance.
  44252. */
  44253. dispose(): void;
  44254. private _gatherRenderTargets;
  44255. }
  44256. }
  44257. declare module BABYLON {
  44258. }
  44259. declare module BABYLON {
  44260. /**
  44261. * Background material used to create an efficient environement around your scene.
  44262. */
  44263. class BackgroundMaterial extends PushMaterial {
  44264. /**
  44265. * Standard reflectance value at parallel view angle.
  44266. */
  44267. static StandardReflectance0: number;
  44268. /**
  44269. * Standard reflectance value at grazing angle.
  44270. */
  44271. static StandardReflectance90: number;
  44272. protected _primaryColor: Color3;
  44273. /**
  44274. * Key light Color (multiply against the environement texture)
  44275. */
  44276. primaryColor: Color3;
  44277. protected __perceptualColor: Nullable<Color3>;
  44278. /**
  44279. * Experimental Internal Use Only.
  44280. *
  44281. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44282. * This acts as a helper to set the primary color to a more "human friendly" value.
  44283. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44284. * output color as close as possible from the chosen value.
  44285. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44286. * part of lighting setup.)
  44287. */
  44288. _perceptualColor: Nullable<Color3>;
  44289. protected _primaryColorShadowLevel: float;
  44290. /**
  44291. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44292. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44293. */
  44294. primaryColorShadowLevel: float;
  44295. protected _primaryColorHighlightLevel: float;
  44296. /**
  44297. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44298. * The primary color is used at the level chosen to define what the white area would look.
  44299. */
  44300. primaryColorHighlightLevel: float;
  44301. protected _reflectionTexture: Nullable<BaseTexture>;
  44302. /**
  44303. * Reflection Texture used in the material.
  44304. * Should be author in a specific way for the best result (refer to the documentation).
  44305. */
  44306. reflectionTexture: Nullable<BaseTexture>;
  44307. protected _reflectionBlur: float;
  44308. /**
  44309. * Reflection Texture level of blur.
  44310. *
  44311. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44312. * texture twice.
  44313. */
  44314. reflectionBlur: float;
  44315. protected _diffuseTexture: Nullable<BaseTexture>;
  44316. /**
  44317. * Diffuse Texture used in the material.
  44318. * Should be author in a specific way for the best result (refer to the documentation).
  44319. */
  44320. diffuseTexture: Nullable<BaseTexture>;
  44321. protected _shadowLights: Nullable<IShadowLight[]>;
  44322. /**
  44323. * Specify the list of lights casting shadow on the material.
  44324. * All scene shadow lights will be included if null.
  44325. */
  44326. shadowLights: Nullable<IShadowLight[]>;
  44327. protected _shadowLevel: float;
  44328. /**
  44329. * Helps adjusting the shadow to a softer level if required.
  44330. * 0 means black shadows and 1 means no shadows.
  44331. */
  44332. shadowLevel: float;
  44333. protected _sceneCenter: Vector3;
  44334. /**
  44335. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44336. * It is usually zero but might be interesting to modify according to your setup.
  44337. */
  44338. sceneCenter: Vector3;
  44339. protected _opacityFresnel: boolean;
  44340. /**
  44341. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44342. * This helps ensuring a nice transition when the camera goes under the ground.
  44343. */
  44344. opacityFresnel: boolean;
  44345. protected _reflectionFresnel: boolean;
  44346. /**
  44347. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44348. * This helps adding a mirror texture on the ground.
  44349. */
  44350. reflectionFresnel: boolean;
  44351. protected _reflectionFalloffDistance: number;
  44352. /**
  44353. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44354. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44355. */
  44356. reflectionFalloffDistance: number;
  44357. protected _reflectionAmount: number;
  44358. /**
  44359. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44360. */
  44361. reflectionAmount: number;
  44362. protected _reflectionReflectance0: number;
  44363. /**
  44364. * This specifies the weight of the reflection at grazing angle.
  44365. */
  44366. reflectionReflectance0: number;
  44367. protected _reflectionReflectance90: number;
  44368. /**
  44369. * This specifies the weight of the reflection at a perpendicular point of view.
  44370. */
  44371. reflectionReflectance90: number;
  44372. /**
  44373. * Sets the reflection reflectance fresnel values according to the default standard
  44374. * empirically know to work well :-)
  44375. */
  44376. reflectionStandardFresnelWeight: number;
  44377. protected _useRGBColor: boolean;
  44378. /**
  44379. * Helps to directly use the maps channels instead of their level.
  44380. */
  44381. useRGBColor: boolean;
  44382. protected _enableNoise: boolean;
  44383. /**
  44384. * This helps reducing the banding effect that could occur on the background.
  44385. */
  44386. enableNoise: boolean;
  44387. /**
  44388. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44389. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44390. * Recommended to be keep at 1.0 except for special cases.
  44391. */
  44392. fovMultiplier: number;
  44393. private _fovMultiplier;
  44394. /**
  44395. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44396. */
  44397. useEquirectangularFOV: boolean;
  44398. private _maxSimultaneousLights;
  44399. /**
  44400. * Number of Simultaneous lights allowed on the material.
  44401. */
  44402. maxSimultaneousLights: int;
  44403. /**
  44404. * Default configuration related to image processing available in the Background Material.
  44405. */
  44406. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44407. /**
  44408. * Keep track of the image processing observer to allow dispose and replace.
  44409. */
  44410. private _imageProcessingObserver;
  44411. /**
  44412. * Attaches a new image processing configuration to the PBR Material.
  44413. * @param configuration (if null the scene configuration will be use)
  44414. */
  44415. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44416. /**
  44417. * Gets the image processing configuration used either in this material.
  44418. */
  44419. /**
  44420. * Sets the Default image processing configuration used either in the this material.
  44421. *
  44422. * If sets to null, the scene one is in use.
  44423. */
  44424. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44425. /**
  44426. * Gets wether the color curves effect is enabled.
  44427. */
  44428. /**
  44429. * Sets wether the color curves effect is enabled.
  44430. */
  44431. cameraColorCurvesEnabled: boolean;
  44432. /**
  44433. * Gets wether the color grading effect is enabled.
  44434. */
  44435. /**
  44436. * Gets wether the color grading effect is enabled.
  44437. */
  44438. cameraColorGradingEnabled: boolean;
  44439. /**
  44440. * Gets wether tonemapping is enabled or not.
  44441. */
  44442. /**
  44443. * Sets wether tonemapping is enabled or not
  44444. */
  44445. cameraToneMappingEnabled: boolean;
  44446. /**
  44447. * The camera exposure used on this material.
  44448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44449. * This corresponds to a photographic exposure.
  44450. */
  44451. /**
  44452. * The camera exposure used on this material.
  44453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44454. * This corresponds to a photographic exposure.
  44455. */
  44456. cameraExposure: float;
  44457. /**
  44458. * Gets The camera contrast used on this material.
  44459. */
  44460. /**
  44461. * Sets The camera contrast used on this material.
  44462. */
  44463. cameraContrast: float;
  44464. /**
  44465. * Gets the Color Grading 2D Lookup Texture.
  44466. */
  44467. /**
  44468. * Sets the Color Grading 2D Lookup Texture.
  44469. */
  44470. cameraColorGradingTexture: Nullable<BaseTexture>;
  44471. /**
  44472. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44473. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44474. * 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;
  44475. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44476. */
  44477. /**
  44478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44480. * 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;
  44481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44482. */
  44483. cameraColorCurves: Nullable<ColorCurves>;
  44484. /**
  44485. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44486. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44487. */
  44488. switchToBGR: boolean;
  44489. private _renderTargets;
  44490. private _reflectionControls;
  44491. private _white;
  44492. private _primaryShadowColor;
  44493. private _primaryHighlightColor;
  44494. /**
  44495. * Instantiates a Background Material in the given scene
  44496. * @param name The friendly name of the material
  44497. * @param scene The scene to add the material to
  44498. */
  44499. constructor(name: string, scene: Scene);
  44500. /**
  44501. * Gets a boolean indicating that current material needs to register RTT
  44502. */
  44503. readonly hasRenderTargetTextures: boolean;
  44504. /**
  44505. * The entire material has been created in order to prevent overdraw.
  44506. * @returns false
  44507. */
  44508. needAlphaTesting(): boolean;
  44509. /**
  44510. * The entire material has been created in order to prevent overdraw.
  44511. * @returns true if blending is enable
  44512. */
  44513. needAlphaBlending(): boolean;
  44514. /**
  44515. * Checks wether the material is ready to be rendered for a given mesh.
  44516. * @param mesh The mesh to render
  44517. * @param subMesh The submesh to check against
  44518. * @param useInstances Specify wether or not the material is used with instances
  44519. * @returns true if all the dependencies are ready (Textures, Effects...)
  44520. */
  44521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44522. /**
  44523. * Compute the primary color according to the chosen perceptual color.
  44524. */
  44525. private _computePrimaryColorFromPerceptualColor;
  44526. /**
  44527. * Compute the highlights and shadow colors according to their chosen levels.
  44528. */
  44529. private _computePrimaryColors;
  44530. /**
  44531. * Build the uniform buffer used in the material.
  44532. */
  44533. buildUniformLayout(): void;
  44534. /**
  44535. * Unbind the material.
  44536. */
  44537. unbind(): void;
  44538. /**
  44539. * Bind only the world matrix to the material.
  44540. * @param world The world matrix to bind.
  44541. */
  44542. bindOnlyWorldMatrix(world: Matrix): void;
  44543. /**
  44544. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44545. * @param world The world matrix to bind.
  44546. * @param subMesh The submesh to bind for.
  44547. */
  44548. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44549. /**
  44550. * Dispose the material.
  44551. * @param forceDisposeEffect Force disposal of the associated effect.
  44552. * @param forceDisposeTextures Force disposal of the associated textures.
  44553. */
  44554. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44555. /**
  44556. * Clones the material.
  44557. * @param name The cloned name.
  44558. * @returns The cloned material.
  44559. */
  44560. clone(name: string): BackgroundMaterial;
  44561. /**
  44562. * Serializes the current material to its JSON representation.
  44563. * @returns The JSON representation.
  44564. */
  44565. serialize(): any;
  44566. /**
  44567. * Gets the class name of the material
  44568. * @returns "BackgroundMaterial"
  44569. */
  44570. getClassName(): string;
  44571. /**
  44572. * Parse a JSON input to create back a background material.
  44573. * @param source The JSON data to parse
  44574. * @param scene The scene to create the parsed material in
  44575. * @param rootUrl The root url of the assets the material depends upon
  44576. * @returns the instantiated BackgroundMaterial.
  44577. */
  44578. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44579. }
  44580. }
  44581. declare module BABYLON {
  44582. /**
  44583. * The Physically based material base class of BJS.
  44584. *
  44585. * This offers the main features of a standard PBR material.
  44586. * For more information, please refer to the documentation :
  44587. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44588. */
  44589. abstract class PBRBaseMaterial extends PushMaterial {
  44590. /**
  44591. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44592. */
  44593. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44594. /**
  44595. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44596. * to enhance interoperability with other engines.
  44597. */
  44598. static readonly LIGHTFALLOFF_GLTF: number;
  44599. /**
  44600. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44601. * to enhance interoperability with other materials.
  44602. */
  44603. static readonly LIGHTFALLOFF_STANDARD: number;
  44604. /**
  44605. * Intensity of the direct lights e.g. the four lights available in your scene.
  44606. * This impacts both the direct diffuse and specular highlights.
  44607. */
  44608. protected _directIntensity: number;
  44609. /**
  44610. * Intensity of the emissive part of the material.
  44611. * This helps controlling the emissive effect without modifying the emissive color.
  44612. */
  44613. protected _emissiveIntensity: number;
  44614. /**
  44615. * Intensity of the environment e.g. how much the environment will light the object
  44616. * either through harmonics for rough material or through the refelction for shiny ones.
  44617. */
  44618. protected _environmentIntensity: number;
  44619. /**
  44620. * This is a special control allowing the reduction of the specular highlights coming from the
  44621. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44622. */
  44623. protected _specularIntensity: number;
  44624. /**
  44625. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44626. */
  44627. private _lightingInfos;
  44628. /**
  44629. * Debug Control allowing disabling the bump map on this material.
  44630. */
  44631. protected _disableBumpMap: boolean;
  44632. /**
  44633. * AKA Diffuse Texture in standard nomenclature.
  44634. */
  44635. protected _albedoTexture: BaseTexture;
  44636. /**
  44637. * AKA Occlusion Texture in other nomenclature.
  44638. */
  44639. protected _ambientTexture: BaseTexture;
  44640. /**
  44641. * AKA Occlusion Texture Intensity in other nomenclature.
  44642. */
  44643. protected _ambientTextureStrength: number;
  44644. /**
  44645. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44646. * 1 means it completely occludes it
  44647. * 0 mean it has no impact
  44648. */
  44649. protected _ambientTextureImpactOnAnalyticalLights: number;
  44650. /**
  44651. * Stores the alpha values in a texture.
  44652. */
  44653. protected _opacityTexture: BaseTexture;
  44654. /**
  44655. * Stores the reflection values in a texture.
  44656. */
  44657. protected _reflectionTexture: BaseTexture;
  44658. /**
  44659. * Stores the refraction values in a texture.
  44660. */
  44661. protected _refractionTexture: BaseTexture;
  44662. /**
  44663. * Stores the emissive values in a texture.
  44664. */
  44665. protected _emissiveTexture: BaseTexture;
  44666. /**
  44667. * AKA Specular texture in other nomenclature.
  44668. */
  44669. protected _reflectivityTexture: BaseTexture;
  44670. /**
  44671. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44672. */
  44673. protected _metallicTexture: BaseTexture;
  44674. /**
  44675. * Specifies the metallic scalar of the metallic/roughness workflow.
  44676. * Can also be used to scale the metalness values of the metallic texture.
  44677. */
  44678. protected _metallic: Nullable<number>;
  44679. /**
  44680. * Specifies the roughness scalar of the metallic/roughness workflow.
  44681. * Can also be used to scale the roughness values of the metallic texture.
  44682. */
  44683. protected _roughness: Nullable<number>;
  44684. /**
  44685. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44686. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44687. */
  44688. protected _microSurfaceTexture: BaseTexture;
  44689. /**
  44690. * Stores surface normal data used to displace a mesh in a texture.
  44691. */
  44692. protected _bumpTexture: BaseTexture;
  44693. /**
  44694. * Stores the pre-calculated light information of a mesh in a texture.
  44695. */
  44696. protected _lightmapTexture: BaseTexture;
  44697. /**
  44698. * The color of a material in ambient lighting.
  44699. */
  44700. protected _ambientColor: Color3;
  44701. /**
  44702. * AKA Diffuse Color in other nomenclature.
  44703. */
  44704. protected _albedoColor: Color3;
  44705. /**
  44706. * AKA Specular Color in other nomenclature.
  44707. */
  44708. protected _reflectivityColor: Color3;
  44709. /**
  44710. * The color applied when light is reflected from a material.
  44711. */
  44712. protected _reflectionColor: Color3;
  44713. /**
  44714. * The color applied when light is emitted from a material.
  44715. */
  44716. protected _emissiveColor: Color3;
  44717. /**
  44718. * AKA Glossiness in other nomenclature.
  44719. */
  44720. protected _microSurface: number;
  44721. /**
  44722. * source material index of refraction (IOR)' / 'destination material IOR.
  44723. */
  44724. protected _indexOfRefraction: number;
  44725. /**
  44726. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44727. */
  44728. protected _invertRefractionY: boolean;
  44729. /**
  44730. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44731. * Materials half opaque for instance using refraction could benefit from this control.
  44732. */
  44733. protected _linkRefractionWithTransparency: boolean;
  44734. /**
  44735. * Specifies that the material will use the light map as a show map.
  44736. */
  44737. protected _useLightmapAsShadowmap: boolean;
  44738. /**
  44739. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44740. * makes the reflect vector face the model (under horizon).
  44741. */
  44742. protected _useHorizonOcclusion: boolean;
  44743. /**
  44744. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44745. * too much the area relying on ambient texture to define their ambient occlusion.
  44746. */
  44747. protected _useRadianceOcclusion: boolean;
  44748. /**
  44749. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44750. */
  44751. protected _useAlphaFromAlbedoTexture: boolean;
  44752. /**
  44753. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44754. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44755. */
  44756. protected _useSpecularOverAlpha: boolean;
  44757. /**
  44758. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44759. */
  44760. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44761. /**
  44762. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44763. */
  44764. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44765. /**
  44766. * Specifies if the metallic texture contains the roughness information in its green channel.
  44767. */
  44768. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44769. /**
  44770. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44771. */
  44772. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44773. /**
  44774. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44775. */
  44776. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44777. /**
  44778. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44779. */
  44780. protected _useAmbientInGrayScale: boolean;
  44781. /**
  44782. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44783. * The material will try to infer what glossiness each pixel should be.
  44784. */
  44785. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44786. /**
  44787. * Defines the falloff type used in this material.
  44788. * It by default is Physical.
  44789. */
  44790. protected _lightFalloff: number;
  44791. /**
  44792. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44793. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44794. */
  44795. protected _useRadianceOverAlpha: boolean;
  44796. /**
  44797. * Allows using an object space normal map (instead of tangent space).
  44798. */
  44799. protected _useObjectSpaceNormalMap: boolean;
  44800. /**
  44801. * Allows using the bump map in parallax mode.
  44802. */
  44803. protected _useParallax: boolean;
  44804. /**
  44805. * Allows using the bump map in parallax occlusion mode.
  44806. */
  44807. protected _useParallaxOcclusion: boolean;
  44808. /**
  44809. * Controls the scale bias of the parallax mode.
  44810. */
  44811. protected _parallaxScaleBias: number;
  44812. /**
  44813. * If sets to true, disables all the lights affecting the material.
  44814. */
  44815. protected _disableLighting: boolean;
  44816. /**
  44817. * Number of Simultaneous lights allowed on the material.
  44818. */
  44819. protected _maxSimultaneousLights: number;
  44820. /**
  44821. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44822. */
  44823. protected _invertNormalMapX: boolean;
  44824. /**
  44825. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44826. */
  44827. protected _invertNormalMapY: boolean;
  44828. /**
  44829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44830. */
  44831. protected _twoSidedLighting: boolean;
  44832. /**
  44833. * Defines the alpha limits in alpha test mode.
  44834. */
  44835. protected _alphaCutOff: number;
  44836. /**
  44837. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44838. */
  44839. protected _forceAlphaTest: boolean;
  44840. /**
  44841. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44842. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44843. */
  44844. protected _useAlphaFresnel: boolean;
  44845. /**
  44846. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44847. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44848. */
  44849. protected _useLinearAlphaFresnel: boolean;
  44850. /**
  44851. * The transparency mode of the material.
  44852. */
  44853. protected _transparencyMode: Nullable<number>;
  44854. /**
  44855. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44856. * from cos thetav and roughness:
  44857. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44858. */
  44859. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44860. /**
  44861. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44862. */
  44863. protected _forceIrradianceInFragment: boolean;
  44864. /**
  44865. * Force normal to face away from face.
  44866. */
  44867. protected _forceNormalForward: boolean;
  44868. /**
  44869. * Enables specular anti aliasing in the PBR shader.
  44870. * It will both interacts on the Geometry for analytical and IBL lighting.
  44871. * It also prefilter the roughness map based on the bump values.
  44872. */
  44873. protected _enableSpecularAntiAliasing: boolean;
  44874. /**
  44875. * Default configuration related to image processing available in the PBR Material.
  44876. */
  44877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44878. /**
  44879. * Keep track of the image processing observer to allow dispose and replace.
  44880. */
  44881. private _imageProcessingObserver;
  44882. /**
  44883. * Attaches a new image processing configuration to the PBR Material.
  44884. * @param configuration
  44885. */
  44886. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44887. /**
  44888. * Stores the available render targets.
  44889. */
  44890. private _renderTargets;
  44891. /**
  44892. * Sets the global ambient color for the material used in lighting calculations.
  44893. */
  44894. private _globalAmbientColor;
  44895. /**
  44896. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44897. */
  44898. private _useLogarithmicDepth;
  44899. /**
  44900. * If set to true, no lighting calculations will be applied.
  44901. */
  44902. private _unlit;
  44903. /**
  44904. * Instantiates a new PBRMaterial instance.
  44905. *
  44906. * @param name The material name
  44907. * @param scene The scene the material will be use in.
  44908. */
  44909. constructor(name: string, scene: Scene);
  44910. /**
  44911. * Gets a boolean indicating that current material needs to register RTT
  44912. */
  44913. readonly hasRenderTargetTextures: boolean;
  44914. /**
  44915. * Gets the name of the material class.
  44916. */
  44917. getClassName(): string;
  44918. /**
  44919. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44920. */
  44921. /**
  44922. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44923. */
  44924. useLogarithmicDepth: boolean;
  44925. /**
  44926. * Gets the current transparency mode.
  44927. */
  44928. /**
  44929. * Sets the transparency mode of the material.
  44930. *
  44931. * | Value | Type | Description |
  44932. * | ----- | ----------------------------------- | ----------- |
  44933. * | 0 | OPAQUE | |
  44934. * | 1 | ALPHATEST | |
  44935. * | 2 | ALPHABLEND | |
  44936. * | 3 | ALPHATESTANDBLEND | |
  44937. *
  44938. */
  44939. transparencyMode: Nullable<number>;
  44940. /**
  44941. * Returns true if alpha blending should be disabled.
  44942. */
  44943. private readonly _disableAlphaBlending;
  44944. /**
  44945. * Specifies whether or not this material should be rendered in alpha blend mode.
  44946. */
  44947. needAlphaBlending(): boolean;
  44948. /**
  44949. * Specifies if the mesh will require alpha blending.
  44950. * @param mesh - BJS mesh.
  44951. */
  44952. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44953. /**
  44954. * Specifies whether or not this material should be rendered in alpha test mode.
  44955. */
  44956. needAlphaTesting(): boolean;
  44957. /**
  44958. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44959. */
  44960. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44961. /**
  44962. * Gets the texture used for the alpha test.
  44963. */
  44964. getAlphaTestTexture(): BaseTexture;
  44965. /**
  44966. * Stores the reflectivity values based on metallic roughness workflow.
  44967. */
  44968. private static _scaledReflectivity;
  44969. /**
  44970. * Specifies that the submesh is ready to be used.
  44971. * @param mesh - BJS mesh.
  44972. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44973. * @param useInstances - Specifies that instances should be used.
  44974. * @returns - boolean indicating that the submesh is ready or not.
  44975. */
  44976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44977. /**
  44978. * Specifies if the material uses metallic roughness workflow.
  44979. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44980. */
  44981. isMetallicWorkflow(): boolean;
  44982. private _prepareEffect;
  44983. private _prepareDefines;
  44984. /**
  44985. * Force shader compilation
  44986. */
  44987. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44988. clipPlane: boolean;
  44989. }>): void;
  44990. /**
  44991. * Initializes the uniform buffer layout for the shader.
  44992. */
  44993. buildUniformLayout(): void;
  44994. /**
  44995. * Unbinds the textures.
  44996. */
  44997. unbind(): void;
  44998. /**
  44999. * Binds the submesh data.
  45000. * @param world - The world matrix.
  45001. * @param mesh - The BJS mesh.
  45002. * @param subMesh - A submesh of the BJS mesh.
  45003. */
  45004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45005. /**
  45006. * Returns the animatable textures.
  45007. * @returns - Array of animatable textures.
  45008. */
  45009. getAnimatables(): IAnimatable[];
  45010. /**
  45011. * Returns the texture used for reflections.
  45012. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45013. */
  45014. private _getReflectionTexture;
  45015. /**
  45016. * Returns the texture used for refraction or null if none is used.
  45017. * @returns - Refection texture if present. If no refraction texture and refraction
  45018. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45019. */
  45020. private _getRefractionTexture;
  45021. /**
  45022. * Disposes the resources of the material.
  45023. * @param forceDisposeEffect - Forces the disposal of effects.
  45024. * @param forceDisposeTextures - Forces the disposal of all textures.
  45025. */
  45026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45027. }
  45028. }
  45029. declare module BABYLON {
  45030. /**
  45031. * The Physically based simple base material of BJS.
  45032. *
  45033. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45034. * It is used as the base class for both the specGloss and metalRough conventions.
  45035. */
  45036. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45037. /**
  45038. * Number of Simultaneous lights allowed on the material.
  45039. */
  45040. maxSimultaneousLights: number;
  45041. /**
  45042. * If sets to true, disables all the lights affecting the material.
  45043. */
  45044. disableLighting: boolean;
  45045. /**
  45046. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45047. */
  45048. environmentTexture: BaseTexture;
  45049. /**
  45050. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45051. */
  45052. invertNormalMapX: boolean;
  45053. /**
  45054. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45055. */
  45056. invertNormalMapY: boolean;
  45057. /**
  45058. * Normal map used in the model.
  45059. */
  45060. normalTexture: BaseTexture;
  45061. /**
  45062. * Emissivie color used to self-illuminate the model.
  45063. */
  45064. emissiveColor: Color3;
  45065. /**
  45066. * Emissivie texture used to self-illuminate the model.
  45067. */
  45068. emissiveTexture: BaseTexture;
  45069. /**
  45070. * Occlusion Channel Strenght.
  45071. */
  45072. occlusionStrength: number;
  45073. /**
  45074. * Occlusion Texture of the material (adding extra occlusion effects).
  45075. */
  45076. occlusionTexture: BaseTexture;
  45077. /**
  45078. * Defines the alpha limits in alpha test mode.
  45079. */
  45080. alphaCutOff: number;
  45081. /**
  45082. * Gets the current double sided mode.
  45083. */
  45084. /**
  45085. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45086. */
  45087. doubleSided: boolean;
  45088. /**
  45089. * Stores the pre-calculated light information of a mesh in a texture.
  45090. */
  45091. lightmapTexture: BaseTexture;
  45092. /**
  45093. * If true, the light map contains occlusion information instead of lighting info.
  45094. */
  45095. useLightmapAsShadowmap: boolean;
  45096. /**
  45097. * Return the active textures of the material.
  45098. */
  45099. getActiveTextures(): BaseTexture[];
  45100. hasTexture(texture: BaseTexture): boolean;
  45101. /**
  45102. * Instantiates a new PBRMaterial instance.
  45103. *
  45104. * @param name The material name
  45105. * @param scene The scene the material will be use in.
  45106. */
  45107. constructor(name: string, scene: Scene);
  45108. getClassName(): string;
  45109. }
  45110. }
  45111. declare module BABYLON {
  45112. /**
  45113. * The Physically based material of BJS.
  45114. *
  45115. * This offers the main features of a standard PBR material.
  45116. * For more information, please refer to the documentation :
  45117. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45118. */
  45119. class PBRMaterial extends PBRBaseMaterial {
  45120. /**
  45121. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45122. */
  45123. static readonly PBRMATERIAL_OPAQUE: number;
  45124. /**
  45125. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45126. */
  45127. static readonly PBRMATERIAL_ALPHATEST: number;
  45128. /**
  45129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45130. */
  45131. static readonly PBRMATERIAL_ALPHABLEND: number;
  45132. /**
  45133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45134. * They are also discarded below the alpha cutoff threshold to improve performances.
  45135. */
  45136. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45137. /**
  45138. * Defines the default value of how much AO map is occluding the analytical lights
  45139. * (point spot...).
  45140. */
  45141. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45142. /**
  45143. * Intensity of the direct lights e.g. the four lights available in your scene.
  45144. * This impacts both the direct diffuse and specular highlights.
  45145. */
  45146. directIntensity: number;
  45147. /**
  45148. * Intensity of the emissive part of the material.
  45149. * This helps controlling the emissive effect without modifying the emissive color.
  45150. */
  45151. emissiveIntensity: number;
  45152. /**
  45153. * Intensity of the environment e.g. how much the environment will light the object
  45154. * either through harmonics for rough material or through the refelction for shiny ones.
  45155. */
  45156. environmentIntensity: number;
  45157. /**
  45158. * This is a special control allowing the reduction of the specular highlights coming from the
  45159. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45160. */
  45161. specularIntensity: number;
  45162. /**
  45163. * Debug Control allowing disabling the bump map on this material.
  45164. */
  45165. disableBumpMap: boolean;
  45166. /**
  45167. * AKA Diffuse Texture in standard nomenclature.
  45168. */
  45169. albedoTexture: BaseTexture;
  45170. /**
  45171. * AKA Occlusion Texture in other nomenclature.
  45172. */
  45173. ambientTexture: BaseTexture;
  45174. /**
  45175. * AKA Occlusion Texture Intensity in other nomenclature.
  45176. */
  45177. ambientTextureStrength: number;
  45178. /**
  45179. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45180. * 1 means it completely occludes it
  45181. * 0 mean it has no impact
  45182. */
  45183. ambientTextureImpactOnAnalyticalLights: number;
  45184. /**
  45185. * Stores the alpha values in a texture.
  45186. */
  45187. opacityTexture: BaseTexture;
  45188. /**
  45189. * Stores the reflection values in a texture.
  45190. */
  45191. reflectionTexture: Nullable<BaseTexture>;
  45192. /**
  45193. * Stores the emissive values in a texture.
  45194. */
  45195. emissiveTexture: BaseTexture;
  45196. /**
  45197. * AKA Specular texture in other nomenclature.
  45198. */
  45199. reflectivityTexture: BaseTexture;
  45200. /**
  45201. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45202. */
  45203. metallicTexture: BaseTexture;
  45204. /**
  45205. * Specifies the metallic scalar of the metallic/roughness workflow.
  45206. * Can also be used to scale the metalness values of the metallic texture.
  45207. */
  45208. metallic: Nullable<number>;
  45209. /**
  45210. * Specifies the roughness scalar of the metallic/roughness workflow.
  45211. * Can also be used to scale the roughness values of the metallic texture.
  45212. */
  45213. roughness: Nullable<number>;
  45214. /**
  45215. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45216. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45217. */
  45218. microSurfaceTexture: BaseTexture;
  45219. /**
  45220. * Stores surface normal data used to displace a mesh in a texture.
  45221. */
  45222. bumpTexture: BaseTexture;
  45223. /**
  45224. * Stores the pre-calculated light information of a mesh in a texture.
  45225. */
  45226. lightmapTexture: BaseTexture;
  45227. /**
  45228. * Stores the refracted light information in a texture.
  45229. */
  45230. refractionTexture: BaseTexture;
  45231. /**
  45232. * The color of a material in ambient lighting.
  45233. */
  45234. ambientColor: Color3;
  45235. /**
  45236. * AKA Diffuse Color in other nomenclature.
  45237. */
  45238. albedoColor: Color3;
  45239. /**
  45240. * AKA Specular Color in other nomenclature.
  45241. */
  45242. reflectivityColor: Color3;
  45243. /**
  45244. * The color reflected from the material.
  45245. */
  45246. reflectionColor: Color3;
  45247. /**
  45248. * The color emitted from the material.
  45249. */
  45250. emissiveColor: Color3;
  45251. /**
  45252. * AKA Glossiness in other nomenclature.
  45253. */
  45254. microSurface: number;
  45255. /**
  45256. * source material index of refraction (IOR)' / 'destination material IOR.
  45257. */
  45258. indexOfRefraction: number;
  45259. /**
  45260. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45261. */
  45262. invertRefractionY: boolean;
  45263. /**
  45264. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45265. * Materials half opaque for instance using refraction could benefit from this control.
  45266. */
  45267. linkRefractionWithTransparency: boolean;
  45268. /**
  45269. * If true, the light map contains occlusion information instead of lighting info.
  45270. */
  45271. useLightmapAsShadowmap: boolean;
  45272. /**
  45273. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45274. */
  45275. useAlphaFromAlbedoTexture: boolean;
  45276. /**
  45277. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45278. */
  45279. forceAlphaTest: boolean;
  45280. /**
  45281. * Defines the alpha limits in alpha test mode.
  45282. */
  45283. alphaCutOff: number;
  45284. /**
  45285. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45286. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45287. */
  45288. useSpecularOverAlpha: boolean;
  45289. /**
  45290. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45291. */
  45292. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45293. /**
  45294. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45295. */
  45296. useRoughnessFromMetallicTextureAlpha: boolean;
  45297. /**
  45298. * Specifies if the metallic texture contains the roughness information in its green channel.
  45299. */
  45300. useRoughnessFromMetallicTextureGreen: boolean;
  45301. /**
  45302. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45303. */
  45304. useMetallnessFromMetallicTextureBlue: boolean;
  45305. /**
  45306. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45307. */
  45308. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45309. /**
  45310. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45311. */
  45312. useAmbientInGrayScale: boolean;
  45313. /**
  45314. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45315. * The material will try to infer what glossiness each pixel should be.
  45316. */
  45317. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45318. /**
  45319. * BJS is using an harcoded light falloff based on a manually sets up range.
  45320. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45321. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45322. */
  45323. /**
  45324. * BJS is using an harcoded light falloff based on a manually sets up range.
  45325. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45326. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45327. */
  45328. usePhysicalLightFalloff: boolean;
  45329. /**
  45330. * In order to support the falloff compatibility with gltf, a special mode has been added
  45331. * to reproduce the gltf light falloff.
  45332. */
  45333. /**
  45334. * In order to support the falloff compatibility with gltf, a special mode has been added
  45335. * to reproduce the gltf light falloff.
  45336. */
  45337. useGLTFLightFalloff: boolean;
  45338. /**
  45339. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45340. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45341. */
  45342. useRadianceOverAlpha: boolean;
  45343. /**
  45344. * Allows using an object space normal map (instead of tangent space).
  45345. */
  45346. useObjectSpaceNormalMap: boolean;
  45347. /**
  45348. * Allows using the bump map in parallax mode.
  45349. */
  45350. useParallax: boolean;
  45351. /**
  45352. * Allows using the bump map in parallax occlusion mode.
  45353. */
  45354. useParallaxOcclusion: boolean;
  45355. /**
  45356. * Controls the scale bias of the parallax mode.
  45357. */
  45358. parallaxScaleBias: number;
  45359. /**
  45360. * If sets to true, disables all the lights affecting the material.
  45361. */
  45362. disableLighting: boolean;
  45363. /**
  45364. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45365. */
  45366. forceIrradianceInFragment: boolean;
  45367. /**
  45368. * Number of Simultaneous lights allowed on the material.
  45369. */
  45370. maxSimultaneousLights: number;
  45371. /**
  45372. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45373. */
  45374. invertNormalMapX: boolean;
  45375. /**
  45376. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45377. */
  45378. invertNormalMapY: boolean;
  45379. /**
  45380. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45381. */
  45382. twoSidedLighting: boolean;
  45383. /**
  45384. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45385. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45386. */
  45387. useAlphaFresnel: boolean;
  45388. /**
  45389. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45390. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45391. */
  45392. useLinearAlphaFresnel: boolean;
  45393. /**
  45394. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45395. * And/Or occlude the blended part.
  45396. */
  45397. environmentBRDFTexture: Nullable<BaseTexture>;
  45398. /**
  45399. * Force normal to face away from face.
  45400. */
  45401. forceNormalForward: boolean;
  45402. /**
  45403. * Enables specular anti aliasing in the PBR shader.
  45404. * It will both interacts on the Geometry for analytical and IBL lighting.
  45405. * It also prefilter the roughness map based on the bump values.
  45406. */
  45407. enableSpecularAntiAliasing: boolean;
  45408. /**
  45409. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45410. * makes the reflect vector face the model (under horizon).
  45411. */
  45412. useHorizonOcclusion: boolean;
  45413. /**
  45414. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45415. * too much the area relying on ambient texture to define their ambient occlusion.
  45416. */
  45417. useRadianceOcclusion: boolean;
  45418. /**
  45419. * If set to true, no lighting calculations will be applied.
  45420. */
  45421. unlit: boolean;
  45422. /**
  45423. * Gets the image processing configuration used either in this material.
  45424. */
  45425. /**
  45426. * Sets the Default image processing configuration used either in the this material.
  45427. *
  45428. * If sets to null, the scene one is in use.
  45429. */
  45430. imageProcessingConfiguration: ImageProcessingConfiguration;
  45431. /**
  45432. * Gets wether the color curves effect is enabled.
  45433. */
  45434. /**
  45435. * Sets wether the color curves effect is enabled.
  45436. */
  45437. cameraColorCurvesEnabled: boolean;
  45438. /**
  45439. * Gets wether the color grading effect is enabled.
  45440. */
  45441. /**
  45442. * Gets wether the color grading effect is enabled.
  45443. */
  45444. cameraColorGradingEnabled: boolean;
  45445. /**
  45446. * Gets wether tonemapping is enabled or not.
  45447. */
  45448. /**
  45449. * Sets wether tonemapping is enabled or not
  45450. */
  45451. cameraToneMappingEnabled: boolean;
  45452. /**
  45453. * The camera exposure used on this material.
  45454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45455. * This corresponds to a photographic exposure.
  45456. */
  45457. /**
  45458. * The camera exposure used on this material.
  45459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45460. * This corresponds to a photographic exposure.
  45461. */
  45462. cameraExposure: number;
  45463. /**
  45464. * Gets The camera contrast used on this material.
  45465. */
  45466. /**
  45467. * Sets The camera contrast used on this material.
  45468. */
  45469. cameraContrast: number;
  45470. /**
  45471. * Gets the Color Grading 2D Lookup Texture.
  45472. */
  45473. /**
  45474. * Sets the Color Grading 2D Lookup Texture.
  45475. */
  45476. cameraColorGradingTexture: Nullable<BaseTexture>;
  45477. /**
  45478. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45479. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45480. * 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;
  45481. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45482. */
  45483. /**
  45484. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45485. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45486. * 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;
  45487. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45488. */
  45489. cameraColorCurves: Nullable<ColorCurves>;
  45490. /**
  45491. * Instantiates a new PBRMaterial instance.
  45492. *
  45493. * @param name The material name
  45494. * @param scene The scene the material will be use in.
  45495. */
  45496. constructor(name: string, scene: Scene);
  45497. /**
  45498. * Returns the name of this material class.
  45499. */
  45500. getClassName(): string;
  45501. /**
  45502. * Returns an array of the actively used textures.
  45503. * @returns - Array of BaseTextures
  45504. */
  45505. getActiveTextures(): BaseTexture[];
  45506. /**
  45507. * Checks to see if a texture is used in the material.
  45508. * @param texture - Base texture to use.
  45509. * @returns - Boolean specifying if a texture is used in the material.
  45510. */
  45511. hasTexture(texture: BaseTexture): boolean;
  45512. /**
  45513. * Makes a duplicate of the current material.
  45514. * @param name - name to use for the new material.
  45515. */
  45516. clone(name: string): PBRMaterial;
  45517. /**
  45518. * Serializes this PBR Material.
  45519. * @returns - An object with the serialized material.
  45520. */
  45521. serialize(): any;
  45522. /**
  45523. * Parses a PBR Material from a serialized object.
  45524. * @param source - Serialized object.
  45525. * @param scene - BJS scene instance.
  45526. * @param rootUrl - url for the scene object
  45527. * @returns - PBRMaterial
  45528. */
  45529. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45530. }
  45531. }
  45532. declare module BABYLON {
  45533. /**
  45534. * The PBR material of BJS following the metal roughness convention.
  45535. *
  45536. * This fits to the PBR convention in the GLTF definition:
  45537. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45538. */
  45539. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45540. /**
  45541. * The base color has two different interpretations depending on the value of metalness.
  45542. * When the material is a metal, the base color is the specific measured reflectance value
  45543. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45544. * of the material.
  45545. */
  45546. baseColor: Color3;
  45547. /**
  45548. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45549. * well as opacity information in the alpha channel.
  45550. */
  45551. baseTexture: BaseTexture;
  45552. /**
  45553. * Specifies the metallic scalar value of the material.
  45554. * Can also be used to scale the metalness values of the metallic texture.
  45555. */
  45556. metallic: number;
  45557. /**
  45558. * Specifies the roughness scalar value of the material.
  45559. * Can also be used to scale the roughness values of the metallic texture.
  45560. */
  45561. roughness: number;
  45562. /**
  45563. * Texture containing both the metallic value in the B channel and the
  45564. * roughness value in the G channel to keep better precision.
  45565. */
  45566. metallicRoughnessTexture: BaseTexture;
  45567. /**
  45568. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45569. *
  45570. * @param name The material name
  45571. * @param scene The scene the material will be use in.
  45572. */
  45573. constructor(name: string, scene: Scene);
  45574. /**
  45575. * Return the currrent class name of the material.
  45576. */
  45577. getClassName(): string;
  45578. /**
  45579. * Return the active textures of the material.
  45580. */
  45581. getActiveTextures(): BaseTexture[];
  45582. /**
  45583. * Checks to see if a texture is used in the material.
  45584. * @param texture - Base texture to use.
  45585. * @returns - Boolean specifying if a texture is used in the material.
  45586. */
  45587. hasTexture(texture: BaseTexture): boolean;
  45588. /**
  45589. * Makes a duplicate of the current material.
  45590. * @param name - name to use for the new material.
  45591. */
  45592. clone(name: string): PBRMetallicRoughnessMaterial;
  45593. /**
  45594. * Serialize the material to a parsable JSON object.
  45595. */
  45596. serialize(): any;
  45597. /**
  45598. * Parses a JSON object correponding to the serialize function.
  45599. */
  45600. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45601. }
  45602. }
  45603. declare module BABYLON {
  45604. /**
  45605. * The PBR material of BJS following the specular glossiness convention.
  45606. *
  45607. * This fits to the PBR convention in the GLTF definition:
  45608. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45609. */
  45610. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45611. /**
  45612. * Specifies the diffuse color of the material.
  45613. */
  45614. diffuseColor: Color3;
  45615. /**
  45616. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45617. * channel.
  45618. */
  45619. diffuseTexture: BaseTexture;
  45620. /**
  45621. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45622. */
  45623. specularColor: Color3;
  45624. /**
  45625. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45626. */
  45627. glossiness: number;
  45628. /**
  45629. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45630. */
  45631. specularGlossinessTexture: BaseTexture;
  45632. /**
  45633. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45634. *
  45635. * @param name The material name
  45636. * @param scene The scene the material will be use in.
  45637. */
  45638. constructor(name: string, scene: Scene);
  45639. /**
  45640. * Return the currrent class name of the material.
  45641. */
  45642. getClassName(): string;
  45643. /**
  45644. * Return the active textures of the material.
  45645. */
  45646. getActiveTextures(): BaseTexture[];
  45647. /**
  45648. * Checks to see if a texture is used in the material.
  45649. * @param texture - Base texture to use.
  45650. * @returns - Boolean specifying if a texture is used in the material.
  45651. */
  45652. hasTexture(texture: BaseTexture): boolean;
  45653. /**
  45654. * Makes a duplicate of the current material.
  45655. * @param name - name to use for the new material.
  45656. */
  45657. clone(name: string): PBRSpecularGlossinessMaterial;
  45658. /**
  45659. * Serialize the material to a parsable JSON object.
  45660. */
  45661. serialize(): any;
  45662. /**
  45663. * Parses a JSON object correponding to the serialize function.
  45664. */
  45665. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45666. }
  45667. }
  45668. declare module BABYLON {
  45669. /**
  45670. * Base class of all the textures in babylon.
  45671. * It groups all the common properties the materials, post process, lights... might need
  45672. * in order to make a correct use of the texture.
  45673. */
  45674. class BaseTexture {
  45675. /**
  45676. * Default anisotropic filtering level for the application.
  45677. * It is set to 4 as a good tradeoff between perf and quality.
  45678. */
  45679. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45680. /**
  45681. * Define the name of the texture.
  45682. */
  45683. name: string;
  45684. private _hasAlpha;
  45685. /**
  45686. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45687. */
  45688. hasAlpha: boolean;
  45689. /**
  45690. * Defines if the alpha value should be determined via the rgb values.
  45691. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45692. */
  45693. getAlphaFromRGB: boolean;
  45694. /**
  45695. * Intensity or strength of the texture.
  45696. * It is commonly used by materials to fine tune the intensity of the texture
  45697. */
  45698. level: number;
  45699. /**
  45700. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45701. * This is part of the texture as textures usually maps to one uv set.
  45702. */
  45703. coordinatesIndex: number;
  45704. private _coordinatesMode;
  45705. /**
  45706. * How a texture is mapped.
  45707. *
  45708. * | Value | Type | Description |
  45709. * | ----- | ----------------------------------- | ----------- |
  45710. * | 0 | EXPLICIT_MODE | |
  45711. * | 1 | SPHERICAL_MODE | |
  45712. * | 2 | PLANAR_MODE | |
  45713. * | 3 | CUBIC_MODE | |
  45714. * | 4 | PROJECTION_MODE | |
  45715. * | 5 | SKYBOX_MODE | |
  45716. * | 6 | INVCUBIC_MODE | |
  45717. * | 7 | EQUIRECTANGULAR_MODE | |
  45718. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45719. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45720. */
  45721. coordinatesMode: number;
  45722. /**
  45723. * | Value | Type | Description |
  45724. * | ----- | ------------------ | ----------- |
  45725. * | 0 | CLAMP_ADDRESSMODE | |
  45726. * | 1 | WRAP_ADDRESSMODE | |
  45727. * | 2 | MIRROR_ADDRESSMODE | |
  45728. */
  45729. wrapU: number;
  45730. /**
  45731. * | Value | Type | Description |
  45732. * | ----- | ------------------ | ----------- |
  45733. * | 0 | CLAMP_ADDRESSMODE | |
  45734. * | 1 | WRAP_ADDRESSMODE | |
  45735. * | 2 | MIRROR_ADDRESSMODE | |
  45736. */
  45737. wrapV: number;
  45738. /**
  45739. * | Value | Type | Description |
  45740. * | ----- | ------------------ | ----------- |
  45741. * | 0 | CLAMP_ADDRESSMODE | |
  45742. * | 1 | WRAP_ADDRESSMODE | |
  45743. * | 2 | MIRROR_ADDRESSMODE | |
  45744. */
  45745. wrapR: number;
  45746. /**
  45747. * With compliant hardware and browser (supporting anisotropic filtering)
  45748. * this defines the level of anisotropic filtering in the texture.
  45749. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45750. */
  45751. anisotropicFilteringLevel: number;
  45752. /**
  45753. * Define if the texture is a cube texture or if false a 2d texture.
  45754. */
  45755. isCube: boolean;
  45756. /**
  45757. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45758. */
  45759. is3D: boolean;
  45760. /**
  45761. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45762. * HDR texture are usually stored in linear space.
  45763. * This only impacts the PBR and Background materials
  45764. */
  45765. gammaSpace: boolean;
  45766. /**
  45767. * Gets whether or not the texture contains RGBD data.
  45768. */
  45769. readonly isRGBD: boolean;
  45770. /**
  45771. * Is Z inverted in the texture (useful in a cube texture).
  45772. */
  45773. invertZ: boolean;
  45774. /**
  45775. * @hidden
  45776. */
  45777. lodLevelInAlpha: boolean;
  45778. /**
  45779. * With prefiltered texture, defined the offset used during the prefiltering steps.
  45780. */
  45781. lodGenerationOffset: number;
  45782. /**
  45783. * With prefiltered texture, defined the scale used during the prefiltering steps.
  45784. */
  45785. lodGenerationScale: number;
  45786. /**
  45787. * Define if the texture is a render target.
  45788. */
  45789. isRenderTarget: boolean;
  45790. /**
  45791. * Define the unique id of the texture in the scene.
  45792. */
  45793. readonly uid: string;
  45794. /**
  45795. * Return a string representation of the texture.
  45796. * @returns the texture as a string
  45797. */
  45798. toString(): string;
  45799. /**
  45800. * Get the class name of the texture.
  45801. * @returns "BaseTexture"
  45802. */
  45803. getClassName(): string;
  45804. /**
  45805. * Define the list of animation attached to the texture.
  45806. */
  45807. animations: Animation[];
  45808. /**
  45809. * An event triggered when the texture is disposed.
  45810. */
  45811. onDisposeObservable: Observable<BaseTexture>;
  45812. private _onDisposeObserver;
  45813. /**
  45814. * Callback triggered when the texture has been disposed.
  45815. * Kept for back compatibility, you can use the onDisposeObservable instead.
  45816. */
  45817. onDispose: () => void;
  45818. /**
  45819. * Define the current state of the loading sequence when in delayed load mode.
  45820. */
  45821. delayLoadState: number;
  45822. private _scene;
  45823. /** @hidden */
  45824. _texture: Nullable<InternalTexture>;
  45825. private _uid;
  45826. /**
  45827. * Define if the texture is preventinga material to render or not.
  45828. * If not and the texture is not ready, the engine will use a default black texture instead.
  45829. */
  45830. readonly isBlocking: boolean;
  45831. /**
  45832. * Instantiates a new BaseTexture.
  45833. * Base class of all the textures in babylon.
  45834. * It groups all the common properties the materials, post process, lights... might need
  45835. * in order to make a correct use of the texture.
  45836. * @param scene Define the scene the texture blongs to
  45837. */
  45838. constructor(scene: Nullable<Scene>);
  45839. /**
  45840. * Get the scene the texture belongs to.
  45841. * @returns the scene or null if undefined
  45842. */
  45843. getScene(): Nullable<Scene>;
  45844. /**
  45845. * Get the texture transform matrix used to offset tile the texture for istance.
  45846. * @returns the transformation matrix
  45847. */
  45848. getTextureMatrix(): Matrix;
  45849. /**
  45850. * Get the texture reflection matrix used to rotate/transform the reflection.
  45851. * @returns the reflection matrix
  45852. */
  45853. getReflectionTextureMatrix(): Matrix;
  45854. /**
  45855. * Get the underlying lower level texture from Babylon.
  45856. * @returns the insternal texture
  45857. */
  45858. getInternalTexture(): Nullable<InternalTexture>;
  45859. /**
  45860. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  45861. * @returns true if ready or not blocking
  45862. */
  45863. isReadyOrNotBlocking(): boolean;
  45864. /**
  45865. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  45866. * @returns true if fully ready
  45867. */
  45868. isReady(): boolean;
  45869. private _cachedSize;
  45870. /**
  45871. * Get the size of the texture.
  45872. * @returns the texture size.
  45873. */
  45874. getSize(): ISize;
  45875. /**
  45876. * Get the base size of the texture.
  45877. * It can be different from the size if the texture has been resized for POT for instance
  45878. * @returns the base size
  45879. */
  45880. getBaseSize(): ISize;
  45881. /**
  45882. * Scales the texture if is `canRescale()`
  45883. * @param ratio the resize factor we want to use to rescale
  45884. */
  45885. scale(ratio: number): void;
  45886. /**
  45887. * Get if the texture can rescale.
  45888. */
  45889. readonly canRescale: boolean;
  45890. /** @hidden */
  45891. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45892. /** @hidden */
  45893. _rebuild(): void;
  45894. /**
  45895. * Triggers the load sequence in delayed load mode.
  45896. */
  45897. delayLoad(): void;
  45898. /**
  45899. * Clones the texture.
  45900. * @returns the cloned texture
  45901. */
  45902. clone(): Nullable<BaseTexture>;
  45903. /**
  45904. * Get the texture underlying type (INT, FLOAT...)
  45905. */
  45906. readonly textureType: number;
  45907. /**
  45908. * Get the texture underlying format (RGB, RGBA...)
  45909. */
  45910. readonly textureFormat: number;
  45911. /**
  45912. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  45913. * This will returns an RGBA array buffer containing either in values (0-255) or
  45914. * float values (0-1) depending of the underlying buffer type.
  45915. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  45916. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  45917. * @param buffer defines a user defined buffer to fill with data (can be null)
  45918. * @returns The Array buffer containing the pixels data.
  45919. */
  45920. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  45921. /**
  45922. * Release and destroy the underlying lower level texture aka internalTexture.
  45923. */
  45924. releaseInternalTexture(): void;
  45925. /**
  45926. * Get the polynomial representation of the texture data.
  45927. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45928. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45929. */
  45930. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45931. /** @hidden */
  45932. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45933. /** @hidden */
  45934. readonly _lodTextureMid: Nullable<BaseTexture>;
  45935. /** @hidden */
  45936. readonly _lodTextureLow: Nullable<BaseTexture>;
  45937. /**
  45938. * Dispose the texture and release its associated resources.
  45939. */
  45940. dispose(): void;
  45941. /**
  45942. * Serialize the texture into a JSON representation that can be parsed later on.
  45943. * @returns the JSON representation of the texture
  45944. */
  45945. serialize(): any;
  45946. /**
  45947. * Helper function to be called back once a list of texture contains only ready textures.
  45948. * @param textures Define the list of textures to wait for
  45949. * @param callback Define the callback triggered once the entire list will be ready
  45950. */
  45951. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45952. }
  45953. }
  45954. declare module BABYLON {
  45955. /**
  45956. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45957. * It can help converting any input color in a desired output one. This can then be used to create effects
  45958. * from sepia, black and white to sixties or futuristic rendering...
  45959. *
  45960. * The only supported format is currently 3dl.
  45961. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45962. */
  45963. class ColorGradingTexture extends BaseTexture {
  45964. /**
  45965. * The current texture matrix. (will always be identity in color grading texture)
  45966. */
  45967. private _textureMatrix;
  45968. /**
  45969. * The texture URL.
  45970. */
  45971. url: string;
  45972. /**
  45973. * Empty line regex stored for GC.
  45974. */
  45975. private static _noneEmptyLineRegex;
  45976. private _engine;
  45977. /**
  45978. * Instantiates a ColorGradingTexture from the following parameters.
  45979. *
  45980. * @param url The location of the color gradind data (currently only supporting 3dl)
  45981. * @param scene The scene the texture will be used in
  45982. */
  45983. constructor(url: string, scene: Scene);
  45984. /**
  45985. * Returns the texture matrix used in most of the material.
  45986. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45987. */
  45988. getTextureMatrix(): Matrix;
  45989. /**
  45990. * Occurs when the file being loaded is a .3dl LUT file.
  45991. */
  45992. private load3dlTexture;
  45993. /**
  45994. * Starts the loading process of the texture.
  45995. */
  45996. private loadTexture;
  45997. /**
  45998. * Clones the color gradind texture.
  45999. */
  46000. clone(): ColorGradingTexture;
  46001. /**
  46002. * Called during delayed load for textures.
  46003. */
  46004. delayLoad(): void;
  46005. /**
  46006. * Parses a color grading texture serialized by Babylon.
  46007. * @param parsedTexture The texture information being parsedTexture
  46008. * @param scene The scene to load the texture in
  46009. * @param rootUrl The root url of the data assets to load
  46010. * @return A color gradind texture
  46011. */
  46012. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46013. /**
  46014. * Serializes the LUT texture to json format.
  46015. */
  46016. serialize(): any;
  46017. }
  46018. }
  46019. declare module BABYLON {
  46020. /**
  46021. * Class for creating a cube texture
  46022. */
  46023. class CubeTexture extends BaseTexture {
  46024. /**
  46025. * The url of the texture
  46026. */
  46027. url: string;
  46028. /**
  46029. * Gets or sets the center of the bounding box associated with the cube texture.
  46030. * It must define where the camera used to render the texture was set
  46031. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46032. */
  46033. boundingBoxPosition: Vector3;
  46034. private _boundingBoxSize;
  46035. /**
  46036. * Gets or sets the size of the bounding box associated with the cube texture
  46037. * When defined, the cubemap will switch to local mode
  46038. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46039. * @example https://www.babylonjs-playground.com/#RNASML
  46040. */
  46041. /**
  46042. * Returns the bounding box size
  46043. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46044. */
  46045. boundingBoxSize: Vector3;
  46046. protected _rotationY: number;
  46047. /**
  46048. * Sets texture matrix rotation angle around Y axis in radians.
  46049. */
  46050. /**
  46051. * Gets texture matrix rotation angle around Y axis radians.
  46052. */
  46053. rotationY: number;
  46054. private _noMipmap;
  46055. private _files;
  46056. private _extensions;
  46057. private _textureMatrix;
  46058. private _format;
  46059. private _createPolynomials;
  46060. /** @hidden */
  46061. readonly _prefiltered: boolean;
  46062. /**
  46063. * Creates a cube texture from an array of image urls
  46064. * @param files defines an array of image urls
  46065. * @param scene defines the hosting scene
  46066. * @param noMipmap specifies if mip maps are not used
  46067. * @returns a cube texture
  46068. */
  46069. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46070. /**
  46071. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46072. * @param url defines the url of the prefiltered texture
  46073. * @param scene defines the scene the texture is attached to
  46074. * @param forcedExtension defines the extension of the file if different from the url
  46075. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46076. * @return the prefiltered texture
  46077. */
  46078. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46079. /**
  46080. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46081. * as prefiltered data.
  46082. * @param rootUrl defines the url of the texture or the root name of the six images
  46083. * @param scene defines the scene the texture is attached to
  46084. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46085. * @param noMipmap defines if mipmaps should be created or not
  46086. * @param files defines the six files to load for the different faces
  46087. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46088. * @param onError defines a callback triggered in case of error during load
  46089. * @param format defines the internal format to use for the texture once loaded
  46090. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46091. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46092. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46093. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46094. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46095. * @return the cube texture
  46096. */
  46097. 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);
  46098. /**
  46099. * Delays loading of the cube texture
  46100. */
  46101. delayLoad(): void;
  46102. /**
  46103. * Returns the reflection texture matrix
  46104. * @returns the reflection texture matrix
  46105. */
  46106. getReflectionTextureMatrix(): Matrix;
  46107. /**
  46108. * Sets the reflection texture matrix
  46109. * @param value Reflection texture matrix
  46110. */
  46111. setReflectionTextureMatrix(value: Matrix): void;
  46112. /**
  46113. * Parses text to create a cube texture
  46114. * @param parsedTexture define the serialized text to read from
  46115. * @param scene defines the hosting scene
  46116. * @param rootUrl defines the root url of the cube texture
  46117. * @returns a cube texture
  46118. */
  46119. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46120. /**
  46121. * Makes a clone, or deep copy, of the cube texture
  46122. * @returns a new cube texture
  46123. */
  46124. clone(): CubeTexture;
  46125. }
  46126. }
  46127. declare module BABYLON {
  46128. /**
  46129. * A class extending Texture allowing drawing on a texture
  46130. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46131. */
  46132. class DynamicTexture extends Texture {
  46133. private _generateMipMaps;
  46134. private _canvas;
  46135. private _context;
  46136. private _engine;
  46137. /**
  46138. * Creates a DynamicTexture
  46139. * @param name defines the name of the texture
  46140. * @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
  46141. * @param scene defines the scene where you want the texture
  46142. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46143. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46144. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46145. */
  46146. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46147. /**
  46148. * Gets the current state of canRescale
  46149. */
  46150. readonly canRescale: boolean;
  46151. private _recreate;
  46152. /**
  46153. * Scales the texture
  46154. * @param ratio the scale factor to apply to both width and height
  46155. */
  46156. scale(ratio: number): void;
  46157. /**
  46158. * Resizes the texture
  46159. * @param width the new width
  46160. * @param height the new height
  46161. */
  46162. scaleTo(width: number, height: number): void;
  46163. /**
  46164. * Gets the context of the canvas used by the texture
  46165. * @returns the canvas context of the dynamic texture
  46166. */
  46167. getContext(): CanvasRenderingContext2D;
  46168. /**
  46169. * Clears the texture
  46170. */
  46171. clear(): void;
  46172. /**
  46173. * Updates the texture
  46174. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46175. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46176. */
  46177. update(invertY?: boolean, premulAlpha?: boolean): void;
  46178. /**
  46179. * Draws text onto the texture
  46180. * @param text defines the text to be drawn
  46181. * @param x defines the placement of the text from the left
  46182. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46183. * @param font defines the font to be used with font-style, font-size, font-name
  46184. * @param color defines the color used for the text
  46185. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46186. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46187. * @param update defines whether texture is immediately update (default is true)
  46188. */
  46189. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46190. /**
  46191. * Clones the texture
  46192. * @returns the clone of the texture.
  46193. */
  46194. clone(): DynamicTexture;
  46195. /**
  46196. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46197. * @returns a serialized dynamic texture object
  46198. */
  46199. serialize(): any;
  46200. /** @hidden */
  46201. _rebuild(): void;
  46202. }
  46203. }
  46204. declare module BABYLON {
  46205. /**
  46206. * This represents a texture coming from an HDR input.
  46207. *
  46208. * The only supported format is currently panorama picture stored in RGBE format.
  46209. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46210. */
  46211. class HDRCubeTexture extends BaseTexture {
  46212. private static _facesMapping;
  46213. private _generateHarmonics;
  46214. private _noMipmap;
  46215. private _textureMatrix;
  46216. private _size;
  46217. private _onLoad;
  46218. private _onError;
  46219. /**
  46220. * The texture URL.
  46221. */
  46222. url: string;
  46223. /**
  46224. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46225. */
  46226. coordinatesMode: number;
  46227. protected _isBlocking: boolean;
  46228. /**
  46229. * Sets wether or not the texture is blocking during loading.
  46230. */
  46231. /**
  46232. * Gets wether or not the texture is blocking during loading.
  46233. */
  46234. isBlocking: boolean;
  46235. protected _rotationY: number;
  46236. /**
  46237. * Sets texture matrix rotation angle around Y axis in radians.
  46238. */
  46239. /**
  46240. * Gets texture matrix rotation angle around Y axis radians.
  46241. */
  46242. rotationY: number;
  46243. /**
  46244. * Gets or sets the center of the bounding box associated with the cube texture
  46245. * It must define where the camera used to render the texture was set
  46246. */
  46247. boundingBoxPosition: Vector3;
  46248. private _boundingBoxSize;
  46249. /**
  46250. * Gets or sets the size of the bounding box associated with the cube texture
  46251. * When defined, the cubemap will switch to local mode
  46252. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46253. * @example https://www.babylonjs-playground.com/#RNASML
  46254. */
  46255. boundingBoxSize: Vector3;
  46256. /**
  46257. * Instantiates an HDRTexture from the following parameters.
  46258. *
  46259. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46260. * @param scene The scene the texture will be used in
  46261. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46262. * @param noMipmap Forces to not generate the mipmap if true
  46263. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46264. * @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)
  46265. * @param reserved Reserved flag for internal use.
  46266. */
  46267. 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>);
  46268. /**
  46269. * Occurs when the file is raw .hdr file.
  46270. */
  46271. private loadTexture;
  46272. clone(): HDRCubeTexture;
  46273. delayLoad(): void;
  46274. /**
  46275. * Get the texture reflection matrix used to rotate/transform the reflection.
  46276. * @returns the reflection matrix
  46277. */
  46278. getReflectionTextureMatrix(): Matrix;
  46279. /**
  46280. * Set the texture reflection matrix used to rotate/transform the reflection.
  46281. * @param value Define the reflection matrix to set
  46282. */
  46283. setReflectionTextureMatrix(value: Matrix): void;
  46284. /**
  46285. * Parses a JSON representation of an HDR Texture in order to create the texture
  46286. * @param parsedTexture Define the JSON representation
  46287. * @param scene Define the scene the texture should be created in
  46288. * @param rootUrl Define the root url in case we need to load relative dependencies
  46289. * @returns the newly created texture after parsing
  46290. */
  46291. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46292. serialize(): any;
  46293. }
  46294. }
  46295. declare module BABYLON {
  46296. /**
  46297. * Class used to store data associated with WebGL texture data for the engine
  46298. * This class should not be used directly
  46299. */
  46300. class InternalTexture implements IInternalTextureTracker {
  46301. /**
  46302. * The source of the texture data is unknown
  46303. */
  46304. static DATASOURCE_UNKNOWN: number;
  46305. /**
  46306. * Texture data comes from an URL
  46307. */
  46308. static DATASOURCE_URL: number;
  46309. /**
  46310. * Texture data is only used for temporary storage
  46311. */
  46312. static DATASOURCE_TEMP: number;
  46313. /**
  46314. * Texture data comes from raw data (ArrayBuffer)
  46315. */
  46316. static DATASOURCE_RAW: number;
  46317. /**
  46318. * Texture content is dynamic (video or dynamic texture)
  46319. */
  46320. static DATASOURCE_DYNAMIC: number;
  46321. /**
  46322. * Texture content is generated by rendering to it
  46323. */
  46324. static DATASOURCE_RENDERTARGET: number;
  46325. /**
  46326. * Texture content is part of a multi render target process
  46327. */
  46328. static DATASOURCE_MULTIRENDERTARGET: number;
  46329. /**
  46330. * Texture data comes from a cube data file
  46331. */
  46332. static DATASOURCE_CUBE: number;
  46333. /**
  46334. * Texture data comes from a raw cube data
  46335. */
  46336. static DATASOURCE_CUBERAW: number;
  46337. /**
  46338. * Texture data come from a prefiltered cube data file
  46339. */
  46340. static DATASOURCE_CUBEPREFILTERED: number;
  46341. /**
  46342. * Texture content is raw 3D data
  46343. */
  46344. static DATASOURCE_RAW3D: number;
  46345. /**
  46346. * Texture content is a depth texture
  46347. */
  46348. static DATASOURCE_DEPTHTEXTURE: number;
  46349. /**
  46350. * Texture data comes from a raw cube data encoded with RGBD
  46351. */
  46352. static DATASOURCE_CUBERAW_RGBD: number;
  46353. /**
  46354. * Defines if the texture is ready
  46355. */
  46356. isReady: boolean;
  46357. /**
  46358. * Defines if the texture is a cube texture
  46359. */
  46360. isCube: boolean;
  46361. /**
  46362. * Defines if the texture contains 3D data
  46363. */
  46364. is3D: boolean;
  46365. /**
  46366. * Gets the URL used to load this texture
  46367. */
  46368. url: string;
  46369. /**
  46370. * Gets the sampling mode of the texture
  46371. */
  46372. samplingMode: number;
  46373. /**
  46374. * Gets a boolean indicating if the texture needs mipmaps generation
  46375. */
  46376. generateMipMaps: boolean;
  46377. /**
  46378. * Gets the number of samples used by the texture (WebGL2+ only)
  46379. */
  46380. samples: number;
  46381. /**
  46382. * Gets the type of the texture (int, float...)
  46383. */
  46384. type: number;
  46385. /**
  46386. * Gets the format of the texture (RGB, RGBA...)
  46387. */
  46388. format: number;
  46389. /**
  46390. * Observable called when the texture is loaded
  46391. */
  46392. onLoadedObservable: Observable<InternalTexture>;
  46393. /**
  46394. * Gets the width of the texture
  46395. */
  46396. width: number;
  46397. /**
  46398. * Gets the height of the texture
  46399. */
  46400. height: number;
  46401. /**
  46402. * Gets the depth of the texture
  46403. */
  46404. depth: number;
  46405. /**
  46406. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46407. */
  46408. baseWidth: number;
  46409. /**
  46410. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46411. */
  46412. baseHeight: number;
  46413. /**
  46414. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46415. */
  46416. baseDepth: number;
  46417. /**
  46418. * Gets a boolean indicating if the texture is inverted on Y axis
  46419. */
  46420. invertY: boolean;
  46421. /**
  46422. * Gets or set the previous tracker in the list
  46423. */
  46424. previous: Nullable<IInternalTextureTracker>;
  46425. /**
  46426. * Gets or set the next tracker in the list
  46427. */
  46428. next: Nullable<IInternalTextureTracker>;
  46429. /** @hidden */
  46430. _initialSlot: number;
  46431. /** @hidden */
  46432. _designatedSlot: number;
  46433. /** @hidden */
  46434. _dataSource: number;
  46435. /** @hidden */
  46436. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46437. /** @hidden */
  46438. _bufferView: Nullable<ArrayBufferView>;
  46439. /** @hidden */
  46440. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46441. /** @hidden */
  46442. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46443. /** @hidden */
  46444. _size: number;
  46445. /** @hidden */
  46446. _extension: string;
  46447. /** @hidden */
  46448. _files: Nullable<string[]>;
  46449. /** @hidden */
  46450. _workingCanvas: HTMLCanvasElement;
  46451. /** @hidden */
  46452. _workingContext: CanvasRenderingContext2D;
  46453. /** @hidden */
  46454. _framebuffer: Nullable<WebGLFramebuffer>;
  46455. /** @hidden */
  46456. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46457. /** @hidden */
  46458. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46459. /** @hidden */
  46460. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46461. /** @hidden */
  46462. _attachments: Nullable<number[]>;
  46463. /** @hidden */
  46464. _cachedCoordinatesMode: Nullable<number>;
  46465. /** @hidden */
  46466. _cachedWrapU: Nullable<number>;
  46467. /** @hidden */
  46468. _cachedWrapV: Nullable<number>;
  46469. /** @hidden */
  46470. _cachedWrapR: Nullable<number>;
  46471. /** @hidden */
  46472. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46473. /** @hidden */
  46474. _isDisabled: boolean;
  46475. /** @hidden */
  46476. _compression: Nullable<string>;
  46477. /** @hidden */
  46478. _generateStencilBuffer: boolean;
  46479. /** @hidden */
  46480. _generateDepthBuffer: boolean;
  46481. /** @hidden */
  46482. _comparisonFunction: number;
  46483. /** @hidden */
  46484. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46485. /** @hidden */
  46486. _lodGenerationScale: number;
  46487. /** @hidden */
  46488. _lodGenerationOffset: number;
  46489. /** @hidden */
  46490. _lodTextureHigh: BaseTexture;
  46491. /** @hidden */
  46492. _lodTextureMid: BaseTexture;
  46493. /** @hidden */
  46494. _lodTextureLow: BaseTexture;
  46495. /** @hidden */
  46496. _isRGBD: boolean;
  46497. /** @hidden */
  46498. _webGLTexture: Nullable<WebGLTexture>;
  46499. /** @hidden */
  46500. _references: number;
  46501. private _engine;
  46502. /**
  46503. * Gets the Engine the texture belongs to.
  46504. * @returns The babylon engine
  46505. */
  46506. getEngine(): Engine;
  46507. /**
  46508. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46509. */
  46510. readonly dataSource: number;
  46511. /**
  46512. * Creates a new InternalTexture
  46513. * @param engine defines the engine to use
  46514. * @param dataSource defines the type of data that will be used
  46515. * @param delayAllocation if the texture allocation should be delayed (default: false)
  46516. */
  46517. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  46518. /**
  46519. * Increments the number of references (ie. the number of Texture that point to it)
  46520. */
  46521. incrementReferences(): void;
  46522. /**
  46523. * Change the size of the texture (not the size of the content)
  46524. * @param width defines the new width
  46525. * @param height defines the new height
  46526. * @param depth defines the new depth (1 by default)
  46527. */
  46528. updateSize(width: int, height: int, depth?: int): void;
  46529. /** @hidden */
  46530. _rebuild(): void;
  46531. /** @hidden */
  46532. _swapAndDie(target: InternalTexture): void;
  46533. /**
  46534. * Dispose the current allocated resources
  46535. */
  46536. dispose(): void;
  46537. }
  46538. }
  46539. declare module BABYLON {
  46540. /**
  46541. * This represents the required contract to create a new type of texture loader.
  46542. */
  46543. interface IInternalTextureLoader {
  46544. /**
  46545. * Defines wether the loader supports cascade loading the different faces.
  46546. */
  46547. supportCascades: boolean;
  46548. /**
  46549. * This returns if the loader support the current file information.
  46550. * @param extension defines the file extension of the file being loaded
  46551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46552. * @param fallback defines the fallback internal texture if any
  46553. * @param isBase64 defines whether the texture is encoded as a base64
  46554. * @param isBuffer defines whether the texture data are stored as a buffer
  46555. * @returns true if the loader can load the specified file
  46556. */
  46557. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46558. /**
  46559. * Transform the url before loading if required.
  46560. * @param rootUrl the url of the texture
  46561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46562. * @returns the transformed texture
  46563. */
  46564. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46565. /**
  46566. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46567. * @param rootUrl the url of the texture
  46568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46569. * @returns the fallback texture
  46570. */
  46571. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46572. /**
  46573. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46574. * @param data contains the texture data
  46575. * @param texture defines the BabylonJS internal texture
  46576. * @param createPolynomials will be true if polynomials have been requested
  46577. * @param onLoad defines the callback to trigger once the texture is ready
  46578. * @param onError defines the callback to trigger in case of error
  46579. */
  46580. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46581. /**
  46582. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46583. * @param data contains the texture data
  46584. * @param texture defines the BabylonJS internal texture
  46585. * @param callback defines the method to call once ready to upload
  46586. */
  46587. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46588. }
  46589. }
  46590. declare module BABYLON {
  46591. /**
  46592. * Internal interface used to track InternalTexture already bound to the GL context
  46593. */
  46594. interface IInternalTextureTracker {
  46595. /**
  46596. * Gets or set the previous tracker in the list
  46597. */
  46598. previous: Nullable<IInternalTextureTracker>;
  46599. /**
  46600. * Gets or set the next tracker in the list
  46601. */
  46602. next: Nullable<IInternalTextureTracker>;
  46603. }
  46604. /**
  46605. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46606. */
  46607. class DummyInternalTextureTracker {
  46608. /**
  46609. * Gets or set the previous tracker in the list
  46610. */
  46611. previous: Nullable<IInternalTextureTracker>;
  46612. /**
  46613. * Gets or set the next tracker in the list
  46614. */
  46615. next: Nullable<IInternalTextureTracker>;
  46616. }
  46617. }
  46618. declare module BABYLON {
  46619. /**
  46620. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46621. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46622. * You can then easily use it as a reflectionTexture on a flat surface.
  46623. * In case the surface is not a plane, please consider relying on reflection probes.
  46624. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46625. */
  46626. class MirrorTexture extends RenderTargetTexture {
  46627. private scene;
  46628. /**
  46629. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46630. * 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.
  46631. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46632. */
  46633. mirrorPlane: Plane;
  46634. /**
  46635. * Define the blur ratio used to blur the reflection if needed.
  46636. */
  46637. blurRatio: number;
  46638. /**
  46639. * Define the adaptive blur kernel used to blur the reflection if needed.
  46640. * This will autocompute the closest best match for the `blurKernel`
  46641. */
  46642. adaptiveBlurKernel: number;
  46643. /**
  46644. * Define the blur kernel used to blur the reflection if needed.
  46645. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46646. */
  46647. blurKernel: number;
  46648. /**
  46649. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46650. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46651. */
  46652. blurKernelX: number;
  46653. /**
  46654. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46655. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46656. */
  46657. blurKernelY: number;
  46658. private _autoComputeBlurKernel;
  46659. protected _onRatioRescale(): void;
  46660. private _updateGammaSpace;
  46661. private _imageProcessingConfigChangeObserver;
  46662. private _transformMatrix;
  46663. private _mirrorMatrix;
  46664. private _savedViewMatrix;
  46665. private _blurX;
  46666. private _blurY;
  46667. private _adaptiveBlurKernel;
  46668. private _blurKernelX;
  46669. private _blurKernelY;
  46670. private _blurRatio;
  46671. /**
  46672. * Instantiates a Mirror Texture.
  46673. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46674. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46675. * You can then easily use it as a reflectionTexture on a flat surface.
  46676. * In case the surface is not a plane, please consider relying on reflection probes.
  46677. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46678. * @param name
  46679. * @param size
  46680. * @param scene
  46681. * @param generateMipMaps
  46682. * @param type
  46683. * @param samplingMode
  46684. * @param generateDepthBuffer
  46685. */
  46686. constructor(name: string, size: number | {
  46687. width: number;
  46688. height: number;
  46689. } | {
  46690. ratio: number;
  46691. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46692. private _preparePostProcesses;
  46693. /**
  46694. * Clone the mirror texture.
  46695. * @returns the cloned texture
  46696. */
  46697. clone(): MirrorTexture;
  46698. /**
  46699. * Serialize the texture to a JSON representation you could use in Parse later on
  46700. * @returns the serialized JSON representation
  46701. */
  46702. serialize(): any;
  46703. /**
  46704. * Dispose the texture and release its associated resources.
  46705. */
  46706. dispose(): void;
  46707. }
  46708. }
  46709. declare module BABYLON {
  46710. /**
  46711. * Creation options of the multi render target texture.
  46712. */
  46713. interface IMultiRenderTargetOptions {
  46714. /**
  46715. * Define if the texture needs to create mip maps after render.
  46716. */
  46717. generateMipMaps?: boolean;
  46718. /**
  46719. * Define the types of all the draw buffers we want to create
  46720. */
  46721. types?: number[];
  46722. /**
  46723. * Define the sampling modes of all the draw buffers we want to create
  46724. */
  46725. samplingModes?: number[];
  46726. /**
  46727. * Define if a depth buffer is required
  46728. */
  46729. generateDepthBuffer?: boolean;
  46730. /**
  46731. * Define if a stencil buffer is required
  46732. */
  46733. generateStencilBuffer?: boolean;
  46734. /**
  46735. * Define if a depth texture is required instead of a depth buffer
  46736. */
  46737. generateDepthTexture?: boolean;
  46738. /**
  46739. * Define the number of desired draw buffers
  46740. */
  46741. textureCount?: number;
  46742. /**
  46743. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46744. */
  46745. doNotChangeAspectRatio?: boolean;
  46746. /**
  46747. * Define the default type of the buffers we are creating
  46748. */
  46749. defaultType?: number;
  46750. }
  46751. /**
  46752. * A multi render target, like a render target provides the ability to render to a texture.
  46753. * Unlike the render target, it can render to several draw buffers in one draw.
  46754. * This is specially interesting in deferred rendering or for any effects requiring more than
  46755. * just one color from a single pass.
  46756. */
  46757. class MultiRenderTarget extends RenderTargetTexture {
  46758. private _internalTextures;
  46759. private _textures;
  46760. private _multiRenderTargetOptions;
  46761. /**
  46762. * Get if draw buffers are currently supported by the used hardware and browser.
  46763. */
  46764. readonly isSupported: boolean;
  46765. /**
  46766. * Get the list of textures generated by the multi render target.
  46767. */
  46768. readonly textures: Texture[];
  46769. /**
  46770. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46771. */
  46772. readonly depthTexture: Texture;
  46773. /**
  46774. * Set the wrapping mode on U of all the textures we are rendering to.
  46775. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46776. */
  46777. wrapU: number;
  46778. /**
  46779. * Set the wrapping mode on V of all the textures we are rendering to.
  46780. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46781. */
  46782. wrapV: number;
  46783. /**
  46784. * Instantiate a new multi render target texture.
  46785. * A multi render target, like a render target provides the ability to render to a texture.
  46786. * Unlike the render target, it can render to several draw buffers in one draw.
  46787. * This is specially interesting in deferred rendering or for any effects requiring more than
  46788. * just one color from a single pass.
  46789. * @param name Define the name of the texture
  46790. * @param size Define the size of the buffers to render to
  46791. * @param count Define the number of target we are rendering into
  46792. * @param scene Define the scene the texture belongs to
  46793. * @param options Define the options used to create the multi render target
  46794. */
  46795. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46796. /** @hidden */
  46797. _rebuild(): void;
  46798. private _createInternalTextures;
  46799. private _createTextures;
  46800. /**
  46801. * Define the number of samples used if MSAA is enabled.
  46802. */
  46803. samples: number;
  46804. /**
  46805. * Resize all the textures in the multi render target.
  46806. * Be carrefull as it will recreate all the data in the new texture.
  46807. * @param size Define the new size
  46808. */
  46809. resize(size: any): void;
  46810. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46811. /**
  46812. * Dispose the render targets and their associated resources
  46813. */
  46814. dispose(): void;
  46815. /**
  46816. * Release all the underlying texture used as draw buffers.
  46817. */
  46818. releaseInternalTextures(): void;
  46819. }
  46820. }
  46821. declare module BABYLON {
  46822. /**
  46823. * Raw cube texture where the raw buffers are passed in
  46824. */
  46825. class RawCubeTexture extends CubeTexture {
  46826. /**
  46827. * Creates a cube texture where the raw buffers are passed in.
  46828. * @param scene defines the scene the texture is attached to
  46829. * @param data defines the array of data to use to create each face
  46830. * @param size defines the size of the textures
  46831. * @param format defines the format of the data
  46832. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  46833. * @param generateMipMaps defines if the engine should generate the mip levels
  46834. * @param invertY defines if data must be stored with Y axis inverted
  46835. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  46836. * @param compression defines the compression used (null by default)
  46837. */
  46838. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46839. /**
  46840. * Updates the raw cube texture.
  46841. * @param data defines the data to store
  46842. * @param format defines the data format
  46843. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46844. * @param invertY defines if data must be stored with Y axis inverted
  46845. * @param compression defines the compression used (null by default)
  46846. * @param level defines which level of the texture to update
  46847. */
  46848. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46849. /**
  46850. * Updates a raw cube texture with RGBD encoded data.
  46851. * @param data defines the array of data [mipmap][face] to use to create each face
  46852. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46853. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46854. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46855. * @returns a promsie that resolves when the operation is complete
  46856. */
  46857. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46858. /**
  46859. * Clones the raw cube texture.
  46860. * @return a new cube texture
  46861. */
  46862. clone(): CubeTexture;
  46863. /** @hidden */
  46864. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46865. }
  46866. }
  46867. declare module BABYLON {
  46868. /**
  46869. * Raw texture can help creating a texture directly from an array of data.
  46870. * This can be super useful if you either get the data from an uncompressed source or
  46871. * if you wish to create your texture pixel by pixel.
  46872. */
  46873. class RawTexture extends Texture {
  46874. /**
  46875. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46876. */
  46877. format: number;
  46878. private _engine;
  46879. /**
  46880. * Instantiates a new RawTexture.
  46881. * Raw texture can help creating a texture directly from an array of data.
  46882. * This can be super useful if you either get the data from an uncompressed source or
  46883. * if you wish to create your texture pixel by pixel.
  46884. * @param data define the array of data to use to create the texture
  46885. * @param width define the width of the texture
  46886. * @param height define the height of the texture
  46887. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46888. * @param scene define the scene the texture belongs to
  46889. * @param generateMipMaps define whether mip maps should be generated or not
  46890. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46891. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46892. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46893. */
  46894. constructor(data: ArrayBufferView, width: number, height: number,
  46895. /**
  46896. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46897. */
  46898. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46899. /**
  46900. * Updates the texture underlying data.
  46901. * @param data Define the new data of the texture
  46902. */
  46903. update(data: ArrayBufferView): void;
  46904. /**
  46905. * Creates a luminance texture from some data.
  46906. * @param data Define the texture data
  46907. * @param width Define the width of the texture
  46908. * @param height Define the height of the texture
  46909. * @param scene Define the scene the texture belongs to
  46910. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46911. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46912. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46913. * @returns the luminance texture
  46914. */
  46915. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46916. /**
  46917. * Creates a luminance alpha texture from some data.
  46918. * @param data Define the texture data
  46919. * @param width Define the width of the texture
  46920. * @param height Define the height of the texture
  46921. * @param scene Define the scene the texture belongs to
  46922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46925. * @returns the luminance alpha texture
  46926. */
  46927. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46928. /**
  46929. * Creates an alpha texture from some data.
  46930. * @param data Define the texture data
  46931. * @param width Define the width of the texture
  46932. * @param height Define the height of the texture
  46933. * @param scene Define the scene the texture belongs to
  46934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46937. * @returns the alpha texture
  46938. */
  46939. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46940. /**
  46941. * Creates a RGB texture from some data.
  46942. * @param data Define the texture data
  46943. * @param width Define the width of the texture
  46944. * @param height Define the height of the texture
  46945. * @param scene Define the scene the texture belongs to
  46946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46949. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46950. * @returns the RGB alpha texture
  46951. */
  46952. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46953. /**
  46954. * Creates a RGBA texture from some data.
  46955. * @param data Define the texture data
  46956. * @param width Define the width of the texture
  46957. * @param height Define the height of the texture
  46958. * @param scene Define the scene the texture belongs to
  46959. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46960. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46961. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46962. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46963. * @returns the RGBA texture
  46964. */
  46965. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46966. /**
  46967. * Creates a R texture from some data.
  46968. * @param data Define the texture data
  46969. * @param width Define the width of the texture
  46970. * @param height Define the height of the texture
  46971. * @param scene Define the scene the texture belongs to
  46972. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46973. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46974. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46975. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46976. * @returns the R texture
  46977. */
  46978. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46979. }
  46980. }
  46981. declare module BABYLON {
  46982. /**
  46983. * Class used to store 3D textures containing user data
  46984. */
  46985. class RawTexture3D extends Texture {
  46986. /** Gets or sets the texture format to use */
  46987. format: number;
  46988. private _engine;
  46989. /**
  46990. * Create a new RawTexture3D
  46991. * @param data defines the data of the texture
  46992. * @param width defines the width of the texture
  46993. * @param height defines the height of the texture
  46994. * @param depth defines the depth of the texture
  46995. * @param format defines the texture format to use
  46996. * @param scene defines the hosting scene
  46997. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46998. * @param invertY defines if texture must be stored with Y axis inverted
  46999. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47000. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47001. */
  47002. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47003. /** Gets or sets the texture format to use */
  47004. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47005. /**
  47006. * Update the texture with new data
  47007. * @param data defines the data to store in the texture
  47008. */
  47009. update(data: ArrayBufferView): void;
  47010. }
  47011. }
  47012. declare module BABYLON {
  47013. /**
  47014. * Creates a refraction texture used by refraction channel of the standard material.
  47015. * It is like a mirror but to see through a material.
  47016. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47017. */
  47018. class RefractionTexture extends RenderTargetTexture {
  47019. /**
  47020. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47021. * 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.
  47022. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47023. */
  47024. refractionPlane: Plane;
  47025. /**
  47026. * Define how deep under the surface we should see.
  47027. */
  47028. depth: number;
  47029. /**
  47030. * Creates a refraction texture used by refraction channel of the standard material.
  47031. * It is like a mirror but to see through a material.
  47032. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47033. * @param name Define the texture name
  47034. * @param size Define the size of the underlying texture
  47035. * @param scene Define the scene the refraction belongs to
  47036. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47037. */
  47038. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47039. /**
  47040. * Clone the refraction texture.
  47041. * @returns the cloned texture
  47042. */
  47043. clone(): RefractionTexture;
  47044. /**
  47045. * Serialize the texture to a JSON representation you could use in Parse later on
  47046. * @returns the serialized JSON representation
  47047. */
  47048. serialize(): any;
  47049. }
  47050. }
  47051. declare module BABYLON {
  47052. /**
  47053. * This Helps creating a texture that will be created from a camera in your scene.
  47054. * It is basically a dynamic texture that could be used to create special effects for instance.
  47055. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47056. */
  47057. class RenderTargetTexture extends Texture {
  47058. isCube: boolean;
  47059. /**
  47060. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47061. */
  47062. static readonly REFRESHRATE_RENDER_ONCE: number;
  47063. /**
  47064. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47065. */
  47066. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47067. /**
  47068. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47069. * the central point of your effect and can save a lot of performances.
  47070. */
  47071. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47072. /**
  47073. * Use this predicate to dynamically define the list of mesh you want to render.
  47074. * If set, the renderList property will be overwritten.
  47075. */
  47076. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47077. private _renderList;
  47078. /**
  47079. * Use this list to define the list of mesh you want to render.
  47080. */
  47081. renderList: Nullable<Array<AbstractMesh>>;
  47082. private _hookArray;
  47083. /**
  47084. * Define if particles should be rendered in your texture.
  47085. */
  47086. renderParticles: boolean;
  47087. /**
  47088. * Define if sprites should be rendered in your texture.
  47089. */
  47090. renderSprites: boolean;
  47091. /**
  47092. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47093. */
  47094. coordinatesMode: number;
  47095. /**
  47096. * Define the camera used to render the texture.
  47097. */
  47098. activeCamera: Nullable<Camera>;
  47099. /**
  47100. * Override the render function of the texture with your own one.
  47101. */
  47102. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47103. /**
  47104. * Define if camera post processes should be use while rendering the texture.
  47105. */
  47106. useCameraPostProcesses: boolean;
  47107. /**
  47108. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47109. */
  47110. ignoreCameraViewport: boolean;
  47111. private _postProcessManager;
  47112. private _postProcesses;
  47113. private _resizeObserver;
  47114. /**
  47115. * An event triggered when the texture is unbind.
  47116. */
  47117. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47118. /**
  47119. * An event triggered when the texture is unbind.
  47120. */
  47121. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47122. private _onAfterUnbindObserver;
  47123. /**
  47124. * Set a after unbind callback in the texture.
  47125. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47126. */
  47127. onAfterUnbind: () => void;
  47128. /**
  47129. * An event triggered before rendering the texture
  47130. */
  47131. onBeforeRenderObservable: Observable<number>;
  47132. private _onBeforeRenderObserver;
  47133. /**
  47134. * Set a before render callback in the texture.
  47135. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47136. */
  47137. onBeforeRender: (faceIndex: number) => void;
  47138. /**
  47139. * An event triggered after rendering the texture
  47140. */
  47141. onAfterRenderObservable: Observable<number>;
  47142. private _onAfterRenderObserver;
  47143. /**
  47144. * Set a after render callback in the texture.
  47145. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47146. */
  47147. onAfterRender: (faceIndex: number) => void;
  47148. /**
  47149. * An event triggered after the texture clear
  47150. */
  47151. onClearObservable: Observable<Engine>;
  47152. private _onClearObserver;
  47153. /**
  47154. * Set a clear callback in the texture.
  47155. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47156. */
  47157. onClear: (Engine: Engine) => void;
  47158. /**
  47159. * Define the clear color of the Render Target if it should be different from the scene.
  47160. */
  47161. clearColor: Color4;
  47162. protected _size: number | {
  47163. width: number;
  47164. height: number;
  47165. };
  47166. protected _initialSizeParameter: number | {
  47167. width: number;
  47168. height: number;
  47169. } | {
  47170. ratio: number;
  47171. };
  47172. protected _sizeRatio: Nullable<number>;
  47173. /** @hidden */
  47174. _generateMipMaps: boolean;
  47175. protected _renderingManager: RenderingManager;
  47176. /** @hidden */
  47177. _waitingRenderList: string[];
  47178. protected _doNotChangeAspectRatio: boolean;
  47179. protected _currentRefreshId: number;
  47180. protected _refreshRate: number;
  47181. protected _textureMatrix: Matrix;
  47182. protected _samples: number;
  47183. protected _renderTargetOptions: RenderTargetCreationOptions;
  47184. /**
  47185. * Gets render target creation options that were used.
  47186. */
  47187. readonly renderTargetOptions: RenderTargetCreationOptions;
  47188. protected _engine: Engine;
  47189. protected _onRatioRescale(): void;
  47190. /**
  47191. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47192. * It must define where the camera used to render the texture is set
  47193. */
  47194. boundingBoxPosition: Vector3;
  47195. private _boundingBoxSize;
  47196. /**
  47197. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47198. * When defined, the cubemap will switch to local mode
  47199. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47200. * @example https://www.babylonjs-playground.com/#RNASML
  47201. */
  47202. boundingBoxSize: Vector3;
  47203. /**
  47204. * In case the RTT has been created with a depth texture, get the associated
  47205. * depth texture.
  47206. * Otherwise, return null.
  47207. */
  47208. depthStencilTexture: Nullable<InternalTexture>;
  47209. /**
  47210. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47211. * or used a shadow, depth texture...
  47212. * @param name The friendly name of the texture
  47213. * @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)
  47214. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47215. * @param generateMipMaps True if mip maps need to be generated after render.
  47216. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47217. * @param type The type of the buffer in the RTT (int, half float, float...)
  47218. * @param isCube True if a cube texture needs to be created
  47219. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47220. * @param generateDepthBuffer True to generate a depth buffer
  47221. * @param generateStencilBuffer True to generate a stencil buffer
  47222. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47223. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47224. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47225. */
  47226. constructor(name: string, size: number | {
  47227. width: number;
  47228. height: number;
  47229. } | {
  47230. ratio: number;
  47231. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47232. /**
  47233. * Creates a depth stencil texture.
  47234. * This is only available in WebGL 2 or with the depth texture extension available.
  47235. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47236. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47237. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47238. */
  47239. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47240. private _processSizeParameter;
  47241. /**
  47242. * Define the number of samples to use in case of MSAA.
  47243. * It defaults to one meaning no MSAA has been enabled.
  47244. */
  47245. samples: number;
  47246. /**
  47247. * Resets the refresh counter of the texture and start bak from scratch.
  47248. * Could be usefull to regenerate the texture if it is setup to render only once.
  47249. */
  47250. resetRefreshCounter(): void;
  47251. /**
  47252. * Define the refresh rate of the texture or the rendering frequency.
  47253. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47254. */
  47255. refreshRate: number;
  47256. /**
  47257. * Adds a post process to the render target rendering passes.
  47258. * @param postProcess define the post process to add
  47259. */
  47260. addPostProcess(postProcess: PostProcess): void;
  47261. /**
  47262. * Clear all the post processes attached to the render target
  47263. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47264. */
  47265. clearPostProcesses(dispose?: boolean): void;
  47266. /**
  47267. * Remove one of the post process from the list of attached post processes to the texture
  47268. * @param postProcess define the post process to remove from the list
  47269. */
  47270. removePostProcess(postProcess: PostProcess): void;
  47271. /** @hidden */
  47272. _shouldRender(): boolean;
  47273. /**
  47274. * Gets the actual render size of the texture.
  47275. * @returns the width of the render size
  47276. */
  47277. getRenderSize(): number;
  47278. /**
  47279. * Gets the actual render width of the texture.
  47280. * @returns the width of the render size
  47281. */
  47282. getRenderWidth(): number;
  47283. /**
  47284. * Gets the actual render height of the texture.
  47285. * @returns the height of the render size
  47286. */
  47287. getRenderHeight(): number;
  47288. /**
  47289. * Get if the texture can be rescaled or not.
  47290. */
  47291. readonly canRescale: boolean;
  47292. /**
  47293. * Resize the texture using a ratio.
  47294. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47295. */
  47296. scale(ratio: number): void;
  47297. /**
  47298. * Get the texture reflection matrix used to rotate/transform the reflection.
  47299. * @returns the reflection matrix
  47300. */
  47301. getReflectionTextureMatrix(): Matrix;
  47302. /**
  47303. * Resize the texture to a new desired size.
  47304. * Be carrefull as it will recreate all the data in the new texture.
  47305. * @param size Define the new size. It can be:
  47306. * - a number for squared texture,
  47307. * - an object containing { width: number, height: number }
  47308. * - or an object containing a ratio { ratio: number }
  47309. */
  47310. resize(size: number | {
  47311. width: number;
  47312. height: number;
  47313. } | {
  47314. ratio: number;
  47315. }): void;
  47316. /**
  47317. * Renders all the objects from the render list into the texture.
  47318. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47319. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47320. */
  47321. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47322. private _bestReflectionRenderTargetDimension;
  47323. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47324. private renderToTarget;
  47325. /**
  47326. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47327. * This allowed control for front to back rendering or reversly depending of the special needs.
  47328. *
  47329. * @param renderingGroupId The rendering group id corresponding to its index
  47330. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47331. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47332. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47333. */
  47334. 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;
  47335. /**
  47336. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47337. *
  47338. * @param renderingGroupId The rendering group id corresponding to its index
  47339. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47340. */
  47341. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47342. /**
  47343. * Clones the texture.
  47344. * @returns the cloned texture
  47345. */
  47346. clone(): RenderTargetTexture;
  47347. /**
  47348. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47349. * @returns The JSON representation of the texture
  47350. */
  47351. serialize(): any;
  47352. /**
  47353. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47354. */
  47355. disposeFramebufferObjects(): void;
  47356. /**
  47357. * Dispose the texture and release its associated resources.
  47358. */
  47359. dispose(): void;
  47360. /** @hidden */
  47361. _rebuild(): void;
  47362. /**
  47363. * Clear the info related to rendering groups preventing retention point in material dispose.
  47364. */
  47365. freeRenderingGroups(): void;
  47366. }
  47367. }
  47368. declare module BABYLON {
  47369. /**
  47370. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47371. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47372. */
  47373. class Texture extends BaseTexture {
  47374. /** nearest is mag = nearest and min = nearest and mip = linear */
  47375. static readonly NEAREST_SAMPLINGMODE: number;
  47376. /** nearest is mag = nearest and min = nearest and mip = linear */
  47377. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47379. static readonly BILINEAR_SAMPLINGMODE: number;
  47380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47381. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47382. /** Trilinear is mag = linear and min = linear and mip = linear */
  47383. static readonly TRILINEAR_SAMPLINGMODE: number;
  47384. /** Trilinear is mag = linear and min = linear and mip = linear */
  47385. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47386. /** mag = nearest and min = nearest and mip = nearest */
  47387. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47388. /** mag = nearest and min = linear and mip = nearest */
  47389. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47390. /** mag = nearest and min = linear and mip = linear */
  47391. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47392. /** mag = nearest and min = linear and mip = none */
  47393. static readonly NEAREST_LINEAR: number;
  47394. /** mag = nearest and min = nearest and mip = none */
  47395. static readonly NEAREST_NEAREST: number;
  47396. /** mag = linear and min = nearest and mip = nearest */
  47397. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47398. /** mag = linear and min = nearest and mip = linear */
  47399. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47400. /** mag = linear and min = linear and mip = none */
  47401. static readonly LINEAR_LINEAR: number;
  47402. /** mag = linear and min = nearest and mip = none */
  47403. static readonly LINEAR_NEAREST: number;
  47404. /** Explicit coordinates mode */
  47405. static readonly EXPLICIT_MODE: number;
  47406. /** Spherical coordinates mode */
  47407. static readonly SPHERICAL_MODE: number;
  47408. /** Planar coordinates mode */
  47409. static readonly PLANAR_MODE: number;
  47410. /** Cubic coordinates mode */
  47411. static readonly CUBIC_MODE: number;
  47412. /** Projection coordinates mode */
  47413. static readonly PROJECTION_MODE: number;
  47414. /** Inverse Cubic coordinates mode */
  47415. static readonly SKYBOX_MODE: number;
  47416. /** Inverse Cubic coordinates mode */
  47417. static readonly INVCUBIC_MODE: number;
  47418. /** Equirectangular coordinates mode */
  47419. static readonly EQUIRECTANGULAR_MODE: number;
  47420. /** Equirectangular Fixed coordinates mode */
  47421. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47422. /** Equirectangular Fixed Mirrored coordinates mode */
  47423. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47424. /** Texture is not repeating outside of 0..1 UVs */
  47425. static readonly CLAMP_ADDRESSMODE: number;
  47426. /** Texture is repeating outside of 0..1 UVs */
  47427. static readonly WRAP_ADDRESSMODE: number;
  47428. /** Texture is repeating and mirrored */
  47429. static readonly MIRROR_ADDRESSMODE: number;
  47430. /**
  47431. * 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
  47432. */
  47433. static UseSerializedUrlIfAny: boolean;
  47434. /**
  47435. * Define the url of the texture.
  47436. */
  47437. url: Nullable<string>;
  47438. /**
  47439. * Define an offset on the texture to offset the u coordinates of the UVs
  47440. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47441. */
  47442. uOffset: number;
  47443. /**
  47444. * Define an offset on the texture to offset the v coordinates of the UVs
  47445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47446. */
  47447. vOffset: number;
  47448. /**
  47449. * Define an offset on the texture to scale the u coordinates of the UVs
  47450. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47451. */
  47452. uScale: number;
  47453. /**
  47454. * Define an offset on the texture to scale the v coordinates of the UVs
  47455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47456. */
  47457. vScale: number;
  47458. /**
  47459. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47460. * @see http://doc.babylonjs.com/how_to/more_materials
  47461. */
  47462. uAng: number;
  47463. /**
  47464. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47465. * @see http://doc.babylonjs.com/how_to/more_materials
  47466. */
  47467. vAng: number;
  47468. /**
  47469. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47470. * @see http://doc.babylonjs.com/how_to/more_materials
  47471. */
  47472. wAng: number;
  47473. /**
  47474. * Defines the center of rotation (U)
  47475. */
  47476. uRotationCenter: number;
  47477. /**
  47478. * Defines the center of rotation (V)
  47479. */
  47480. vRotationCenter: number;
  47481. /**
  47482. * Defines the center of rotation (W)
  47483. */
  47484. wRotationCenter: number;
  47485. /**
  47486. * Are mip maps generated for this texture or not.
  47487. */
  47488. readonly noMipmap: boolean;
  47489. private _noMipmap;
  47490. /** @hidden */
  47491. _invertY: boolean;
  47492. private _rowGenerationMatrix;
  47493. private _cachedTextureMatrix;
  47494. private _projectionModeMatrix;
  47495. private _t0;
  47496. private _t1;
  47497. private _t2;
  47498. private _cachedUOffset;
  47499. private _cachedVOffset;
  47500. private _cachedUScale;
  47501. private _cachedVScale;
  47502. private _cachedUAng;
  47503. private _cachedVAng;
  47504. private _cachedWAng;
  47505. private _cachedProjectionMatrixId;
  47506. private _cachedCoordinatesMode;
  47507. /** @hidden */
  47508. _samplingMode: number;
  47509. /** @hidden */
  47510. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47511. private _deleteBuffer;
  47512. protected _format: Nullable<number>;
  47513. private _delayedOnLoad;
  47514. private _delayedOnError;
  47515. /**
  47516. * Observable triggered once the texture has been loaded.
  47517. */
  47518. onLoadObservable: Observable<Texture>;
  47519. protected _isBlocking: boolean;
  47520. /**
  47521. * Is the texture preventing material to render while loading.
  47522. * If false, a default texture will be used instead of the loading one during the preparation step.
  47523. */
  47524. isBlocking: boolean;
  47525. /**
  47526. * Get the current sampling mode associated with the texture.
  47527. */
  47528. readonly samplingMode: number;
  47529. /**
  47530. * Instantiates a new texture.
  47531. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47532. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47533. * @param url define the url of the picture to load as a texture
  47534. * @param scene define the scene the texture will belong to
  47535. * @param noMipmap define if the texture will require mip maps or not
  47536. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47537. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47538. * @param onLoad define a callback triggered when the texture has been loaded
  47539. * @param onError define a callback triggered when an error occurred during the loading session
  47540. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47541. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47542. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47543. */
  47544. 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);
  47545. /**
  47546. * Update the url (and optional buffer) of this texture if url was null during construction.
  47547. * @param url the url of the texture
  47548. * @param buffer the buffer of the texture (defaults to null)
  47549. */
  47550. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47551. /**
  47552. * Finish the loading sequence of a texture flagged as delayed load.
  47553. * @hidden
  47554. */
  47555. delayLoad(): void;
  47556. /**
  47557. * Update the sampling mode of the texture.
  47558. * Default is Trilinear mode.
  47559. *
  47560. * | Value | Type | Description |
  47561. * | ----- | ------------------ | ----------- |
  47562. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47563. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47564. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47565. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47566. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47567. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47568. * | 7 | NEAREST_LINEAR | |
  47569. * | 8 | NEAREST_NEAREST | |
  47570. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47571. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47572. * | 11 | LINEAR_LINEAR | |
  47573. * | 12 | LINEAR_NEAREST | |
  47574. *
  47575. * > _mag_: magnification filter (close to the viewer)
  47576. * > _min_: minification filter (far from the viewer)
  47577. * > _mip_: filter used between mip map levels
  47578. *@param samplingMode Define the new sampling mode of the texture
  47579. */
  47580. updateSamplingMode(samplingMode: number): void;
  47581. private _prepareRowForTextureGeneration;
  47582. /**
  47583. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47584. * @returns the transform matrix of the texture.
  47585. */
  47586. getTextureMatrix(): Matrix;
  47587. /**
  47588. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47589. * @returns The reflection texture transform
  47590. */
  47591. getReflectionTextureMatrix(): Matrix;
  47592. /**
  47593. * Clones the texture.
  47594. * @returns the cloned texture
  47595. */
  47596. clone(): Texture;
  47597. /**
  47598. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47599. * @returns The JSON representation of the texture
  47600. */
  47601. serialize(): any;
  47602. /**
  47603. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47604. * @returns "Texture"
  47605. */
  47606. getClassName(): string;
  47607. /**
  47608. * Dispose the texture and release its associated resources.
  47609. */
  47610. dispose(): void;
  47611. /**
  47612. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47613. * @param parsedTexture Define the JSON representation of the texture
  47614. * @param scene Define the scene the parsed texture should be instantiated in
  47615. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47616. * @returns The parsed texture if successful
  47617. */
  47618. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47619. /**
  47620. * Creates a texture from its base 64 representation.
  47621. * @param data Define the base64 payload without the data: prefix
  47622. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47623. * @param scene Define the scene the texture should belong to
  47624. * @param noMipmap Forces the texture to not create mip map information if true
  47625. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47626. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47627. * @param onLoad define a callback triggered when the texture has been loaded
  47628. * @param onError define a callback triggered when an error occurred during the loading session
  47629. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47630. * @returns the created texture
  47631. */
  47632. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47633. /**
  47634. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47635. * @param data Define the base64 payload without the data: prefix
  47636. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47637. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47638. * @param scene Define the scene the texture should belong to
  47639. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47640. * @param noMipmap Forces the texture to not create mip map information if true
  47641. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47642. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47643. * @param onLoad define a callback triggered when the texture has been loaded
  47644. * @param onError define a callback triggered when an error occurred during the loading session
  47645. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47646. * @returns the created texture
  47647. */
  47648. 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;
  47649. }
  47650. }
  47651. declare module BABYLON {
  47652. /**
  47653. * Settings for finer control over video usage
  47654. */
  47655. interface VideoTextureSettings {
  47656. /**
  47657. * Applies `autoplay` to video, if specified
  47658. */
  47659. autoPlay?: boolean;
  47660. /**
  47661. * Applies `loop` to video, if specified
  47662. */
  47663. loop?: boolean;
  47664. /**
  47665. * Automatically updates internal texture from video at every frame in the render loop
  47666. */
  47667. autoUpdateTexture: boolean;
  47668. /**
  47669. * Image src displayed during the video loading or until the user interacts with the video.
  47670. */
  47671. poster?: string;
  47672. }
  47673. /**
  47674. * If you want to display a video in your scene, this is the special texture for that.
  47675. * This special texture works similar to other textures, with the exception of a few parameters.
  47676. * @see https://doc.babylonjs.com/how_to/video_texture
  47677. */
  47678. class VideoTexture extends Texture {
  47679. /**
  47680. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47681. */
  47682. readonly autoUpdateTexture: boolean;
  47683. /**
  47684. * The video instance used by the texture internally
  47685. */
  47686. readonly video: HTMLVideoElement;
  47687. private _onUserActionRequestedObservable;
  47688. /**
  47689. * Event triggerd when a dom action is required by the user to play the video.
  47690. * This happens due to recent changes in browser policies preventing video to auto start.
  47691. */
  47692. readonly onUserActionRequestedObservable: Observable<Texture>;
  47693. private _generateMipMaps;
  47694. private _engine;
  47695. private _stillImageCaptured;
  47696. private _poster;
  47697. /**
  47698. * Creates a video texture.
  47699. * If you want to display a video in your scene, this is the special texture for that.
  47700. * This special texture works similar to other textures, with the exception of a few parameters.
  47701. * @see https://doc.babylonjs.com/how_to/video_texture
  47702. * @param name optional name, will detect from video source, if not defined
  47703. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47704. * @param scene is obviously the current scene.
  47705. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47706. * @param invertY is false by default but can be used to invert video on Y axis
  47707. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47708. * @param settings allows finer control over video usage
  47709. */
  47710. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47711. private _getName;
  47712. private _getVideo;
  47713. private _createInternalTexture;
  47714. private reset;
  47715. /**
  47716. * @hidden Internal method to initiate `update`.
  47717. */
  47718. _rebuild(): void;
  47719. /**
  47720. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47721. */
  47722. update(): void;
  47723. /**
  47724. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47725. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47726. */
  47727. updateTexture(isVisible: boolean): void;
  47728. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47729. /**
  47730. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47731. * @param url New url.
  47732. */
  47733. updateURL(url: string): void;
  47734. /**
  47735. * Dispose the texture and release its associated resources.
  47736. */
  47737. dispose(): void;
  47738. /**
  47739. * Creates a video texture straight from your WebCam video feed.
  47740. * @param scene Define the scene the texture should be created in
  47741. * @param onReady Define a callback to triggered once the texture will be ready
  47742. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47743. */
  47744. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47745. minWidth: number;
  47746. maxWidth: number;
  47747. minHeight: number;
  47748. maxHeight: number;
  47749. deviceId: string;
  47750. }): void;
  47751. }
  47752. }
  47753. declare var DracoDecoderModule: any;
  47754. declare var WebAssembly: any;
  47755. declare module BABYLON {
  47756. /**
  47757. * Configuration for Draco compression
  47758. */
  47759. interface IDracoCompressionConfiguration {
  47760. /**
  47761. * Configuration for the decoder.
  47762. */
  47763. decoder?: {
  47764. /**
  47765. * The url to the WebAssembly module.
  47766. */
  47767. wasmUrl?: string;
  47768. /**
  47769. * The url to the WebAssembly binary.
  47770. */
  47771. wasmBinaryUrl?: string;
  47772. /**
  47773. * The url to the fallback JavaScript module.
  47774. */
  47775. fallbackUrl?: string;
  47776. };
  47777. }
  47778. /**
  47779. * Draco compression (https://google.github.io/draco/)
  47780. *
  47781. * This class wraps the Draco module.
  47782. *
  47783. * **Encoder**
  47784. *
  47785. * The encoder is not currently implemented.
  47786. *
  47787. * **Decoder**
  47788. *
  47789. * 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.
  47790. *
  47791. * To update the configuration, use the following code:
  47792. * ```javascript
  47793. * BABYLON.DracoCompression.Configuration = {
  47794. * decoder: {
  47795. * wasmUrl: "<url to the WebAssembly library>",
  47796. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47797. * fallbackUrl: "<url to the fallback JavaScript library>",
  47798. * }
  47799. * };
  47800. * ```
  47801. *
  47802. * 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.
  47803. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47804. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47805. *
  47806. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47807. * ```javascript
  47808. * var dracoCompression = new BABYLON.DracoCompression();
  47809. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47810. * [BABYLON.VertexBuffer.PositionKind]: 0
  47811. * });
  47812. * ```
  47813. *
  47814. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47815. */
  47816. class DracoCompression implements IDisposable {
  47817. private static _DecoderModulePromise;
  47818. /**
  47819. * The configuration. Defaults to the following urls:
  47820. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47821. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47822. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47823. */
  47824. static Configuration: IDracoCompressionConfiguration;
  47825. /**
  47826. * Returns true if the decoder is available.
  47827. */
  47828. static readonly DecoderAvailable: boolean;
  47829. /**
  47830. * Constructor
  47831. */
  47832. constructor();
  47833. /**
  47834. * Stop all async operations and release resources.
  47835. */
  47836. dispose(): void;
  47837. /**
  47838. * Decode Draco compressed mesh data to vertex data.
  47839. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47840. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47841. * @returns A promise that resolves with the decoded vertex data
  47842. */
  47843. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47844. [kind: string]: number;
  47845. }): Promise<VertexData>;
  47846. private static _GetDecoderModule;
  47847. private static _LoadScriptAsync;
  47848. private static _LoadFileAsync;
  47849. }
  47850. }
  47851. declare module BABYLON {
  47852. /** @hidden */
  47853. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47854. private _useDeltaForWorldStep;
  47855. world: any;
  47856. name: string;
  47857. private _physicsMaterials;
  47858. private _fixedTimeStep;
  47859. BJSCANNON: any;
  47860. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47861. setGravity(gravity: Vector3): void;
  47862. setTimeStep(timeStep: number): void;
  47863. getTimeStep(): number;
  47864. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47865. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47866. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47867. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47868. private _processChildMeshes;
  47869. removePhysicsBody(impostor: PhysicsImpostor): void;
  47870. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47871. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47872. private _addMaterial;
  47873. private _checkWithEpsilon;
  47874. private _createShape;
  47875. private _createHeightmap;
  47876. private _minus90X;
  47877. private _plus90X;
  47878. private _tmpPosition;
  47879. private _tmpDeltaPosition;
  47880. private _tmpUnityRotation;
  47881. private _updatePhysicsBodyTransformation;
  47882. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47883. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47884. isSupported(): boolean;
  47885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47890. getBodyMass(impostor: PhysicsImpostor): number;
  47891. getBodyFriction(impostor: PhysicsImpostor): number;
  47892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47893. getBodyRestitution(impostor: PhysicsImpostor): number;
  47894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47895. sleepBody(impostor: PhysicsImpostor): void;
  47896. wakeUpBody(impostor: PhysicsImpostor): void;
  47897. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47898. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47899. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47900. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47901. getRadius(impostor: PhysicsImpostor): number;
  47902. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47903. dispose(): void;
  47904. private _extendNamespace;
  47905. }
  47906. }
  47907. declare module BABYLON {
  47908. /** @hidden */
  47909. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47910. world: any;
  47911. name: string;
  47912. BJSOIMO: any;
  47913. constructor(iterations?: number);
  47914. setGravity(gravity: Vector3): void;
  47915. setTimeStep(timeStep: number): void;
  47916. getTimeStep(): number;
  47917. private _tmpImpostorsArray;
  47918. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47919. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47920. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47921. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47922. private _tmpPositionVector;
  47923. removePhysicsBody(impostor: PhysicsImpostor): void;
  47924. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47925. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47926. isSupported(): boolean;
  47927. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47928. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47929. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47930. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47931. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47932. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47933. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47934. getBodyMass(impostor: PhysicsImpostor): number;
  47935. getBodyFriction(impostor: PhysicsImpostor): number;
  47936. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47937. getBodyRestitution(impostor: PhysicsImpostor): number;
  47938. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47939. sleepBody(impostor: PhysicsImpostor): void;
  47940. wakeUpBody(impostor: PhysicsImpostor): void;
  47941. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47942. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47943. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47945. getRadius(impostor: PhysicsImpostor): number;
  47946. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47947. dispose(): void;
  47948. }
  47949. }
  47950. declare module BABYLON {
  47951. /**
  47952. * Particle emitter emitting particles from the inside of a box.
  47953. * It emits the particles randomly between 2 given directions.
  47954. */
  47955. class BoxParticleEmitter implements IParticleEmitterType {
  47956. /**
  47957. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47958. */
  47959. direction1: Vector3;
  47960. /**
  47961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47962. */
  47963. direction2: Vector3;
  47964. /**
  47965. * 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.
  47966. */
  47967. minEmitBox: Vector3;
  47968. /**
  47969. * 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.
  47970. */
  47971. maxEmitBox: Vector3;
  47972. /**
  47973. * Creates a new instance BoxParticleEmitter
  47974. */
  47975. constructor();
  47976. /**
  47977. * Called by the particle System when the direction is computed for the created particle.
  47978. * @param worldMatrix is the world matrix of the particle system
  47979. * @param directionToUpdate is the direction vector to update with the result
  47980. * @param particle is the particle we are computed the direction for
  47981. */
  47982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47983. /**
  47984. * Called by the particle System when the position is computed for the created particle.
  47985. * @param worldMatrix is the world matrix of the particle system
  47986. * @param positionToUpdate is the position vector to update with the result
  47987. * @param particle is the particle we are computed the position for
  47988. */
  47989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47990. /**
  47991. * Clones the current emitter and returns a copy of it
  47992. * @returns the new emitter
  47993. */
  47994. clone(): BoxParticleEmitter;
  47995. /**
  47996. * Called by the GPUParticleSystem to setup the update shader
  47997. * @param effect defines the update shader
  47998. */
  47999. applyToShader(effect: Effect): void;
  48000. /**
  48001. * Returns a string to use to update the GPU particles update shader
  48002. * @returns a string containng the defines string
  48003. */
  48004. getEffectDefines(): string;
  48005. /**
  48006. * Returns the string "BoxParticleEmitter"
  48007. * @returns a string containing the class name
  48008. */
  48009. getClassName(): string;
  48010. /**
  48011. * Serializes the particle system to a JSON object.
  48012. * @returns the JSON object
  48013. */
  48014. serialize(): any;
  48015. /**
  48016. * Parse properties from a JSON object
  48017. * @param serializationObject defines the JSON object
  48018. */
  48019. parse(serializationObject: any): void;
  48020. }
  48021. }
  48022. declare module BABYLON {
  48023. /**
  48024. * Particle emitter emitting particles from the inside of a cone.
  48025. * It emits the particles alongside the cone volume from the base to the particle.
  48026. * The emission direction might be randomized.
  48027. */
  48028. class ConeParticleEmitter implements IParticleEmitterType {
  48029. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48030. directionRandomizer: number;
  48031. private _radius;
  48032. private _angle;
  48033. private _height;
  48034. /**
  48035. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48036. */
  48037. radiusRange: number;
  48038. /**
  48039. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48040. */
  48041. heightRange: number;
  48042. /**
  48043. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48044. */
  48045. emitFromSpawnPointOnly: boolean;
  48046. /**
  48047. * Gets or sets the radius of the emission cone
  48048. */
  48049. radius: number;
  48050. /**
  48051. * Gets or sets the angle of the emission cone
  48052. */
  48053. angle: number;
  48054. private _buildHeight;
  48055. /**
  48056. * Creates a new instance ConeParticleEmitter
  48057. * @param radius the radius of the emission cone (1 by default)
  48058. * @param angles the cone base angle (PI by default)
  48059. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48060. */
  48061. constructor(radius?: number, angle?: number,
  48062. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48063. directionRandomizer?: number);
  48064. /**
  48065. * Called by the particle System when the direction is computed for the created particle.
  48066. * @param worldMatrix is the world matrix of the particle system
  48067. * @param directionToUpdate is the direction vector to update with the result
  48068. * @param particle is the particle we are computed the direction for
  48069. */
  48070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48071. /**
  48072. * Called by the particle System when the position is computed for the created particle.
  48073. * @param worldMatrix is the world matrix of the particle system
  48074. * @param positionToUpdate is the position vector to update with the result
  48075. * @param particle is the particle we are computed the position for
  48076. */
  48077. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48078. /**
  48079. * Clones the current emitter and returns a copy of it
  48080. * @returns the new emitter
  48081. */
  48082. clone(): ConeParticleEmitter;
  48083. /**
  48084. * Called by the GPUParticleSystem to setup the update shader
  48085. * @param effect defines the update shader
  48086. */
  48087. applyToShader(effect: Effect): void;
  48088. /**
  48089. * Returns a string to use to update the GPU particles update shader
  48090. * @returns a string containng the defines string
  48091. */
  48092. getEffectDefines(): string;
  48093. /**
  48094. * Returns the string "ConeParticleEmitter"
  48095. * @returns a string containing the class name
  48096. */
  48097. getClassName(): string;
  48098. /**
  48099. * Serializes the particle system to a JSON object.
  48100. * @returns the JSON object
  48101. */
  48102. serialize(): any;
  48103. /**
  48104. * Parse properties from a JSON object
  48105. * @param serializationObject defines the JSON object
  48106. */
  48107. parse(serializationObject: any): void;
  48108. }
  48109. }
  48110. declare module BABYLON {
  48111. /**
  48112. * Particle emitter emitting particles from the inside of a cylinder.
  48113. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48114. */
  48115. class CylinderParticleEmitter implements IParticleEmitterType {
  48116. /**
  48117. * The radius of the emission cylinder.
  48118. */
  48119. radius: number;
  48120. /**
  48121. * The height of the emission cylinder.
  48122. */
  48123. height: number;
  48124. /**
  48125. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48126. */
  48127. radiusRange: number;
  48128. /**
  48129. * How much to randomize the particle direction [0-1].
  48130. */
  48131. directionRandomizer: number;
  48132. /**
  48133. * Creates a new instance CylinderParticleEmitter
  48134. * @param radius the radius of the emission cylinder (1 by default)
  48135. * @param height the height of the emission cylinder (1 by default)
  48136. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48138. */
  48139. constructor(
  48140. /**
  48141. * The radius of the emission cylinder.
  48142. */
  48143. radius?: number,
  48144. /**
  48145. * The height of the emission cylinder.
  48146. */
  48147. height?: number,
  48148. /**
  48149. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48150. */
  48151. radiusRange?: number,
  48152. /**
  48153. * How much to randomize the particle direction [0-1].
  48154. */
  48155. directionRandomizer?: number);
  48156. /**
  48157. * Called by the particle System when the direction is computed for the created particle.
  48158. * @param worldMatrix is the world matrix of the particle system
  48159. * @param directionToUpdate is the direction vector to update with the result
  48160. * @param particle is the particle we are computed the direction for
  48161. */
  48162. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48163. /**
  48164. * Called by the particle System when the position is computed for the created particle.
  48165. * @param worldMatrix is the world matrix of the particle system
  48166. * @param positionToUpdate is the position vector to update with the result
  48167. * @param particle is the particle we are computed the position for
  48168. */
  48169. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48170. /**
  48171. * Clones the current emitter and returns a copy of it
  48172. * @returns the new emitter
  48173. */
  48174. clone(): CylinderParticleEmitter;
  48175. /**
  48176. * Called by the GPUParticleSystem to setup the update shader
  48177. * @param effect defines the update shader
  48178. */
  48179. applyToShader(effect: Effect): void;
  48180. /**
  48181. * Returns a string to use to update the GPU particles update shader
  48182. * @returns a string containng the defines string
  48183. */
  48184. getEffectDefines(): string;
  48185. /**
  48186. * Returns the string "CylinderParticleEmitter"
  48187. * @returns a string containing the class name
  48188. */
  48189. getClassName(): string;
  48190. /**
  48191. * Serializes the particle system to a JSON object.
  48192. * @returns the JSON object
  48193. */
  48194. serialize(): any;
  48195. /**
  48196. * Parse properties from a JSON object
  48197. * @param serializationObject defines the JSON object
  48198. */
  48199. parse(serializationObject: any): void;
  48200. }
  48201. /**
  48202. * Particle emitter emitting particles from the inside of a cylinder.
  48203. * It emits the particles randomly between two vectors.
  48204. */
  48205. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48206. /**
  48207. * The min limit of the emission direction.
  48208. */
  48209. direction1: Vector3;
  48210. /**
  48211. * The max limit of the emission direction.
  48212. */
  48213. direction2: Vector3;
  48214. /**
  48215. * Creates a new instance CylinderDirectedParticleEmitter
  48216. * @param radius the radius of the emission cylinder (1 by default)
  48217. * @param height the height of the emission cylinder (1 by default)
  48218. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48219. * @param direction1 the min limit of the emission direction (up vector by default)
  48220. * @param direction2 the max limit of the emission direction (up vector by default)
  48221. */
  48222. constructor(radius?: number, height?: number, radiusRange?: number,
  48223. /**
  48224. * The min limit of the emission direction.
  48225. */
  48226. direction1?: Vector3,
  48227. /**
  48228. * The max limit of the emission direction.
  48229. */
  48230. direction2?: Vector3);
  48231. /**
  48232. * Called by the particle System when the direction is computed for the created particle.
  48233. * @param worldMatrix is the world matrix of the particle system
  48234. * @param directionToUpdate is the direction vector to update with the result
  48235. * @param particle is the particle we are computed the direction for
  48236. */
  48237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48238. /**
  48239. * Clones the current emitter and returns a copy of it
  48240. * @returns the new emitter
  48241. */
  48242. clone(): CylinderDirectedParticleEmitter;
  48243. /**
  48244. * Called by the GPUParticleSystem to setup the update shader
  48245. * @param effect defines the update shader
  48246. */
  48247. applyToShader(effect: Effect): void;
  48248. /**
  48249. * Returns a string to use to update the GPU particles update shader
  48250. * @returns a string containng the defines string
  48251. */
  48252. getEffectDefines(): string;
  48253. /**
  48254. * Returns the string "CylinderDirectedParticleEmitter"
  48255. * @returns a string containing the class name
  48256. */
  48257. getClassName(): string;
  48258. /**
  48259. * Serializes the particle system to a JSON object.
  48260. * @returns the JSON object
  48261. */
  48262. serialize(): any;
  48263. /**
  48264. * Parse properties from a JSON object
  48265. * @param serializationObject defines the JSON object
  48266. */
  48267. parse(serializationObject: any): void;
  48268. }
  48269. }
  48270. declare module BABYLON {
  48271. /**
  48272. * Particle emitter emitting particles from the inside of a hemisphere.
  48273. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48274. */
  48275. class HemisphericParticleEmitter implements IParticleEmitterType {
  48276. /**
  48277. * The radius of the emission hemisphere.
  48278. */
  48279. radius: number;
  48280. /**
  48281. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48282. */
  48283. radiusRange: number;
  48284. /**
  48285. * How much to randomize the particle direction [0-1].
  48286. */
  48287. directionRandomizer: number;
  48288. /**
  48289. * Creates a new instance HemisphericParticleEmitter
  48290. * @param radius the radius of the emission hemisphere (1 by default)
  48291. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48292. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48293. */
  48294. constructor(
  48295. /**
  48296. * The radius of the emission hemisphere.
  48297. */
  48298. radius?: number,
  48299. /**
  48300. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48301. */
  48302. radiusRange?: number,
  48303. /**
  48304. * How much to randomize the particle direction [0-1].
  48305. */
  48306. directionRandomizer?: number);
  48307. /**
  48308. * Called by the particle System when the direction is computed for the created particle.
  48309. * @param worldMatrix is the world matrix of the particle system
  48310. * @param directionToUpdate is the direction vector to update with the result
  48311. * @param particle is the particle we are computed the direction for
  48312. */
  48313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48314. /**
  48315. * Called by the particle System when the position is computed for the created particle.
  48316. * @param worldMatrix is the world matrix of the particle system
  48317. * @param positionToUpdate is the position vector to update with the result
  48318. * @param particle is the particle we are computed the position for
  48319. */
  48320. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48321. /**
  48322. * Clones the current emitter and returns a copy of it
  48323. * @returns the new emitter
  48324. */
  48325. clone(): HemisphericParticleEmitter;
  48326. /**
  48327. * Called by the GPUParticleSystem to setup the update shader
  48328. * @param effect defines the update shader
  48329. */
  48330. applyToShader(effect: Effect): void;
  48331. /**
  48332. * Returns a string to use to update the GPU particles update shader
  48333. * @returns a string containng the defines string
  48334. */
  48335. getEffectDefines(): string;
  48336. /**
  48337. * Returns the string "HemisphericParticleEmitter"
  48338. * @returns a string containing the class name
  48339. */
  48340. getClassName(): string;
  48341. /**
  48342. * Serializes the particle system to a JSON object.
  48343. * @returns the JSON object
  48344. */
  48345. serialize(): any;
  48346. /**
  48347. * Parse properties from a JSON object
  48348. * @param serializationObject defines the JSON object
  48349. */
  48350. parse(serializationObject: any): void;
  48351. }
  48352. }
  48353. declare module BABYLON {
  48354. /**
  48355. * Particle emitter represents a volume emitting particles.
  48356. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48357. */
  48358. interface IParticleEmitterType {
  48359. /**
  48360. * Called by the particle System when the direction is computed for the created particle.
  48361. * @param worldMatrix is the world matrix of the particle system
  48362. * @param directionToUpdate is the direction vector to update with the result
  48363. * @param particle is the particle we are computed the direction for
  48364. */
  48365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48366. /**
  48367. * Called by the particle System when the position is computed for the created particle.
  48368. * @param worldMatrix is the world matrix of the particle system
  48369. * @param positionToUpdate is the position vector to update with the result
  48370. * @param particle is the particle we are computed the position for
  48371. */
  48372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48373. /**
  48374. * Clones the current emitter and returns a copy of it
  48375. * @returns the new emitter
  48376. */
  48377. clone(): IParticleEmitterType;
  48378. /**
  48379. * Called by the GPUParticleSystem to setup the update shader
  48380. * @param effect defines the update shader
  48381. */
  48382. applyToShader(effect: Effect): void;
  48383. /**
  48384. * Returns a string to use to update the GPU particles update shader
  48385. * @returns the effect defines string
  48386. */
  48387. getEffectDefines(): string;
  48388. /**
  48389. * Returns a string representing the class name
  48390. * @returns a string containing the class name
  48391. */
  48392. getClassName(): string;
  48393. /**
  48394. * Serializes the particle system to a JSON object.
  48395. * @returns the JSON object
  48396. */
  48397. serialize(): any;
  48398. /**
  48399. * Parse properties from a JSON object
  48400. * @param serializationObject defines the JSON object
  48401. */
  48402. parse(serializationObject: any): void;
  48403. }
  48404. }
  48405. declare module BABYLON {
  48406. /**
  48407. * Particle emitter emitting particles from a point.
  48408. * It emits the particles randomly between 2 given directions.
  48409. */
  48410. class PointParticleEmitter implements IParticleEmitterType {
  48411. /**
  48412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48413. */
  48414. direction1: Vector3;
  48415. /**
  48416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48417. */
  48418. direction2: Vector3;
  48419. /**
  48420. * Creates a new instance PointParticleEmitter
  48421. */
  48422. constructor();
  48423. /**
  48424. * Called by the particle System when the direction is computed for the created particle.
  48425. * @param worldMatrix is the world matrix of the particle system
  48426. * @param directionToUpdate is the direction vector to update with the result
  48427. * @param particle is the particle we are computed the direction for
  48428. */
  48429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48430. /**
  48431. * Called by the particle System when the position is computed for the created particle.
  48432. * @param worldMatrix is the world matrix of the particle system
  48433. * @param positionToUpdate is the position vector to update with the result
  48434. * @param particle is the particle we are computed the position for
  48435. */
  48436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48437. /**
  48438. * Clones the current emitter and returns a copy of it
  48439. * @returns the new emitter
  48440. */
  48441. clone(): PointParticleEmitter;
  48442. /**
  48443. * Called by the GPUParticleSystem to setup the update shader
  48444. * @param effect defines the update shader
  48445. */
  48446. applyToShader(effect: Effect): void;
  48447. /**
  48448. * Returns a string to use to update the GPU particles update shader
  48449. * @returns a string containng the defines string
  48450. */
  48451. getEffectDefines(): string;
  48452. /**
  48453. * Returns the string "PointParticleEmitter"
  48454. * @returns a string containing the class name
  48455. */
  48456. getClassName(): string;
  48457. /**
  48458. * Serializes the particle system to a JSON object.
  48459. * @returns the JSON object
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parse properties from a JSON object
  48464. * @param serializationObject defines the JSON object
  48465. */
  48466. parse(serializationObject: any): void;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Particle emitter emitting particles from the inside of a sphere.
  48472. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48473. */
  48474. class SphereParticleEmitter implements IParticleEmitterType {
  48475. /**
  48476. * The radius of the emission sphere.
  48477. */
  48478. radius: number;
  48479. /**
  48480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48481. */
  48482. radiusRange: number;
  48483. /**
  48484. * How much to randomize the particle direction [0-1].
  48485. */
  48486. directionRandomizer: number;
  48487. /**
  48488. * Creates a new instance SphereParticleEmitter
  48489. * @param radius the radius of the emission sphere (1 by default)
  48490. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48491. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48492. */
  48493. constructor(
  48494. /**
  48495. * The radius of the emission sphere.
  48496. */
  48497. radius?: number,
  48498. /**
  48499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48500. */
  48501. radiusRange?: number,
  48502. /**
  48503. * How much to randomize the particle direction [0-1].
  48504. */
  48505. directionRandomizer?: number);
  48506. /**
  48507. * Called by the particle System when the direction is computed for the created particle.
  48508. * @param worldMatrix is the world matrix of the particle system
  48509. * @param directionToUpdate is the direction vector to update with the result
  48510. * @param particle is the particle we are computed the direction for
  48511. */
  48512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48513. /**
  48514. * Called by the particle System when the position is computed for the created particle.
  48515. * @param worldMatrix is the world matrix of the particle system
  48516. * @param positionToUpdate is the position vector to update with the result
  48517. * @param particle is the particle we are computed the position for
  48518. */
  48519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48520. /**
  48521. * Clones the current emitter and returns a copy of it
  48522. * @returns the new emitter
  48523. */
  48524. clone(): SphereParticleEmitter;
  48525. /**
  48526. * Called by the GPUParticleSystem to setup the update shader
  48527. * @param effect defines the update shader
  48528. */
  48529. applyToShader(effect: Effect): void;
  48530. /**
  48531. * Returns a string to use to update the GPU particles update shader
  48532. * @returns a string containng the defines string
  48533. */
  48534. getEffectDefines(): string;
  48535. /**
  48536. * Returns the string "SphereParticleEmitter"
  48537. * @returns a string containing the class name
  48538. */
  48539. getClassName(): string;
  48540. /**
  48541. * Serializes the particle system to a JSON object.
  48542. * @returns the JSON object
  48543. */
  48544. serialize(): any;
  48545. /**
  48546. * Parse properties from a JSON object
  48547. * @param serializationObject defines the JSON object
  48548. */
  48549. parse(serializationObject: any): void;
  48550. }
  48551. /**
  48552. * Particle emitter emitting particles from the inside of a sphere.
  48553. * It emits the particles randomly between two vectors.
  48554. */
  48555. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48556. /**
  48557. * The min limit of the emission direction.
  48558. */
  48559. direction1: Vector3;
  48560. /**
  48561. * The max limit of the emission direction.
  48562. */
  48563. direction2: Vector3;
  48564. /**
  48565. * Creates a new instance SphereDirectedParticleEmitter
  48566. * @param radius the radius of the emission sphere (1 by default)
  48567. * @param direction1 the min limit of the emission direction (up vector by default)
  48568. * @param direction2 the max limit of the emission direction (up vector by default)
  48569. */
  48570. constructor(radius?: number,
  48571. /**
  48572. * The min limit of the emission direction.
  48573. */
  48574. direction1?: Vector3,
  48575. /**
  48576. * The max limit of the emission direction.
  48577. */
  48578. direction2?: Vector3);
  48579. /**
  48580. * Called by the particle System when the direction is computed for the created particle.
  48581. * @param worldMatrix is the world matrix of the particle system
  48582. * @param directionToUpdate is the direction vector to update with the result
  48583. * @param particle is the particle we are computed the direction for
  48584. */
  48585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48586. /**
  48587. * Clones the current emitter and returns a copy of it
  48588. * @returns the new emitter
  48589. */
  48590. clone(): SphereDirectedParticleEmitter;
  48591. /**
  48592. * Called by the GPUParticleSystem to setup the update shader
  48593. * @param effect defines the update shader
  48594. */
  48595. applyToShader(effect: Effect): void;
  48596. /**
  48597. * Returns a string to use to update the GPU particles update shader
  48598. * @returns a string containng the defines string
  48599. */
  48600. getEffectDefines(): string;
  48601. /**
  48602. * Returns the string "SphereDirectedParticleEmitter"
  48603. * @returns a string containing the class name
  48604. */
  48605. getClassName(): string;
  48606. /**
  48607. * Serializes the particle system to a JSON object.
  48608. * @returns the JSON object
  48609. */
  48610. serialize(): any;
  48611. /**
  48612. * Parse properties from a JSON object
  48613. * @param serializationObject defines the JSON object
  48614. */
  48615. parse(serializationObject: any): void;
  48616. }
  48617. }
  48618. declare module BABYLON {
  48619. /**
  48620. * This represents a set of one or more post processes in Babylon.
  48621. * A post process can be used to apply a shader to a texture after it is rendered.
  48622. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48623. */
  48624. class PostProcessRenderEffect {
  48625. private _postProcesses;
  48626. private _getPostProcesses;
  48627. private _singleInstance;
  48628. private _cameras;
  48629. private _indicesForCamera;
  48630. /**
  48631. * Name of the effect
  48632. * @hidden
  48633. */
  48634. _name: string;
  48635. /**
  48636. * Instantiates a post process render effect.
  48637. * A post process can be used to apply a shader to a texture after it is rendered.
  48638. * @param engine The engine the effect is tied to
  48639. * @param name The name of the effect
  48640. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48641. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48642. */
  48643. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48644. /**
  48645. * Checks if all the post processes in the effect are supported.
  48646. */
  48647. readonly isSupported: boolean;
  48648. /**
  48649. * Updates the current state of the effect
  48650. * @hidden
  48651. */
  48652. _update(): void;
  48653. /**
  48654. * Attaches the effect on cameras
  48655. * @param cameras The camera to attach to.
  48656. * @hidden
  48657. */
  48658. _attachCameras(cameras: Camera): void;
  48659. /**
  48660. * Attaches the effect on cameras
  48661. * @param cameras The camera to attach to.
  48662. * @hidden
  48663. */
  48664. _attachCameras(cameras: Camera[]): void;
  48665. /**
  48666. * Detatches the effect on cameras
  48667. * @param cameras The camera to detatch from.
  48668. * @hidden
  48669. */
  48670. _detachCameras(cameras: Camera): void;
  48671. /**
  48672. * Detatches the effect on cameras
  48673. * @param cameras The camera to detatch from.
  48674. * @hidden
  48675. */
  48676. _detachCameras(cameras: Camera[]): void;
  48677. /**
  48678. * Enables the effect on given cameras
  48679. * @param cameras The camera to enable.
  48680. * @hidden
  48681. */
  48682. _enable(cameras: Camera): void;
  48683. /**
  48684. * Enables the effect on given cameras
  48685. * @param cameras The camera to enable.
  48686. * @hidden
  48687. */
  48688. _enable(cameras: Nullable<Camera[]>): void;
  48689. /**
  48690. * Disables the effect on the given cameras
  48691. * @param cameras The camera to disable.
  48692. * @hidden
  48693. */
  48694. _disable(cameras: Camera): void;
  48695. /**
  48696. * Disables the effect on the given cameras
  48697. * @param cameras The camera to disable.
  48698. * @hidden
  48699. */
  48700. _disable(cameras: Nullable<Camera[]>): void;
  48701. /**
  48702. * Gets a list of the post processes contained in the effect.
  48703. * @param camera The camera to get the post processes on.
  48704. * @returns The list of the post processes in the effect.
  48705. */
  48706. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48707. }
  48708. }
  48709. declare module BABYLON {
  48710. /**
  48711. * PostProcessRenderPipeline
  48712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48713. */
  48714. class PostProcessRenderPipeline {
  48715. private engine;
  48716. private _renderEffects;
  48717. private _renderEffectsForIsolatedPass;
  48718. /**
  48719. * @hidden
  48720. */
  48721. protected _cameras: Camera[];
  48722. /** @hidden */
  48723. _name: string;
  48724. /**
  48725. * Initializes a PostProcessRenderPipeline
  48726. * @param engine engine to add the pipeline to
  48727. * @param name name of the pipeline
  48728. */
  48729. constructor(engine: Engine, name: string);
  48730. /**
  48731. * "PostProcessRenderPipeline"
  48732. * @returns "PostProcessRenderPipeline"
  48733. */
  48734. getClassName(): string;
  48735. /**
  48736. * If all the render effects in the pipeline are support
  48737. */
  48738. readonly isSupported: boolean;
  48739. /**
  48740. * Adds an effect to the pipeline
  48741. * @param renderEffect the effect to add
  48742. */
  48743. addEffect(renderEffect: PostProcessRenderEffect): void;
  48744. /** @hidden */
  48745. _rebuild(): void;
  48746. /** @hidden */
  48747. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48748. /** @hidden */
  48749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48750. /** @hidden */
  48751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48752. /** @hidden */
  48753. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48754. /** @hidden */
  48755. _attachCameras(cameras: Camera, unique: boolean): void;
  48756. /** @hidden */
  48757. _attachCameras(cameras: Camera[], unique: boolean): void;
  48758. /** @hidden */
  48759. _detachCameras(cameras: Camera): void;
  48760. /** @hidden */
  48761. _detachCameras(cameras: Nullable<Camera[]>): void;
  48762. /** @hidden */
  48763. _update(): void;
  48764. /** @hidden */
  48765. _reset(): void;
  48766. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48767. /**
  48768. * Disposes of the pipeline
  48769. */
  48770. dispose(): void;
  48771. }
  48772. }
  48773. declare module BABYLON {
  48774. /**
  48775. * PostProcessRenderPipelineManager class
  48776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48777. */
  48778. class PostProcessRenderPipelineManager {
  48779. private _renderPipelines;
  48780. /**
  48781. * Initializes a PostProcessRenderPipelineManager
  48782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48783. */
  48784. constructor();
  48785. /**
  48786. * Adds a pipeline to the manager
  48787. * @param renderPipeline The pipeline to add
  48788. */
  48789. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  48790. /**
  48791. * Attaches a camera to the pipeline
  48792. * @param renderPipelineName The name of the pipeline to attach to
  48793. * @param cameras the camera to attach
  48794. * @param unique if the camera can be attached multiple times to the pipeline
  48795. */
  48796. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  48797. /**
  48798. * Detaches a camera from the pipeline
  48799. * @param renderPipelineName The name of the pipeline to detach from
  48800. * @param cameras the camera to detach
  48801. */
  48802. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  48803. /**
  48804. * Enables an effect by name on a pipeline
  48805. * @param renderPipelineName the name of the pipeline to enable the effect in
  48806. * @param renderEffectName the name of the effect to enable
  48807. * @param cameras the cameras that the effect should be enabled on
  48808. */
  48809. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48810. /**
  48811. * Disables an effect by name on a pipeline
  48812. * @param renderPipelineName the name of the pipeline to disable the effect in
  48813. * @param renderEffectName the name of the effect to disable
  48814. * @param cameras the cameras that the effect should be disabled on
  48815. */
  48816. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48817. /**
  48818. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  48819. */
  48820. update(): void;
  48821. /** @hidden */
  48822. _rebuild(): void;
  48823. /**
  48824. * Disposes of the manager and pipelines
  48825. */
  48826. dispose(): void;
  48827. }
  48828. }
  48829. declare module BABYLON {
  48830. interface Scene {
  48831. /** @hidden (Backing field) */
  48832. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48833. /**
  48834. * Gets the postprocess render pipeline manager
  48835. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48836. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48837. */
  48838. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48839. }
  48840. /**
  48841. * Defines the Render Pipeline scene component responsible to rendering pipelines
  48842. */
  48843. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  48844. /**
  48845. * The component name helpfull to identify the component in the list of scene components.
  48846. */
  48847. readonly name: string;
  48848. /**
  48849. * The scene the component belongs to.
  48850. */
  48851. scene: Scene;
  48852. /**
  48853. * Creates a new instance of the component for the given scene
  48854. * @param scene Defines the scene to register the component in
  48855. */
  48856. constructor(scene: Scene);
  48857. /**
  48858. * Registers the component in a given scene
  48859. */
  48860. register(): void;
  48861. /**
  48862. * Rebuilds the elements related to this component in case of
  48863. * context lost for instance.
  48864. */
  48865. rebuild(): void;
  48866. /**
  48867. * Disposes the component and the associated ressources
  48868. */
  48869. dispose(): void;
  48870. private _gatherRenderTargets;
  48871. }
  48872. }
  48873. declare module BABYLON {
  48874. /**
  48875. * Helper class dealing with the extraction of spherical polynomial dataArray
  48876. * from a cube map.
  48877. */
  48878. class CubeMapToSphericalPolynomialTools {
  48879. private static FileFaces;
  48880. /**
  48881. * Converts a texture to the according Spherical Polynomial data.
  48882. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48883. *
  48884. * @param texture The texture to extract the information from.
  48885. * @return The Spherical Polynomial data.
  48886. */
  48887. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48888. /**
  48889. * Converts a cubemap to the according Spherical Polynomial data.
  48890. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48891. *
  48892. * @param cubeInfo The Cube map to extract the information from.
  48893. * @return The Spherical Polynomial data.
  48894. */
  48895. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48896. }
  48897. }
  48898. declare module BABYLON {
  48899. /**
  48900. * Header information of HDR texture files.
  48901. */
  48902. interface HDRInfo {
  48903. /**
  48904. * The height of the texture in pixels.
  48905. */
  48906. height: number;
  48907. /**
  48908. * The width of the texture in pixels.
  48909. */
  48910. width: number;
  48911. /**
  48912. * The index of the beginning of the data in the binary file.
  48913. */
  48914. dataPosition: number;
  48915. }
  48916. /**
  48917. * This groups tools to convert HDR texture to native colors array.
  48918. */
  48919. class HDRTools {
  48920. private static Ldexp;
  48921. private static Rgbe2float;
  48922. private static readStringLine;
  48923. /**
  48924. * Reads header information from an RGBE texture stored in a native array.
  48925. * More information on this format are available here:
  48926. * https://en.wikipedia.org/wiki/RGBE_image_format
  48927. *
  48928. * @param uint8array The binary file stored in native array.
  48929. * @return The header information.
  48930. */
  48931. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48932. /**
  48933. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48934. * This RGBE texture needs to store the information as a panorama.
  48935. *
  48936. * More information on this format are available here:
  48937. * https://en.wikipedia.org/wiki/RGBE_image_format
  48938. *
  48939. * @param buffer The binary file stored in an array buffer.
  48940. * @param size The expected size of the extracted cubemap.
  48941. * @return The Cube Map information.
  48942. */
  48943. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48944. /**
  48945. * Returns the pixels data extracted from an RGBE texture.
  48946. * This pixels will be stored left to right up to down in the R G B order in one array.
  48947. *
  48948. * More information on this format are available here:
  48949. * https://en.wikipedia.org/wiki/RGBE_image_format
  48950. *
  48951. * @param uint8array The binary file stored in an array buffer.
  48952. * @param hdrInfo The header information of the file.
  48953. * @return The pixels data in RGB right to left up to down order.
  48954. */
  48955. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48956. private static RGBE_ReadPixels_RLE;
  48957. }
  48958. }
  48959. declare module BABYLON {
  48960. /**
  48961. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48962. */
  48963. interface CubeMapInfo {
  48964. /**
  48965. * The pixel array for the front face.
  48966. * This is stored in format, left to right, up to down format.
  48967. */
  48968. front: Nullable<ArrayBufferView>;
  48969. /**
  48970. * The pixel array for the back face.
  48971. * This is stored in format, left to right, up to down format.
  48972. */
  48973. back: Nullable<ArrayBufferView>;
  48974. /**
  48975. * The pixel array for the left face.
  48976. * This is stored in format, left to right, up to down format.
  48977. */
  48978. left: Nullable<ArrayBufferView>;
  48979. /**
  48980. * The pixel array for the right face.
  48981. * This is stored in format, left to right, up to down format.
  48982. */
  48983. right: Nullable<ArrayBufferView>;
  48984. /**
  48985. * The pixel array for the up face.
  48986. * This is stored in format, left to right, up to down format.
  48987. */
  48988. up: Nullable<ArrayBufferView>;
  48989. /**
  48990. * The pixel array for the down face.
  48991. * This is stored in format, left to right, up to down format.
  48992. */
  48993. down: Nullable<ArrayBufferView>;
  48994. /**
  48995. * The size of the cubemap stored.
  48996. *
  48997. * Each faces will be size * size pixels.
  48998. */
  48999. size: number;
  49000. /**
  49001. * The format of the texture.
  49002. *
  49003. * RGBA, RGB.
  49004. */
  49005. format: number;
  49006. /**
  49007. * The type of the texture data.
  49008. *
  49009. * UNSIGNED_INT, FLOAT.
  49010. */
  49011. type: number;
  49012. /**
  49013. * Specifies whether the texture is in gamma space.
  49014. */
  49015. gammaSpace: boolean;
  49016. }
  49017. /**
  49018. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49019. */
  49020. class PanoramaToCubeMapTools {
  49021. private static FACE_FRONT;
  49022. private static FACE_BACK;
  49023. private static FACE_RIGHT;
  49024. private static FACE_LEFT;
  49025. private static FACE_DOWN;
  49026. private static FACE_UP;
  49027. /**
  49028. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49029. *
  49030. * @param float32Array The source data.
  49031. * @param inputWidth The width of the input panorama.
  49032. * @param inputHeight The height of the input panorama.
  49033. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49034. * @return The cubemap data
  49035. */
  49036. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49037. private static CreateCubemapTexture;
  49038. private static CalcProjectionSpherical;
  49039. }
  49040. }
  49041. declare module BABYLON {
  49042. }
  49043. declare module BABYLON {
  49044. }
  49045. declare module BABYLON {
  49046. }
  49047. declare module BABYLON {
  49048. }
  49049. declare module BABYLON {
  49050. /**
  49051. * 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.
  49052. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49053. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49054. */
  49055. class CustomProceduralTexture extends ProceduralTexture {
  49056. private _animate;
  49057. private _time;
  49058. private _config;
  49059. private _texturePath;
  49060. /**
  49061. * Instantiates a new Custom Procedural Texture.
  49062. * 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.
  49063. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49064. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49065. * @param name Define the name of the texture
  49066. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49067. * @param size Define the size of the texture to create
  49068. * @param scene Define the scene the texture belongs to
  49069. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49070. * @param generateMipMaps Define if the texture should creates mip maps or not
  49071. */
  49072. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49073. private _loadJson;
  49074. /**
  49075. * Is the texture ready to be used ? (rendered at least once)
  49076. * @returns true if ready, otherwise, false.
  49077. */
  49078. isReady(): boolean;
  49079. /**
  49080. * Render the texture to its associated render target.
  49081. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49082. */
  49083. render(useCameraPostProcess?: boolean): void;
  49084. /**
  49085. * Update the list of dependant textures samplers in the shader.
  49086. */
  49087. updateTextures(): void;
  49088. /**
  49089. * Update the uniform values of the procedural texture in the shader.
  49090. */
  49091. updateShaderUniforms(): void;
  49092. /**
  49093. * Define if the texture animates or not.
  49094. */
  49095. animate: boolean;
  49096. }
  49097. }
  49098. declare module BABYLON {
  49099. /**
  49100. * Class used to generate noise procedural textures
  49101. */
  49102. class NoiseProceduralTexture extends ProceduralTexture {
  49103. private _time;
  49104. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49105. brightness: number;
  49106. /** Defines the number of octaves to process */
  49107. octaves: number;
  49108. /** Defines the level of persistence (0.8 by default) */
  49109. persistence: number;
  49110. /** Gets or sets animation speed factor (default is 1) */
  49111. animationSpeedFactor: number;
  49112. /**
  49113. * Creates a new NoiseProceduralTexture
  49114. * @param name defines the name fo the texture
  49115. * @param size defines the size of the texture (default is 256)
  49116. * @param scene defines the hosting scene
  49117. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49118. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49119. */
  49120. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49121. private _updateShaderUniforms;
  49122. protected _getDefines(): string;
  49123. /** Generate the current state of the procedural texture */
  49124. render(useCameraPostProcess?: boolean): void;
  49125. /**
  49126. * Serializes this noise procedural texture
  49127. * @returns a serialized noise procedural texture object
  49128. */
  49129. serialize(): any;
  49130. /**
  49131. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49132. * @param parsedTexture defines parsed texture data
  49133. * @param scene defines the current scene
  49134. * @param rootUrl defines the root URL containing noise procedural texture information
  49135. * @returns a parsed NoiseProceduralTexture
  49136. */
  49137. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49138. }
  49139. }
  49140. declare module BABYLON {
  49141. /**
  49142. * 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.
  49143. * This is the base class of any Procedural texture and contains most of the shareable code.
  49144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49145. */
  49146. class ProceduralTexture extends Texture {
  49147. isCube: boolean;
  49148. /**
  49149. * Define if the texture is enabled or not (disabled texture will not render)
  49150. */
  49151. isEnabled: boolean;
  49152. /**
  49153. * Define if the texture must be cleared before rendering (default is true)
  49154. */
  49155. autoClear: boolean;
  49156. /**
  49157. * Callback called when the texture is generated
  49158. */
  49159. onGenerated: () => void;
  49160. /**
  49161. * Event raised when the texture is generated
  49162. */
  49163. onGeneratedObservable: Observable<ProceduralTexture>;
  49164. /** @hidden */
  49165. _generateMipMaps: boolean;
  49166. /** @hidden **/
  49167. _effect: Effect;
  49168. /** @hidden */
  49169. _textures: {
  49170. [key: string]: Texture;
  49171. };
  49172. private _size;
  49173. private _currentRefreshId;
  49174. private _refreshRate;
  49175. private _vertexBuffers;
  49176. private _indexBuffer;
  49177. private _uniforms;
  49178. private _samplers;
  49179. private _fragment;
  49180. private _floats;
  49181. private _ints;
  49182. private _floatsArrays;
  49183. private _colors3;
  49184. private _colors4;
  49185. private _vectors2;
  49186. private _vectors3;
  49187. private _matrices;
  49188. private _fallbackTexture;
  49189. private _fallbackTextureUsed;
  49190. private _engine;
  49191. private _cachedDefines;
  49192. private _contentUpdateId;
  49193. private _contentData;
  49194. /**
  49195. * Instantiates a new procedural texture.
  49196. * 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.
  49197. * This is the base class of any Procedural texture and contains most of the shareable code.
  49198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49199. * @param name Define the name of the texture
  49200. * @param size Define the size of the texture to create
  49201. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49202. * @param scene Define the scene the texture belongs to
  49203. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49204. * @param generateMipMaps Define if the texture should creates mip maps or not
  49205. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49206. */
  49207. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49208. /**
  49209. * The effect that is created when initializing the post process.
  49210. * @returns The created effect corrisponding the the postprocess.
  49211. */
  49212. getEffect(): Effect;
  49213. /**
  49214. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49215. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49216. */
  49217. getContent(): Nullable<ArrayBufferView>;
  49218. private _createIndexBuffer;
  49219. /** @hidden */
  49220. _rebuild(): void;
  49221. /**
  49222. * Resets the texture in order to recreate its associated resources.
  49223. * This can be called in case of context loss
  49224. */
  49225. reset(): void;
  49226. protected _getDefines(): string;
  49227. /**
  49228. * Is the texture ready to be used ? (rendered at least once)
  49229. * @returns true if ready, otherwise, false.
  49230. */
  49231. isReady(): boolean;
  49232. /**
  49233. * Resets the refresh counter of the texture and start bak from scratch.
  49234. * Could be usefull to regenerate the texture if it is setup to render only once.
  49235. */
  49236. resetRefreshCounter(): void;
  49237. /**
  49238. * Set the fragment shader to use in order to render the texture.
  49239. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49240. */
  49241. setFragment(fragment: any): void;
  49242. /**
  49243. * Define the refresh rate of the texture or the rendering frequency.
  49244. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49245. */
  49246. refreshRate: number;
  49247. /** @hidden */
  49248. _shouldRender(): boolean;
  49249. /**
  49250. * Get the size the texture is rendering at.
  49251. * @returns the size (texture is always squared)
  49252. */
  49253. getRenderSize(): number;
  49254. /**
  49255. * Resize the texture to new value.
  49256. * @param size Define the new size the texture should have
  49257. * @param generateMipMaps Define whether the new texture should create mip maps
  49258. */
  49259. resize(size: number, generateMipMaps: boolean): void;
  49260. private _checkUniform;
  49261. /**
  49262. * Set a texture in the shader program used to render.
  49263. * @param name Define the name of the uniform samplers as defined in the shader
  49264. * @param texture Define the texture to bind to this sampler
  49265. * @return the texture itself allowing "fluent" like uniform updates
  49266. */
  49267. setTexture(name: string, texture: Texture): ProceduralTexture;
  49268. /**
  49269. * Set a float in the shader.
  49270. * @param name Define the name of the uniform as defined in the shader
  49271. * @param value Define the value to give to the uniform
  49272. * @return the texture itself allowing "fluent" like uniform updates
  49273. */
  49274. setFloat(name: string, value: number): ProceduralTexture;
  49275. /**
  49276. * Set a int in the shader.
  49277. * @param name Define the name of the uniform as defined in the shader
  49278. * @param value Define the value to give to the uniform
  49279. * @return the texture itself allowing "fluent" like uniform updates
  49280. */
  49281. setInt(name: string, value: number): ProceduralTexture;
  49282. /**
  49283. * Set an array of floats in the shader.
  49284. * @param name Define the name of the uniform as defined in the shader
  49285. * @param value Define the value to give to the uniform
  49286. * @return the texture itself allowing "fluent" like uniform updates
  49287. */
  49288. setFloats(name: string, value: number[]): ProceduralTexture;
  49289. /**
  49290. * Set a vec3 in the shader from a Color3.
  49291. * @param name Define the name of the uniform as defined in the shader
  49292. * @param value Define the value to give to the uniform
  49293. * @return the texture itself allowing "fluent" like uniform updates
  49294. */
  49295. setColor3(name: string, value: Color3): ProceduralTexture;
  49296. /**
  49297. * Set a vec4 in the shader from a Color4.
  49298. * @param name Define the name of the uniform as defined in the shader
  49299. * @param value Define the value to give to the uniform
  49300. * @return the texture itself allowing "fluent" like uniform updates
  49301. */
  49302. setColor4(name: string, value: Color4): ProceduralTexture;
  49303. /**
  49304. * Set a vec2 in the shader from a Vector2.
  49305. * @param name Define the name of the uniform as defined in the shader
  49306. * @param value Define the value to give to the uniform
  49307. * @return the texture itself allowing "fluent" like uniform updates
  49308. */
  49309. setVector2(name: string, value: Vector2): ProceduralTexture;
  49310. /**
  49311. * Set a vec3 in the shader from a Vector3.
  49312. * @param name Define the name of the uniform as defined in the shader
  49313. * @param value Define the value to give to the uniform
  49314. * @return the texture itself allowing "fluent" like uniform updates
  49315. */
  49316. setVector3(name: string, value: Vector3): ProceduralTexture;
  49317. /**
  49318. * Set a mat4 in the shader from a MAtrix.
  49319. * @param name Define the name of the uniform as defined in the shader
  49320. * @param value Define the value to give to the uniform
  49321. * @return the texture itself allowing "fluent" like uniform updates
  49322. */
  49323. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49324. /**
  49325. * Render the texture to its associated render target.
  49326. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49327. */
  49328. render(useCameraPostProcess?: boolean): void;
  49329. /**
  49330. * Clone the texture.
  49331. * @returns the cloned texture
  49332. */
  49333. clone(): ProceduralTexture;
  49334. /**
  49335. * Dispose the texture and release its asoociated resources.
  49336. */
  49337. dispose(): void;
  49338. }
  49339. }
  49340. declare module BABYLON {
  49341. interface AbstractScene {
  49342. /**
  49343. * The list of procedural textures added to the scene
  49344. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49345. */
  49346. proceduralTextures: Array<ProceduralTexture>;
  49347. }
  49348. /**
  49349. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49350. * in a given scene.
  49351. */
  49352. class ProceduralTextureSceneComponent implements ISceneComponent {
  49353. /**
  49354. * The component name helpfull to identify the component in the list of scene components.
  49355. */
  49356. readonly name: string;
  49357. /**
  49358. * The scene the component belongs to.
  49359. */
  49360. scene: Scene;
  49361. /**
  49362. * Creates a new instance of the component for the given scene
  49363. * @param scene Defines the scene to register the component in
  49364. */
  49365. constructor(scene: Scene);
  49366. /**
  49367. * Registers the component in a given scene
  49368. */
  49369. register(): void;
  49370. /**
  49371. * Rebuilds the elements related to this component in case of
  49372. * context lost for instance.
  49373. */
  49374. rebuild(): void;
  49375. /**
  49376. * Disposes the component and the associated ressources.
  49377. */
  49378. dispose(): void;
  49379. private _beforeClear;
  49380. }
  49381. }
  49382. declare module BABYLON {
  49383. /**
  49384. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49385. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49386. */
  49387. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49388. private _scene;
  49389. private _camerasToBeAttached;
  49390. /**
  49391. * ID of the sharpen post process,
  49392. */
  49393. private readonly SharpenPostProcessId;
  49394. /**
  49395. * @ignore
  49396. * ID of the image processing post process;
  49397. */
  49398. readonly ImageProcessingPostProcessId: string;
  49399. /**
  49400. * @ignore
  49401. * ID of the Fast Approximate Anti-Aliasing post process;
  49402. */
  49403. readonly FxaaPostProcessId: string;
  49404. /**
  49405. * ID of the chromatic aberration post process,
  49406. */
  49407. private readonly ChromaticAberrationPostProcessId;
  49408. /**
  49409. * ID of the grain post process
  49410. */
  49411. private readonly GrainPostProcessId;
  49412. /**
  49413. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49414. */
  49415. sharpen: SharpenPostProcess;
  49416. private _sharpenEffect;
  49417. private bloom;
  49418. /**
  49419. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49420. */
  49421. depthOfField: DepthOfFieldEffect;
  49422. /**
  49423. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49424. */
  49425. fxaa: FxaaPostProcess;
  49426. /**
  49427. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49428. */
  49429. imageProcessing: ImageProcessingPostProcess;
  49430. /**
  49431. * Chromatic aberration post process which will shift rgb colors in the image
  49432. */
  49433. chromaticAberration: ChromaticAberrationPostProcess;
  49434. private _chromaticAberrationEffect;
  49435. /**
  49436. * Grain post process which add noise to the image
  49437. */
  49438. grain: GrainPostProcess;
  49439. private _grainEffect;
  49440. /**
  49441. * Glow post process which adds a glow to emmisive areas of the image
  49442. */
  49443. private _glowLayer;
  49444. /**
  49445. * Animations which can be used to tweak settings over a period of time
  49446. */
  49447. animations: Animation[];
  49448. private _imageProcessingConfigurationObserver;
  49449. private _sharpenEnabled;
  49450. private _bloomEnabled;
  49451. private _depthOfFieldEnabled;
  49452. private _depthOfFieldBlurLevel;
  49453. private _fxaaEnabled;
  49454. private _imageProcessingEnabled;
  49455. private _defaultPipelineTextureType;
  49456. private _bloomScale;
  49457. private _chromaticAberrationEnabled;
  49458. private _grainEnabled;
  49459. private _buildAllowed;
  49460. /**
  49461. * Enable or disable the sharpen process from the pipeline
  49462. */
  49463. sharpenEnabled: boolean;
  49464. private _resizeObserver;
  49465. private _hardwareScaleLevel;
  49466. private _bloomKernel;
  49467. /**
  49468. * Specifies the size of the bloom blur kernel, relative to the final output size
  49469. */
  49470. bloomKernel: number;
  49471. /**
  49472. * Specifies the weight of the bloom in the final rendering
  49473. */
  49474. private _bloomWeight;
  49475. /**
  49476. * Specifies the luma threshold for the area that will be blurred by the bloom
  49477. */
  49478. private _bloomThreshold;
  49479. private _hdr;
  49480. /**
  49481. * The strength of the bloom.
  49482. */
  49483. bloomWeight: number;
  49484. /**
  49485. * The strength of the bloom.
  49486. */
  49487. bloomThreshold: number;
  49488. /**
  49489. * The scale of the bloom, lower value will provide better performance.
  49490. */
  49491. bloomScale: number;
  49492. /**
  49493. * Enable or disable the bloom from the pipeline
  49494. */
  49495. bloomEnabled: boolean;
  49496. private _rebuildBloom;
  49497. /**
  49498. * If the depth of field is enabled.
  49499. */
  49500. depthOfFieldEnabled: boolean;
  49501. /**
  49502. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49503. */
  49504. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49505. /**
  49506. * If the anti aliasing is enabled.
  49507. */
  49508. fxaaEnabled: boolean;
  49509. private _samples;
  49510. /**
  49511. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49512. */
  49513. samples: number;
  49514. /**
  49515. * If image processing is enabled.
  49516. */
  49517. imageProcessingEnabled: boolean;
  49518. /**
  49519. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49520. */
  49521. glowLayerEnabled: boolean;
  49522. /**
  49523. * Enable or disable the chromaticAberration process from the pipeline
  49524. */
  49525. chromaticAberrationEnabled: boolean;
  49526. /**
  49527. * Enable or disable the grain process from the pipeline
  49528. */
  49529. grainEnabled: boolean;
  49530. /**
  49531. * @constructor
  49532. * @param name - The rendering pipeline name (default: "")
  49533. * @param hdr - If high dynamic range textures should be used (default: true)
  49534. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49535. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49536. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49537. */
  49538. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49539. /**
  49540. * Force the compilation of the entire pipeline.
  49541. */
  49542. prepare(): void;
  49543. private _hasCleared;
  49544. private _prevPostProcess;
  49545. private _prevPrevPostProcess;
  49546. private _setAutoClearAndTextureSharing;
  49547. private _depthOfFieldSceneObserver;
  49548. private _buildPipeline;
  49549. private _disposePostProcesses;
  49550. /**
  49551. * Adds a camera to the pipeline
  49552. * @param camera the camera to be added
  49553. */
  49554. addCamera(camera: Camera): void;
  49555. /**
  49556. * Removes a camera from the pipeline
  49557. * @param camera the camera to remove
  49558. */
  49559. removeCamera(camera: Camera): void;
  49560. /**
  49561. * Dispose of the pipeline and stop all post processes
  49562. */
  49563. dispose(): void;
  49564. /**
  49565. * Serialize the rendering pipeline (Used when exporting)
  49566. * @returns the serialized object
  49567. */
  49568. serialize(): any;
  49569. /**
  49570. * Parse the serialized pipeline
  49571. * @param source Source pipeline.
  49572. * @param scene The scene to load the pipeline to.
  49573. * @param rootUrl The URL of the serialized pipeline.
  49574. * @returns An instantiated pipeline from the serialized object.
  49575. */
  49576. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49577. }
  49578. }
  49579. declare module BABYLON {
  49580. /**
  49581. * BABYLON.JS Chromatic Aberration GLSL Shader
  49582. * Author: Olivier Guyot
  49583. * Separates very slightly R, G and B colors on the edges of the screen
  49584. * Inspired by Francois Tarlier & Martins Upitis
  49585. */
  49586. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49587. /**
  49588. * @ignore
  49589. * The chromatic aberration PostProcess id in the pipeline
  49590. */
  49591. LensChromaticAberrationEffect: string;
  49592. /**
  49593. * @ignore
  49594. * The highlights enhancing PostProcess id in the pipeline
  49595. */
  49596. HighlightsEnhancingEffect: string;
  49597. /**
  49598. * @ignore
  49599. * The depth-of-field PostProcess id in the pipeline
  49600. */
  49601. LensDepthOfFieldEffect: string;
  49602. private _scene;
  49603. private _depthTexture;
  49604. private _grainTexture;
  49605. private _chromaticAberrationPostProcess;
  49606. private _highlightsPostProcess;
  49607. private _depthOfFieldPostProcess;
  49608. private _edgeBlur;
  49609. private _grainAmount;
  49610. private _chromaticAberration;
  49611. private _distortion;
  49612. private _highlightsGain;
  49613. private _highlightsThreshold;
  49614. private _dofDistance;
  49615. private _dofAperture;
  49616. private _dofDarken;
  49617. private _dofPentagon;
  49618. private _blurNoise;
  49619. /**
  49620. * @constructor
  49621. *
  49622. * Effect parameters are as follow:
  49623. * {
  49624. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49625. * edge_blur: number; // from 0 to x (1 for realism)
  49626. * distortion: number; // from 0 to x (1 for realism)
  49627. * grain_amount: number; // from 0 to 1
  49628. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49629. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49630. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49631. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49632. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49633. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49634. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49635. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49636. * }
  49637. * Note: if an effect parameter is unset, effect is disabled
  49638. *
  49639. * @param name The rendering pipeline name
  49640. * @param parameters - An object containing all parameters (see above)
  49641. * @param scene The scene linked to this pipeline
  49642. * @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)
  49643. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49644. */
  49645. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49646. /**
  49647. * Sets the amount of blur at the edges
  49648. * @param amount blur amount
  49649. */
  49650. setEdgeBlur(amount: number): void;
  49651. /**
  49652. * Sets edge blur to 0
  49653. */
  49654. disableEdgeBlur(): void;
  49655. /**
  49656. * Sets the amout of grain
  49657. * @param amount Amount of grain
  49658. */
  49659. setGrainAmount(amount: number): void;
  49660. /**
  49661. * Set grain amount to 0
  49662. */
  49663. disableGrain(): void;
  49664. /**
  49665. * Sets the chromatic aberration amount
  49666. * @param amount amount of chromatic aberration
  49667. */
  49668. setChromaticAberration(amount: number): void;
  49669. /**
  49670. * Sets chromatic aberration amount to 0
  49671. */
  49672. disableChromaticAberration(): void;
  49673. /**
  49674. * Sets the EdgeDistortion amount
  49675. * @param amount amount of EdgeDistortion
  49676. */
  49677. setEdgeDistortion(amount: number): void;
  49678. /**
  49679. * Sets edge distortion to 0
  49680. */
  49681. disableEdgeDistortion(): void;
  49682. /**
  49683. * Sets the FocusDistance amount
  49684. * @param amount amount of FocusDistance
  49685. */
  49686. setFocusDistance(amount: number): void;
  49687. /**
  49688. * Disables depth of field
  49689. */
  49690. disableDepthOfField(): void;
  49691. /**
  49692. * Sets the Aperture amount
  49693. * @param amount amount of Aperture
  49694. */
  49695. setAperture(amount: number): void;
  49696. /**
  49697. * Sets the DarkenOutOfFocus amount
  49698. * @param amount amount of DarkenOutOfFocus
  49699. */
  49700. setDarkenOutOfFocus(amount: number): void;
  49701. /**
  49702. * Creates a pentagon bokeh effect
  49703. */
  49704. enablePentagonBokeh(): void;
  49705. /**
  49706. * Disables the pentagon bokeh effect
  49707. */
  49708. disablePentagonBokeh(): void;
  49709. /**
  49710. * Enables noise blur
  49711. */
  49712. enableNoiseBlur(): void;
  49713. /**
  49714. * Disables noise blur
  49715. */
  49716. disableNoiseBlur(): void;
  49717. /**
  49718. * Sets the HighlightsGain amount
  49719. * @param amount amount of HighlightsGain
  49720. */
  49721. setHighlightsGain(amount: number): void;
  49722. /**
  49723. * Sets the HighlightsThreshold amount
  49724. * @param amount amount of HighlightsThreshold
  49725. */
  49726. setHighlightsThreshold(amount: number): void;
  49727. /**
  49728. * Disables highlights
  49729. */
  49730. disableHighlights(): void;
  49731. /**
  49732. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49733. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49734. */
  49735. dispose(disableDepthRender?: boolean): void;
  49736. private _createChromaticAberrationPostProcess;
  49737. private _createHighlightsPostProcess;
  49738. private _createDepthOfFieldPostProcess;
  49739. private _createGrainTexture;
  49740. }
  49741. }
  49742. declare module BABYLON {
  49743. /**
  49744. * Render pipeline to produce ssao effect
  49745. */
  49746. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49747. /**
  49748. * @ignore
  49749. * The PassPostProcess id in the pipeline that contains the original scene color
  49750. */
  49751. SSAOOriginalSceneColorEffect: string;
  49752. /**
  49753. * @ignore
  49754. * The SSAO PostProcess id in the pipeline
  49755. */
  49756. SSAORenderEffect: string;
  49757. /**
  49758. * @ignore
  49759. * The horizontal blur PostProcess id in the pipeline
  49760. */
  49761. SSAOBlurHRenderEffect: string;
  49762. /**
  49763. * @ignore
  49764. * The vertical blur PostProcess id in the pipeline
  49765. */
  49766. SSAOBlurVRenderEffect: string;
  49767. /**
  49768. * @ignore
  49769. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49770. */
  49771. SSAOCombineRenderEffect: string;
  49772. /**
  49773. * The output strength of the SSAO post-process. Default value is 1.0.
  49774. */
  49775. totalStrength: number;
  49776. /**
  49777. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  49778. */
  49779. maxZ: number;
  49780. /**
  49781. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  49782. */
  49783. minZAspect: number;
  49784. private _samples;
  49785. /**
  49786. * Number of samples used for the SSAO calculations. Default value is 8
  49787. */
  49788. samples: number;
  49789. private _textureSamples;
  49790. /**
  49791. * Number of samples to use for antialiasing
  49792. */
  49793. textureSamples: number;
  49794. /**
  49795. * Ratio object used for SSAO ratio and blur ratio
  49796. */
  49797. private _ratio;
  49798. /**
  49799. * Dynamically generated sphere sampler.
  49800. */
  49801. private _sampleSphere;
  49802. /**
  49803. * Blur filter offsets
  49804. */
  49805. private _samplerOffsets;
  49806. private _expensiveBlur;
  49807. /**
  49808. * If bilateral blur should be used
  49809. */
  49810. expensiveBlur: boolean;
  49811. /**
  49812. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  49813. */
  49814. radius: number;
  49815. /**
  49816. * The base color of the SSAO post-process
  49817. * The final result is "base + ssao" between [0, 1]
  49818. */
  49819. base: number;
  49820. /**
  49821. * Support test.
  49822. */
  49823. static readonly IsSupported: boolean;
  49824. private _scene;
  49825. private _depthTexture;
  49826. private _normalTexture;
  49827. private _randomTexture;
  49828. private _originalColorPostProcess;
  49829. private _ssaoPostProcess;
  49830. private _blurHPostProcess;
  49831. private _blurVPostProcess;
  49832. private _ssaoCombinePostProcess;
  49833. private _firstUpdate;
  49834. /**
  49835. * @constructor
  49836. * @param name The rendering pipeline name
  49837. * @param scene The scene linked to this pipeline
  49838. * @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 }
  49839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49840. */
  49841. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49842. /**
  49843. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49844. */
  49845. dispose(disableGeometryBufferRenderer?: boolean): void;
  49846. private _createBlurPostProcess;
  49847. /** @hidden */
  49848. _rebuild(): void;
  49849. private _bits;
  49850. private _radicalInverse_VdC;
  49851. private _hammersley;
  49852. private _hemisphereSample_uniform;
  49853. private _generateHemisphere;
  49854. private _createSSAOPostProcess;
  49855. private _createSSAOCombinePostProcess;
  49856. private _createRandomTexture;
  49857. /**
  49858. * Serialize the rendering pipeline (Used when exporting)
  49859. * @returns the serialized object
  49860. */
  49861. serialize(): any;
  49862. /**
  49863. * Parse the serialized pipeline
  49864. * @param source Source pipeline.
  49865. * @param scene The scene to load the pipeline to.
  49866. * @param rootUrl The URL of the serialized pipeline.
  49867. * @returns An instantiated pipeline from the serialized object.
  49868. */
  49869. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  49870. }
  49871. }
  49872. declare module BABYLON {
  49873. /**
  49874. * Render pipeline to produce ssao effect
  49875. */
  49876. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  49877. /**
  49878. * @ignore
  49879. * The PassPostProcess id in the pipeline that contains the original scene color
  49880. */
  49881. SSAOOriginalSceneColorEffect: string;
  49882. /**
  49883. * @ignore
  49884. * The SSAO PostProcess id in the pipeline
  49885. */
  49886. SSAORenderEffect: string;
  49887. /**
  49888. * @ignore
  49889. * The horizontal blur PostProcess id in the pipeline
  49890. */
  49891. SSAOBlurHRenderEffect: string;
  49892. /**
  49893. * @ignore
  49894. * The vertical blur PostProcess id in the pipeline
  49895. */
  49896. SSAOBlurVRenderEffect: string;
  49897. /**
  49898. * @ignore
  49899. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49900. */
  49901. SSAOCombineRenderEffect: string;
  49902. /**
  49903. * The output strength of the SSAO post-process. Default value is 1.0.
  49904. */
  49905. totalStrength: number;
  49906. /**
  49907. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49908. */
  49909. radius: number;
  49910. /**
  49911. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  49912. * Must not be equal to fallOff and superior to fallOff.
  49913. * Default value is 0.975
  49914. */
  49915. area: number;
  49916. /**
  49917. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  49918. * Must not be equal to area and inferior to area.
  49919. * Default value is 0.0
  49920. */
  49921. fallOff: number;
  49922. /**
  49923. * The base color of the SSAO post-process
  49924. * The final result is "base + ssao" between [0, 1]
  49925. */
  49926. base: number;
  49927. private _scene;
  49928. private _depthTexture;
  49929. private _randomTexture;
  49930. private _originalColorPostProcess;
  49931. private _ssaoPostProcess;
  49932. private _blurHPostProcess;
  49933. private _blurVPostProcess;
  49934. private _ssaoCombinePostProcess;
  49935. private _firstUpdate;
  49936. /**
  49937. * @constructor
  49938. * @param name - The rendering pipeline name
  49939. * @param scene - The scene linked to this pipeline
  49940. * @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 }
  49941. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49942. */
  49943. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49944. /**
  49945. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49946. */
  49947. dispose(disableDepthRender?: boolean): void;
  49948. private _createBlurPostProcess;
  49949. /** @hidden */
  49950. _rebuild(): void;
  49951. private _createSSAOPostProcess;
  49952. private _createSSAOCombinePostProcess;
  49953. private _createRandomTexture;
  49954. }
  49955. }
  49956. declare module BABYLON {
  49957. /**
  49958. * Standard rendering pipeline
  49959. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49960. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49961. */
  49962. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49963. /**
  49964. * Public members
  49965. */
  49966. /**
  49967. * Post-process which contains the original scene color before the pipeline applies all the effects
  49968. */
  49969. originalPostProcess: Nullable<PostProcess>;
  49970. /**
  49971. * Post-process used to down scale an image x4
  49972. */
  49973. downSampleX4PostProcess: Nullable<PostProcess>;
  49974. /**
  49975. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49976. */
  49977. brightPassPostProcess: Nullable<PostProcess>;
  49978. /**
  49979. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49980. */
  49981. blurHPostProcesses: PostProcess[];
  49982. /**
  49983. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49984. */
  49985. blurVPostProcesses: PostProcess[];
  49986. /**
  49987. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49988. */
  49989. textureAdderPostProcess: Nullable<PostProcess>;
  49990. /**
  49991. * Post-process used to create volumetric lighting effect
  49992. */
  49993. volumetricLightPostProcess: Nullable<PostProcess>;
  49994. /**
  49995. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49996. */
  49997. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49998. /**
  49999. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50000. */
  50001. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50002. /**
  50003. * Post-process used to merge the volumetric light effect and the real scene color
  50004. */
  50005. volumetricLightMergePostProces: Nullable<PostProcess>;
  50006. /**
  50007. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50008. */
  50009. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50010. /**
  50011. * Base post-process used to calculate the average luminance of the final image for HDR
  50012. */
  50013. luminancePostProcess: Nullable<PostProcess>;
  50014. /**
  50015. * Post-processes used to create down sample post-processes in order to get
  50016. * the average luminance of the final image for HDR
  50017. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50018. */
  50019. luminanceDownSamplePostProcesses: PostProcess[];
  50020. /**
  50021. * Post-process used to create a HDR effect (light adaptation)
  50022. */
  50023. hdrPostProcess: Nullable<PostProcess>;
  50024. /**
  50025. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50026. */
  50027. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50028. /**
  50029. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50030. */
  50031. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50032. /**
  50033. * Post-process used to merge the final HDR post-process and the real scene color
  50034. */
  50035. hdrFinalPostProcess: Nullable<PostProcess>;
  50036. /**
  50037. * Post-process used to create a lens flare effect
  50038. */
  50039. lensFlarePostProcess: Nullable<PostProcess>;
  50040. /**
  50041. * Post-process that merges the result of the lens flare post-process and the real scene color
  50042. */
  50043. lensFlareComposePostProcess: Nullable<PostProcess>;
  50044. /**
  50045. * Post-process used to create a motion blur effect
  50046. */
  50047. motionBlurPostProcess: Nullable<PostProcess>;
  50048. /**
  50049. * Post-process used to create a depth of field effect
  50050. */
  50051. depthOfFieldPostProcess: Nullable<PostProcess>;
  50052. /**
  50053. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50054. */
  50055. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50056. /**
  50057. * Represents the brightness threshold in order to configure the illuminated surfaces
  50058. */
  50059. brightThreshold: number;
  50060. /**
  50061. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50062. */
  50063. blurWidth: number;
  50064. /**
  50065. * Sets if the blur for highlighted surfaces must be only horizontal
  50066. */
  50067. horizontalBlur: boolean;
  50068. /**
  50069. * Sets the overall exposure used by the pipeline
  50070. */
  50071. exposure: number;
  50072. /**
  50073. * Texture used typically to simulate "dirty" on camera lens
  50074. */
  50075. lensTexture: Nullable<Texture>;
  50076. /**
  50077. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50078. */
  50079. volumetricLightCoefficient: number;
  50080. /**
  50081. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50082. */
  50083. volumetricLightPower: number;
  50084. /**
  50085. * Used the set the blur intensity to smooth the volumetric lights
  50086. */
  50087. volumetricLightBlurScale: number;
  50088. /**
  50089. * Light (spot or directional) used to generate the volumetric lights rays
  50090. * The source light must have a shadow generate so the pipeline can get its
  50091. * depth map
  50092. */
  50093. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50094. /**
  50095. * For eye adaptation, represents the minimum luminance the eye can see
  50096. */
  50097. hdrMinimumLuminance: number;
  50098. /**
  50099. * For eye adaptation, represents the decrease luminance speed
  50100. */
  50101. hdrDecreaseRate: number;
  50102. /**
  50103. * For eye adaptation, represents the increase luminance speed
  50104. */
  50105. hdrIncreaseRate: number;
  50106. /**
  50107. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50108. */
  50109. lensColorTexture: Nullable<Texture>;
  50110. /**
  50111. * The overall strengh for the lens flare effect
  50112. */
  50113. lensFlareStrength: number;
  50114. /**
  50115. * Dispersion coefficient for lens flare ghosts
  50116. */
  50117. lensFlareGhostDispersal: number;
  50118. /**
  50119. * Main lens flare halo width
  50120. */
  50121. lensFlareHaloWidth: number;
  50122. /**
  50123. * Based on the lens distortion effect, defines how much the lens flare result
  50124. * is distorted
  50125. */
  50126. lensFlareDistortionStrength: number;
  50127. /**
  50128. * Lens star texture must be used to simulate rays on the flares and is available
  50129. * in the documentation
  50130. */
  50131. lensStarTexture: Nullable<Texture>;
  50132. /**
  50133. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50134. * flare effect by taking account of the dirt texture
  50135. */
  50136. lensFlareDirtTexture: Nullable<Texture>;
  50137. /**
  50138. * Represents the focal length for the depth of field effect
  50139. */
  50140. depthOfFieldDistance: number;
  50141. /**
  50142. * Represents the blur intensity for the blurred part of the depth of field effect
  50143. */
  50144. depthOfFieldBlurWidth: number;
  50145. /**
  50146. * For motion blur, defines how much the image is blurred by the movement
  50147. */
  50148. motionStrength: number;
  50149. /**
  50150. * List of animations for the pipeline (IAnimatable implementation)
  50151. */
  50152. animations: Animation[];
  50153. /**
  50154. * Private members
  50155. */
  50156. private _scene;
  50157. private _currentDepthOfFieldSource;
  50158. private _basePostProcess;
  50159. private _hdrCurrentLuminance;
  50160. private _floatTextureType;
  50161. private _ratio;
  50162. private _bloomEnabled;
  50163. private _depthOfFieldEnabled;
  50164. private _vlsEnabled;
  50165. private _lensFlareEnabled;
  50166. private _hdrEnabled;
  50167. private _motionBlurEnabled;
  50168. private _fxaaEnabled;
  50169. private _motionBlurSamples;
  50170. private _volumetricLightStepsCount;
  50171. private _samples;
  50172. /**
  50173. * @ignore
  50174. * Specifies if the bloom pipeline is enabled
  50175. */
  50176. BloomEnabled: boolean;
  50177. /**
  50178. * @ignore
  50179. * Specifies if the depth of field pipeline is enabed
  50180. */
  50181. DepthOfFieldEnabled: boolean;
  50182. /**
  50183. * @ignore
  50184. * Specifies if the lens flare pipeline is enabed
  50185. */
  50186. LensFlareEnabled: boolean;
  50187. /**
  50188. * @ignore
  50189. * Specifies if the HDR pipeline is enabled
  50190. */
  50191. HDREnabled: boolean;
  50192. /**
  50193. * @ignore
  50194. * Specifies if the volumetric lights scattering effect is enabled
  50195. */
  50196. VLSEnabled: boolean;
  50197. /**
  50198. * @ignore
  50199. * Specifies if the motion blur effect is enabled
  50200. */
  50201. MotionBlurEnabled: boolean;
  50202. /**
  50203. * Specifies if anti-aliasing is enabled
  50204. */
  50205. fxaaEnabled: boolean;
  50206. /**
  50207. * Specifies the number of steps used to calculate the volumetric lights
  50208. * Typically in interval [50, 200]
  50209. */
  50210. volumetricLightStepsCount: number;
  50211. /**
  50212. * Specifies the number of samples used for the motion blur effect
  50213. * Typically in interval [16, 64]
  50214. */
  50215. motionBlurSamples: number;
  50216. /**
  50217. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50218. */
  50219. samples: number;
  50220. /**
  50221. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50222. * @constructor
  50223. * @param name The rendering pipeline name
  50224. * @param scene The scene linked to this pipeline
  50225. * @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)
  50226. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50227. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50228. */
  50229. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50230. private _buildPipeline;
  50231. private _createDownSampleX4PostProcess;
  50232. private _createBrightPassPostProcess;
  50233. private _createBlurPostProcesses;
  50234. private _createTextureAdderPostProcess;
  50235. private _createVolumetricLightPostProcess;
  50236. private _createLuminancePostProcesses;
  50237. private _createHdrPostProcess;
  50238. private _createLensFlarePostProcess;
  50239. private _createDepthOfFieldPostProcess;
  50240. private _createMotionBlurPostProcess;
  50241. private _getDepthTexture;
  50242. private _disposePostProcesses;
  50243. /**
  50244. * Dispose of the pipeline and stop all post processes
  50245. */
  50246. dispose(): void;
  50247. /**
  50248. * Serialize the rendering pipeline (Used when exporting)
  50249. * @returns the serialized object
  50250. */
  50251. serialize(): any;
  50252. /**
  50253. * Parse the serialized pipeline
  50254. * @param source Source pipeline.
  50255. * @param scene The scene to load the pipeline to.
  50256. * @param rootUrl The URL of the serialized pipeline.
  50257. * @returns An instantiated pipeline from the serialized object.
  50258. */
  50259. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50260. /**
  50261. * Luminance steps
  50262. */
  50263. static LuminanceSteps: number;
  50264. }
  50265. }