babylon.d.ts 2.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341
  1. declare module 'babylonjs' { export = BABYLON; }
  2. declare module BABYLON {
  3. /** Alias type for value that can be null */
  4. export type Nullable<T> = T | null;
  5. /**
  6. * Alias type for number that are floats
  7. * @ignorenaming
  8. */
  9. export type float = number;
  10. /**
  11. * Alias type for number that are doubles.
  12. * @ignorenaming
  13. */
  14. export type double = number;
  15. /**
  16. * Alias type for number that are integer
  17. * @ignorenaming
  18. */
  19. export type int = number;
  20. /** Alias type for number array or Float32Array */
  21. export type FloatArray = number[] | Float32Array;
  22. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  23. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  24. /**
  25. * Alias for types that can be used by a Buffer or VertexBuffer.
  26. */
  27. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  28. /**
  29. * Alias type for primitive types
  30. * @ignorenaming
  31. */
  32. type Primitive = undefined | null | boolean | string | number | Function;
  33. /**
  34. * Type modifier to make all the properties of an object Readonly
  35. */
  36. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  37. /**
  38. * Type modifier to make all the properties of an object Readonly recursively
  39. */
  40. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  41. /** @hidden */
  42. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  43. }
  44. /** @hidden */
  45. /** @hidden */
  46. type DeepImmutableObject<T> = {
  47. readonly [K in keyof T]: DeepImmutable<T[K]>;
  48. };
  49. }
  50. declare module BABYLON {
  51. /**
  52. * Class containing a set of static utilities functions for arrays.
  53. */
  54. export class ArrayTools {
  55. /**
  56. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57. * @param size the number of element to construct and put in the array
  58. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59. * @returns a new array filled with new objects
  60. */
  61. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62. }
  63. }
  64. declare module BABYLON {
  65. /**
  66. * Scalar computation library
  67. */
  68. export class Scalar {
  69. /**
  70. * Two pi constants convenient for computation.
  71. */
  72. static TwoPi: number;
  73. /**
  74. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75. * @param a number
  76. * @param b number
  77. * @param epsilon (default = 1.401298E-45)
  78. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79. */
  80. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81. /**
  82. * Returns a string : the upper case translation of the number i to hexadecimal.
  83. * @param i number
  84. * @returns the upper case translation of the number i to hexadecimal.
  85. */
  86. static ToHex(i: number): string;
  87. /**
  88. * Returns -1 if value is negative and +1 is value is positive.
  89. * @param value the value
  90. * @returns the value itself if it's equal to zero.
  91. */
  92. static Sign(value: number): number;
  93. /**
  94. * Returns the value itself if it's between min and max.
  95. * Returns min if the value is lower than min.
  96. * Returns max if the value is greater than max.
  97. * @param value the value to clmap
  98. * @param min the min value to clamp to (default: 0)
  99. * @param max the max value to clamp to (default: 1)
  100. * @returns the clamped value
  101. */
  102. static Clamp(value: number, min?: number, max?: number): number;
  103. /**
  104. * the log2 of value.
  105. * @param value the value to compute log2 of
  106. * @returns the log2 of value.
  107. */
  108. static Log2(value: number): number;
  109. /**
  110. * Loops the value, so that it is never larger than length and never smaller than 0.
  111. *
  112. * This is similar to the modulo operator but it works with floating point numbers.
  113. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  114. * With t = 5 and length = 2.5, the result would be 0.0.
  115. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  116. * @param value the value
  117. * @param length the length
  118. * @returns the looped value
  119. */
  120. static Repeat(value: number, length: number): number;
  121. /**
  122. * Normalize the value between 0.0 and 1.0 using min and max values
  123. * @param value value to normalize
  124. * @param min max to normalize between
  125. * @param max min to normalize between
  126. * @returns the normalized value
  127. */
  128. static Normalize(value: number, min: number, max: number): number;
  129. /**
  130. * Denormalize the value from 0.0 and 1.0 using min and max values
  131. * @param normalized value to denormalize
  132. * @param min max to denormalize between
  133. * @param max min to denormalize between
  134. * @returns the denormalized value
  135. */
  136. static Denormalize(normalized: number, min: number, max: number): number;
  137. /**
  138. * Calculates the shortest difference between two given angles given in degrees.
  139. * @param current current angle in degrees
  140. * @param target target angle in degrees
  141. * @returns the delta
  142. */
  143. static DeltaAngle(current: number, target: number): number;
  144. /**
  145. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  146. * @param tx value
  147. * @param length length
  148. * @returns The returned value will move back and forth between 0 and length
  149. */
  150. static PingPong(tx: number, length: number): number;
  151. /**
  152. * Interpolates between min and max with smoothing at the limits.
  153. *
  154. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  155. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  156. * @param from from
  157. * @param to to
  158. * @param tx value
  159. * @returns the smooth stepped value
  160. */
  161. static SmoothStep(from: number, to: number, tx: number): number;
  162. /**
  163. * Moves a value current towards target.
  164. *
  165. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  166. * Negative values of maxDelta pushes the value away from target.
  167. * @param current current value
  168. * @param target target value
  169. * @param maxDelta max distance to move
  170. * @returns resulting value
  171. */
  172. static MoveTowards(current: number, target: number, maxDelta: number): number;
  173. /**
  174. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  175. *
  176. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  177. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  178. * @param current current value
  179. * @param target target value
  180. * @param maxDelta max distance to move
  181. * @returns resulting angle
  182. */
  183. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  184. /**
  185. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  186. * @param start start value
  187. * @param end target value
  188. * @param amount amount to lerp between
  189. * @returns the lerped value
  190. */
  191. static Lerp(start: number, end: number, amount: number): number;
  192. /**
  193. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  194. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  195. * @param start start value
  196. * @param end target value
  197. * @param amount amount to lerp between
  198. * @returns the lerped value
  199. */
  200. static LerpAngle(start: number, end: number, amount: number): number;
  201. /**
  202. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  203. * @param a start value
  204. * @param b target value
  205. * @param value value between a and b
  206. * @returns the inverseLerp value
  207. */
  208. static InverseLerp(a: number, b: number, value: number): number;
  209. /**
  210. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  211. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  212. * @param value1 spline value
  213. * @param tangent1 spline value
  214. * @param value2 spline value
  215. * @param tangent2 spline value
  216. * @param amount input value
  217. * @returns hermite result
  218. */
  219. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  220. /**
  221. * Returns a random float number between and min and max values
  222. * @param min min value of random
  223. * @param max max value of random
  224. * @returns random value
  225. */
  226. static RandomRange(min: number, max: number): number;
  227. /**
  228. * This function returns percentage of a number in a given range.
  229. *
  230. * RangeToPercent(40,20,60) will return 0.5 (50%)
  231. * RangeToPercent(34,0,100) will return 0.34 (34%)
  232. * @param number to convert to percentage
  233. * @param min min range
  234. * @param max max range
  235. * @returns the percentage
  236. */
  237. static RangeToPercent(number: number, min: number, max: number): number;
  238. /**
  239. * This function returns number that corresponds to the percentage in a given range.
  240. *
  241. * PercentToRange(0.34,0,100) will return 34.
  242. * @param percent to convert to number
  243. * @param min min range
  244. * @param max max range
  245. * @returns the number
  246. */
  247. static PercentToRange(percent: number, min: number, max: number): number;
  248. /**
  249. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  250. * @param angle The angle to normalize in radian.
  251. * @return The converted angle.
  252. */
  253. static NormalizeRadians(angle: number): number;
  254. }
  255. }
  256. declare module BABYLON {
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * 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.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * 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).
  4310. * 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.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @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.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Notify all Observers by calling their respective callback with the given data
  4354. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4355. * @param eventData defines the data to send to all observers
  4356. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4357. * @param target defines the original target of the state
  4358. * @param currentTarget defines the current target of the state
  4359. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4360. */
  4361. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4362. /**
  4363. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4364. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4365. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4366. * and it is crucial that all callbacks will be executed.
  4367. * The order of the callbacks is kept, callbacks are not executed parallel.
  4368. *
  4369. * @param eventData The data to be sent to each callback
  4370. * @param mask is used to filter observers defaults to -1
  4371. * @param target defines the callback target (see EventState)
  4372. * @param currentTarget defines he current object in the bubbling phase
  4373. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4374. */
  4375. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4376. /**
  4377. * Notify a specific observer
  4378. * @param observer defines the observer to notify
  4379. * @param eventData defines the data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. */
  4382. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4383. /**
  4384. * Gets a boolean indicating if the observable has at least one observer
  4385. * @returns true is the Observable has at least one Observer registered
  4386. */
  4387. hasObservers(): boolean;
  4388. /**
  4389. * Clear the list of observers
  4390. */
  4391. clear(): void;
  4392. /**
  4393. * Clone the current observable
  4394. * @returns a new observable
  4395. */
  4396. clone(): Observable<T>;
  4397. /**
  4398. * Does this observable handles observer registered with a given mask
  4399. * @param mask defines the mask to be tested
  4400. * @return whether or not one observer registered with the given mask is handeled
  4401. **/
  4402. hasSpecificMask(mask?: number): boolean;
  4403. }
  4404. }
  4405. declare module BABYLON {
  4406. /**
  4407. * Class used to help managing file picking and drag'n'drop
  4408. * File Storage
  4409. */
  4410. export class FilesInputStore {
  4411. /**
  4412. * List of files ready to be loaded
  4413. */
  4414. static FilesToLoad: {
  4415. [key: string]: File;
  4416. };
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /** Defines the cross module used constants to avoid circular dependncies */
  4421. export class Constants {
  4422. /** Defines that alpha blending is disabled */
  4423. static readonly ALPHA_DISABLE: number;
  4424. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4425. static readonly ALPHA_ADD: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4427. static readonly ALPHA_COMBINE: number;
  4428. /** Defines that alpha blending to DEST - SRC * DEST */
  4429. static readonly ALPHA_SUBTRACT: number;
  4430. /** Defines that alpha blending to SRC * DEST */
  4431. static readonly ALPHA_MULTIPLY: number;
  4432. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4433. static readonly ALPHA_MAXIMIZED: number;
  4434. /** Defines that alpha blending to SRC + DEST */
  4435. static readonly ALPHA_ONEONE: number;
  4436. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_PREMULTIPLIED: number;
  4438. /**
  4439. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4440. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4441. */
  4442. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4443. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4444. static readonly ALPHA_INTERPOLATE: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4447. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. /** Defines that the ressource is not delayed*/
  4451. static readonly DELAYLOADSTATE_NONE: number;
  4452. /** Defines that the ressource was successfully delay loaded */
  4453. static readonly DELAYLOADSTATE_LOADED: number;
  4454. /** Defines that the ressource is currently delay loading */
  4455. static readonly DELAYLOADSTATE_LOADING: number;
  4456. /** Defines that the ressource is delayed and has not started loading */
  4457. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4459. static readonly NEVER: number;
  4460. /** 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 */
  4461. static readonly ALWAYS: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4463. static readonly LESS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4465. static readonly EQUAL: number;
  4466. /** 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 */
  4467. static readonly LEQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4469. static readonly GREATER: number;
  4470. /** 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 */
  4471. static readonly GEQUAL: number;
  4472. /** 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 */
  4473. static readonly NOTEQUAL: number;
  4474. /** Passed to stencilOperation to specify that stencil value must be kept */
  4475. static readonly KEEP: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4477. static readonly REPLACE: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4479. static readonly INCR: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4481. static readonly DECR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4483. static readonly INVERT: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4485. static readonly INCR_WRAP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4487. static readonly DECR_WRAP: number;
  4488. /** Texture is not repeating outside of 0..1 UVs */
  4489. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4490. /** Texture is repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4492. /** Texture is repeating and mirrored */
  4493. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4494. /** ALPHA */
  4495. static readonly TEXTUREFORMAT_ALPHA: number;
  4496. /** LUMINANCE */
  4497. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4498. /** LUMINANCE_ALPHA */
  4499. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4500. /** RGB */
  4501. static readonly TEXTUREFORMAT_RGB: number;
  4502. /** RGBA */
  4503. static readonly TEXTUREFORMAT_RGBA: number;
  4504. /** RED */
  4505. static readonly TEXTUREFORMAT_RED: number;
  4506. /** RED (2nd reference) */
  4507. static readonly TEXTUREFORMAT_R: number;
  4508. /** RG */
  4509. static readonly TEXTUREFORMAT_RG: number;
  4510. /** RED_INTEGER */
  4511. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4512. /** RED_INTEGER (2nd reference) */
  4513. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4514. /** RG_INTEGER */
  4515. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4516. /** RGB_INTEGER */
  4517. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4518. /** RGBA_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4520. /** UNSIGNED_BYTE */
  4521. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4522. /** UNSIGNED_BYTE (2nd reference) */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4524. /** FLOAT */
  4525. static readonly TEXTURETYPE_FLOAT: number;
  4526. /** HALF_FLOAT */
  4527. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4528. /** BYTE */
  4529. static readonly TEXTURETYPE_BYTE: number;
  4530. /** SHORT */
  4531. static readonly TEXTURETYPE_SHORT: number;
  4532. /** UNSIGNED_SHORT */
  4533. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4534. /** INT */
  4535. static readonly TEXTURETYPE_INT: number;
  4536. /** UNSIGNED_INT */
  4537. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4538. /** UNSIGNED_SHORT_4_4_4_4 */
  4539. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4540. /** UNSIGNED_SHORT_5_5_5_1 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4542. /** UNSIGNED_SHORT_5_6_5 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4544. /** UNSIGNED_INT_2_10_10_10_REV */
  4545. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4546. /** UNSIGNED_INT_24_8 */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4548. /** UNSIGNED_INT_10F_11F_11F_REV */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4550. /** UNSIGNED_INT_5_9_9_9_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4552. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4553. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4554. /** nearest is mag = nearest and min = nearest and mip = linear */
  4555. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4557. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4558. /** Trilinear is mag = linear and min = linear and mip = linear */
  4559. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4560. /** nearest is mag = nearest and min = nearest and mip = linear */
  4561. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4563. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4564. /** Trilinear is mag = linear and min = linear and mip = linear */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4566. /** mag = nearest and min = nearest and mip = nearest */
  4567. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4568. /** mag = nearest and min = linear and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = linear */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4572. /** mag = nearest and min = linear and mip = none */
  4573. static readonly TEXTURE_NEAREST_LINEAR: number;
  4574. /** mag = nearest and min = nearest and mip = none */
  4575. static readonly TEXTURE_NEAREST_NEAREST: number;
  4576. /** mag = linear and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4578. /** mag = linear and min = nearest and mip = linear */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4580. /** mag = linear and min = linear and mip = none */
  4581. static readonly TEXTURE_LINEAR_LINEAR: number;
  4582. /** mag = linear and min = nearest and mip = none */
  4583. static readonly TEXTURE_LINEAR_NEAREST: number;
  4584. /** Explicit coordinates mode */
  4585. static readonly TEXTURE_EXPLICIT_MODE: number;
  4586. /** Spherical coordinates mode */
  4587. static readonly TEXTURE_SPHERICAL_MODE: number;
  4588. /** Planar coordinates mode */
  4589. static readonly TEXTURE_PLANAR_MODE: number;
  4590. /** Cubic coordinates mode */
  4591. static readonly TEXTURE_CUBIC_MODE: number;
  4592. /** Projection coordinates mode */
  4593. static readonly TEXTURE_PROJECTION_MODE: number;
  4594. /** Skybox coordinates mode */
  4595. static readonly TEXTURE_SKYBOX_MODE: number;
  4596. /** Inverse Cubic coordinates mode */
  4597. static readonly TEXTURE_INVCUBIC_MODE: number;
  4598. /** Equirectangular coordinates mode */
  4599. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4600. /** Equirectangular Fixed coordinates mode */
  4601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed Mirrored coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4604. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4605. static readonly SCALEMODE_FLOOR: number;
  4606. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4607. static readonly SCALEMODE_NEAREST: number;
  4608. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4609. static readonly SCALEMODE_CEILING: number;
  4610. /**
  4611. * The dirty texture flag value
  4612. */
  4613. static readonly MATERIAL_TextureDirtyFlag: number;
  4614. /**
  4615. * The dirty light flag value
  4616. */
  4617. static readonly MATERIAL_LightDirtyFlag: number;
  4618. /**
  4619. * The dirty fresnel flag value
  4620. */
  4621. static readonly MATERIAL_FresnelDirtyFlag: number;
  4622. /**
  4623. * The dirty attribute flag value
  4624. */
  4625. static readonly MATERIAL_AttributesDirtyFlag: number;
  4626. /**
  4627. * The dirty misc flag value
  4628. */
  4629. static readonly MATERIAL_MiscDirtyFlag: number;
  4630. /**
  4631. * The all dirty flag value
  4632. */
  4633. static readonly MATERIAL_AllDirtyFlag: number;
  4634. /**
  4635. * Returns the triangle fill mode
  4636. */
  4637. static readonly MATERIAL_TriangleFillMode: number;
  4638. /**
  4639. * Returns the wireframe mode
  4640. */
  4641. static readonly MATERIAL_WireFrameFillMode: number;
  4642. /**
  4643. * Returns the point fill mode
  4644. */
  4645. static readonly MATERIAL_PointFillMode: number;
  4646. /**
  4647. * Returns the point list draw mode
  4648. */
  4649. static readonly MATERIAL_PointListDrawMode: number;
  4650. /**
  4651. * Returns the line list draw mode
  4652. */
  4653. static readonly MATERIAL_LineListDrawMode: number;
  4654. /**
  4655. * Returns the line loop draw mode
  4656. */
  4657. static readonly MATERIAL_LineLoopDrawMode: number;
  4658. /**
  4659. * Returns the line strip draw mode
  4660. */
  4661. static readonly MATERIAL_LineStripDrawMode: number;
  4662. /**
  4663. * Returns the triangle strip draw mode
  4664. */
  4665. static readonly MATERIAL_TriangleStripDrawMode: number;
  4666. /**
  4667. * Returns the triangle fan draw mode
  4668. */
  4669. static readonly MATERIAL_TriangleFanDrawMode: number;
  4670. /**
  4671. * Stores the clock-wise side orientation
  4672. */
  4673. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4674. /**
  4675. * Stores the counter clock-wise side orientation
  4676. */
  4677. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4678. /**
  4679. * Nothing
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_NothingTrigger: number;
  4683. /**
  4684. * On pick
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnPickTrigger: number;
  4688. /**
  4689. * On left pick
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_OnLeftPickTrigger: number;
  4693. /**
  4694. * On right pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnRightPickTrigger: number;
  4698. /**
  4699. * On center pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnCenterPickTrigger: number;
  4703. /**
  4704. * On pick down
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickDownTrigger: number;
  4708. /**
  4709. * On double pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnDoublePickTrigger: number;
  4713. /**
  4714. * On pick up
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickUpTrigger: number;
  4718. /**
  4719. * On pick out.
  4720. * This trigger will only be raised if you also declared a OnPickDown
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnPickOutTrigger: number;
  4724. /**
  4725. * On long press
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnLongPressTrigger: number;
  4729. /**
  4730. * On pointer over
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPointerOverTrigger: number;
  4734. /**
  4735. * On pointer out
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnPointerOutTrigger: number;
  4739. /**
  4740. * On every frame
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnEveryFrameTrigger: number;
  4744. /**
  4745. * On intersection enter
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4749. /**
  4750. * On intersection exit
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnIntersectionExitTrigger: number;
  4754. /**
  4755. * On key down
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnKeyDownTrigger: number;
  4759. /**
  4760. * On key up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnKeyUpTrigger: number;
  4764. /**
  4765. * Billboard mode will only apply to Y axis
  4766. */
  4767. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4768. /**
  4769. * Billboard mode will apply to all axes
  4770. */
  4771. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4772. /**
  4773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4774. */
  4775. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4776. /**
  4777. * Gets or sets base Assets URL
  4778. */
  4779. static readonly PARTICLES_BaseAssetsUrl: string;
  4780. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4781. * Test order :
  4782. * Is the bounding sphere outside the frustum ?
  4783. * If not, are the bounding box vertices outside the frustum ?
  4784. * It not, then the cullable object is in the frustum.
  4785. */
  4786. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4787. /** Culling strategy : Bounding Sphere Only.
  4788. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4789. * It's also less accurate than the standard because some not visible objects can still be selected.
  4790. * Test : is the bounding sphere outside the frustum ?
  4791. * If not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4794. /** Culling strategy : Optimistic Inclusion.
  4795. * This in an inclusion test first, then the standard exclusion test.
  4796. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4797. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4798. * Anyway, it's as accurate as the standard strategy.
  4799. * Test :
  4800. * Is the cullable object bounding sphere center in the frustum ?
  4801. * If not, apply the default culling strategy.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4804. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4805. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4806. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4808. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4814. /**
  4815. * No logging while loading
  4816. */
  4817. static readonly SCENELOADER_NO_LOGGING: number;
  4818. /**
  4819. * Minimal logging while loading
  4820. */
  4821. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4822. /**
  4823. * Summary logging while loading
  4824. */
  4825. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4826. /**
  4827. * Detailled logging while loading
  4828. */
  4829. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /**
  4834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4835. * Babylon.js
  4836. */
  4837. export class DomManagement {
  4838. /**
  4839. * Checks if the window object exists
  4840. * @returns true if the window object exists
  4841. */
  4842. static IsWindowObjectExist(): boolean;
  4843. /**
  4844. * Extracts text content from a DOM element hierarchy
  4845. * @param element defines the root element
  4846. * @returns a string
  4847. */
  4848. static GetDOMTextContent(element: HTMLElement): string;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. /**
  4853. * Logger used througouht the application to allow configuration of
  4854. * the log level required for the messages.
  4855. */
  4856. export class Logger {
  4857. /**
  4858. * No log
  4859. */
  4860. static readonly NoneLogLevel: number;
  4861. /**
  4862. * Only message logs
  4863. */
  4864. static readonly MessageLogLevel: number;
  4865. /**
  4866. * Only warning logs
  4867. */
  4868. static readonly WarningLogLevel: number;
  4869. /**
  4870. * Only error logs
  4871. */
  4872. static readonly ErrorLogLevel: number;
  4873. /**
  4874. * All logs
  4875. */
  4876. static readonly AllLogLevel: number;
  4877. private static _LogCache;
  4878. /**
  4879. * Gets a value indicating the number of loading errors
  4880. * @ignorenaming
  4881. */
  4882. static errorsCount: number;
  4883. /**
  4884. * Callback called when a new log is added
  4885. */
  4886. static OnNewCacheEntry: (entry: string) => void;
  4887. private static _AddLogEntry;
  4888. private static _FormatMessage;
  4889. private static _LogDisabled;
  4890. private static _LogEnabled;
  4891. private static _WarnDisabled;
  4892. private static _WarnEnabled;
  4893. private static _ErrorDisabled;
  4894. private static _ErrorEnabled;
  4895. /**
  4896. * Log a message to the console
  4897. */
  4898. static Log: (message: string) => void;
  4899. /**
  4900. * Write a warning message to the console
  4901. */
  4902. static Warn: (message: string) => void;
  4903. /**
  4904. * Write an error message to the console
  4905. */
  4906. static Error: (message: string) => void;
  4907. /**
  4908. * Gets current log cache (list of logs)
  4909. */
  4910. static readonly LogCache: string;
  4911. /**
  4912. * Clears the log cache
  4913. */
  4914. static ClearLogCache(): void;
  4915. /**
  4916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4917. */
  4918. static LogLevels: number;
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class _TypeStore {
  4924. /** @hidden */
  4925. static RegisteredTypes: {
  4926. [key: string]: Object;
  4927. };
  4928. /** @hidden */
  4929. static GetClass(fqdn: string): any;
  4930. }
  4931. }
  4932. declare module BABYLON {
  4933. /**
  4934. * Class containing a set of static utilities functions for deep copy.
  4935. */
  4936. export class DeepCopier {
  4937. /**
  4938. * Tries to copy an object by duplicating every property
  4939. * @param source defines the source object
  4940. * @param destination defines the target object
  4941. * @param doNotCopyList defines a list of properties to avoid
  4942. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4943. */
  4944. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /**
  4949. * Class containing a set of static utilities functions for precision date
  4950. */
  4951. export class PrecisionDate {
  4952. /**
  4953. * Gets either window.performance.now() if supported or Date.now() else
  4954. */
  4955. static readonly Now: number;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class used to evalaute queries containing `and` and `or` operators
  4961. */
  4962. export class AndOrNotEvaluator {
  4963. /**
  4964. * Evaluate a query
  4965. * @param query defines the query to evaluate
  4966. * @param evaluateCallback defines the callback used to filter result
  4967. * @returns true if the query matches
  4968. */
  4969. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4970. private static _HandleParenthesisContent;
  4971. private static _SimplifyNegation;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Class used to store custom tags
  4977. */
  4978. export class Tags {
  4979. /**
  4980. * Adds support for tags on the given object
  4981. * @param obj defines the object to use
  4982. */
  4983. static EnableFor(obj: any): void;
  4984. /**
  4985. * Removes tags support
  4986. * @param obj defines the object to use
  4987. */
  4988. static DisableFor(obj: any): void;
  4989. /**
  4990. * Gets a boolean indicating if the given object has tags
  4991. * @param obj defines the object to use
  4992. * @returns a boolean
  4993. */
  4994. static HasTags(obj: any): boolean;
  4995. /**
  4996. * Gets the tags available on a given object
  4997. * @param obj defines the object to use
  4998. * @param asString defines if the tags must be returned as a string instead of an array of strings
  4999. * @returns the tags
  5000. */
  5001. static GetTags(obj: any, asString?: boolean): any;
  5002. /**
  5003. * Adds tags to an object
  5004. * @param obj defines the object to use
  5005. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5006. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5007. */
  5008. static AddTagsTo(obj: any, tagsString: string): void;
  5009. /**
  5010. * @hidden
  5011. */
  5012. static _AddTagTo(obj: any, tag: string): void;
  5013. /**
  5014. * Removes specific tags from a specific object
  5015. * @param obj defines the object to use
  5016. * @param tagsString defines the tags to remove
  5017. */
  5018. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5019. /**
  5020. * @hidden
  5021. */
  5022. static _RemoveTagFrom(obj: any, tag: string): void;
  5023. /**
  5024. * Defines if tags hosted on an object match a given query
  5025. * @param obj defines the object to use
  5026. * @param tagsQuery defines the tag query
  5027. * @returns a boolean
  5028. */
  5029. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5030. }
  5031. }
  5032. declare module BABYLON {
  5033. /**
  5034. * Manages the defines for the Material
  5035. */
  5036. export class MaterialDefines {
  5037. private _keys;
  5038. private _isDirty;
  5039. /** @hidden */
  5040. _renderId: number;
  5041. /** @hidden */
  5042. _areLightsDirty: boolean;
  5043. /** @hidden */
  5044. _areAttributesDirty: boolean;
  5045. /** @hidden */
  5046. _areTexturesDirty: boolean;
  5047. /** @hidden */
  5048. _areFresnelDirty: boolean;
  5049. /** @hidden */
  5050. _areMiscDirty: boolean;
  5051. /** @hidden */
  5052. _areImageProcessingDirty: boolean;
  5053. /** @hidden */
  5054. _normals: boolean;
  5055. /** @hidden */
  5056. _uvs: boolean;
  5057. /** @hidden */
  5058. _needNormals: boolean;
  5059. /** @hidden */
  5060. _needUVs: boolean;
  5061. /**
  5062. * Specifies if the material needs to be re-calculated
  5063. */
  5064. readonly isDirty: boolean;
  5065. /**
  5066. * Marks the material to indicate that it has been re-calculated
  5067. */
  5068. markAsProcessed(): void;
  5069. /**
  5070. * Marks the material to indicate that it needs to be re-calculated
  5071. */
  5072. markAsUnprocessed(): void;
  5073. /**
  5074. * Marks the material to indicate all of its defines need to be re-calculated
  5075. */
  5076. markAllAsDirty(): void;
  5077. /**
  5078. * Marks the material to indicate that image processing needs to be re-calculated
  5079. */
  5080. markAsImageProcessingDirty(): void;
  5081. /**
  5082. * Marks the material to indicate the lights need to be re-calculated
  5083. */
  5084. markAsLightDirty(): void;
  5085. /**
  5086. * Marks the attribute state as changed
  5087. */
  5088. markAsAttributesDirty(): void;
  5089. /**
  5090. * Marks the texture state as changed
  5091. */
  5092. markAsTexturesDirty(): void;
  5093. /**
  5094. * Marks the fresnel state as changed
  5095. */
  5096. markAsFresnelDirty(): void;
  5097. /**
  5098. * Marks the misc state as changed
  5099. */
  5100. markAsMiscDirty(): void;
  5101. /**
  5102. * Rebuilds the material defines
  5103. */
  5104. rebuild(): void;
  5105. /**
  5106. * Specifies if two material defines are equal
  5107. * @param other - A material define instance to compare to
  5108. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5109. */
  5110. isEqual(other: MaterialDefines): boolean;
  5111. /**
  5112. * Clones this instance's defines to another instance
  5113. * @param other - material defines to clone values to
  5114. */
  5115. cloneTo(other: MaterialDefines): void;
  5116. /**
  5117. * Resets the material define values
  5118. */
  5119. reset(): void;
  5120. /**
  5121. * Converts the material define values to a string
  5122. * @returns - String of material define information
  5123. */
  5124. toString(): string;
  5125. }
  5126. }
  5127. declare module BABYLON {
  5128. /**
  5129. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5130. */
  5131. export class PerformanceMonitor {
  5132. private _enabled;
  5133. private _rollingFrameTime;
  5134. private _lastFrameTimeMs;
  5135. /**
  5136. * constructor
  5137. * @param frameSampleSize The number of samples required to saturate the sliding window
  5138. */
  5139. constructor(frameSampleSize?: number);
  5140. /**
  5141. * Samples current frame
  5142. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5143. */
  5144. sampleFrame(timeMs?: number): void;
  5145. /**
  5146. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5147. */
  5148. readonly averageFrameTime: number;
  5149. /**
  5150. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5151. */
  5152. readonly averageFrameTimeVariance: number;
  5153. /**
  5154. * Returns the frame time of the most recent frame
  5155. */
  5156. readonly instantaneousFrameTime: number;
  5157. /**
  5158. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFPS: number;
  5161. /**
  5162. * Returns the average framerate in frames per second using the most recent frame time
  5163. */
  5164. readonly instantaneousFPS: number;
  5165. /**
  5166. * Returns true if enough samples have been taken to completely fill the sliding window
  5167. */
  5168. readonly isSaturated: boolean;
  5169. /**
  5170. * Enables contributions to the sliding window sample set
  5171. */
  5172. enable(): void;
  5173. /**
  5174. * Disables contributions to the sliding window sample set
  5175. * Samples will not be interpolated over the disabled period
  5176. */
  5177. disable(): void;
  5178. /**
  5179. * Returns true if sampling is enabled
  5180. */
  5181. readonly isEnabled: boolean;
  5182. /**
  5183. * Resets performance monitor
  5184. */
  5185. reset(): void;
  5186. }
  5187. /**
  5188. * RollingAverage
  5189. *
  5190. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5191. */
  5192. export class RollingAverage {
  5193. /**
  5194. * Current average
  5195. */
  5196. average: number;
  5197. /**
  5198. * Current variance
  5199. */
  5200. variance: number;
  5201. protected _samples: Array<number>;
  5202. protected _sampleCount: number;
  5203. protected _pos: number;
  5204. protected _m2: number;
  5205. /**
  5206. * constructor
  5207. * @param length The number of samples required to saturate the sliding window
  5208. */
  5209. constructor(length: number);
  5210. /**
  5211. * Adds a sample to the sample set
  5212. * @param v The sample value
  5213. */
  5214. add(v: number): void;
  5215. /**
  5216. * Returns previously added values or null if outside of history or outside the sliding window domain
  5217. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5218. * @return Value previously recorded with add() or null if outside of range
  5219. */
  5220. history(i: number): number;
  5221. /**
  5222. * Returns true if enough samples have been taken to completely fill the sliding window
  5223. * @return true if sample-set saturated
  5224. */
  5225. isSaturated(): boolean;
  5226. /**
  5227. * Resets the rolling average (equivalent to 0 samples taken so far)
  5228. */
  5229. reset(): void;
  5230. /**
  5231. * Wraps a value around the sample range boundaries
  5232. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5233. * @return Wrapped position in sample range
  5234. */
  5235. protected _wrapPosition(i: number): number;
  5236. }
  5237. }
  5238. declare module BABYLON {
  5239. /**
  5240. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5241. * The underlying implementation relies on an associative array to ensure the best performances.
  5242. * The value can be anything including 'null' but except 'undefined'
  5243. */
  5244. export class StringDictionary<T> {
  5245. /**
  5246. * This will clear this dictionary and copy the content from the 'source' one.
  5247. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5248. * @param source the dictionary to take the content from and copy to this dictionary
  5249. */
  5250. copyFrom(source: StringDictionary<T>): void;
  5251. /**
  5252. * Get a value based from its key
  5253. * @param key the given key to get the matching value from
  5254. * @return the value if found, otherwise undefined is returned
  5255. */
  5256. get(key: string): T | undefined;
  5257. /**
  5258. * Get a value from its key or add it if it doesn't exist.
  5259. * This method will ensure you that a given key/data will be present in the dictionary.
  5260. * @param key the given key to get the matching value from
  5261. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5262. * The factory will only be invoked if there's no data for the given key.
  5263. * @return the value corresponding to the key.
  5264. */
  5265. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5266. /**
  5267. * Get a value from its key if present in the dictionary otherwise add it
  5268. * @param key the key to get the value from
  5269. * @param val if there's no such key/value pair in the dictionary add it with this value
  5270. * @return the value corresponding to the key
  5271. */
  5272. getOrAdd(key: string, val: T): T;
  5273. /**
  5274. * Check if there's a given key in the dictionary
  5275. * @param key the key to check for
  5276. * @return true if the key is present, false otherwise
  5277. */
  5278. contains(key: string): boolean;
  5279. /**
  5280. * Add a new key and its corresponding value
  5281. * @param key the key to add
  5282. * @param value the value corresponding to the key
  5283. * @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
  5284. */
  5285. add(key: string, value: T): boolean;
  5286. /**
  5287. * Update a specific value associated to a key
  5288. * @param key defines the key to use
  5289. * @param value defines the value to store
  5290. * @returns true if the value was updated (or false if the key was not found)
  5291. */
  5292. set(key: string, value: T): boolean;
  5293. /**
  5294. * Get the element of the given key and remove it from the dictionary
  5295. * @param key defines the key to search
  5296. * @returns the value associated with the key or null if not found
  5297. */
  5298. getAndRemove(key: string): Nullable<T>;
  5299. /**
  5300. * Remove a key/value from the dictionary.
  5301. * @param key the key to remove
  5302. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5303. */
  5304. remove(key: string): boolean;
  5305. /**
  5306. * Clear the whole content of the dictionary
  5307. */
  5308. clear(): void;
  5309. /**
  5310. * Gets the current count
  5311. */
  5312. readonly count: number;
  5313. /**
  5314. * Execute a callback on each key/val of the dictionary.
  5315. * Note that you can remove any element in this dictionary in the callback implementation
  5316. * @param callback the callback to execute on a given key/value pair
  5317. */
  5318. forEach(callback: (key: string, val: T) => void): void;
  5319. /**
  5320. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5321. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5322. * Note that you can remove any element in this dictionary in the callback implementation
  5323. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5324. * @returns the first item
  5325. */
  5326. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5327. private _count;
  5328. private _data;
  5329. }
  5330. }
  5331. declare module BABYLON {
  5332. /**
  5333. * Helper class that provides a small promise polyfill
  5334. */
  5335. export class PromisePolyfill {
  5336. /**
  5337. * Static function used to check if the polyfill is required
  5338. * If this is the case then the function will inject the polyfill to window.Promise
  5339. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5340. */
  5341. static Apply(force?: boolean): void;
  5342. }
  5343. }
  5344. declare module BABYLON {
  5345. /**
  5346. * Class used to store data that will be store in GPU memory
  5347. */
  5348. export class Buffer {
  5349. private _engine;
  5350. private _buffer;
  5351. /** @hidden */
  5352. _data: Nullable<DataArray>;
  5353. private _updatable;
  5354. private _instanced;
  5355. /**
  5356. * Gets the byte stride.
  5357. */
  5358. readonly byteStride: number;
  5359. /**
  5360. * Constructor
  5361. * @param engine the engine
  5362. * @param data the data to use for this buffer
  5363. * @param updatable whether the data is updatable
  5364. * @param stride the stride (optional)
  5365. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5366. * @param instanced whether the buffer is instanced (optional)
  5367. * @param useBytes set to true if the stride in in bytes (optional)
  5368. */
  5369. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5370. /**
  5371. * Create a new VertexBuffer based on the current buffer
  5372. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5373. * @param offset defines offset in the buffer (0 by default)
  5374. * @param size defines the size in floats of attributes (position is 3 for instance)
  5375. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5376. * @param instanced defines if the vertex buffer contains indexed data
  5377. * @param useBytes defines if the offset and stride are in bytes
  5378. * @returns the new vertex buffer
  5379. */
  5380. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5381. /**
  5382. * Gets a boolean indicating if the Buffer is updatable?
  5383. * @returns true if the buffer is updatable
  5384. */
  5385. isUpdatable(): boolean;
  5386. /**
  5387. * Gets current buffer's data
  5388. * @returns a DataArray or null
  5389. */
  5390. getData(): Nullable<DataArray>;
  5391. /**
  5392. * Gets underlying native buffer
  5393. * @returns underlying native buffer
  5394. */
  5395. getBuffer(): Nullable<WebGLBuffer>;
  5396. /**
  5397. * Gets the stride in float32 units (i.e. byte stride / 4).
  5398. * May not be an integer if the byte stride is not divisible by 4.
  5399. * DEPRECATED. Use byteStride instead.
  5400. * @returns the stride in float32 units
  5401. */
  5402. getStrideSize(): number;
  5403. /**
  5404. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5405. * @param data defines the data to store
  5406. */
  5407. create(data?: Nullable<DataArray>): void;
  5408. /** @hidden */
  5409. _rebuild(): void;
  5410. /**
  5411. * Update current buffer data
  5412. * @param data defines the data to store
  5413. */
  5414. update(data: DataArray): void;
  5415. /**
  5416. * Updates the data directly.
  5417. * @param data the new data
  5418. * @param offset the new offset
  5419. * @param vertexCount the vertex count (optional)
  5420. * @param useBytes set to true if the offset is in bytes
  5421. */
  5422. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5423. /**
  5424. * Release all resources
  5425. */
  5426. dispose(): void;
  5427. }
  5428. /**
  5429. * Specialized buffer used to store vertex data
  5430. */
  5431. export class VertexBuffer {
  5432. /** @hidden */
  5433. _buffer: Buffer;
  5434. private _kind;
  5435. private _size;
  5436. private _ownsBuffer;
  5437. private _instanced;
  5438. private _instanceDivisor;
  5439. /**
  5440. * The byte type.
  5441. */
  5442. static readonly BYTE: number;
  5443. /**
  5444. * The unsigned byte type.
  5445. */
  5446. static readonly UNSIGNED_BYTE: number;
  5447. /**
  5448. * The short type.
  5449. */
  5450. static readonly SHORT: number;
  5451. /**
  5452. * The unsigned short type.
  5453. */
  5454. static readonly UNSIGNED_SHORT: number;
  5455. /**
  5456. * The integer type.
  5457. */
  5458. static readonly INT: number;
  5459. /**
  5460. * The unsigned integer type.
  5461. */
  5462. static readonly UNSIGNED_INT: number;
  5463. /**
  5464. * The float type.
  5465. */
  5466. static readonly FLOAT: number;
  5467. /**
  5468. * Gets or sets the instance divisor when in instanced mode
  5469. */
  5470. instanceDivisor: number;
  5471. /**
  5472. * Gets the byte stride.
  5473. */
  5474. readonly byteStride: number;
  5475. /**
  5476. * Gets the byte offset.
  5477. */
  5478. readonly byteOffset: number;
  5479. /**
  5480. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5481. */
  5482. readonly normalized: boolean;
  5483. /**
  5484. * Gets the data type of each component in the array.
  5485. */
  5486. readonly type: number;
  5487. /**
  5488. * Constructor
  5489. * @param engine the engine
  5490. * @param data the data to use for this vertex buffer
  5491. * @param kind the vertex buffer kind
  5492. * @param updatable whether the data is updatable
  5493. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5494. * @param stride the stride (optional)
  5495. * @param instanced whether the buffer is instanced (optional)
  5496. * @param offset the offset of the data (optional)
  5497. * @param size the number of components (optional)
  5498. * @param type the type of the component (optional)
  5499. * @param normalized whether the data contains normalized data (optional)
  5500. * @param useBytes set to true if stride and offset are in bytes (optional)
  5501. */
  5502. 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);
  5503. /** @hidden */
  5504. _rebuild(): void;
  5505. /**
  5506. * Returns the kind of the VertexBuffer (string)
  5507. * @returns a string
  5508. */
  5509. getKind(): string;
  5510. /**
  5511. * Gets a boolean indicating if the VertexBuffer is updatable?
  5512. * @returns true if the buffer is updatable
  5513. */
  5514. isUpdatable(): boolean;
  5515. /**
  5516. * Gets current buffer's data
  5517. * @returns a DataArray or null
  5518. */
  5519. getData(): Nullable<DataArray>;
  5520. /**
  5521. * Gets underlying native buffer
  5522. * @returns underlying native buffer
  5523. */
  5524. getBuffer(): Nullable<WebGLBuffer>;
  5525. /**
  5526. * Gets the stride in float32 units (i.e. byte stride / 4).
  5527. * May not be an integer if the byte stride is not divisible by 4.
  5528. * DEPRECATED. Use byteStride instead.
  5529. * @returns the stride in float32 units
  5530. */
  5531. getStrideSize(): number;
  5532. /**
  5533. * Returns the offset as a multiple of the type byte length.
  5534. * DEPRECATED. Use byteOffset instead.
  5535. * @returns the offset in bytes
  5536. */
  5537. getOffset(): number;
  5538. /**
  5539. * Returns the number of components per vertex attribute (integer)
  5540. * @returns the size in float
  5541. */
  5542. getSize(): number;
  5543. /**
  5544. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5545. * @returns true if this buffer is instanced
  5546. */
  5547. getIsInstanced(): boolean;
  5548. /**
  5549. * Returns the instancing divisor, zero for non-instanced (integer).
  5550. * @returns a number
  5551. */
  5552. getInstanceDivisor(): number;
  5553. /**
  5554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5555. * @param data defines the data to store
  5556. */
  5557. create(data?: DataArray): void;
  5558. /**
  5559. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5560. * This function will create a new buffer if the current one is not updatable
  5561. * @param data defines the data to store
  5562. */
  5563. update(data: DataArray): void;
  5564. /**
  5565. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5566. * Returns the directly updated WebGLBuffer.
  5567. * @param data the new data
  5568. * @param offset the new offset
  5569. * @param useBytes set to true if the offset is in bytes
  5570. */
  5571. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5572. /**
  5573. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5574. */
  5575. dispose(): void;
  5576. /**
  5577. * Enumerates each value of this vertex buffer as numbers.
  5578. * @param count the number of values to enumerate
  5579. * @param callback the callback function called for each value
  5580. */
  5581. forEach(count: number, callback: (value: number, index: number) => void): void;
  5582. /**
  5583. * Positions
  5584. */
  5585. static readonly PositionKind: string;
  5586. /**
  5587. * Normals
  5588. */
  5589. static readonly NormalKind: string;
  5590. /**
  5591. * Tangents
  5592. */
  5593. static readonly TangentKind: string;
  5594. /**
  5595. * Texture coordinates
  5596. */
  5597. static readonly UVKind: string;
  5598. /**
  5599. * Texture coordinates 2
  5600. */
  5601. static readonly UV2Kind: string;
  5602. /**
  5603. * Texture coordinates 3
  5604. */
  5605. static readonly UV3Kind: string;
  5606. /**
  5607. * Texture coordinates 4
  5608. */
  5609. static readonly UV4Kind: string;
  5610. /**
  5611. * Texture coordinates 5
  5612. */
  5613. static readonly UV5Kind: string;
  5614. /**
  5615. * Texture coordinates 6
  5616. */
  5617. static readonly UV6Kind: string;
  5618. /**
  5619. * Colors
  5620. */
  5621. static readonly ColorKind: string;
  5622. /**
  5623. * Matrix indices (for bones)
  5624. */
  5625. static readonly MatricesIndicesKind: string;
  5626. /**
  5627. * Matrix weights (for bones)
  5628. */
  5629. static readonly MatricesWeightsKind: string;
  5630. /**
  5631. * Additional matrix indices (for bones)
  5632. */
  5633. static readonly MatricesIndicesExtraKind: string;
  5634. /**
  5635. * Additional matrix weights (for bones)
  5636. */
  5637. static readonly MatricesWeightsExtraKind: string;
  5638. /**
  5639. * Deduces the stride given a kind.
  5640. * @param kind The kind string to deduce
  5641. * @returns The deduced stride
  5642. */
  5643. static DeduceStride(kind: string): number;
  5644. /**
  5645. * Gets the byte length of the given type.
  5646. * @param type the type
  5647. * @returns the number of bytes
  5648. */
  5649. static GetTypeByteLength(type: number): number;
  5650. /**
  5651. * Enumerates each value of the given parameters as numbers.
  5652. * @param data the data to enumerate
  5653. * @param byteOffset the byte offset of the data
  5654. * @param byteStride the byte stride of the data
  5655. * @param componentCount the number of components per element
  5656. * @param componentType the type of the component
  5657. * @param count the total number of components
  5658. * @param normalized whether the data is normalized
  5659. * @param callback the callback function called for each value
  5660. */
  5661. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5662. private static _GetFloatValue;
  5663. }
  5664. }
  5665. declare module BABYLON {
  5666. /**
  5667. * Class representing spherical polynomial coefficients to the 3rd degree
  5668. */
  5669. export class SphericalPolynomial {
  5670. /**
  5671. * The x coefficients of the spherical polynomial
  5672. */
  5673. x: Vector3;
  5674. /**
  5675. * The y coefficients of the spherical polynomial
  5676. */
  5677. y: Vector3;
  5678. /**
  5679. * The z coefficients of the spherical polynomial
  5680. */
  5681. z: Vector3;
  5682. /**
  5683. * The xx coefficients of the spherical polynomial
  5684. */
  5685. xx: Vector3;
  5686. /**
  5687. * The yy coefficients of the spherical polynomial
  5688. */
  5689. yy: Vector3;
  5690. /**
  5691. * The zz coefficients of the spherical polynomial
  5692. */
  5693. zz: Vector3;
  5694. /**
  5695. * The xy coefficients of the spherical polynomial
  5696. */
  5697. xy: Vector3;
  5698. /**
  5699. * The yz coefficients of the spherical polynomial
  5700. */
  5701. yz: Vector3;
  5702. /**
  5703. * The zx coefficients of the spherical polynomial
  5704. */
  5705. zx: Vector3;
  5706. /**
  5707. * Adds an ambient color to the spherical polynomial
  5708. * @param color the color to add
  5709. */
  5710. addAmbient(color: Color3): void;
  5711. /**
  5712. * Scales the spherical polynomial by the given amount
  5713. * @param scale the amount to scale
  5714. */
  5715. scale(scale: number): void;
  5716. /**
  5717. * Gets the spherical polynomial from harmonics
  5718. * @param harmonics the spherical harmonics
  5719. * @returns the spherical polynomial
  5720. */
  5721. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5722. /**
  5723. * Constructs a spherical polynomial from an array.
  5724. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5725. * @returns the spherical polynomial
  5726. */
  5727. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5728. }
  5729. /**
  5730. * Class representing spherical harmonics coefficients to the 3rd degree
  5731. */
  5732. export class SphericalHarmonics {
  5733. /**
  5734. * The l0,0 coefficients of the spherical harmonics
  5735. */
  5736. l00: Vector3;
  5737. /**
  5738. * The l1,-1 coefficients of the spherical harmonics
  5739. */
  5740. l1_1: Vector3;
  5741. /**
  5742. * The l1,0 coefficients of the spherical harmonics
  5743. */
  5744. l10: Vector3;
  5745. /**
  5746. * The l1,1 coefficients of the spherical harmonics
  5747. */
  5748. l11: Vector3;
  5749. /**
  5750. * The l2,-2 coefficients of the spherical harmonics
  5751. */
  5752. l2_2: Vector3;
  5753. /**
  5754. * The l2,-1 coefficients of the spherical harmonics
  5755. */
  5756. l2_1: Vector3;
  5757. /**
  5758. * The l2,0 coefficients of the spherical harmonics
  5759. */
  5760. l20: Vector3;
  5761. /**
  5762. * The l2,1 coefficients of the spherical harmonics
  5763. */
  5764. l21: Vector3;
  5765. /**
  5766. * The l2,2 coefficients of the spherical harmonics
  5767. */
  5768. lL22: Vector3;
  5769. /**
  5770. * Adds a light to the spherical harmonics
  5771. * @param direction the direction of the light
  5772. * @param color the color of the light
  5773. * @param deltaSolidAngle the delta solid angle of the light
  5774. */
  5775. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5776. /**
  5777. * Scales the spherical harmonics by the given amount
  5778. * @param scale the amount to scale
  5779. */
  5780. scale(scale: number): void;
  5781. /**
  5782. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5783. *
  5784. * ```
  5785. * E_lm = A_l * L_lm
  5786. * ```
  5787. *
  5788. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5789. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5790. * the scaling factors are given in equation 9.
  5791. */
  5792. convertIncidentRadianceToIrradiance(): void;
  5793. /**
  5794. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5795. *
  5796. * ```
  5797. * L = (1/pi) * E * rho
  5798. * ```
  5799. *
  5800. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5801. */
  5802. convertIrradianceToLambertianRadiance(): void;
  5803. /**
  5804. * Gets the spherical harmonics from polynomial
  5805. * @param polynomial the spherical polynomial
  5806. * @returns the spherical harmonics
  5807. */
  5808. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5809. /**
  5810. * Constructs a spherical harmonics from an array.
  5811. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5812. * @returns the spherical harmonics
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5815. }
  5816. }
  5817. declare module BABYLON {
  5818. /**
  5819. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5820. */
  5821. export interface CubeMapInfo {
  5822. /**
  5823. * The pixel array for the front face.
  5824. * This is stored in format, left to right, up to down format.
  5825. */
  5826. front: Nullable<ArrayBufferView>;
  5827. /**
  5828. * The pixel array for the back face.
  5829. * This is stored in format, left to right, up to down format.
  5830. */
  5831. back: Nullable<ArrayBufferView>;
  5832. /**
  5833. * The pixel array for the left face.
  5834. * This is stored in format, left to right, up to down format.
  5835. */
  5836. left: Nullable<ArrayBufferView>;
  5837. /**
  5838. * The pixel array for the right face.
  5839. * This is stored in format, left to right, up to down format.
  5840. */
  5841. right: Nullable<ArrayBufferView>;
  5842. /**
  5843. * The pixel array for the up face.
  5844. * This is stored in format, left to right, up to down format.
  5845. */
  5846. up: Nullable<ArrayBufferView>;
  5847. /**
  5848. * The pixel array for the down face.
  5849. * This is stored in format, left to right, up to down format.
  5850. */
  5851. down: Nullable<ArrayBufferView>;
  5852. /**
  5853. * The size of the cubemap stored.
  5854. *
  5855. * Each faces will be size * size pixels.
  5856. */
  5857. size: number;
  5858. /**
  5859. * The format of the texture.
  5860. *
  5861. * RGBA, RGB.
  5862. */
  5863. format: number;
  5864. /**
  5865. * The type of the texture data.
  5866. *
  5867. * UNSIGNED_INT, FLOAT.
  5868. */
  5869. type: number;
  5870. /**
  5871. * Specifies whether the texture is in gamma space.
  5872. */
  5873. gammaSpace: boolean;
  5874. }
  5875. /**
  5876. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5877. */
  5878. export class PanoramaToCubeMapTools {
  5879. private static FACE_FRONT;
  5880. private static FACE_BACK;
  5881. private static FACE_RIGHT;
  5882. private static FACE_LEFT;
  5883. private static FACE_DOWN;
  5884. private static FACE_UP;
  5885. /**
  5886. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5887. *
  5888. * @param float32Array The source data.
  5889. * @param inputWidth The width of the input panorama.
  5890. * @param inputHeight The height of the input panorama.
  5891. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5892. * @return The cubemap data
  5893. */
  5894. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5895. private static CreateCubemapTexture;
  5896. private static CalcProjectionSpherical;
  5897. }
  5898. }
  5899. declare module BABYLON {
  5900. /**
  5901. * Helper class dealing with the extraction of spherical polynomial dataArray
  5902. * from a cube map.
  5903. */
  5904. export class CubeMapToSphericalPolynomialTools {
  5905. private static FileFaces;
  5906. /**
  5907. * Converts a texture to the according Spherical Polynomial data.
  5908. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5909. *
  5910. * @param texture The texture to extract the information from.
  5911. * @return The Spherical Polynomial data.
  5912. */
  5913. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5914. /**
  5915. * Converts a cubemap to the according Spherical Polynomial data.
  5916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5917. *
  5918. * @param cubeInfo The Cube map to extract the information from.
  5919. * @return The Spherical Polynomial data.
  5920. */
  5921. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5922. }
  5923. }
  5924. declare module BABYLON {
  5925. /**
  5926. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5927. * during the life time of the application.
  5928. */
  5929. export class EngineStore {
  5930. /** Gets the list of created engines */
  5931. static Instances: Engine[];
  5932. /**
  5933. * Gets the latest created engine
  5934. */
  5935. static readonly LastCreatedEngine: Nullable<Engine>;
  5936. /**
  5937. * Gets the latest created scene
  5938. */
  5939. static readonly LastCreatedScene: Nullable<Scene>;
  5940. }
  5941. }
  5942. declare module BABYLON {
  5943. /**
  5944. * Define options used to create a render target texture
  5945. */
  5946. export class RenderTargetCreationOptions {
  5947. /**
  5948. * Specifies is mipmaps must be generated
  5949. */
  5950. generateMipMaps?: boolean;
  5951. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5952. generateDepthBuffer?: boolean;
  5953. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5954. generateStencilBuffer?: boolean;
  5955. /** Defines texture type (int by default) */
  5956. type?: number;
  5957. /** Defines sampling mode (trilinear by default) */
  5958. samplingMode?: number;
  5959. /** Defines format (RGBA by default) */
  5960. format?: number;
  5961. }
  5962. }
  5963. declare module BABYLON {
  5964. /**
  5965. * @hidden
  5966. **/
  5967. export class _AlphaState {
  5968. private _isAlphaBlendDirty;
  5969. private _isBlendFunctionParametersDirty;
  5970. private _isBlendEquationParametersDirty;
  5971. private _isBlendConstantsDirty;
  5972. private _alphaBlend;
  5973. private _blendFunctionParameters;
  5974. private _blendEquationParameters;
  5975. private _blendConstants;
  5976. /**
  5977. * Initializes the state.
  5978. */
  5979. constructor();
  5980. readonly isDirty: boolean;
  5981. alphaBlend: boolean;
  5982. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5983. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5984. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5985. reset(): void;
  5986. apply(gl: WebGLRenderingContext): void;
  5987. }
  5988. }
  5989. declare module BABYLON {
  5990. /**
  5991. * @hidden
  5992. **/
  5993. export class _DepthCullingState {
  5994. private _isDepthTestDirty;
  5995. private _isDepthMaskDirty;
  5996. private _isDepthFuncDirty;
  5997. private _isCullFaceDirty;
  5998. private _isCullDirty;
  5999. private _isZOffsetDirty;
  6000. private _isFrontFaceDirty;
  6001. private _depthTest;
  6002. private _depthMask;
  6003. private _depthFunc;
  6004. private _cull;
  6005. private _cullFace;
  6006. private _zOffset;
  6007. private _frontFace;
  6008. /**
  6009. * Initializes the state.
  6010. */
  6011. constructor();
  6012. readonly isDirty: boolean;
  6013. zOffset: number;
  6014. cullFace: Nullable<number>;
  6015. cull: Nullable<boolean>;
  6016. depthFunc: Nullable<number>;
  6017. depthMask: boolean;
  6018. depthTest: boolean;
  6019. frontFace: Nullable<number>;
  6020. reset(): void;
  6021. apply(gl: WebGLRenderingContext): void;
  6022. }
  6023. }
  6024. declare module BABYLON {
  6025. /**
  6026. * @hidden
  6027. **/
  6028. export class _StencilState {
  6029. /** 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 */
  6030. static readonly ALWAYS: number;
  6031. /** Passed to stencilOperation to specify that stencil value must be kept */
  6032. static readonly KEEP: number;
  6033. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6034. static readonly REPLACE: number;
  6035. private _isStencilTestDirty;
  6036. private _isStencilMaskDirty;
  6037. private _isStencilFuncDirty;
  6038. private _isStencilOpDirty;
  6039. private _stencilTest;
  6040. private _stencilMask;
  6041. private _stencilFunc;
  6042. private _stencilFuncRef;
  6043. private _stencilFuncMask;
  6044. private _stencilOpStencilFail;
  6045. private _stencilOpDepthFail;
  6046. private _stencilOpStencilDepthPass;
  6047. readonly isDirty: boolean;
  6048. stencilFunc: number;
  6049. stencilFuncRef: number;
  6050. stencilFuncMask: number;
  6051. stencilOpStencilFail: number;
  6052. stencilOpDepthFail: number;
  6053. stencilOpStencilDepthPass: number;
  6054. stencilMask: number;
  6055. stencilTest: boolean;
  6056. constructor();
  6057. reset(): void;
  6058. apply(gl: WebGLRenderingContext): void;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * @hidden
  6064. **/
  6065. export class _TimeToken {
  6066. _startTimeQuery: Nullable<WebGLQuery>;
  6067. _endTimeQuery: Nullable<WebGLQuery>;
  6068. _timeElapsedQuery: Nullable<WebGLQuery>;
  6069. _timeElapsedQueryEnded: boolean;
  6070. }
  6071. }
  6072. declare module BABYLON {
  6073. /**
  6074. * Internal interface used to track InternalTexture already bound to the GL context
  6075. */
  6076. export interface IInternalTextureTracker {
  6077. /**
  6078. * Gets or set the previous tracker in the list
  6079. */
  6080. previous: Nullable<IInternalTextureTracker>;
  6081. /**
  6082. * Gets or set the next tracker in the list
  6083. */
  6084. next: Nullable<IInternalTextureTracker>;
  6085. }
  6086. /**
  6087. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6088. */
  6089. export class DummyInternalTextureTracker {
  6090. /**
  6091. * Gets or set the previous tracker in the list
  6092. */
  6093. previous: Nullable<IInternalTextureTracker>;
  6094. /**
  6095. * Gets or set the next tracker in the list
  6096. */
  6097. next: Nullable<IInternalTextureTracker>;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * Class used to store data associated with WebGL texture data for the engine
  6103. * This class should not be used directly
  6104. */
  6105. export class InternalTexture implements IInternalTextureTracker {
  6106. /** hidden */
  6107. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6108. /**
  6109. * The source of the texture data is unknown
  6110. */
  6111. static DATASOURCE_UNKNOWN: number;
  6112. /**
  6113. * Texture data comes from an URL
  6114. */
  6115. static DATASOURCE_URL: number;
  6116. /**
  6117. * Texture data is only used for temporary storage
  6118. */
  6119. static DATASOURCE_TEMP: number;
  6120. /**
  6121. * Texture data comes from raw data (ArrayBuffer)
  6122. */
  6123. static DATASOURCE_RAW: number;
  6124. /**
  6125. * Texture content is dynamic (video or dynamic texture)
  6126. */
  6127. static DATASOURCE_DYNAMIC: number;
  6128. /**
  6129. * Texture content is generated by rendering to it
  6130. */
  6131. static DATASOURCE_RENDERTARGET: number;
  6132. /**
  6133. * Texture content is part of a multi render target process
  6134. */
  6135. static DATASOURCE_MULTIRENDERTARGET: number;
  6136. /**
  6137. * Texture data comes from a cube data file
  6138. */
  6139. static DATASOURCE_CUBE: number;
  6140. /**
  6141. * Texture data comes from a raw cube data
  6142. */
  6143. static DATASOURCE_CUBERAW: number;
  6144. /**
  6145. * Texture data come from a prefiltered cube data file
  6146. */
  6147. static DATASOURCE_CUBEPREFILTERED: number;
  6148. /**
  6149. * Texture content is raw 3D data
  6150. */
  6151. static DATASOURCE_RAW3D: number;
  6152. /**
  6153. * Texture content is a depth texture
  6154. */
  6155. static DATASOURCE_DEPTHTEXTURE: number;
  6156. /**
  6157. * Texture data comes from a raw cube data encoded with RGBD
  6158. */
  6159. static DATASOURCE_CUBERAW_RGBD: number;
  6160. /**
  6161. * Defines if the texture is ready
  6162. */
  6163. isReady: boolean;
  6164. /**
  6165. * Defines if the texture is a cube texture
  6166. */
  6167. isCube: boolean;
  6168. /**
  6169. * Defines if the texture contains 3D data
  6170. */
  6171. is3D: boolean;
  6172. /**
  6173. * Gets the URL used to load this texture
  6174. */
  6175. url: string;
  6176. /**
  6177. * Gets the sampling mode of the texture
  6178. */
  6179. samplingMode: number;
  6180. /**
  6181. * Gets a boolean indicating if the texture needs mipmaps generation
  6182. */
  6183. generateMipMaps: boolean;
  6184. /**
  6185. * Gets the number of samples used by the texture (WebGL2+ only)
  6186. */
  6187. samples: number;
  6188. /**
  6189. * Gets the type of the texture (int, float...)
  6190. */
  6191. type: number;
  6192. /**
  6193. * Gets the format of the texture (RGB, RGBA...)
  6194. */
  6195. format: number;
  6196. /**
  6197. * Observable called when the texture is loaded
  6198. */
  6199. onLoadedObservable: Observable<InternalTexture>;
  6200. /**
  6201. * Gets the width of the texture
  6202. */
  6203. width: number;
  6204. /**
  6205. * Gets the height of the texture
  6206. */
  6207. height: number;
  6208. /**
  6209. * Gets the depth of the texture
  6210. */
  6211. depth: number;
  6212. /**
  6213. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6214. */
  6215. baseWidth: number;
  6216. /**
  6217. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6218. */
  6219. baseHeight: number;
  6220. /**
  6221. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6222. */
  6223. baseDepth: number;
  6224. /**
  6225. * Gets a boolean indicating if the texture is inverted on Y axis
  6226. */
  6227. invertY: boolean;
  6228. /**
  6229. * Gets or set the previous tracker in the list
  6230. */
  6231. previous: Nullable<IInternalTextureTracker>;
  6232. /**
  6233. * Gets or set the next tracker in the list
  6234. */
  6235. next: Nullable<IInternalTextureTracker>;
  6236. /** @hidden */
  6237. _invertVScale: boolean;
  6238. /** @hidden */
  6239. _initialSlot: number;
  6240. /** @hidden */
  6241. _designatedSlot: number;
  6242. /** @hidden */
  6243. _dataSource: number;
  6244. /** @hidden */
  6245. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6246. /** @hidden */
  6247. _bufferView: Nullable<ArrayBufferView>;
  6248. /** @hidden */
  6249. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6250. /** @hidden */
  6251. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6252. /** @hidden */
  6253. _size: number;
  6254. /** @hidden */
  6255. _extension: string;
  6256. /** @hidden */
  6257. _files: Nullable<string[]>;
  6258. /** @hidden */
  6259. _workingCanvas: HTMLCanvasElement;
  6260. /** @hidden */
  6261. _workingContext: CanvasRenderingContext2D;
  6262. /** @hidden */
  6263. _framebuffer: Nullable<WebGLFramebuffer>;
  6264. /** @hidden */
  6265. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6266. /** @hidden */
  6267. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6268. /** @hidden */
  6269. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6270. /** @hidden */
  6271. _attachments: Nullable<number[]>;
  6272. /** @hidden */
  6273. _cachedCoordinatesMode: Nullable<number>;
  6274. /** @hidden */
  6275. _cachedWrapU: Nullable<number>;
  6276. /** @hidden */
  6277. _cachedWrapV: Nullable<number>;
  6278. /** @hidden */
  6279. _cachedWrapR: Nullable<number>;
  6280. /** @hidden */
  6281. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6282. /** @hidden */
  6283. _isDisabled: boolean;
  6284. /** @hidden */
  6285. _compression: Nullable<string>;
  6286. /** @hidden */
  6287. _generateStencilBuffer: boolean;
  6288. /** @hidden */
  6289. _generateDepthBuffer: boolean;
  6290. /** @hidden */
  6291. _comparisonFunction: number;
  6292. /** @hidden */
  6293. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6294. /** @hidden */
  6295. _lodGenerationScale: number;
  6296. /** @hidden */
  6297. _lodGenerationOffset: number;
  6298. /** @hidden */
  6299. _lodTextureHigh: BaseTexture;
  6300. /** @hidden */
  6301. _lodTextureMid: BaseTexture;
  6302. /** @hidden */
  6303. _lodTextureLow: BaseTexture;
  6304. /** @hidden */
  6305. _isRGBD: boolean;
  6306. /** @hidden */
  6307. _webGLTexture: Nullable<WebGLTexture>;
  6308. /** @hidden */
  6309. _references: number;
  6310. private _engine;
  6311. /**
  6312. * Gets the Engine the texture belongs to.
  6313. * @returns The babylon engine
  6314. */
  6315. getEngine(): Engine;
  6316. /**
  6317. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6318. */
  6319. readonly dataSource: number;
  6320. /**
  6321. * Creates a new InternalTexture
  6322. * @param engine defines the engine to use
  6323. * @param dataSource defines the type of data that will be used
  6324. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6325. */
  6326. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6327. /**
  6328. * Increments the number of references (ie. the number of Texture that point to it)
  6329. */
  6330. incrementReferences(): void;
  6331. /**
  6332. * Change the size of the texture (not the size of the content)
  6333. * @param width defines the new width
  6334. * @param height defines the new height
  6335. * @param depth defines the new depth (1 by default)
  6336. */
  6337. updateSize(width: int, height: int, depth?: int): void;
  6338. /** @hidden */
  6339. _rebuild(): void;
  6340. /** @hidden */
  6341. _swapAndDie(target: InternalTexture): void;
  6342. /**
  6343. * Dispose the current allocated resources
  6344. */
  6345. dispose(): void;
  6346. }
  6347. }
  6348. declare module BABYLON {
  6349. /**
  6350. * This represents the main contract an easing function should follow.
  6351. * Easing functions are used throughout the animation system.
  6352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6353. */
  6354. export interface IEasingFunction {
  6355. /**
  6356. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6357. * of the easing function.
  6358. * The link below provides some of the most common examples of easing functions.
  6359. * @see https://easings.net/
  6360. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6361. * @returns the corresponding value on the curve defined by the easing function
  6362. */
  6363. ease(gradient: number): number;
  6364. }
  6365. /**
  6366. * Base class used for every default easing function.
  6367. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6368. */
  6369. export class EasingFunction implements IEasingFunction {
  6370. /**
  6371. * Interpolation follows the mathematical formula associated with the easing function.
  6372. */
  6373. static readonly EASINGMODE_EASEIN: number;
  6374. /**
  6375. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6376. */
  6377. static readonly EASINGMODE_EASEOUT: number;
  6378. /**
  6379. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6380. */
  6381. static readonly EASINGMODE_EASEINOUT: number;
  6382. private _easingMode;
  6383. /**
  6384. * Sets the easing mode of the current function.
  6385. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6386. */
  6387. setEasingMode(easingMode: number): void;
  6388. /**
  6389. * Gets the current easing mode.
  6390. * @returns the easing mode
  6391. */
  6392. getEasingMode(): number;
  6393. /**
  6394. * @hidden
  6395. */
  6396. easeInCore(gradient: number): number;
  6397. /**
  6398. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6399. * of the easing function.
  6400. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6401. * @returns the corresponding value on the curve defined by the easing function
  6402. */
  6403. ease(gradient: number): number;
  6404. }
  6405. /**
  6406. * Easing function with a circle shape (see link below).
  6407. * @see https://easings.net/#easeInCirc
  6408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6409. */
  6410. export class CircleEase extends EasingFunction implements IEasingFunction {
  6411. /** @hidden */
  6412. easeInCore(gradient: number): number;
  6413. }
  6414. /**
  6415. * Easing function with a ease back shape (see link below).
  6416. * @see https://easings.net/#easeInBack
  6417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6418. */
  6419. export class BackEase extends EasingFunction implements IEasingFunction {
  6420. /** Defines the amplitude of the function */
  6421. amplitude: number;
  6422. /**
  6423. * Instantiates a back ease easing
  6424. * @see https://easings.net/#easeInBack
  6425. * @param amplitude Defines the amplitude of the function
  6426. */
  6427. constructor(
  6428. /** Defines the amplitude of the function */
  6429. amplitude?: number);
  6430. /** @hidden */
  6431. easeInCore(gradient: number): number;
  6432. }
  6433. /**
  6434. * Easing function with a bouncing shape (see link below).
  6435. * @see https://easings.net/#easeInBounce
  6436. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6437. */
  6438. export class BounceEase extends EasingFunction implements IEasingFunction {
  6439. /** Defines the number of bounces */
  6440. bounces: number;
  6441. /** Defines the amplitude of the bounce */
  6442. bounciness: number;
  6443. /**
  6444. * Instantiates a bounce easing
  6445. * @see https://easings.net/#easeInBounce
  6446. * @param bounces Defines the number of bounces
  6447. * @param bounciness Defines the amplitude of the bounce
  6448. */
  6449. constructor(
  6450. /** Defines the number of bounces */
  6451. bounces?: number,
  6452. /** Defines the amplitude of the bounce */
  6453. bounciness?: number);
  6454. /** @hidden */
  6455. easeInCore(gradient: number): number;
  6456. }
  6457. /**
  6458. * Easing function with a power of 3 shape (see link below).
  6459. * @see https://easings.net/#easeInCubic
  6460. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6461. */
  6462. export class CubicEase extends EasingFunction implements IEasingFunction {
  6463. /** @hidden */
  6464. easeInCore(gradient: number): number;
  6465. }
  6466. /**
  6467. * Easing function with an elastic shape (see link below).
  6468. * @see https://easings.net/#easeInElastic
  6469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6470. */
  6471. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6472. /** Defines the number of oscillations*/
  6473. oscillations: number;
  6474. /** Defines the amplitude of the oscillations*/
  6475. springiness: number;
  6476. /**
  6477. * Instantiates an elastic easing function
  6478. * @see https://easings.net/#easeInElastic
  6479. * @param oscillations Defines the number of oscillations
  6480. * @param springiness Defines the amplitude of the oscillations
  6481. */
  6482. constructor(
  6483. /** Defines the number of oscillations*/
  6484. oscillations?: number,
  6485. /** Defines the amplitude of the oscillations*/
  6486. springiness?: number);
  6487. /** @hidden */
  6488. easeInCore(gradient: number): number;
  6489. }
  6490. /**
  6491. * Easing function with an exponential shape (see link below).
  6492. * @see https://easings.net/#easeInExpo
  6493. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6494. */
  6495. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6496. /** Defines the exponent of the function */
  6497. exponent: number;
  6498. /**
  6499. * Instantiates an exponential easing function
  6500. * @see https://easings.net/#easeInExpo
  6501. * @param exponent Defines the exponent of the function
  6502. */
  6503. constructor(
  6504. /** Defines the exponent of the function */
  6505. exponent?: number);
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a power shape (see link below).
  6511. * @see https://easings.net/#easeInQuad
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class PowerEase extends EasingFunction implements IEasingFunction {
  6515. /** Defines the power of the function */
  6516. power: number;
  6517. /**
  6518. * Instantiates an power base easing function
  6519. * @see https://easings.net/#easeInQuad
  6520. * @param power Defines the power of the function
  6521. */
  6522. constructor(
  6523. /** Defines the power of the function */
  6524. power?: number);
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with a power of 2 shape (see link below).
  6530. * @see https://easings.net/#easeInQuad
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6534. /** @hidden */
  6535. easeInCore(gradient: number): number;
  6536. }
  6537. /**
  6538. * Easing function with a power of 4 shape (see link below).
  6539. * @see https://easings.net/#easeInQuart
  6540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6541. */
  6542. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6543. /** @hidden */
  6544. easeInCore(gradient: number): number;
  6545. }
  6546. /**
  6547. * Easing function with a power of 5 shape (see link below).
  6548. * @see https://easings.net/#easeInQuint
  6549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6550. */
  6551. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a sin shape (see link below).
  6557. * @see https://easings.net/#easeInSine
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class SineEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with a bezier shape (see link below).
  6566. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the x component of the start tangent in the bezier curve */
  6571. x1: number;
  6572. /** Defines the y component of the start tangent in the bezier curve */
  6573. y1: number;
  6574. /** Defines the x component of the end tangent in the bezier curve */
  6575. x2: number;
  6576. /** Defines the y component of the end tangent in the bezier curve */
  6577. y2: number;
  6578. /**
  6579. * Instantiates a bezier function
  6580. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6581. * @param x1 Defines the x component of the start tangent in the bezier curve
  6582. * @param y1 Defines the y component of the start tangent in the bezier curve
  6583. * @param x2 Defines the x component of the end tangent in the bezier curve
  6584. * @param y2 Defines the y component of the end tangent in the bezier curve
  6585. */
  6586. constructor(
  6587. /** Defines the x component of the start tangent in the bezier curve */
  6588. x1?: number,
  6589. /** Defines the y component of the start tangent in the bezier curve */
  6590. y1?: number,
  6591. /** Defines the x component of the end tangent in the bezier curve */
  6592. x2?: number,
  6593. /** Defines the y component of the end tangent in the bezier curve */
  6594. y2?: number);
  6595. /** @hidden */
  6596. easeInCore(gradient: number): number;
  6597. }
  6598. }
  6599. declare module BABYLON {
  6600. /**
  6601. * Interface used to define a behavior
  6602. */
  6603. export interface Behavior<T> {
  6604. /** gets or sets behavior's name */
  6605. name: string;
  6606. /**
  6607. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6608. */
  6609. init(): void;
  6610. /**
  6611. * Called when the behavior is attached to a target
  6612. * @param target defines the target where the behavior is attached to
  6613. */
  6614. attach(target: T): void;
  6615. /**
  6616. * Called when the behavior is detached from its target
  6617. */
  6618. detach(): void;
  6619. }
  6620. /**
  6621. * Interface implemented by classes supporting behaviors
  6622. */
  6623. export interface IBehaviorAware<T> {
  6624. /**
  6625. * Attach a behavior
  6626. * @param behavior defines the behavior to attach
  6627. * @returns the current host
  6628. */
  6629. addBehavior(behavior: Behavior<T>): T;
  6630. /**
  6631. * Remove a behavior from the current object
  6632. * @param behavior defines the behavior to detach
  6633. * @returns the current host
  6634. */
  6635. removeBehavior(behavior: Behavior<T>): T;
  6636. /**
  6637. * Gets a behavior using its name to search
  6638. * @param name defines the name to search
  6639. * @returns the behavior or null if not found
  6640. */
  6641. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6642. }
  6643. }
  6644. declare module BABYLON {
  6645. /**
  6646. * Defines a runtime animation
  6647. */
  6648. export class RuntimeAnimation {
  6649. private _events;
  6650. /**
  6651. * The current frame of the runtime animation
  6652. */
  6653. private _currentFrame;
  6654. /**
  6655. * The animation used by the runtime animation
  6656. */
  6657. private _animation;
  6658. /**
  6659. * The target of the runtime animation
  6660. */
  6661. private _target;
  6662. /**
  6663. * The initiating animatable
  6664. */
  6665. private _host;
  6666. /**
  6667. * The original value of the runtime animation
  6668. */
  6669. private _originalValue;
  6670. /**
  6671. * The original blend value of the runtime animation
  6672. */
  6673. private _originalBlendValue;
  6674. /**
  6675. * The offsets cache of the runtime animation
  6676. */
  6677. private _offsetsCache;
  6678. /**
  6679. * The high limits cache of the runtime animation
  6680. */
  6681. private _highLimitsCache;
  6682. /**
  6683. * Specifies if the runtime animation has been stopped
  6684. */
  6685. private _stopped;
  6686. /**
  6687. * The blending factor of the runtime animation
  6688. */
  6689. private _blendingFactor;
  6690. /**
  6691. * The BabylonJS scene
  6692. */
  6693. private _scene;
  6694. /**
  6695. * The current value of the runtime animation
  6696. */
  6697. private _currentValue;
  6698. /** @hidden */
  6699. _workValue: any;
  6700. /**
  6701. * The active target of the runtime animation
  6702. */
  6703. private _activeTarget;
  6704. /**
  6705. * The target path of the runtime animation
  6706. */
  6707. private _targetPath;
  6708. /**
  6709. * The weight of the runtime animation
  6710. */
  6711. private _weight;
  6712. /**
  6713. * The ratio offset of the runtime animation
  6714. */
  6715. private _ratioOffset;
  6716. /**
  6717. * The previous delay of the runtime animation
  6718. */
  6719. private _previousDelay;
  6720. /**
  6721. * The previous ratio of the runtime animation
  6722. */
  6723. private _previousRatio;
  6724. /**
  6725. * Gets the current frame of the runtime animation
  6726. */
  6727. readonly currentFrame: number;
  6728. /**
  6729. * Gets the weight of the runtime animation
  6730. */
  6731. readonly weight: number;
  6732. /**
  6733. * Gets the current value of the runtime animation
  6734. */
  6735. readonly currentValue: any;
  6736. /**
  6737. * Gets the target path of the runtime animation
  6738. */
  6739. readonly targetPath: string;
  6740. /**
  6741. * Gets the actual target of the runtime animation
  6742. */
  6743. readonly target: any;
  6744. /**
  6745. * Create a new RuntimeAnimation object
  6746. * @param target defines the target of the animation
  6747. * @param animation defines the source animation object
  6748. * @param scene defines the hosting scene
  6749. * @param host defines the initiating Animatable
  6750. */
  6751. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6752. /**
  6753. * Gets the animation from the runtime animation
  6754. */
  6755. readonly animation: Animation;
  6756. /**
  6757. * Resets the runtime animation to the beginning
  6758. * @param restoreOriginal defines whether to restore the target property to the original value
  6759. */
  6760. reset(restoreOriginal?: boolean): void;
  6761. /**
  6762. * Specifies if the runtime animation is stopped
  6763. * @returns Boolean specifying if the runtime animation is stopped
  6764. */
  6765. isStopped(): boolean;
  6766. /**
  6767. * Disposes of the runtime animation
  6768. */
  6769. dispose(): void;
  6770. /**
  6771. * Interpolates the animation from the current frame
  6772. * @param currentFrame The frame to interpolate the animation to
  6773. * @param repeatCount The number of times that the animation should loop
  6774. * @param loopMode The type of looping mode to use
  6775. * @param offsetValue Animation offset value
  6776. * @param highLimitValue The high limit value
  6777. * @returns The interpolated value
  6778. */
  6779. private _interpolate;
  6780. /**
  6781. * Apply the interpolated value to the target
  6782. * @param currentValue defines the value computed by the animation
  6783. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6784. */
  6785. setValue(currentValue: any, weight?: number): void;
  6786. private _setValue;
  6787. /**
  6788. * Gets the loop pmode of the runtime animation
  6789. * @returns Loop Mode
  6790. */
  6791. private _getCorrectLoopMode;
  6792. /**
  6793. * Move the current animation to a given frame
  6794. * @param frame defines the frame to move to
  6795. */
  6796. goToFrame(frame: number): void;
  6797. /**
  6798. * @hidden Internal use only
  6799. */
  6800. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6801. /**
  6802. * Execute the current animation
  6803. * @param delay defines the delay to add to the current frame
  6804. * @param from defines the lower bound of the animation range
  6805. * @param to defines the upper bound of the animation range
  6806. * @param loop defines if the current animation must loop
  6807. * @param speedRatio defines the current speed ratio
  6808. * @param weight defines the weight of the animation (default is -1 so no weight)
  6809. * @param onLoop optional callback called when animation loops
  6810. * @returns a boolean indicating if the animation is running
  6811. */
  6812. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6813. }
  6814. }
  6815. declare module BABYLON {
  6816. /**
  6817. * Class used to store an actual running animation
  6818. */
  6819. export class Animatable {
  6820. /** defines the target object */
  6821. target: any;
  6822. /** defines the starting frame number (default is 0) */
  6823. fromFrame: number;
  6824. /** defines the ending frame number (default is 100) */
  6825. toFrame: number;
  6826. /** defines if the animation must loop (default is false) */
  6827. loopAnimation: boolean;
  6828. /** defines a callback to call when animation ends if it is not looping */
  6829. onAnimationEnd?: (() => void) | null | undefined;
  6830. /** defines a callback to call when animation loops */
  6831. onAnimationLoop?: (() => void) | null | undefined;
  6832. private _localDelayOffset;
  6833. private _pausedDelay;
  6834. private _runtimeAnimations;
  6835. private _paused;
  6836. private _scene;
  6837. private _speedRatio;
  6838. private _weight;
  6839. private _syncRoot;
  6840. /**
  6841. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6842. * This will only apply for non looping animation (default is true)
  6843. */
  6844. disposeOnEnd: boolean;
  6845. /**
  6846. * Gets a boolean indicating if the animation has started
  6847. */
  6848. animationStarted: boolean;
  6849. /**
  6850. * Observer raised when the animation ends
  6851. */
  6852. onAnimationEndObservable: Observable<Animatable>;
  6853. /**
  6854. * Observer raised when the animation loops
  6855. */
  6856. onAnimationLoopObservable: Observable<Animatable>;
  6857. /**
  6858. * Gets the root Animatable used to synchronize and normalize animations
  6859. */
  6860. readonly syncRoot: Animatable;
  6861. /**
  6862. * Gets the current frame of the first RuntimeAnimation
  6863. * Used to synchronize Animatables
  6864. */
  6865. readonly masterFrame: number;
  6866. /**
  6867. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6868. */
  6869. weight: number;
  6870. /**
  6871. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6872. */
  6873. speedRatio: number;
  6874. /**
  6875. * Creates a new Animatable
  6876. * @param scene defines the hosting scene
  6877. * @param target defines the target object
  6878. * @param fromFrame defines the starting frame number (default is 0)
  6879. * @param toFrame defines the ending frame number (default is 100)
  6880. * @param loopAnimation defines if the animation must loop (default is false)
  6881. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6882. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6883. * @param animations defines a group of animation to add to the new Animatable
  6884. * @param onAnimationLoop defines a callback to call when animation loops
  6885. */
  6886. constructor(scene: Scene,
  6887. /** defines the target object */
  6888. target: any,
  6889. /** defines the starting frame number (default is 0) */
  6890. fromFrame?: number,
  6891. /** defines the ending frame number (default is 100) */
  6892. toFrame?: number,
  6893. /** defines if the animation must loop (default is false) */
  6894. loopAnimation?: boolean, speedRatio?: number,
  6895. /** defines a callback to call when animation ends if it is not looping */
  6896. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6897. /** defines a callback to call when animation loops */
  6898. onAnimationLoop?: (() => void) | null | undefined);
  6899. /**
  6900. * Synchronize and normalize current Animatable with a source Animatable
  6901. * This is useful when using animation weights and when animations are not of the same length
  6902. * @param root defines the root Animatable to synchronize with
  6903. * @returns the current Animatable
  6904. */
  6905. syncWith(root: Animatable): Animatable;
  6906. /**
  6907. * Gets the list of runtime animations
  6908. * @returns an array of RuntimeAnimation
  6909. */
  6910. getAnimations(): RuntimeAnimation[];
  6911. /**
  6912. * Adds more animations to the current animatable
  6913. * @param target defines the target of the animations
  6914. * @param animations defines the new animations to add
  6915. */
  6916. appendAnimations(target: any, animations: Animation[]): void;
  6917. /**
  6918. * Gets the source animation for a specific property
  6919. * @param property defines the propertyu to look for
  6920. * @returns null or the source animation for the given property
  6921. */
  6922. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6923. /**
  6924. * Gets the runtime animation for a specific property
  6925. * @param property defines the propertyu to look for
  6926. * @returns null or the runtime animation for the given property
  6927. */
  6928. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6929. /**
  6930. * Resets the animatable to its original state
  6931. */
  6932. reset(): void;
  6933. /**
  6934. * Allows the animatable to blend with current running animations
  6935. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6936. * @param blendingSpeed defines the blending speed to use
  6937. */
  6938. enableBlending(blendingSpeed: number): void;
  6939. /**
  6940. * Disable animation blending
  6941. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6942. */
  6943. disableBlending(): void;
  6944. /**
  6945. * Jump directly to a given frame
  6946. * @param frame defines the frame to jump to
  6947. */
  6948. goToFrame(frame: number): void;
  6949. /**
  6950. * Pause the animation
  6951. */
  6952. pause(): void;
  6953. /**
  6954. * Restart the animation
  6955. */
  6956. restart(): void;
  6957. private _raiseOnAnimationEnd;
  6958. /**
  6959. * Stop and delete the current animation
  6960. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6961. * @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)
  6962. */
  6963. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6964. /**
  6965. * Wait asynchronously for the animation to end
  6966. * @returns a promise which will be fullfilled when the animation ends
  6967. */
  6968. waitAsync(): Promise<Animatable>;
  6969. /** @hidden */
  6970. _animate(delay: number): boolean;
  6971. }
  6972. }
  6973. declare module BABYLON {
  6974. /**
  6975. * Class used to override all child animations of a given target
  6976. */
  6977. export class AnimationPropertiesOverride {
  6978. /**
  6979. * Gets or sets a value indicating if animation blending must be used
  6980. */
  6981. enableBlending: boolean;
  6982. /**
  6983. * Gets or sets the blending speed to use when enableBlending is true
  6984. */
  6985. blendingSpeed: number;
  6986. /**
  6987. * Gets or sets the default loop mode to use
  6988. */
  6989. loopMode: number;
  6990. }
  6991. }
  6992. declare module BABYLON {
  6993. /** @hidden */
  6994. export class Collider {
  6995. /** Define if a collision was found */
  6996. collisionFound: boolean;
  6997. /**
  6998. * Define last intersection point in local space
  6999. */
  7000. intersectionPoint: Vector3;
  7001. /**
  7002. * Define last collided mesh
  7003. */
  7004. collidedMesh: Nullable<AbstractMesh>;
  7005. private _collisionPoint;
  7006. private _planeIntersectionPoint;
  7007. private _tempVector;
  7008. private _tempVector2;
  7009. private _tempVector3;
  7010. private _tempVector4;
  7011. private _edge;
  7012. private _baseToVertex;
  7013. private _destinationPoint;
  7014. private _slidePlaneNormal;
  7015. private _displacementVector;
  7016. /** @hidden */
  7017. _radius: Vector3;
  7018. /** @hidden */
  7019. _retry: number;
  7020. private _velocity;
  7021. private _basePoint;
  7022. private _epsilon;
  7023. /** @hidden */
  7024. _velocityWorldLength: number;
  7025. /** @hidden */
  7026. _basePointWorld: Vector3;
  7027. private _velocityWorld;
  7028. private _normalizedVelocity;
  7029. /** @hidden */
  7030. _initialVelocity: Vector3;
  7031. /** @hidden */
  7032. _initialPosition: Vector3;
  7033. private _nearestDistance;
  7034. private _collisionMask;
  7035. collisionMask: number;
  7036. /**
  7037. * Gets the plane normal used to compute the sliding response (in local space)
  7038. */
  7039. readonly slidePlaneNormal: Vector3;
  7040. /** @hidden */
  7041. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7042. /** @hidden */
  7043. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7044. /** @hidden */
  7045. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7046. /** @hidden */
  7047. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7048. /** @hidden */
  7049. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7050. /** @hidden */
  7051. _getResponse(pos: Vector3, vel: Vector3): void;
  7052. }
  7053. }
  7054. declare module BABYLON {
  7055. /**
  7056. * @hidden
  7057. */
  7058. export class IntersectionInfo {
  7059. bu: Nullable<number>;
  7060. bv: Nullable<number>;
  7061. distance: number;
  7062. faceId: number;
  7063. subMeshId: number;
  7064. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7065. }
  7066. }
  7067. declare module BABYLON {
  7068. /**
  7069. * ActionEvent is the event being sent when an action is triggered.
  7070. */
  7071. export class ActionEvent {
  7072. /** The mesh or sprite that triggered the action */
  7073. source: any;
  7074. /** The X mouse cursor position at the time of the event */
  7075. pointerX: number;
  7076. /** The Y mouse cursor position at the time of the event */
  7077. pointerY: number;
  7078. /** The mesh that is currently pointed at (can be null) */
  7079. meshUnderPointer: Nullable<AbstractMesh>;
  7080. /** the original (browser) event that triggered the ActionEvent */
  7081. sourceEvent?: any;
  7082. /** additional data for the event */
  7083. additionalData?: any;
  7084. /**
  7085. * Creates a new ActionEvent
  7086. * @param source The mesh or sprite that triggered the action
  7087. * @param pointerX The X mouse cursor position at the time of the event
  7088. * @param pointerY The Y mouse cursor position at the time of the event
  7089. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7090. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7091. * @param additionalData additional data for the event
  7092. */
  7093. constructor(
  7094. /** The mesh or sprite that triggered the action */
  7095. source: any,
  7096. /** The X mouse cursor position at the time of the event */
  7097. pointerX: number,
  7098. /** The Y mouse cursor position at the time of the event */
  7099. pointerY: number,
  7100. /** The mesh that is currently pointed at (can be null) */
  7101. meshUnderPointer: Nullable<AbstractMesh>,
  7102. /** the original (browser) event that triggered the ActionEvent */
  7103. sourceEvent?: any,
  7104. /** additional data for the event */
  7105. additionalData?: any);
  7106. /**
  7107. * Helper function to auto-create an ActionEvent from a source mesh.
  7108. * @param source The source mesh that triggered the event
  7109. * @param evt The original (browser) event
  7110. * @param additionalData additional data for the event
  7111. * @returns the new ActionEvent
  7112. */
  7113. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7114. /**
  7115. * Helper function to auto-create an ActionEvent from a source sprite
  7116. * @param source The source sprite that triggered the event
  7117. * @param scene Scene associated with the sprite
  7118. * @param evt The original (browser) event
  7119. * @param additionalData additional data for the event
  7120. * @returns the new ActionEvent
  7121. */
  7122. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7123. /**
  7124. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7125. * @param scene the scene where the event occurred
  7126. * @param evt The original (browser) event
  7127. * @returns the new ActionEvent
  7128. */
  7129. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7130. /**
  7131. * Helper function to auto-create an ActionEvent from a primitive
  7132. * @param prim defines the target primitive
  7133. * @param pointerPos defines the pointer position
  7134. * @param evt The original (browser) event
  7135. * @param additionalData additional data for the event
  7136. * @returns the new ActionEvent
  7137. */
  7138. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /**
  7143. * Class used to store bounding sphere information
  7144. */
  7145. export class BoundingSphere {
  7146. /**
  7147. * Gets the center of the bounding sphere in local space
  7148. */
  7149. readonly center: Vector3;
  7150. /**
  7151. * Radius of the bounding sphere in local space
  7152. */
  7153. radius: number;
  7154. /**
  7155. * Gets the center of the bounding sphere in world space
  7156. */
  7157. readonly centerWorld: Vector3;
  7158. /**
  7159. * Radius of the bounding sphere in world space
  7160. */
  7161. radiusWorld: number;
  7162. /**
  7163. * Gets the minimum vector in local space
  7164. */
  7165. readonly minimum: Vector3;
  7166. /**
  7167. * Gets the maximum vector in local space
  7168. */
  7169. readonly maximum: Vector3;
  7170. private _worldMatrix;
  7171. private static readonly TmpVector3;
  7172. /**
  7173. * Creates a new bounding sphere
  7174. * @param min defines the minimum vector (in local space)
  7175. * @param max defines the maximum vector (in local space)
  7176. * @param worldMatrix defines the new world matrix
  7177. */
  7178. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7179. /**
  7180. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7181. * @param min defines the new minimum vector (in local space)
  7182. * @param max defines the new maximum vector (in local space)
  7183. * @param worldMatrix defines the new world matrix
  7184. */
  7185. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7186. /**
  7187. * Scale the current bounding sphere by applying a scale factor
  7188. * @param factor defines the scale factor to apply
  7189. * @returns the current bounding box
  7190. */
  7191. scale(factor: number): BoundingSphere;
  7192. /**
  7193. * Gets the world matrix of the bounding box
  7194. * @returns a matrix
  7195. */
  7196. getWorldMatrix(): DeepImmutable<Matrix>;
  7197. /** @hidden */
  7198. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7199. /**
  7200. * Tests if the bounding sphere is intersecting the frustum planes
  7201. * @param frustumPlanes defines the frustum planes to test
  7202. * @returns true if there is an intersection
  7203. */
  7204. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7205. /**
  7206. * Tests if the bounding sphere center is in between the frustum planes.
  7207. * Used for optimistic fast inclusion.
  7208. * @param frustumPlanes defines the frustum planes to test
  7209. * @returns true if the sphere center is in between the frustum planes
  7210. */
  7211. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7212. /**
  7213. * Tests if a point is inside the bounding sphere
  7214. * @param point defines the point to test
  7215. * @returns true if the point is inside the bounding sphere
  7216. */
  7217. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7218. /**
  7219. * Checks if two sphere intersct
  7220. * @param sphere0 sphere 0
  7221. * @param sphere1 sphere 1
  7222. * @returns true if the speres intersect
  7223. */
  7224. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7225. }
  7226. }
  7227. declare module BABYLON {
  7228. /**
  7229. * Class used to store bounding box information
  7230. */
  7231. export class BoundingBox implements ICullable {
  7232. /**
  7233. * Gets the 8 vectors representing the bounding box in local space
  7234. */
  7235. readonly vectors: Vector3[];
  7236. /**
  7237. * Gets the center of the bounding box in local space
  7238. */
  7239. readonly center: Vector3;
  7240. /**
  7241. * Gets the center of the bounding box in world space
  7242. */
  7243. readonly centerWorld: Vector3;
  7244. /**
  7245. * Gets the extend size in local space
  7246. */
  7247. readonly extendSize: Vector3;
  7248. /**
  7249. * Gets the extend size in world space
  7250. */
  7251. readonly extendSizeWorld: Vector3;
  7252. /**
  7253. * Gets the OBB (object bounding box) directions
  7254. */
  7255. readonly directions: Vector3[];
  7256. /**
  7257. * Gets the 8 vectors representing the bounding box in world space
  7258. */
  7259. readonly vectorsWorld: Vector3[];
  7260. /**
  7261. * Gets the minimum vector in world space
  7262. */
  7263. readonly minimumWorld: Vector3;
  7264. /**
  7265. * Gets the maximum vector in world space
  7266. */
  7267. readonly maximumWorld: Vector3;
  7268. /**
  7269. * Gets the minimum vector in local space
  7270. */
  7271. readonly minimum: Vector3;
  7272. /**
  7273. * Gets the maximum vector in local space
  7274. */
  7275. readonly maximum: Vector3;
  7276. private _worldMatrix;
  7277. private static readonly TmpVector3;
  7278. /**
  7279. * @hidden
  7280. */
  7281. _tag: number;
  7282. /**
  7283. * Creates a new bounding box
  7284. * @param min defines the minimum vector (in local space)
  7285. * @param max defines the maximum vector (in local space)
  7286. * @param worldMatrix defines the new world matrix
  7287. */
  7288. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7289. /**
  7290. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7291. * @param min defines the new minimum vector (in local space)
  7292. * @param max defines the new maximum vector (in local space)
  7293. * @param worldMatrix defines the new world matrix
  7294. */
  7295. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7296. /**
  7297. * Scale the current bounding box by applying a scale factor
  7298. * @param factor defines the scale factor to apply
  7299. * @returns the current bounding box
  7300. */
  7301. scale(factor: number): BoundingBox;
  7302. /**
  7303. * Gets the world matrix of the bounding box
  7304. * @returns a matrix
  7305. */
  7306. getWorldMatrix(): DeepImmutable<Matrix>;
  7307. /** @hidden */
  7308. _update(world: DeepImmutable<Matrix>): void;
  7309. /**
  7310. * Tests if the bounding box is intersecting the frustum planes
  7311. * @param frustumPlanes defines the frustum planes to test
  7312. * @returns true if there is an intersection
  7313. */
  7314. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7315. /**
  7316. * Tests if the bounding box is entirely inside the frustum planes
  7317. * @param frustumPlanes defines the frustum planes to test
  7318. * @returns true if there is an inclusion
  7319. */
  7320. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7321. /**
  7322. * Tests if a point is inside the bounding box
  7323. * @param point defines the point to test
  7324. * @returns true if the point is inside the bounding box
  7325. */
  7326. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7327. /**
  7328. * Tests if the bounding box intersects with a bounding sphere
  7329. * @param sphere defines the sphere to test
  7330. * @returns true if there is an intersection
  7331. */
  7332. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7333. /**
  7334. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7335. * @param min defines the min vector to use
  7336. * @param max defines the max vector to use
  7337. * @returns true if there is an intersection
  7338. */
  7339. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7340. /**
  7341. * Tests if two bounding boxes are intersections
  7342. * @param box0 defines the first box to test
  7343. * @param box1 defines the second box to test
  7344. * @returns true if there is an intersection
  7345. */
  7346. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7347. /**
  7348. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7349. * @param minPoint defines the minimum vector of the bounding box
  7350. * @param maxPoint defines the maximum vector of the bounding box
  7351. * @param sphereCenter defines the sphere center
  7352. * @param sphereRadius defines the sphere radius
  7353. * @returns true if there is an intersection
  7354. */
  7355. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7356. /**
  7357. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7358. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7359. * @param frustumPlanes defines the frustum planes to test
  7360. * @return true if there is an inclusion
  7361. */
  7362. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7363. /**
  7364. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7365. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7366. * @param frustumPlanes defines the frustum planes to test
  7367. * @return true if there is an intersection
  7368. */
  7369. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7370. }
  7371. }
  7372. declare module BABYLON {
  7373. /**
  7374. * Interface for cullable objects
  7375. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7376. */
  7377. export interface ICullable {
  7378. /**
  7379. * Checks if the object or part of the object is in the frustum
  7380. * @param frustumPlanes Camera near/planes
  7381. * @returns true if the object is in frustum otherwise false
  7382. */
  7383. isInFrustum(frustumPlanes: Plane[]): boolean;
  7384. /**
  7385. * Checks if a cullable object (mesh...) is in the camera frustum
  7386. * Unlike isInFrustum this cheks the full bounding box
  7387. * @param frustumPlanes Camera near/planes
  7388. * @returns true if the object is in frustum otherwise false
  7389. */
  7390. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7391. }
  7392. /**
  7393. * Info for a bounding data of a mesh
  7394. */
  7395. export class BoundingInfo implements ICullable {
  7396. /**
  7397. * Bounding box for the mesh
  7398. */
  7399. readonly boundingBox: BoundingBox;
  7400. /**
  7401. * Bounding sphere for the mesh
  7402. */
  7403. readonly boundingSphere: BoundingSphere;
  7404. private _isLocked;
  7405. private static readonly TmpVector3;
  7406. /**
  7407. * Constructs bounding info
  7408. * @param minimum min vector of the bounding box/sphere
  7409. * @param maximum max vector of the bounding box/sphere
  7410. * @param worldMatrix defines the new world matrix
  7411. */
  7412. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7413. /**
  7414. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7415. * @param min defines the new minimum vector (in local space)
  7416. * @param max defines the new maximum vector (in local space)
  7417. * @param worldMatrix defines the new world matrix
  7418. */
  7419. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7420. /**
  7421. * min vector of the bounding box/sphere
  7422. */
  7423. readonly minimum: Vector3;
  7424. /**
  7425. * max vector of the bounding box/sphere
  7426. */
  7427. readonly maximum: Vector3;
  7428. /**
  7429. * If the info is locked and won't be updated to avoid perf overhead
  7430. */
  7431. isLocked: boolean;
  7432. /**
  7433. * Updates the bounding sphere and box
  7434. * @param world world matrix to be used to update
  7435. */
  7436. update(world: DeepImmutable<Matrix>): void;
  7437. /**
  7438. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7439. * @param center New center of the bounding info
  7440. * @param extend New extend of the bounding info
  7441. * @returns the current bounding info
  7442. */
  7443. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7444. /**
  7445. * Scale the current bounding info by applying a scale factor
  7446. * @param factor defines the scale factor to apply
  7447. * @returns the current bounding info
  7448. */
  7449. scale(factor: number): BoundingInfo;
  7450. /**
  7451. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7452. * @param frustumPlanes defines the frustum to test
  7453. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7454. * @returns true if the bounding info is in the frustum planes
  7455. */
  7456. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7457. /**
  7458. * Gets the world distance between the min and max points of the bounding box
  7459. */
  7460. readonly diagonalLength: number;
  7461. /**
  7462. * Checks if a cullable object (mesh...) is in the camera frustum
  7463. * Unlike isInFrustum this cheks the full bounding box
  7464. * @param frustumPlanes Camera near/planes
  7465. * @returns true if the object is in frustum otherwise false
  7466. */
  7467. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7468. /** @hidden */
  7469. _checkCollision(collider: Collider): boolean;
  7470. /**
  7471. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7472. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7473. * @param point the point to check intersection with
  7474. * @returns if the point intersects
  7475. */
  7476. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7477. /**
  7478. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7479. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7480. * @param boundingInfo the bounding info to check intersection with
  7481. * @param precise if the intersection should be done using OBB
  7482. * @returns if the bounding info intersects
  7483. */
  7484. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Defines an array and its length.
  7490. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7491. */
  7492. export interface ISmartArrayLike<T> {
  7493. /**
  7494. * The data of the array.
  7495. */
  7496. data: Array<T>;
  7497. /**
  7498. * The active length of the array.
  7499. */
  7500. length: number;
  7501. }
  7502. /**
  7503. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7504. */
  7505. export class SmartArray<T> implements ISmartArrayLike<T> {
  7506. /**
  7507. * The full set of data from the array.
  7508. */
  7509. data: Array<T>;
  7510. /**
  7511. * The active length of the array.
  7512. */
  7513. length: number;
  7514. protected _id: number;
  7515. /**
  7516. * Instantiates a Smart Array.
  7517. * @param capacity defines the default capacity of the array.
  7518. */
  7519. constructor(capacity: number);
  7520. /**
  7521. * Pushes a value at the end of the active data.
  7522. * @param value defines the object to push in the array.
  7523. */
  7524. push(value: T): void;
  7525. /**
  7526. * Iterates over the active data and apply the lambda to them.
  7527. * @param func defines the action to apply on each value.
  7528. */
  7529. forEach(func: (content: T) => void): void;
  7530. /**
  7531. * Sorts the full sets of data.
  7532. * @param compareFn defines the comparison function to apply.
  7533. */
  7534. sort(compareFn: (a: T, b: T) => number): void;
  7535. /**
  7536. * Resets the active data to an empty array.
  7537. */
  7538. reset(): void;
  7539. /**
  7540. * Releases all the data from the array as well as the array.
  7541. */
  7542. dispose(): void;
  7543. /**
  7544. * Concats the active data with a given array.
  7545. * @param array defines the data to concatenate with.
  7546. */
  7547. concat(array: any): void;
  7548. /**
  7549. * Returns the position of a value in the active data.
  7550. * @param value defines the value to find the index for
  7551. * @returns the index if found in the active data otherwise -1
  7552. */
  7553. indexOf(value: T): number;
  7554. /**
  7555. * Returns whether an element is part of the active data.
  7556. * @param value defines the value to look for
  7557. * @returns true if found in the active data otherwise false
  7558. */
  7559. contains(value: T): boolean;
  7560. private static _GlobalId;
  7561. }
  7562. /**
  7563. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7564. * The data in this array can only be present once
  7565. */
  7566. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7567. private _duplicateId;
  7568. /**
  7569. * Pushes a value at the end of the active data.
  7570. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7571. * @param value defines the object to push in the array.
  7572. */
  7573. push(value: T): void;
  7574. /**
  7575. * Pushes a value at the end of the active data.
  7576. * If the data is already present, it won t be added again
  7577. * @param value defines the object to push in the array.
  7578. * @returns true if added false if it was already present
  7579. */
  7580. pushNoDuplicate(value: T): boolean;
  7581. /**
  7582. * Resets the active data to an empty array.
  7583. */
  7584. reset(): void;
  7585. /**
  7586. * Concats the active data with a given array.
  7587. * This ensures no dupplicate will be present in the result.
  7588. * @param array defines the data to concatenate with.
  7589. */
  7590. concatWithNoDuplicate(array: any): void;
  7591. }
  7592. }
  7593. declare module BABYLON {
  7594. /**
  7595. * Class for creating a cube texture
  7596. */
  7597. export class CubeTexture extends BaseTexture {
  7598. private _delayedOnLoad;
  7599. /**
  7600. * The url of the texture
  7601. */
  7602. url: string;
  7603. /**
  7604. * Gets or sets the center of the bounding box associated with the cube texture.
  7605. * It must define where the camera used to render the texture was set
  7606. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7607. */
  7608. boundingBoxPosition: Vector3;
  7609. private _boundingBoxSize;
  7610. /**
  7611. * Gets or sets the size of the bounding box associated with the cube texture
  7612. * When defined, the cubemap will switch to local mode
  7613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7614. * @example https://www.babylonjs-playground.com/#RNASML
  7615. */
  7616. /**
  7617. * Returns the bounding box size
  7618. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7619. */
  7620. boundingBoxSize: Vector3;
  7621. protected _rotationY: number;
  7622. /**
  7623. * Sets texture matrix rotation angle around Y axis in radians.
  7624. */
  7625. /**
  7626. * Gets texture matrix rotation angle around Y axis radians.
  7627. */
  7628. rotationY: number;
  7629. /**
  7630. * Are mip maps generated for this texture or not.
  7631. */
  7632. readonly noMipmap: boolean;
  7633. private _noMipmap;
  7634. private _files;
  7635. private _extensions;
  7636. private _textureMatrix;
  7637. private _format;
  7638. private _createPolynomials;
  7639. /** @hidden */
  7640. _prefiltered: boolean;
  7641. /**
  7642. * Creates a cube texture from an array of image urls
  7643. * @param files defines an array of image urls
  7644. * @param scene defines the hosting scene
  7645. * @param noMipmap specifies if mip maps are not used
  7646. * @returns a cube texture
  7647. */
  7648. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7649. /**
  7650. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7651. * @param url defines the url of the prefiltered texture
  7652. * @param scene defines the scene the texture is attached to
  7653. * @param forcedExtension defines the extension of the file if different from the url
  7654. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7655. * @return the prefiltered texture
  7656. */
  7657. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7658. /**
  7659. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7660. * as prefiltered data.
  7661. * @param rootUrl defines the url of the texture or the root name of the six images
  7662. * @param scene defines the scene the texture is attached to
  7663. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7664. * @param noMipmap defines if mipmaps should be created or not
  7665. * @param files defines the six files to load for the different faces
  7666. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7667. * @param onError defines a callback triggered in case of error during load
  7668. * @param format defines the internal format to use for the texture once loaded
  7669. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7670. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7671. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7672. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7673. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7674. * @return the cube texture
  7675. */
  7676. 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);
  7677. /**
  7678. * Get the current class name of the texture useful for serialization or dynamic coding.
  7679. * @returns "CubeTexture"
  7680. */
  7681. getClassName(): string;
  7682. /**
  7683. * Update the url (and optional buffer) of this texture if url was null during construction.
  7684. * @param url the url of the texture
  7685. * @param forcedExtension defines the extension to use
  7686. * @param onLoad callback called when the texture is loaded (defaults to null)
  7687. */
  7688. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7689. /**
  7690. * Delays loading of the cube texture
  7691. * @param forcedExtension defines the extension to use
  7692. */
  7693. delayLoad(forcedExtension?: string): void;
  7694. /**
  7695. * Returns the reflection texture matrix
  7696. * @returns the reflection texture matrix
  7697. */
  7698. getReflectionTextureMatrix(): Matrix;
  7699. /**
  7700. * Sets the reflection texture matrix
  7701. * @param value Reflection texture matrix
  7702. */
  7703. setReflectionTextureMatrix(value: Matrix): void;
  7704. /**
  7705. * Parses text to create a cube texture
  7706. * @param parsedTexture define the serialized text to read from
  7707. * @param scene defines the hosting scene
  7708. * @param rootUrl defines the root url of the cube texture
  7709. * @returns a cube texture
  7710. */
  7711. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7712. /**
  7713. * Makes a clone, or deep copy, of the cube texture
  7714. * @returns a new cube texture
  7715. */
  7716. clone(): CubeTexture;
  7717. }
  7718. }
  7719. declare module BABYLON {
  7720. /** @hidden */
  7721. export var postprocessVertexShader: {
  7722. name: string;
  7723. shader: string;
  7724. };
  7725. }
  7726. declare module BABYLON {
  7727. /**
  7728. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7729. * This is the base of the follow, arc rotate cameras and Free camera
  7730. * @see http://doc.babylonjs.com/features/cameras
  7731. */
  7732. export class TargetCamera extends Camera {
  7733. private static _RigCamTransformMatrix;
  7734. private static _TargetTransformMatrix;
  7735. private static _TargetFocalPoint;
  7736. /**
  7737. * Define the current direction the camera is moving to
  7738. */
  7739. cameraDirection: Vector3;
  7740. /**
  7741. * Define the current rotation the camera is rotating to
  7742. */
  7743. cameraRotation: Vector2;
  7744. /**
  7745. * When set, the up vector of the camera will be updated by the rotation of the camera
  7746. */
  7747. updateUpVectorFromRotation: boolean;
  7748. private _tmpQuaternion;
  7749. /**
  7750. * Define the current rotation of the camera
  7751. */
  7752. rotation: Vector3;
  7753. /**
  7754. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7755. */
  7756. rotationQuaternion: Quaternion;
  7757. /**
  7758. * Define the current speed of the camera
  7759. */
  7760. speed: number;
  7761. /**
  7762. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7763. * around all axis.
  7764. */
  7765. noRotationConstraint: boolean;
  7766. /**
  7767. * Define the current target of the camera as an object or a position.
  7768. */
  7769. lockedTarget: any;
  7770. /** @hidden */
  7771. _currentTarget: Vector3;
  7772. /** @hidden */
  7773. _initialFocalDistance: number;
  7774. /** @hidden */
  7775. _viewMatrix: Matrix;
  7776. /** @hidden */
  7777. _camMatrix: Matrix;
  7778. /** @hidden */
  7779. _cameraTransformMatrix: Matrix;
  7780. /** @hidden */
  7781. _cameraRotationMatrix: Matrix;
  7782. /** @hidden */
  7783. _referencePoint: Vector3;
  7784. /** @hidden */
  7785. _transformedReferencePoint: Vector3;
  7786. protected _globalCurrentTarget: Vector3;
  7787. protected _globalCurrentUpVector: Vector3;
  7788. /** @hidden */
  7789. _reset: () => void;
  7790. private _defaultUp;
  7791. /**
  7792. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7793. * This is the base of the follow, arc rotate cameras and Free camera
  7794. * @see http://doc.babylonjs.com/features/cameras
  7795. * @param name Defines the name of the camera in the scene
  7796. * @param position Defines the start position of the camera in the scene
  7797. * @param scene Defines the scene the camera belongs to
  7798. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7799. */
  7800. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7801. /**
  7802. * Gets the position in front of the camera at a given distance.
  7803. * @param distance The distance from the camera we want the position to be
  7804. * @returns the position
  7805. */
  7806. getFrontPosition(distance: number): Vector3;
  7807. /** @hidden */
  7808. _getLockedTargetPosition(): Nullable<Vector3>;
  7809. private _storedPosition;
  7810. private _storedRotation;
  7811. private _storedRotationQuaternion;
  7812. /**
  7813. * Store current camera state of the camera (fov, position, rotation, etc..)
  7814. * @returns the camera
  7815. */
  7816. storeState(): Camera;
  7817. /**
  7818. * Restored camera state. You must call storeState() first
  7819. * @returns whether it was successful or not
  7820. * @hidden
  7821. */
  7822. _restoreStateValues(): boolean;
  7823. /** @hidden */
  7824. _initCache(): void;
  7825. /** @hidden */
  7826. _updateCache(ignoreParentClass?: boolean): void;
  7827. /** @hidden */
  7828. _isSynchronizedViewMatrix(): boolean;
  7829. /** @hidden */
  7830. _computeLocalCameraSpeed(): number;
  7831. /** @hidden */
  7832. setTarget(target: Vector3): void;
  7833. /**
  7834. * Return the current target position of the camera. This value is expressed in local space.
  7835. * @returns the target position
  7836. */
  7837. getTarget(): Vector3;
  7838. /** @hidden */
  7839. _decideIfNeedsToMove(): boolean;
  7840. /** @hidden */
  7841. _updatePosition(): void;
  7842. /** @hidden */
  7843. _checkInputs(): void;
  7844. protected _updateCameraRotationMatrix(): void;
  7845. /**
  7846. * 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)
  7847. * @returns the current camera
  7848. */
  7849. private _rotateUpVectorWithCameraRotationMatrix;
  7850. private _cachedRotationZ;
  7851. private _cachedQuaternionRotationZ;
  7852. /** @hidden */
  7853. _getViewMatrix(): Matrix;
  7854. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7855. /**
  7856. * @hidden
  7857. */
  7858. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7859. /**
  7860. * @hidden
  7861. */
  7862. _updateRigCameras(): void;
  7863. private _getRigCamPositionAndTarget;
  7864. /**
  7865. * Gets the current object class name.
  7866. * @return the class name
  7867. */
  7868. getClassName(): string;
  7869. }
  7870. }
  7871. declare module BABYLON {
  7872. /**
  7873. * @ignore
  7874. * This is a list of all the different input types that are available in the application.
  7875. * Fo instance: ArcRotateCameraGamepadInput...
  7876. */
  7877. export var CameraInputTypes: {};
  7878. /**
  7879. * This is the contract to implement in order to create a new input class.
  7880. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7881. */
  7882. export interface ICameraInput<TCamera extends Camera> {
  7883. /**
  7884. * Defines the camera the input is attached to.
  7885. */
  7886. camera: Nullable<TCamera>;
  7887. /**
  7888. * Gets the class name of the current intput.
  7889. * @returns the class name
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Get the friendly name associated with the input class.
  7894. * @returns the input friendly name
  7895. */
  7896. getSimpleName(): string;
  7897. /**
  7898. * Attach the input controls to a specific dom element to get the input from.
  7899. * @param element Defines the element the controls should be listened from
  7900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7901. */
  7902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7903. /**
  7904. * Detach the current controls from the specified dom element.
  7905. * @param element Defines the element to stop listening the inputs from
  7906. */
  7907. detachControl(element: Nullable<HTMLElement>): void;
  7908. /**
  7909. * Update the current camera state depending on the inputs that have been used this frame.
  7910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7911. */
  7912. checkInputs?: () => void;
  7913. }
  7914. /**
  7915. * Represents a map of input types to input instance or input index to input instance.
  7916. */
  7917. export interface CameraInputsMap<TCamera extends Camera> {
  7918. /**
  7919. * Accessor to the input by input type.
  7920. */
  7921. [name: string]: ICameraInput<TCamera>;
  7922. /**
  7923. * Accessor to the input by input index.
  7924. */
  7925. [idx: number]: ICameraInput<TCamera>;
  7926. }
  7927. /**
  7928. * This represents the input manager used within a camera.
  7929. * It helps dealing with all the different kind of input attached to a camera.
  7930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7931. */
  7932. export class CameraInputsManager<TCamera extends Camera> {
  7933. /**
  7934. * Defines the list of inputs attahed to the camera.
  7935. */
  7936. attached: CameraInputsMap<TCamera>;
  7937. /**
  7938. * Defines the dom element the camera is collecting inputs from.
  7939. * This is null if the controls have not been attached.
  7940. */
  7941. attachedElement: Nullable<HTMLElement>;
  7942. /**
  7943. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7944. */
  7945. noPreventDefault: boolean;
  7946. /**
  7947. * Defined the camera the input manager belongs to.
  7948. */
  7949. camera: TCamera;
  7950. /**
  7951. * Update the current camera state depending on the inputs that have been used this frame.
  7952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7953. */
  7954. checkInputs: () => void;
  7955. /**
  7956. * Instantiate a new Camera Input Manager.
  7957. * @param camera Defines the camera the input manager blongs to
  7958. */
  7959. constructor(camera: TCamera);
  7960. /**
  7961. * Add an input method to a camera
  7962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7963. * @param input camera input method
  7964. */
  7965. add(input: ICameraInput<TCamera>): void;
  7966. /**
  7967. * Remove a specific input method from a camera
  7968. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7969. * @param inputToRemove camera input method
  7970. */
  7971. remove(inputToRemove: ICameraInput<TCamera>): void;
  7972. /**
  7973. * Remove a specific input type from a camera
  7974. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7975. * @param inputType the type of the input to remove
  7976. */
  7977. removeByType(inputType: string): void;
  7978. private _addCheckInputs;
  7979. /**
  7980. * Attach the input controls to the currently attached dom element to listen the events from.
  7981. * @param input Defines the input to attach
  7982. */
  7983. attachInput(input: ICameraInput<TCamera>): void;
  7984. /**
  7985. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7986. * @param element Defines the dom element to collect the events from
  7987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7988. */
  7989. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7990. /**
  7991. * Detach the current manager inputs controls from a specific dom element.
  7992. * @param element Defines the dom element to collect the events from
  7993. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7994. */
  7995. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7996. /**
  7997. * Rebuild the dynamic inputCheck function from the current list of
  7998. * defined inputs in the manager.
  7999. */
  8000. rebuildInputCheck(): void;
  8001. /**
  8002. * Remove all attached input methods from a camera
  8003. */
  8004. clear(): void;
  8005. /**
  8006. * Serialize the current input manager attached to a camera.
  8007. * This ensures than once parsed,
  8008. * the input associated to the camera will be identical to the current ones
  8009. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8010. */
  8011. serialize(serializedCamera: any): void;
  8012. /**
  8013. * Parses an input manager serialized JSON to restore the previous list of inputs
  8014. * and states associated to a camera.
  8015. * @param parsedCamera Defines the JSON to parse
  8016. */
  8017. parse(parsedCamera: any): void;
  8018. }
  8019. }
  8020. declare module BABYLON {
  8021. /**
  8022. * Gather the list of keyboard event types as constants.
  8023. */
  8024. export class KeyboardEventTypes {
  8025. /**
  8026. * The keydown event is fired when a key becomes active (pressed).
  8027. */
  8028. static readonly KEYDOWN: number;
  8029. /**
  8030. * The keyup event is fired when a key has been released.
  8031. */
  8032. static readonly KEYUP: number;
  8033. }
  8034. /**
  8035. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8036. */
  8037. export class KeyboardInfo {
  8038. /**
  8039. * Defines the type of event (KeyboardEventTypes)
  8040. */
  8041. type: number;
  8042. /**
  8043. * Defines the related dom event
  8044. */
  8045. event: KeyboardEvent;
  8046. /**
  8047. * Instantiates a new keyboard info.
  8048. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8049. * @param type Defines the type of event (KeyboardEventTypes)
  8050. * @param event Defines the related dom event
  8051. */
  8052. constructor(
  8053. /**
  8054. * Defines the type of event (KeyboardEventTypes)
  8055. */
  8056. type: number,
  8057. /**
  8058. * Defines the related dom event
  8059. */
  8060. event: KeyboardEvent);
  8061. }
  8062. /**
  8063. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8064. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8065. */
  8066. export class KeyboardInfoPre extends KeyboardInfo {
  8067. /**
  8068. * Defines the type of event (KeyboardEventTypes)
  8069. */
  8070. type: number;
  8071. /**
  8072. * Defines the related dom event
  8073. */
  8074. event: KeyboardEvent;
  8075. /**
  8076. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8077. */
  8078. skipOnPointerObservable: boolean;
  8079. /**
  8080. * Instantiates a new keyboard pre info.
  8081. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8082. * @param type Defines the type of event (KeyboardEventTypes)
  8083. * @param event Defines the related dom event
  8084. */
  8085. constructor(
  8086. /**
  8087. * Defines the type of event (KeyboardEventTypes)
  8088. */
  8089. type: number,
  8090. /**
  8091. * Defines the related dom event
  8092. */
  8093. event: KeyboardEvent);
  8094. }
  8095. }
  8096. declare module BABYLON {
  8097. /**
  8098. * Manage the keyboard inputs to control the movement of a free camera.
  8099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8100. */
  8101. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8102. /**
  8103. * Defines the camera the input is attached to.
  8104. */
  8105. camera: FreeCamera;
  8106. /**
  8107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8108. */
  8109. keysUp: number[];
  8110. /**
  8111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8112. */
  8113. keysDown: number[];
  8114. /**
  8115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8116. */
  8117. keysLeft: number[];
  8118. /**
  8119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8120. */
  8121. keysRight: number[];
  8122. private _keys;
  8123. private _onCanvasBlurObserver;
  8124. private _onKeyboardObserver;
  8125. private _engine;
  8126. private _scene;
  8127. /**
  8128. * Attach the input controls to a specific dom element to get the input from.
  8129. * @param element Defines the element the controls should be listened from
  8130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8131. */
  8132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8133. /**
  8134. * Detach the current controls from the specified dom element.
  8135. * @param element Defines the element to stop listening the inputs from
  8136. */
  8137. detachControl(element: Nullable<HTMLElement>): void;
  8138. /**
  8139. * Update the current camera state depending on the inputs that have been used this frame.
  8140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8141. */
  8142. checkInputs(): void;
  8143. /**
  8144. * Gets the class name of the current intput.
  8145. * @returns the class name
  8146. */
  8147. getClassName(): string;
  8148. /** @hidden */
  8149. _onLostFocus(): void;
  8150. /**
  8151. * Get the friendly name associated with the input class.
  8152. * @returns the input friendly name
  8153. */
  8154. getSimpleName(): string;
  8155. }
  8156. }
  8157. declare module BABYLON {
  8158. /**
  8159. * Gather the list of pointer event types as constants.
  8160. */
  8161. export class PointerEventTypes {
  8162. /**
  8163. * 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.
  8164. */
  8165. static readonly POINTERDOWN: number;
  8166. /**
  8167. * The pointerup event is fired when a pointer is no longer active.
  8168. */
  8169. static readonly POINTERUP: number;
  8170. /**
  8171. * The pointermove event is fired when a pointer changes coordinates.
  8172. */
  8173. static readonly POINTERMOVE: number;
  8174. /**
  8175. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8176. */
  8177. static readonly POINTERWHEEL: number;
  8178. /**
  8179. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8180. */
  8181. static readonly POINTERPICK: number;
  8182. /**
  8183. * The pointertap event is fired when a the object has been touched and released without drag.
  8184. */
  8185. static readonly POINTERTAP: number;
  8186. /**
  8187. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8188. */
  8189. static readonly POINTERDOUBLETAP: number;
  8190. }
  8191. /**
  8192. * Base class of pointer info types.
  8193. */
  8194. export class PointerInfoBase {
  8195. /**
  8196. * Defines the type of event (PointerEventTypes)
  8197. */
  8198. type: number;
  8199. /**
  8200. * Defines the related dom event
  8201. */
  8202. event: PointerEvent | MouseWheelEvent;
  8203. /**
  8204. * Instantiates the base class of pointers info.
  8205. * @param type Defines the type of event (PointerEventTypes)
  8206. * @param event Defines the related dom event
  8207. */
  8208. constructor(
  8209. /**
  8210. * Defines the type of event (PointerEventTypes)
  8211. */
  8212. type: number,
  8213. /**
  8214. * Defines the related dom event
  8215. */
  8216. event: PointerEvent | MouseWheelEvent);
  8217. }
  8218. /**
  8219. * This class is used to store pointer related info for the onPrePointerObservable event.
  8220. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8221. */
  8222. export class PointerInfoPre extends PointerInfoBase {
  8223. /**
  8224. * Ray from a pointer if availible (eg. 6dof controller)
  8225. */
  8226. ray: Nullable<Ray>;
  8227. /**
  8228. * Defines the local position of the pointer on the canvas.
  8229. */
  8230. localPosition: Vector2;
  8231. /**
  8232. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8233. */
  8234. skipOnPointerObservable: boolean;
  8235. /**
  8236. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8237. * @param type Defines the type of event (PointerEventTypes)
  8238. * @param event Defines the related dom event
  8239. * @param localX Defines the local x coordinates of the pointer when the event occured
  8240. * @param localY Defines the local y coordinates of the pointer when the event occured
  8241. */
  8242. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8243. }
  8244. /**
  8245. * This type contains all the data related to a pointer event in Babylon.js.
  8246. * 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.
  8247. */
  8248. export class PointerInfo extends PointerInfoBase {
  8249. /**
  8250. * Defines the picking info associated to the info (if any)\
  8251. */
  8252. pickInfo: Nullable<PickingInfo>;
  8253. /**
  8254. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8255. * @param type Defines the type of event (PointerEventTypes)
  8256. * @param event Defines the related dom event
  8257. * @param pickInfo Defines the picking info associated to the info (if any)\
  8258. */
  8259. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8260. /**
  8261. * Defines the picking info associated to the info (if any)\
  8262. */
  8263. pickInfo: Nullable<PickingInfo>);
  8264. }
  8265. }
  8266. declare module BABYLON {
  8267. /**
  8268. * Manage the mouse inputs to control the movement of a free camera.
  8269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8270. */
  8271. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8272. /**
  8273. * Define if touch is enabled in the mouse input
  8274. */
  8275. touchEnabled: boolean;
  8276. /**
  8277. * Defines the camera the input is attached to.
  8278. */
  8279. camera: FreeCamera;
  8280. /**
  8281. * Defines the buttons associated with the input to handle camera move.
  8282. */
  8283. buttons: number[];
  8284. /**
  8285. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8286. */
  8287. angularSensibility: number;
  8288. private _pointerInput;
  8289. private _onMouseMove;
  8290. private _observer;
  8291. private previousPosition;
  8292. /**
  8293. * Manage the mouse inputs to control the movement of a free camera.
  8294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8295. * @param touchEnabled Defines if touch is enabled or not
  8296. */
  8297. constructor(
  8298. /**
  8299. * Define if touch is enabled in the mouse input
  8300. */
  8301. touchEnabled?: boolean);
  8302. /**
  8303. * Attach the input controls to a specific dom element to get the input from.
  8304. * @param element Defines the element the controls should be listened from
  8305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8306. */
  8307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8308. /**
  8309. * Detach the current controls from the specified dom element.
  8310. * @param element Defines the element to stop listening the inputs from
  8311. */
  8312. detachControl(element: Nullable<HTMLElement>): void;
  8313. /**
  8314. * Gets the class name of the current intput.
  8315. * @returns the class name
  8316. */
  8317. getClassName(): string;
  8318. /**
  8319. * Get the friendly name associated with the input class.
  8320. * @returns the input friendly name
  8321. */
  8322. getSimpleName(): string;
  8323. }
  8324. }
  8325. declare module BABYLON {
  8326. /**
  8327. * Manage the touch inputs to control the movement of a free camera.
  8328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8329. */
  8330. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8331. /**
  8332. * Defines the camera the input is attached to.
  8333. */
  8334. camera: FreeCamera;
  8335. /**
  8336. * Defines the touch sensibility for rotation.
  8337. * The higher the faster.
  8338. */
  8339. touchAngularSensibility: number;
  8340. /**
  8341. * Defines the touch sensibility for move.
  8342. * The higher the faster.
  8343. */
  8344. touchMoveSensibility: number;
  8345. private _offsetX;
  8346. private _offsetY;
  8347. private _pointerPressed;
  8348. private _pointerInput;
  8349. private _observer;
  8350. private _onLostFocus;
  8351. /**
  8352. * Attach the input controls to a specific dom element to get the input from.
  8353. * @param element Defines the element the controls should be listened from
  8354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8355. */
  8356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8357. /**
  8358. * Detach the current controls from the specified dom element.
  8359. * @param element Defines the element to stop listening the inputs from
  8360. */
  8361. detachControl(element: Nullable<HTMLElement>): void;
  8362. /**
  8363. * Update the current camera state depending on the inputs that have been used this frame.
  8364. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8365. */
  8366. checkInputs(): void;
  8367. /**
  8368. * Gets the class name of the current intput.
  8369. * @returns the class name
  8370. */
  8371. getClassName(): string;
  8372. /**
  8373. * Get the friendly name associated with the input class.
  8374. * @returns the input friendly name
  8375. */
  8376. getSimpleName(): string;
  8377. }
  8378. }
  8379. declare module BABYLON {
  8380. /**
  8381. * Default Inputs manager for the FreeCamera.
  8382. * It groups all the default supported inputs for ease of use.
  8383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8384. */
  8385. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8386. /**
  8387. * Instantiates a new FreeCameraInputsManager.
  8388. * @param camera Defines the camera the inputs belong to
  8389. */
  8390. constructor(camera: FreeCamera);
  8391. /**
  8392. * Add keyboard input support to the input manager.
  8393. * @returns the current input manager
  8394. */
  8395. addKeyboard(): FreeCameraInputsManager;
  8396. /**
  8397. * Add mouse input support to the input manager.
  8398. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8399. * @returns the current input manager
  8400. */
  8401. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8402. /**
  8403. * Add touch input support to the input manager.
  8404. * @returns the current input manager
  8405. */
  8406. addTouch(): FreeCameraInputsManager;
  8407. }
  8408. }
  8409. declare module BABYLON {
  8410. /**
  8411. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8412. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8413. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8414. */
  8415. export class FreeCamera extends TargetCamera {
  8416. /**
  8417. * Define the collision ellipsoid of the camera.
  8418. * This is helpful to simulate a camera body like the player body around the camera
  8419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8420. */
  8421. ellipsoid: Vector3;
  8422. /**
  8423. * Define an offset for the position of the ellipsoid around the camera.
  8424. * This can be helpful to determine the center of the body near the gravity center of the body
  8425. * instead of its head.
  8426. */
  8427. ellipsoidOffset: Vector3;
  8428. /**
  8429. * Enable or disable collisions of the camera with the rest of the scene objects.
  8430. */
  8431. checkCollisions: boolean;
  8432. /**
  8433. * Enable or disable gravity on the camera.
  8434. */
  8435. applyGravity: boolean;
  8436. /**
  8437. * Define the input manager associated to the camera.
  8438. */
  8439. inputs: FreeCameraInputsManager;
  8440. /**
  8441. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8442. * Higher values reduce sensitivity.
  8443. */
  8444. /**
  8445. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8446. * Higher values reduce sensitivity.
  8447. */
  8448. angularSensibility: number;
  8449. /**
  8450. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8451. */
  8452. keysUp: number[];
  8453. /**
  8454. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8455. */
  8456. keysDown: number[];
  8457. /**
  8458. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8459. */
  8460. keysLeft: number[];
  8461. /**
  8462. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8463. */
  8464. keysRight: number[];
  8465. /**
  8466. * Event raised when the camera collide with a mesh in the scene.
  8467. */
  8468. onCollide: (collidedMesh: AbstractMesh) => void;
  8469. private _collider;
  8470. private _needMoveForGravity;
  8471. private _oldPosition;
  8472. private _diffPosition;
  8473. private _newPosition;
  8474. /** @hidden */
  8475. _localDirection: Vector3;
  8476. /** @hidden */
  8477. _transformedDirection: Vector3;
  8478. /**
  8479. * Instantiates a Free Camera.
  8480. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8481. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8482. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8483. * @param name Define the name of the camera in the scene
  8484. * @param position Define the start position of the camera in the scene
  8485. * @param scene Define the scene the camera belongs to
  8486. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8487. */
  8488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8489. /**
  8490. * Attached controls to the current camera.
  8491. * @param element Defines the element the controls should be listened from
  8492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8493. */
  8494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8495. /**
  8496. * Detach the current controls from the camera.
  8497. * The camera will stop reacting to inputs.
  8498. * @param element Defines the element to stop listening the inputs from
  8499. */
  8500. detachControl(element: HTMLElement): void;
  8501. private _collisionMask;
  8502. /**
  8503. * Define a collision mask to limit the list of object the camera can collide with
  8504. */
  8505. collisionMask: number;
  8506. /** @hidden */
  8507. _collideWithWorld(displacement: Vector3): void;
  8508. private _onCollisionPositionChange;
  8509. /** @hidden */
  8510. _checkInputs(): void;
  8511. /** @hidden */
  8512. _decideIfNeedsToMove(): boolean;
  8513. /** @hidden */
  8514. _updatePosition(): void;
  8515. /**
  8516. * Destroy the camera and release the current resources hold by it.
  8517. */
  8518. dispose(): void;
  8519. /**
  8520. * Gets the current object class name.
  8521. * @return the class name
  8522. */
  8523. getClassName(): string;
  8524. }
  8525. }
  8526. declare module BABYLON {
  8527. /**
  8528. * Represents a gamepad control stick position
  8529. */
  8530. export class StickValues {
  8531. /**
  8532. * The x component of the control stick
  8533. */
  8534. x: number;
  8535. /**
  8536. * The y component of the control stick
  8537. */
  8538. y: number;
  8539. /**
  8540. * Initializes the gamepad x and y control stick values
  8541. * @param x The x component of the gamepad control stick value
  8542. * @param y The y component of the gamepad control stick value
  8543. */
  8544. constructor(
  8545. /**
  8546. * The x component of the control stick
  8547. */
  8548. x: number,
  8549. /**
  8550. * The y component of the control stick
  8551. */
  8552. y: number);
  8553. }
  8554. /**
  8555. * An interface which manages callbacks for gamepad button changes
  8556. */
  8557. export interface GamepadButtonChanges {
  8558. /**
  8559. * Called when a gamepad has been changed
  8560. */
  8561. changed: boolean;
  8562. /**
  8563. * Called when a gamepad press event has been triggered
  8564. */
  8565. pressChanged: boolean;
  8566. /**
  8567. * Called when a touch event has been triggered
  8568. */
  8569. touchChanged: boolean;
  8570. /**
  8571. * Called when a value has changed
  8572. */
  8573. valueChanged: boolean;
  8574. }
  8575. /**
  8576. * Represents a gamepad
  8577. */
  8578. export class Gamepad {
  8579. /**
  8580. * The id of the gamepad
  8581. */
  8582. id: string;
  8583. /**
  8584. * The index of the gamepad
  8585. */
  8586. index: number;
  8587. /**
  8588. * The browser gamepad
  8589. */
  8590. browserGamepad: any;
  8591. /**
  8592. * Specifies what type of gamepad this represents
  8593. */
  8594. type: number;
  8595. private _leftStick;
  8596. private _rightStick;
  8597. /** @hidden */
  8598. _isConnected: boolean;
  8599. private _leftStickAxisX;
  8600. private _leftStickAxisY;
  8601. private _rightStickAxisX;
  8602. private _rightStickAxisY;
  8603. /**
  8604. * Triggered when the left control stick has been changed
  8605. */
  8606. private _onleftstickchanged;
  8607. /**
  8608. * Triggered when the right control stick has been changed
  8609. */
  8610. private _onrightstickchanged;
  8611. /**
  8612. * Represents a gamepad controller
  8613. */
  8614. static GAMEPAD: number;
  8615. /**
  8616. * Represents a generic controller
  8617. */
  8618. static GENERIC: number;
  8619. /**
  8620. * Represents an XBox controller
  8621. */
  8622. static XBOX: number;
  8623. /**
  8624. * Represents a pose-enabled controller
  8625. */
  8626. static POSE_ENABLED: number;
  8627. /**
  8628. * Specifies whether the left control stick should be Y-inverted
  8629. */
  8630. protected _invertLeftStickY: boolean;
  8631. /**
  8632. * Specifies if the gamepad has been connected
  8633. */
  8634. readonly isConnected: boolean;
  8635. /**
  8636. * Initializes the gamepad
  8637. * @param id The id of the gamepad
  8638. * @param index The index of the gamepad
  8639. * @param browserGamepad The browser gamepad
  8640. * @param leftStickX The x component of the left joystick
  8641. * @param leftStickY The y component of the left joystick
  8642. * @param rightStickX The x component of the right joystick
  8643. * @param rightStickY The y component of the right joystick
  8644. */
  8645. constructor(
  8646. /**
  8647. * The id of the gamepad
  8648. */
  8649. id: string,
  8650. /**
  8651. * The index of the gamepad
  8652. */
  8653. index: number,
  8654. /**
  8655. * The browser gamepad
  8656. */
  8657. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8658. /**
  8659. * Callback triggered when the left joystick has changed
  8660. * @param callback
  8661. */
  8662. onleftstickchanged(callback: (values: StickValues) => void): void;
  8663. /**
  8664. * Callback triggered when the right joystick has changed
  8665. * @param callback
  8666. */
  8667. onrightstickchanged(callback: (values: StickValues) => void): void;
  8668. /**
  8669. * Gets the left joystick
  8670. */
  8671. /**
  8672. * Sets the left joystick values
  8673. */
  8674. leftStick: StickValues;
  8675. /**
  8676. * Gets the right joystick
  8677. */
  8678. /**
  8679. * Sets the right joystick value
  8680. */
  8681. rightStick: StickValues;
  8682. /**
  8683. * Updates the gamepad joystick positions
  8684. */
  8685. update(): void;
  8686. /**
  8687. * Disposes the gamepad
  8688. */
  8689. dispose(): void;
  8690. }
  8691. /**
  8692. * Represents a generic gamepad
  8693. */
  8694. export class GenericPad extends Gamepad {
  8695. private _buttons;
  8696. private _onbuttondown;
  8697. private _onbuttonup;
  8698. /**
  8699. * Observable triggered when a button has been pressed
  8700. */
  8701. onButtonDownObservable: Observable<number>;
  8702. /**
  8703. * Observable triggered when a button has been released
  8704. */
  8705. onButtonUpObservable: Observable<number>;
  8706. /**
  8707. * Callback triggered when a button has been pressed
  8708. * @param callback Called when a button has been pressed
  8709. */
  8710. onbuttondown(callback: (buttonPressed: number) => void): void;
  8711. /**
  8712. * Callback triggered when a button has been released
  8713. * @param callback Called when a button has been released
  8714. */
  8715. onbuttonup(callback: (buttonReleased: number) => void): void;
  8716. /**
  8717. * Initializes the generic gamepad
  8718. * @param id The id of the generic gamepad
  8719. * @param index The index of the generic gamepad
  8720. * @param browserGamepad The browser gamepad
  8721. */
  8722. constructor(id: string, index: number, browserGamepad: any);
  8723. private _setButtonValue;
  8724. /**
  8725. * Updates the generic gamepad
  8726. */
  8727. update(): void;
  8728. /**
  8729. * Disposes the generic gamepad
  8730. */
  8731. dispose(): void;
  8732. }
  8733. }
  8734. declare module BABYLON {
  8735. /**
  8736. * Raw texture can help creating a texture directly from an array of data.
  8737. * This can be super useful if you either get the data from an uncompressed source or
  8738. * if you wish to create your texture pixel by pixel.
  8739. */
  8740. export class RawTexture extends Texture {
  8741. /**
  8742. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8743. */
  8744. format: number;
  8745. private _engine;
  8746. /**
  8747. * Instantiates a new RawTexture.
  8748. * Raw texture can help creating a texture directly from an array of data.
  8749. * This can be super useful if you either get the data from an uncompressed source or
  8750. * if you wish to create your texture pixel by pixel.
  8751. * @param data define the array of data to use to create the texture
  8752. * @param width define the width of the texture
  8753. * @param height define the height of the texture
  8754. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8755. * @param scene define the scene the texture belongs to
  8756. * @param generateMipMaps define whether mip maps should be generated or not
  8757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8759. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8760. */
  8761. constructor(data: ArrayBufferView, width: number, height: number,
  8762. /**
  8763. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8764. */
  8765. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  8766. /**
  8767. * Updates the texture underlying data.
  8768. * @param data Define the new data of the texture
  8769. */
  8770. update(data: ArrayBufferView): void;
  8771. /**
  8772. * Creates a luminance texture from some data.
  8773. * @param data Define the texture data
  8774. * @param width Define the width of the texture
  8775. * @param height Define the height of the texture
  8776. * @param scene Define the scene the texture belongs to
  8777. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8778. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8779. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8780. * @returns the luminance texture
  8781. */
  8782. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8783. /**
  8784. * Creates a luminance alpha texture from some data.
  8785. * @param data Define the texture data
  8786. * @param width Define the width of the texture
  8787. * @param height Define the height of the texture
  8788. * @param scene Define the scene the texture belongs to
  8789. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8790. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8791. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8792. * @returns the luminance alpha texture
  8793. */
  8794. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8795. /**
  8796. * Creates an alpha texture from some data.
  8797. * @param data Define the texture data
  8798. * @param width Define the width of the texture
  8799. * @param height Define the height of the texture
  8800. * @param scene Define the scene the texture belongs to
  8801. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8802. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8803. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8804. * @returns the alpha texture
  8805. */
  8806. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8807. /**
  8808. * Creates a RGB texture from some data.
  8809. * @param data Define the texture data
  8810. * @param width Define the width of the texture
  8811. * @param height Define the height of the texture
  8812. * @param scene Define the scene the texture belongs to
  8813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8816. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8817. * @returns the RGB alpha texture
  8818. */
  8819. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8820. /**
  8821. * Creates a RGBA texture from some data.
  8822. * @param data Define the texture data
  8823. * @param width Define the width of the texture
  8824. * @param height Define the height of the texture
  8825. * @param scene Define the scene the texture belongs to
  8826. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8829. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8830. * @returns the RGBA texture
  8831. */
  8832. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8833. /**
  8834. * Creates a R texture from some data.
  8835. * @param data Define the texture data
  8836. * @param width Define the width of the texture
  8837. * @param height Define the height of the texture
  8838. * @param scene Define the scene the texture belongs to
  8839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8842. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8843. * @returns the R texture
  8844. */
  8845. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8846. }
  8847. }
  8848. declare module BABYLON {
  8849. /**
  8850. * Class used to handle skinning animations
  8851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8852. */
  8853. export class Skeleton implements IAnimatable {
  8854. /** defines the skeleton name */
  8855. name: string;
  8856. /** defines the skeleton Id */
  8857. id: string;
  8858. /**
  8859. * Defines the list of child bones
  8860. */
  8861. bones: Bone[];
  8862. /**
  8863. * Defines an estimate of the dimension of the skeleton at rest
  8864. */
  8865. dimensionsAtRest: Vector3;
  8866. /**
  8867. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  8868. */
  8869. needInitialSkinMatrix: boolean;
  8870. /**
  8871. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  8872. */
  8873. overrideMesh: Nullable<AbstractMesh>;
  8874. /**
  8875. * Gets the list of animations attached to this skeleton
  8876. */
  8877. animations: Array<Animation>;
  8878. private _scene;
  8879. private _isDirty;
  8880. private _transformMatrices;
  8881. private _transformMatrixTexture;
  8882. private _meshesWithPoseMatrix;
  8883. private _animatables;
  8884. private _identity;
  8885. private _synchronizedWithMesh;
  8886. private _ranges;
  8887. private _lastAbsoluteTransformsUpdateId;
  8888. private _canUseTextureForBones;
  8889. /** @hidden */
  8890. _numBonesWithLinkedTransformNode: number;
  8891. /**
  8892. * Specifies if the skeleton should be serialized
  8893. */
  8894. doNotSerialize: boolean;
  8895. /**
  8896. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  8897. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  8898. */
  8899. useTextureToStoreBoneMatrices: boolean;
  8900. private _animationPropertiesOverride;
  8901. /**
  8902. * Gets or sets the animation properties override
  8903. */
  8904. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8905. /**
  8906. * An observable triggered before computing the skeleton's matrices
  8907. */
  8908. onBeforeComputeObservable: Observable<Skeleton>;
  8909. /**
  8910. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  8911. */
  8912. readonly isUsingTextureForMatrices: boolean;
  8913. /**
  8914. * Creates a new skeleton
  8915. * @param name defines the skeleton name
  8916. * @param id defines the skeleton Id
  8917. * @param scene defines the hosting scene
  8918. */
  8919. constructor(
  8920. /** defines the skeleton name */
  8921. name: string,
  8922. /** defines the skeleton Id */
  8923. id: string, scene: Scene);
  8924. /**
  8925. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  8926. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  8927. * @returns a Float32Array containing matrices data
  8928. */
  8929. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  8930. /**
  8931. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  8932. * @returns a raw texture containing the data
  8933. */
  8934. getTransformMatrixTexture(): Nullable<RawTexture>;
  8935. /**
  8936. * Gets the current hosting scene
  8937. * @returns a scene object
  8938. */
  8939. getScene(): Scene;
  8940. /**
  8941. * Gets a string representing the current skeleton data
  8942. * @param fullDetails defines a boolean indicating if we want a verbose version
  8943. * @returns a string representing the current skeleton data
  8944. */
  8945. toString(fullDetails?: boolean): string;
  8946. /**
  8947. * Get bone's index searching by name
  8948. * @param name defines bone's name to search for
  8949. * @return the indice of the bone. Returns -1 if not found
  8950. */
  8951. getBoneIndexByName(name: string): number;
  8952. /**
  8953. * Creater a new animation range
  8954. * @param name defines the name of the range
  8955. * @param from defines the start key
  8956. * @param to defines the end key
  8957. */
  8958. createAnimationRange(name: string, from: number, to: number): void;
  8959. /**
  8960. * Delete a specific animation range
  8961. * @param name defines the name of the range
  8962. * @param deleteFrames defines if frames must be removed as well
  8963. */
  8964. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  8965. /**
  8966. * Gets a specific animation range
  8967. * @param name defines the name of the range to look for
  8968. * @returns the requested animation range or null if not found
  8969. */
  8970. getAnimationRange(name: string): Nullable<AnimationRange>;
  8971. /**
  8972. * Gets the list of all animation ranges defined on this skeleton
  8973. * @returns an array
  8974. */
  8975. getAnimationRanges(): Nullable<AnimationRange>[];
  8976. /**
  8977. * Copy animation range from a source skeleton.
  8978. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  8979. * @param source defines the source skeleton
  8980. * @param name defines the name of the range to copy
  8981. * @param rescaleAsRequired defines if rescaling must be applied if required
  8982. * @returns true if operation was successful
  8983. */
  8984. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  8985. /**
  8986. * Forces the skeleton to go to rest pose
  8987. */
  8988. returnToRest(): void;
  8989. private _getHighestAnimationFrame;
  8990. /**
  8991. * Begin a specific animation range
  8992. * @param name defines the name of the range to start
  8993. * @param loop defines if looping must be turned on (false by default)
  8994. * @param speedRatio defines the speed ratio to apply (1 by default)
  8995. * @param onAnimationEnd defines a callback which will be called when animation will end
  8996. * @returns a new animatable
  8997. */
  8998. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  8999. /** @hidden */
  9000. _markAsDirty(): void;
  9001. /** @hidden */
  9002. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9003. /** @hidden */
  9004. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9005. private _computeTransformMatrices;
  9006. /**
  9007. * Build all resources required to render a skeleton
  9008. */
  9009. prepare(): void;
  9010. /**
  9011. * Gets the list of animatables currently running for this skeleton
  9012. * @returns an array of animatables
  9013. */
  9014. getAnimatables(): IAnimatable[];
  9015. /**
  9016. * Clone the current skeleton
  9017. * @param name defines the name of the new skeleton
  9018. * @param id defines the id of the enw skeleton
  9019. * @returns the new skeleton
  9020. */
  9021. clone(name: string, id: string): Skeleton;
  9022. /**
  9023. * Enable animation blending for this skeleton
  9024. * @param blendingSpeed defines the blending speed to apply
  9025. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9026. */
  9027. enableBlending(blendingSpeed?: number): void;
  9028. /**
  9029. * Releases all resources associated with the current skeleton
  9030. */
  9031. dispose(): void;
  9032. /**
  9033. * Serialize the skeleton in a JSON object
  9034. * @returns a JSON object
  9035. */
  9036. serialize(): any;
  9037. /**
  9038. * Creates a new skeleton from serialized data
  9039. * @param parsedSkeleton defines the serialized data
  9040. * @param scene defines the hosting scene
  9041. * @returns a new skeleton
  9042. */
  9043. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9044. /**
  9045. * Compute all node absolute transforms
  9046. * @param forceUpdate defines if computation must be done even if cache is up to date
  9047. */
  9048. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9049. /**
  9050. * Gets the root pose matrix
  9051. * @returns a matrix
  9052. */
  9053. getPoseMatrix(): Nullable<Matrix>;
  9054. /**
  9055. * Sorts bones per internal index
  9056. */
  9057. sortBones(): void;
  9058. private _sortBones;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * Class used to store bone information
  9064. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9065. */
  9066. export class Bone extends Node {
  9067. /**
  9068. * defines the bone name
  9069. */
  9070. name: string;
  9071. private static _tmpVecs;
  9072. private static _tmpQuat;
  9073. private static _tmpMats;
  9074. /**
  9075. * Gets the list of child bones
  9076. */
  9077. children: Bone[];
  9078. /** Gets the animations associated with this bone */
  9079. animations: Animation[];
  9080. /**
  9081. * Gets or sets bone length
  9082. */
  9083. length: number;
  9084. /**
  9085. * @hidden Internal only
  9086. * Set this value to map this bone to a different index in the transform matrices
  9087. * Set this value to -1 to exclude the bone from the transform matrices
  9088. */
  9089. _index: Nullable<number>;
  9090. private _skeleton;
  9091. private _localMatrix;
  9092. private _restPose;
  9093. private _baseMatrix;
  9094. private _absoluteTransform;
  9095. private _invertedAbsoluteTransform;
  9096. private _parent;
  9097. private _scalingDeterminant;
  9098. private _worldTransform;
  9099. private _localScaling;
  9100. private _localRotation;
  9101. private _localPosition;
  9102. private _needToDecompose;
  9103. private _needToCompose;
  9104. /** @hidden */
  9105. _linkedTransformNode: Nullable<TransformNode>;
  9106. /** @hidden */
  9107. /** @hidden */
  9108. _matrix: Matrix;
  9109. /**
  9110. * Create a new bone
  9111. * @param name defines the bone name
  9112. * @param skeleton defines the parent skeleton
  9113. * @param parentBone defines the parent (can be null if the bone is the root)
  9114. * @param localMatrix defines the local matrix
  9115. * @param restPose defines the rest pose matrix
  9116. * @param baseMatrix defines the base matrix
  9117. * @param index defines index of the bone in the hiearchy
  9118. */
  9119. constructor(
  9120. /**
  9121. * defines the bone name
  9122. */
  9123. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9124. /**
  9125. * Gets the parent skeleton
  9126. * @returns a skeleton
  9127. */
  9128. getSkeleton(): Skeleton;
  9129. /**
  9130. * Gets parent bone
  9131. * @returns a bone or null if the bone is the root of the bone hierarchy
  9132. */
  9133. getParent(): Nullable<Bone>;
  9134. /**
  9135. * Sets the parent bone
  9136. * @param parent defines the parent (can be null if the bone is the root)
  9137. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9138. */
  9139. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9140. /**
  9141. * Gets the local matrix
  9142. * @returns a matrix
  9143. */
  9144. getLocalMatrix(): Matrix;
  9145. /**
  9146. * Gets the base matrix (initial matrix which remains unchanged)
  9147. * @returns a matrix
  9148. */
  9149. getBaseMatrix(): Matrix;
  9150. /**
  9151. * Gets the rest pose matrix
  9152. * @returns a matrix
  9153. */
  9154. getRestPose(): Matrix;
  9155. /**
  9156. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9157. */
  9158. getWorldMatrix(): Matrix;
  9159. /**
  9160. * Sets the local matrix to rest pose matrix
  9161. */
  9162. returnToRest(): void;
  9163. /**
  9164. * Gets the inverse of the absolute transform matrix.
  9165. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9166. * @returns a matrix
  9167. */
  9168. getInvertedAbsoluteTransform(): Matrix;
  9169. /**
  9170. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9171. * @returns a matrix
  9172. */
  9173. getAbsoluteTransform(): Matrix;
  9174. /**
  9175. * Links with the given transform node.
  9176. * The local matrix of this bone is copied from the transform node every frame.
  9177. * @param transformNode defines the transform node to link to
  9178. */
  9179. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9180. /** Gets or sets current position (in local space) */
  9181. position: Vector3;
  9182. /** Gets or sets current rotation (in local space) */
  9183. rotation: Vector3;
  9184. /** Gets or sets current rotation quaternion (in local space) */
  9185. rotationQuaternion: Quaternion;
  9186. /** Gets or sets current scaling (in local space) */
  9187. scaling: Vector3;
  9188. /**
  9189. * Gets the animation properties override
  9190. */
  9191. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9192. private _decompose;
  9193. private _compose;
  9194. /**
  9195. * Update the base and local matrices
  9196. * @param matrix defines the new base or local matrix
  9197. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9198. * @param updateLocalMatrix defines if the local matrix should be updated
  9199. */
  9200. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9201. /** @hidden */
  9202. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9203. /**
  9204. * Flag the bone as dirty (Forcing it to update everything)
  9205. */
  9206. markAsDirty(): void;
  9207. private _markAsDirtyAndCompose;
  9208. private _markAsDirtyAndDecompose;
  9209. /**
  9210. * Copy an animation range from another bone
  9211. * @param source defines the source bone
  9212. * @param rangeName defines the range name to copy
  9213. * @param frameOffset defines the frame offset
  9214. * @param rescaleAsRequired defines if rescaling must be applied if required
  9215. * @param skelDimensionsRatio defines the scaling ratio
  9216. * @returns true if operation was successful
  9217. */
  9218. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9219. /**
  9220. * Translate the bone in local or world space
  9221. * @param vec The amount to translate the bone
  9222. * @param space The space that the translation is in
  9223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9224. */
  9225. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9226. /**
  9227. * Set the postion of the bone in local or world space
  9228. * @param position The position to set the bone
  9229. * @param space The space that the position is in
  9230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9231. */
  9232. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9233. /**
  9234. * Set the absolute position of the bone (world space)
  9235. * @param position The position to set the bone
  9236. * @param mesh The mesh that this bone is attached to
  9237. */
  9238. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9239. /**
  9240. * Scale the bone on the x, y and z axes (in local space)
  9241. * @param x The amount to scale the bone on the x axis
  9242. * @param y The amount to scale the bone on the y axis
  9243. * @param z The amount to scale the bone on the z axis
  9244. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9245. */
  9246. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9247. /**
  9248. * Set the bone scaling in local space
  9249. * @param scale defines the scaling vector
  9250. */
  9251. setScale(scale: Vector3): void;
  9252. /**
  9253. * Gets the current scaling in local space
  9254. * @returns the current scaling vector
  9255. */
  9256. getScale(): Vector3;
  9257. /**
  9258. * Gets the current scaling in local space and stores it in a target vector
  9259. * @param result defines the target vector
  9260. */
  9261. getScaleToRef(result: Vector3): void;
  9262. /**
  9263. * Set the yaw, pitch, and roll of the bone in local or world space
  9264. * @param yaw The rotation of the bone on the y axis
  9265. * @param pitch The rotation of the bone on the x axis
  9266. * @param roll The rotation of the bone on the z axis
  9267. * @param space The space that the axes of rotation are in
  9268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9269. */
  9270. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9271. /**
  9272. * Add a rotation to the bone on an axis in local or world space
  9273. * @param axis The axis to rotate the bone on
  9274. * @param amount The amount to rotate the bone
  9275. * @param space The space that the axis is in
  9276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9277. */
  9278. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9279. /**
  9280. * Set the rotation of the bone to a particular axis angle in local or world space
  9281. * @param axis The axis to rotate the bone on
  9282. * @param angle The angle that the bone should be rotated to
  9283. * @param space The space that the axis is in
  9284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9285. */
  9286. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9287. /**
  9288. * Set the euler rotation of the bone in local of world space
  9289. * @param rotation The euler rotation that the bone should be set to
  9290. * @param space The space that the rotation is in
  9291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9292. */
  9293. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9294. /**
  9295. * Set the quaternion rotation of the bone in local of world space
  9296. * @param quat The quaternion rotation that the bone should be set to
  9297. * @param space The space that the rotation is in
  9298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9299. */
  9300. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9301. /**
  9302. * Set the rotation matrix of the bone in local of world space
  9303. * @param rotMat The rotation matrix that the bone should be set to
  9304. * @param space The space that the rotation is in
  9305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9306. */
  9307. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9308. private _rotateWithMatrix;
  9309. private _getNegativeRotationToRef;
  9310. /**
  9311. * Get the position of the bone in local or world space
  9312. * @param space The space that the returned position is in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @returns The position of the bone
  9315. */
  9316. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9317. /**
  9318. * Copy the position of the bone to a vector3 in local or world space
  9319. * @param space The space that the returned position is in
  9320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9321. * @param result The vector3 to copy the position to
  9322. */
  9323. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9324. /**
  9325. * Get the absolute position of the bone (world space)
  9326. * @param mesh The mesh that this bone is attached to
  9327. * @returns The absolute position of the bone
  9328. */
  9329. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9330. /**
  9331. * Copy the absolute position of the bone (world space) to the result param
  9332. * @param mesh The mesh that this bone is attached to
  9333. * @param result The vector3 to copy the absolute position to
  9334. */
  9335. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9336. /**
  9337. * Compute the absolute transforms of this bone and its children
  9338. */
  9339. computeAbsoluteTransforms(): void;
  9340. /**
  9341. * Get the world direction from an axis that is in the local space of the bone
  9342. * @param localAxis The local direction that is used to compute the world direction
  9343. * @param mesh The mesh that this bone is attached to
  9344. * @returns The world direction
  9345. */
  9346. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9347. /**
  9348. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9349. * @param localAxis The local direction that is used to compute the world direction
  9350. * @param mesh The mesh that this bone is attached to
  9351. * @param result The vector3 that the world direction will be copied to
  9352. */
  9353. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9354. /**
  9355. * Get the euler rotation of the bone in local or world space
  9356. * @param space The space that the rotation should be in
  9357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9358. * @returns The euler rotation
  9359. */
  9360. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9361. /**
  9362. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9363. * @param space The space that the rotation should be in
  9364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9365. * @param result The vector3 that the rotation should be copied to
  9366. */
  9367. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9368. /**
  9369. * Get the quaternion rotation of the bone in either local or world space
  9370. * @param space The space that the rotation should be in
  9371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9372. * @returns The quaternion rotation
  9373. */
  9374. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9375. /**
  9376. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9377. * @param space The space that the rotation should be in
  9378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9379. * @param result The quaternion that the rotation should be copied to
  9380. */
  9381. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9382. /**
  9383. * Get the rotation matrix of the bone in local or world space
  9384. * @param space The space that the rotation should be in
  9385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9386. * @returns The rotation matrix
  9387. */
  9388. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9389. /**
  9390. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9391. * @param space The space that the rotation should be in
  9392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9393. * @param result The quaternion that the rotation should be copied to
  9394. */
  9395. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9396. /**
  9397. * Get the world position of a point that is in the local space of the bone
  9398. * @param position The local position
  9399. * @param mesh The mesh that this bone is attached to
  9400. * @returns The world position
  9401. */
  9402. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9403. /**
  9404. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9405. * @param position The local position
  9406. * @param mesh The mesh that this bone is attached to
  9407. * @param result The vector3 that the world position should be copied to
  9408. */
  9409. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9410. /**
  9411. * Get the local position of a point that is in world space
  9412. * @param position The world position
  9413. * @param mesh The mesh that this bone is attached to
  9414. * @returns The local position
  9415. */
  9416. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9417. /**
  9418. * Get the local position of a point that is in world space and copy it to the result param
  9419. * @param position The world position
  9420. * @param mesh The mesh that this bone is attached to
  9421. * @param result The vector3 that the local position should be copied to
  9422. */
  9423. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9424. }
  9425. }
  9426. declare module BABYLON {
  9427. /**
  9428. * 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.
  9429. * @see https://doc.babylonjs.com/how_to/transformnode
  9430. */
  9431. export class TransformNode extends Node {
  9432. /**
  9433. * Object will not rotate to face the camera
  9434. */
  9435. static BILLBOARDMODE_NONE: number;
  9436. /**
  9437. * Object will rotate to face the camera but only on the x axis
  9438. */
  9439. static BILLBOARDMODE_X: number;
  9440. /**
  9441. * Object will rotate to face the camera but only on the y axis
  9442. */
  9443. static BILLBOARDMODE_Y: number;
  9444. /**
  9445. * Object will rotate to face the camera but only on the z axis
  9446. */
  9447. static BILLBOARDMODE_Z: number;
  9448. /**
  9449. * Object will rotate to face the camera
  9450. */
  9451. static BILLBOARDMODE_ALL: number;
  9452. private _forward;
  9453. private _forwardInverted;
  9454. private _up;
  9455. private _right;
  9456. private _rightInverted;
  9457. private _position;
  9458. private _rotation;
  9459. private _rotationQuaternion;
  9460. protected _scaling: Vector3;
  9461. protected _isDirty: boolean;
  9462. private _transformToBoneReferal;
  9463. /**
  9464. * Set the billboard mode. Default is 0.
  9465. *
  9466. * | Value | Type | Description |
  9467. * | --- | --- | --- |
  9468. * | 0 | BILLBOARDMODE_NONE | |
  9469. * | 1 | BILLBOARDMODE_X | |
  9470. * | 2 | BILLBOARDMODE_Y | |
  9471. * | 4 | BILLBOARDMODE_Z | |
  9472. * | 7 | BILLBOARDMODE_ALL | |
  9473. *
  9474. */
  9475. billboardMode: number;
  9476. /**
  9477. * 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
  9478. */
  9479. scalingDeterminant: number;
  9480. /**
  9481. * Sets the distance of the object to max, often used by skybox
  9482. */
  9483. infiniteDistance: boolean;
  9484. /**
  9485. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9486. * By default the system will update normals to compensate
  9487. */
  9488. ignoreNonUniformScaling: boolean;
  9489. /** @hidden */
  9490. _poseMatrix: Matrix;
  9491. /** @hidden */
  9492. _localMatrix: Matrix;
  9493. private _absolutePosition;
  9494. private _pivotMatrix;
  9495. private _pivotMatrixInverse;
  9496. protected _postMultiplyPivotMatrix: boolean;
  9497. protected _isWorldMatrixFrozen: boolean;
  9498. /** @hidden */
  9499. _indexInSceneTransformNodesArray: number;
  9500. /**
  9501. * An event triggered after the world matrix is updated
  9502. */
  9503. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9504. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9505. /**
  9506. * Gets a string identifying the name of the class
  9507. * @returns "TransformNode" string
  9508. */
  9509. getClassName(): string;
  9510. /**
  9511. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9512. */
  9513. position: Vector3;
  9514. /**
  9515. * 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)).
  9516. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9517. */
  9518. rotation: Vector3;
  9519. /**
  9520. * 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)).
  9521. */
  9522. scaling: Vector3;
  9523. /**
  9524. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  9525. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9526. */
  9527. rotationQuaternion: Nullable<Quaternion>;
  9528. /**
  9529. * The forward direction of that transform in world space.
  9530. */
  9531. readonly forward: Vector3;
  9532. /**
  9533. * The up direction of that transform in world space.
  9534. */
  9535. readonly up: Vector3;
  9536. /**
  9537. * The right direction of that transform in world space.
  9538. */
  9539. readonly right: Vector3;
  9540. /**
  9541. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9542. * @param matrix the matrix to copy the pose from
  9543. * @returns this TransformNode.
  9544. */
  9545. updatePoseMatrix(matrix: Matrix): TransformNode;
  9546. /**
  9547. * Returns the mesh Pose matrix.
  9548. * @returns the pose matrix
  9549. */
  9550. getPoseMatrix(): Matrix;
  9551. /** @hidden */
  9552. _isSynchronized(): boolean;
  9553. /** @hidden */
  9554. _initCache(): void;
  9555. /**
  9556. * Flag the transform node as dirty (Forcing it to update everything)
  9557. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9558. * @returns this transform node
  9559. */
  9560. markAsDirty(property: string): TransformNode;
  9561. /**
  9562. * Returns the current mesh absolute position.
  9563. * Returns a Vector3.
  9564. */
  9565. readonly absolutePosition: Vector3;
  9566. /**
  9567. * Sets a new matrix to apply before all other transformation
  9568. * @param matrix defines the transform matrix
  9569. * @returns the current TransformNode
  9570. */
  9571. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9572. /**
  9573. * Sets a new pivot matrix to the current node
  9574. * @param matrix defines the new pivot matrix to use
  9575. * @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
  9576. * @returns the current TransformNode
  9577. */
  9578. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9579. /**
  9580. * Returns the mesh pivot matrix.
  9581. * Default : Identity.
  9582. * @returns the matrix
  9583. */
  9584. getPivotMatrix(): Matrix;
  9585. /**
  9586. * Prevents the World matrix to be computed any longer.
  9587. * @returns the TransformNode.
  9588. */
  9589. freezeWorldMatrix(): TransformNode;
  9590. /**
  9591. * Allows back the World matrix computation.
  9592. * @returns the TransformNode.
  9593. */
  9594. unfreezeWorldMatrix(): this;
  9595. /**
  9596. * True if the World matrix has been frozen.
  9597. */
  9598. readonly isWorldMatrixFrozen: boolean;
  9599. /**
  9600. * Retuns the mesh absolute position in the World.
  9601. * @returns a Vector3.
  9602. */
  9603. getAbsolutePosition(): Vector3;
  9604. /**
  9605. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9606. * @param absolutePosition the absolute position to set
  9607. * @returns the TransformNode.
  9608. */
  9609. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9610. /**
  9611. * Sets the mesh position in its local space.
  9612. * @param vector3 the position to set in localspace
  9613. * @returns the TransformNode.
  9614. */
  9615. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9616. /**
  9617. * Returns the mesh position in the local space from the current World matrix values.
  9618. * @returns a new Vector3.
  9619. */
  9620. getPositionExpressedInLocalSpace(): Vector3;
  9621. /**
  9622. * Translates the mesh along the passed Vector3 in its local space.
  9623. * @param vector3 the distance to translate in localspace
  9624. * @returns the TransformNode.
  9625. */
  9626. locallyTranslate(vector3: Vector3): TransformNode;
  9627. private static _lookAtVectorCache;
  9628. /**
  9629. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9630. * @param targetPoint the position (must be in same space as current mesh) to look at
  9631. * @param yawCor optional yaw (y-axis) correction in radians
  9632. * @param pitchCor optional pitch (x-axis) correction in radians
  9633. * @param rollCor optional roll (z-axis) correction in radians
  9634. * @param space the choosen space of the target
  9635. * @returns the TransformNode.
  9636. */
  9637. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9638. /**
  9639. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9640. * This Vector3 is expressed in the World space.
  9641. * @param localAxis axis to rotate
  9642. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9643. */
  9644. getDirection(localAxis: Vector3): Vector3;
  9645. /**
  9646. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9647. * localAxis is expressed in the mesh local space.
  9648. * result is computed in the Wordl space from the mesh World matrix.
  9649. * @param localAxis axis to rotate
  9650. * @param result the resulting transformnode
  9651. * @returns this TransformNode.
  9652. */
  9653. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9654. /**
  9655. * Sets this transform node rotation to the given local axis.
  9656. * @param localAxis the axis in local space
  9657. * @param yawCor optional yaw (y-axis) correction in radians
  9658. * @param pitchCor optional pitch (x-axis) correction in radians
  9659. * @param rollCor optional roll (z-axis) correction in radians
  9660. * @returns this TransformNode
  9661. */
  9662. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9663. /**
  9664. * Sets a new pivot point to the current node
  9665. * @param point defines the new pivot point to use
  9666. * @param space defines if the point is in world or local space (local by default)
  9667. * @returns the current TransformNode
  9668. */
  9669. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9670. /**
  9671. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9672. * @returns the pivot point
  9673. */
  9674. getPivotPoint(): Vector3;
  9675. /**
  9676. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9677. * @param result the vector3 to store the result
  9678. * @returns this TransformNode.
  9679. */
  9680. getPivotPointToRef(result: Vector3): TransformNode;
  9681. /**
  9682. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9683. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9684. */
  9685. getAbsolutePivotPoint(): Vector3;
  9686. /**
  9687. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9688. * @param result vector3 to store the result
  9689. * @returns this TransformNode.
  9690. */
  9691. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9692. /**
  9693. * Defines the passed node as the parent of the current node.
  9694. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9695. * @param node the node ot set as the parent
  9696. * @returns this TransformNode.
  9697. */
  9698. setParent(node: Nullable<Node>): TransformNode;
  9699. private _nonUniformScaling;
  9700. /**
  9701. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9702. */
  9703. readonly nonUniformScaling: boolean;
  9704. /** @hidden */
  9705. _updateNonUniformScalingState(value: boolean): boolean;
  9706. /**
  9707. * Attach the current TransformNode to another TransformNode associated with a bone
  9708. * @param bone Bone affecting the TransformNode
  9709. * @param affectedTransformNode TransformNode associated with the bone
  9710. * @returns this object
  9711. */
  9712. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9713. /**
  9714. * Detach the transform node if its associated with a bone
  9715. * @returns this object
  9716. */
  9717. detachFromBone(): TransformNode;
  9718. private static _rotationAxisCache;
  9719. /**
  9720. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9721. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9722. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9723. * The passed axis is also normalized.
  9724. * @param axis the axis to rotate around
  9725. * @param amount the amount to rotate in radians
  9726. * @param space Space to rotate in (Default: local)
  9727. * @returns the TransformNode.
  9728. */
  9729. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9730. /**
  9731. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9732. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9733. * The passed axis is also normalized. .
  9734. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9735. * @param point the point to rotate around
  9736. * @param axis the axis to rotate around
  9737. * @param amount the amount to rotate in radians
  9738. * @returns the TransformNode
  9739. */
  9740. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9741. /**
  9742. * Translates the mesh along the axis vector for the passed distance in the given space.
  9743. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9744. * @param axis the axis to translate in
  9745. * @param distance the distance to translate
  9746. * @param space Space to rotate in (Default: local)
  9747. * @returns the TransformNode.
  9748. */
  9749. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9750. /**
  9751. * Adds a rotation step to the mesh current rotation.
  9752. * x, y, z are Euler angles expressed in radians.
  9753. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9754. * This means this rotation is made in the mesh local space only.
  9755. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9756. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9757. * ```javascript
  9758. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9759. * ```
  9760. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9761. * 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.
  9762. * @param x Rotation to add
  9763. * @param y Rotation to add
  9764. * @param z Rotation to add
  9765. * @returns the TransformNode.
  9766. */
  9767. addRotation(x: number, y: number, z: number): TransformNode;
  9768. /**
  9769. * Computes the world matrix of the node
  9770. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9771. * @returns the world matrix
  9772. */
  9773. computeWorldMatrix(force?: boolean): Matrix;
  9774. protected _afterComputeWorldMatrix(): void;
  9775. /**
  9776. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9777. * @param func callback function to add
  9778. *
  9779. * @returns the TransformNode.
  9780. */
  9781. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9782. /**
  9783. * Removes a registered callback function.
  9784. * @param func callback function to remove
  9785. * @returns the TransformNode.
  9786. */
  9787. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9788. /**
  9789. * Gets the position of the current mesh in camera space
  9790. * @param camera defines the camera to use
  9791. * @returns a position
  9792. */
  9793. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9794. /**
  9795. * Returns the distance from the mesh to the active camera
  9796. * @param camera defines the camera to use
  9797. * @returns the distance
  9798. */
  9799. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9800. /**
  9801. * Clone the current transform node
  9802. * @param name Name of the new clone
  9803. * @param newParent New parent for the clone
  9804. * @param doNotCloneChildren Do not clone children hierarchy
  9805. * @returns the new transform node
  9806. */
  9807. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9808. /**
  9809. * Serializes the objects information.
  9810. * @param currentSerializationObject defines the object to serialize in
  9811. * @returns the serialized object
  9812. */
  9813. serialize(currentSerializationObject?: any): any;
  9814. /**
  9815. * Returns a new TransformNode object parsed from the source provided.
  9816. * @param parsedTransformNode is the source.
  9817. * @param scene the scne the object belongs to
  9818. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9819. * @returns a new TransformNode object parsed from the source provided.
  9820. */
  9821. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9822. /**
  9823. * Get all child-transformNodes of this node
  9824. * @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
  9825. * @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
  9826. * @returns an array of TransformNode
  9827. */
  9828. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9829. /**
  9830. * Releases resources associated with this transform node.
  9831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9833. */
  9834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9835. }
  9836. }
  9837. declare module BABYLON {
  9838. /**
  9839. * Defines the types of pose enabled controllers that are supported
  9840. */
  9841. export enum PoseEnabledControllerType {
  9842. /**
  9843. * HTC Vive
  9844. */
  9845. VIVE = 0,
  9846. /**
  9847. * Oculus Rift
  9848. */
  9849. OCULUS = 1,
  9850. /**
  9851. * Windows mixed reality
  9852. */
  9853. WINDOWS = 2,
  9854. /**
  9855. * Samsung gear VR
  9856. */
  9857. GEAR_VR = 3,
  9858. /**
  9859. * Google Daydream
  9860. */
  9861. DAYDREAM = 4,
  9862. /**
  9863. * Generic
  9864. */
  9865. GENERIC = 5
  9866. }
  9867. /**
  9868. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9869. */
  9870. export interface MutableGamepadButton {
  9871. /**
  9872. * Value of the button/trigger
  9873. */
  9874. value: number;
  9875. /**
  9876. * If the button/trigger is currently touched
  9877. */
  9878. touched: boolean;
  9879. /**
  9880. * If the button/trigger is currently pressed
  9881. */
  9882. pressed: boolean;
  9883. }
  9884. /**
  9885. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  9886. * @hidden
  9887. */
  9888. export interface ExtendedGamepadButton extends GamepadButton {
  9889. /**
  9890. * If the button/trigger is currently pressed
  9891. */
  9892. readonly pressed: boolean;
  9893. /**
  9894. * If the button/trigger is currently touched
  9895. */
  9896. readonly touched: boolean;
  9897. /**
  9898. * Value of the button/trigger
  9899. */
  9900. readonly value: number;
  9901. }
  9902. /** @hidden */
  9903. export interface _GamePadFactory {
  9904. /**
  9905. * Returns wether or not the current gamepad can be created for this type of controller.
  9906. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9907. * @returns true if it can be created, otherwise false
  9908. */
  9909. canCreate(gamepadInfo: any): boolean;
  9910. /**
  9911. * Creates a new instance of the Gamepad.
  9912. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9913. * @returns the new gamepad instance
  9914. */
  9915. create(gamepadInfo: any): Gamepad;
  9916. }
  9917. /**
  9918. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9919. */
  9920. export class PoseEnabledControllerHelper {
  9921. /** @hidden */
  9922. static _ControllerFactories: _GamePadFactory[];
  9923. /** @hidden */
  9924. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  9925. /**
  9926. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9927. * @param vrGamepad the gamepad to initialized
  9928. * @returns a vr controller of the type the gamepad identified as
  9929. */
  9930. static InitiateController(vrGamepad: any): Gamepad;
  9931. }
  9932. /**
  9933. * Defines the PoseEnabledController object that contains state of a vr capable controller
  9934. */
  9935. export class PoseEnabledController extends Gamepad implements PoseControlled {
  9936. private _deviceRoomPosition;
  9937. private _deviceRoomRotationQuaternion;
  9938. /**
  9939. * The device position in babylon space
  9940. */
  9941. devicePosition: Vector3;
  9942. /**
  9943. * The device rotation in babylon space
  9944. */
  9945. deviceRotationQuaternion: Quaternion;
  9946. /**
  9947. * The scale factor of the device in babylon space
  9948. */
  9949. deviceScaleFactor: number;
  9950. /**
  9951. * (Likely devicePosition should be used instead) The device position in its room space
  9952. */
  9953. position: Vector3;
  9954. /**
  9955. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  9956. */
  9957. rotationQuaternion: Quaternion;
  9958. /**
  9959. * The type of controller (Eg. Windows mixed reality)
  9960. */
  9961. controllerType: PoseEnabledControllerType;
  9962. protected _calculatedPosition: Vector3;
  9963. private _calculatedRotation;
  9964. /**
  9965. * The raw pose from the device
  9966. */
  9967. rawPose: DevicePose;
  9968. private _trackPosition;
  9969. private _maxRotationDistFromHeadset;
  9970. private _draggedRoomRotation;
  9971. /**
  9972. * @hidden
  9973. */
  9974. _disableTrackPosition(fixedPosition: Vector3): void;
  9975. /**
  9976. * Internal, the mesh attached to the controller
  9977. * @hidden
  9978. */
  9979. _mesh: Nullable<AbstractMesh>;
  9980. private _poseControlledCamera;
  9981. private _leftHandSystemQuaternion;
  9982. /**
  9983. * Internal, matrix used to convert room space to babylon space
  9984. * @hidden
  9985. */
  9986. _deviceToWorld: Matrix;
  9987. /**
  9988. * Node to be used when casting a ray from the controller
  9989. * @hidden
  9990. */
  9991. _pointingPoseNode: Nullable<TransformNode>;
  9992. /**
  9993. * Name of the child mesh that can be used to cast a ray from the controller
  9994. */
  9995. static readonly POINTING_POSE: string;
  9996. /**
  9997. * Creates a new PoseEnabledController from a gamepad
  9998. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  9999. */
  10000. constructor(browserGamepad: any);
  10001. private _workingMatrix;
  10002. /**
  10003. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  10004. */
  10005. update(): void;
  10006. /**
  10007. * Updates only the pose device and mesh without doing any button event checking
  10008. */
  10009. protected _updatePoseAndMesh(): void;
  10010. /**
  10011. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  10012. * @param poseData raw pose fromthe device
  10013. */
  10014. updateFromDevice(poseData: DevicePose): void;
  10015. /**
  10016. * @hidden
  10017. */
  10018. _meshAttachedObservable: Observable<AbstractMesh>;
  10019. /**
  10020. * Attaches a mesh to the controller
  10021. * @param mesh the mesh to be attached
  10022. */
  10023. attachToMesh(mesh: AbstractMesh): void;
  10024. /**
  10025. * Attaches the controllers mesh to a camera
  10026. * @param camera the camera the mesh should be attached to
  10027. */
  10028. attachToPoseControlledCamera(camera: TargetCamera): void;
  10029. /**
  10030. * Disposes of the controller
  10031. */
  10032. dispose(): void;
  10033. /**
  10034. * The mesh that is attached to the controller
  10035. */
  10036. readonly mesh: Nullable<AbstractMesh>;
  10037. /**
  10038. * Gets the ray of the controller in the direction the controller is pointing
  10039. * @param length the length the resulting ray should be
  10040. * @returns a ray in the direction the controller is pointing
  10041. */
  10042. getForwardRay(length?: number): Ray;
  10043. }
  10044. }
  10045. declare module BABYLON {
  10046. /**
  10047. * Defines the WebVRController object that represents controllers tracked in 3D space
  10048. */
  10049. export abstract class WebVRController extends PoseEnabledController {
  10050. /**
  10051. * Internal, the default controller model for the controller
  10052. */
  10053. protected _defaultModel: AbstractMesh;
  10054. /**
  10055. * Fired when the trigger state has changed
  10056. */
  10057. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  10058. /**
  10059. * Fired when the main button state has changed
  10060. */
  10061. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10062. /**
  10063. * Fired when the secondary button state has changed
  10064. */
  10065. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10066. /**
  10067. * Fired when the pad state has changed
  10068. */
  10069. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  10070. /**
  10071. * Fired when controllers stick values have changed
  10072. */
  10073. onPadValuesChangedObservable: Observable<StickValues>;
  10074. /**
  10075. * Array of button availible on the controller
  10076. */
  10077. protected _buttons: Array<MutableGamepadButton>;
  10078. private _onButtonStateChange;
  10079. /**
  10080. * Fired when a controller button's state has changed
  10081. * @param callback the callback containing the button that was modified
  10082. */
  10083. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  10084. /**
  10085. * X and Y axis corrisponding to the controllers joystick
  10086. */
  10087. pad: StickValues;
  10088. /**
  10089. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  10090. */
  10091. hand: string;
  10092. /**
  10093. * The default controller model for the controller
  10094. */
  10095. readonly defaultModel: AbstractMesh;
  10096. /**
  10097. * Creates a new WebVRController from a gamepad
  10098. * @param vrGamepad the gamepad that the WebVRController should be created from
  10099. */
  10100. constructor(vrGamepad: any);
  10101. /**
  10102. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  10103. */
  10104. update(): void;
  10105. /**
  10106. * Function to be called when a button is modified
  10107. */
  10108. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  10109. /**
  10110. * Loads a mesh and attaches it to the controller
  10111. * @param scene the scene the mesh should be added to
  10112. * @param meshLoaded callback for when the mesh has been loaded
  10113. */
  10114. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  10115. private _setButtonValue;
  10116. private _changes;
  10117. private _checkChanges;
  10118. /**
  10119. * Disposes of th webVRCOntroller
  10120. */
  10121. dispose(): void;
  10122. }
  10123. }
  10124. declare module BABYLON {
  10125. /**
  10126. * Interface describing all the common properties and methods a shadow light needs to implement.
  10127. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10128. * as well as binding the different shadow properties to the effects.
  10129. */
  10130. export interface IShadowLight extends Light {
  10131. /**
  10132. * The light id in the scene (used in scene.findLighById for instance)
  10133. */
  10134. id: string;
  10135. /**
  10136. * The position the shdow will be casted from.
  10137. */
  10138. position: Vector3;
  10139. /**
  10140. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10141. */
  10142. direction: Vector3;
  10143. /**
  10144. * The transformed position. Position of the light in world space taking parenting in account.
  10145. */
  10146. transformedPosition: Vector3;
  10147. /**
  10148. * The transformed direction. Direction of the light in world space taking parenting in account.
  10149. */
  10150. transformedDirection: Vector3;
  10151. /**
  10152. * The friendly name of the light in the scene.
  10153. */
  10154. name: string;
  10155. /**
  10156. * Defines the shadow projection clipping minimum z value.
  10157. */
  10158. shadowMinZ: number;
  10159. /**
  10160. * Defines the shadow projection clipping maximum z value.
  10161. */
  10162. shadowMaxZ: number;
  10163. /**
  10164. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10165. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10166. */
  10167. computeTransformedInformation(): boolean;
  10168. /**
  10169. * Gets the scene the light belongs to.
  10170. * @returns The scene
  10171. */
  10172. getScene(): Scene;
  10173. /**
  10174. * Callback defining a custom Projection Matrix Builder.
  10175. * This can be used to override the default projection matrix computation.
  10176. */
  10177. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10178. /**
  10179. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10180. * @param matrix The materix to updated with the projection information
  10181. * @param viewMatrix The transform matrix of the light
  10182. * @param renderList The list of mesh to render in the map
  10183. * @returns The current light
  10184. */
  10185. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10186. /**
  10187. * Gets the current depth scale used in ESM.
  10188. * @returns The scale
  10189. */
  10190. getDepthScale(): number;
  10191. /**
  10192. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10193. * @returns true if a cube texture needs to be use
  10194. */
  10195. needCube(): boolean;
  10196. /**
  10197. * Detects if the projection matrix requires to be recomputed this frame.
  10198. * @returns true if it requires to be recomputed otherwise, false.
  10199. */
  10200. needProjectionMatrixCompute(): boolean;
  10201. /**
  10202. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10203. */
  10204. forceProjectionMatrixCompute(): void;
  10205. /**
  10206. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10207. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10208. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10209. */
  10210. getShadowDirection(faceIndex?: number): Vector3;
  10211. /**
  10212. * Gets the minZ used for shadow according to both the scene and the light.
  10213. * @param activeCamera The camera we are returning the min for
  10214. * @returns the depth min z
  10215. */
  10216. getDepthMinZ(activeCamera: Camera): number;
  10217. /**
  10218. * Gets the maxZ used for shadow according to both the scene and the light.
  10219. * @param activeCamera The camera we are returning the max for
  10220. * @returns the depth max z
  10221. */
  10222. getDepthMaxZ(activeCamera: Camera): number;
  10223. }
  10224. /**
  10225. * Base implementation IShadowLight
  10226. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10227. */
  10228. export abstract class ShadowLight extends Light implements IShadowLight {
  10229. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10230. protected _position: Vector3;
  10231. protected _setPosition(value: Vector3): void;
  10232. /**
  10233. * Sets the position the shadow will be casted from. Also use as the light position for both
  10234. * point and spot lights.
  10235. */
  10236. /**
  10237. * Sets the position the shadow will be casted from. Also use as the light position for both
  10238. * point and spot lights.
  10239. */
  10240. position: Vector3;
  10241. protected _direction: Vector3;
  10242. protected _setDirection(value: Vector3): void;
  10243. /**
  10244. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10245. * Also use as the light direction on spot and directional lights.
  10246. */
  10247. /**
  10248. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10249. * Also use as the light direction on spot and directional lights.
  10250. */
  10251. direction: Vector3;
  10252. private _shadowMinZ;
  10253. /**
  10254. * Gets the shadow projection clipping minimum z value.
  10255. */
  10256. /**
  10257. * Sets the shadow projection clipping minimum z value.
  10258. */
  10259. shadowMinZ: number;
  10260. private _shadowMaxZ;
  10261. /**
  10262. * Sets the shadow projection clipping maximum z value.
  10263. */
  10264. /**
  10265. * Gets the shadow projection clipping maximum z value.
  10266. */
  10267. shadowMaxZ: number;
  10268. /**
  10269. * Callback defining a custom Projection Matrix Builder.
  10270. * This can be used to override the default projection matrix computation.
  10271. */
  10272. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10273. /**
  10274. * The transformed position. Position of the light in world space taking parenting in account.
  10275. */
  10276. transformedPosition: Vector3;
  10277. /**
  10278. * The transformed direction. Direction of the light in world space taking parenting in account.
  10279. */
  10280. transformedDirection: Vector3;
  10281. private _needProjectionMatrixCompute;
  10282. /**
  10283. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10284. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10285. */
  10286. computeTransformedInformation(): boolean;
  10287. /**
  10288. * Return the depth scale used for the shadow map.
  10289. * @returns the depth scale.
  10290. */
  10291. getDepthScale(): number;
  10292. /**
  10293. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10294. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10295. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10296. */
  10297. getShadowDirection(faceIndex?: number): Vector3;
  10298. /**
  10299. * Returns the ShadowLight absolute position in the World.
  10300. * @returns the position vector in world space
  10301. */
  10302. getAbsolutePosition(): Vector3;
  10303. /**
  10304. * Sets the ShadowLight direction toward the passed target.
  10305. * @param target The point tot target in local space
  10306. * @returns the updated ShadowLight direction
  10307. */
  10308. setDirectionToTarget(target: Vector3): Vector3;
  10309. /**
  10310. * Returns the light rotation in euler definition.
  10311. * @returns the x y z rotation in local space.
  10312. */
  10313. getRotation(): Vector3;
  10314. /**
  10315. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10316. * @returns true if a cube texture needs to be use
  10317. */
  10318. needCube(): boolean;
  10319. /**
  10320. * Detects if the projection matrix requires to be recomputed this frame.
  10321. * @returns true if it requires to be recomputed otherwise, false.
  10322. */
  10323. needProjectionMatrixCompute(): boolean;
  10324. /**
  10325. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10326. */
  10327. forceProjectionMatrixCompute(): void;
  10328. /** @hidden */
  10329. _initCache(): void;
  10330. /** @hidden */
  10331. _isSynchronized(): boolean;
  10332. /**
  10333. * Computes the world matrix of the node
  10334. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10335. * @returns the world matrix
  10336. */
  10337. computeWorldMatrix(force?: boolean): Matrix;
  10338. /**
  10339. * Gets the minZ used for shadow according to both the scene and the light.
  10340. * @param activeCamera The camera we are returning the min for
  10341. * @returns the depth min z
  10342. */
  10343. getDepthMinZ(activeCamera: Camera): number;
  10344. /**
  10345. * Gets the maxZ used for shadow according to both the scene and the light.
  10346. * @param activeCamera The camera we are returning the max for
  10347. * @returns the depth max z
  10348. */
  10349. getDepthMaxZ(activeCamera: Camera): number;
  10350. /**
  10351. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10352. * @param matrix The materix to updated with the projection information
  10353. * @param viewMatrix The transform matrix of the light
  10354. * @param renderList The list of mesh to render in the map
  10355. * @returns The current light
  10356. */
  10357. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * "Static Class" containing the most commonly used helper while dealing with material for
  10363. * rendering purpose.
  10364. *
  10365. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10366. *
  10367. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10368. */
  10369. export class MaterialHelper {
  10370. /**
  10371. * Bind the current view position to an effect.
  10372. * @param effect The effect to be bound
  10373. * @param scene The scene the eyes position is used from
  10374. */
  10375. static BindEyePosition(effect: Effect, scene: Scene): void;
  10376. /**
  10377. * Helps preparing the defines values about the UVs in used in the effect.
  10378. * UVs are shared as much as we can accross channels in the shaders.
  10379. * @param texture The texture we are preparing the UVs for
  10380. * @param defines The defines to update
  10381. * @param key The channel key "diffuse", "specular"... used in the shader
  10382. */
  10383. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10384. /**
  10385. * Binds a texture matrix value to its corrsponding uniform
  10386. * @param texture The texture to bind the matrix for
  10387. * @param uniformBuffer The uniform buffer receivin the data
  10388. * @param key The channel key "diffuse", "specular"... used in the shader
  10389. */
  10390. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10391. /**
  10392. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10393. * @param mesh defines the current mesh
  10394. * @param scene defines the current scene
  10395. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10396. * @param pointsCloud defines if point cloud rendering has to be turned on
  10397. * @param fogEnabled defines if fog has to be turned on
  10398. * @param alphaTest defines if alpha testing has to be turned on
  10399. * @param defines defines the current list of defines
  10400. */
  10401. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10402. /**
  10403. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10404. * @param scene defines the current scene
  10405. * @param engine defines the current engine
  10406. * @param defines specifies the list of active defines
  10407. * @param useInstances defines if instances have to be turned on
  10408. * @param useClipPlane defines if clip plane have to be turned on
  10409. */
  10410. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10411. /**
  10412. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10413. * @param mesh The mesh containing the geometry data we will draw
  10414. * @param defines The defines to update
  10415. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10416. * @param useBones Precise whether bones should be used or not (override mesh info)
  10417. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10418. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10419. * @returns false if defines are considered not dirty and have not been checked
  10420. */
  10421. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10422. /**
  10423. * Prepares the defines related to the light information passed in parameter
  10424. * @param scene The scene we are intending to draw
  10425. * @param mesh The mesh the effect is compiling for
  10426. * @param defines The defines to update
  10427. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10428. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10429. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10430. * @returns true if normals will be required for the rest of the effect
  10431. */
  10432. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10433. /**
  10434. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10435. * that won t be acctive due to defines being turned off.
  10436. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10437. * @param samplersList The samplers list
  10438. * @param defines The defines helping in the list generation
  10439. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10440. */
  10441. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10442. /**
  10443. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10444. * @param defines The defines to update while falling back
  10445. * @param fallbacks The authorized effect fallbacks
  10446. * @param maxSimultaneousLights The maximum number of lights allowed
  10447. * @param rank the current rank of the Effect
  10448. * @returns The newly affected rank
  10449. */
  10450. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10451. /**
  10452. * Prepares the list of attributes required for morph targets according to the effect defines.
  10453. * @param attribs The current list of supported attribs
  10454. * @param mesh The mesh to prepare the morph targets attributes for
  10455. * @param defines The current Defines of the effect
  10456. */
  10457. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10458. /**
  10459. * Prepares the list of attributes required for bones according to the effect defines.
  10460. * @param attribs The current list of supported attribs
  10461. * @param mesh The mesh to prepare the bones attributes for
  10462. * @param defines The current Defines of the effect
  10463. * @param fallbacks The current efffect fallback strategy
  10464. */
  10465. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10466. /**
  10467. * Prepares the list of attributes required for instances according to the effect defines.
  10468. * @param attribs The current list of supported attribs
  10469. * @param defines The current Defines of the effect
  10470. */
  10471. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10472. /**
  10473. * Binds the light shadow information to the effect for the given mesh.
  10474. * @param light The light containing the generator
  10475. * @param scene The scene the lights belongs to
  10476. * @param mesh The mesh we are binding the information to render
  10477. * @param lightIndex The light index in the effect used to render the mesh
  10478. * @param effect The effect we are binding the data to
  10479. */
  10480. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10481. /**
  10482. * Binds the light information to the effect.
  10483. * @param light The light containing the generator
  10484. * @param effect The effect we are binding the data to
  10485. * @param lightIndex The light index in the effect used to render
  10486. */
  10487. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10488. /**
  10489. * Binds the lights information from the scene to the effect for the given mesh.
  10490. * @param scene The scene the lights belongs to
  10491. * @param mesh The mesh we are binding the information to render
  10492. * @param effect The effect we are binding the data to
  10493. * @param defines The generated defines for the effect
  10494. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10495. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10496. */
  10497. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10498. private static _tempFogColor;
  10499. /**
  10500. * Binds the fog information from the scene to the effect for the given mesh.
  10501. * @param scene The scene the lights belongs to
  10502. * @param mesh The mesh we are binding the information to render
  10503. * @param effect The effect we are binding the data to
  10504. * @param linearSpace Defines if the fog effect is applied in linear space
  10505. */
  10506. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10507. /**
  10508. * Binds the bones information from the mesh to the effect.
  10509. * @param mesh The mesh we are binding the information to render
  10510. * @param effect The effect we are binding the data to
  10511. */
  10512. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10513. /**
  10514. * Binds the morph targets information from the mesh to the effect.
  10515. * @param abstractMesh The mesh we are binding the information to render
  10516. * @param effect The effect we are binding the data to
  10517. */
  10518. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10519. /**
  10520. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10521. * @param defines The generated defines used in the effect
  10522. * @param effect The effect we are binding the data to
  10523. * @param scene The scene we are willing to render with logarithmic scale for
  10524. */
  10525. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10526. /**
  10527. * Binds the clip plane information from the scene to the effect.
  10528. * @param scene The scene the clip plane information are extracted from
  10529. * @param effect The effect we are binding the data to
  10530. */
  10531. static BindClipPlane(effect: Effect, scene: Scene): void;
  10532. }
  10533. }
  10534. declare module BABYLON {
  10535. /** @hidden */
  10536. export var shadowMapPixelShader: {
  10537. name: string;
  10538. shader: string;
  10539. };
  10540. }
  10541. declare module BABYLON {
  10542. /** @hidden */
  10543. export var bonesDeclaration: {
  10544. name: string;
  10545. shader: string;
  10546. };
  10547. }
  10548. declare module BABYLON {
  10549. /** @hidden */
  10550. export var morphTargetsVertexGlobalDeclaration: {
  10551. name: string;
  10552. shader: string;
  10553. };
  10554. }
  10555. declare module BABYLON {
  10556. /** @hidden */
  10557. export var morphTargetsVertexDeclaration: {
  10558. name: string;
  10559. shader: string;
  10560. };
  10561. }
  10562. declare module BABYLON {
  10563. /** @hidden */
  10564. export var instancesDeclaration: {
  10565. name: string;
  10566. shader: string;
  10567. };
  10568. }
  10569. declare module BABYLON {
  10570. /** @hidden */
  10571. export var helperFunctions: {
  10572. name: string;
  10573. shader: string;
  10574. };
  10575. }
  10576. declare module BABYLON {
  10577. /** @hidden */
  10578. export var morphTargetsVertex: {
  10579. name: string;
  10580. shader: string;
  10581. };
  10582. }
  10583. declare module BABYLON {
  10584. /** @hidden */
  10585. export var instancesVertex: {
  10586. name: string;
  10587. shader: string;
  10588. };
  10589. }
  10590. declare module BABYLON {
  10591. /** @hidden */
  10592. export var bonesVertex: {
  10593. name: string;
  10594. shader: string;
  10595. };
  10596. }
  10597. declare module BABYLON {
  10598. /** @hidden */
  10599. export var shadowMapVertexShader: {
  10600. name: string;
  10601. shader: string;
  10602. };
  10603. }
  10604. declare module BABYLON {
  10605. /** @hidden */
  10606. export var depthBoxBlurPixelShader: {
  10607. name: string;
  10608. shader: string;
  10609. };
  10610. }
  10611. declare module BABYLON {
  10612. /**
  10613. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10614. */
  10615. export interface ICustomShaderOptions {
  10616. /**
  10617. * Gets or sets the custom shader name to use
  10618. */
  10619. shaderName: string;
  10620. /**
  10621. * The list of attribute names used in the shader
  10622. */
  10623. attributes?: string[];
  10624. /**
  10625. * The list of unifrom names used in the shader
  10626. */
  10627. uniforms?: string[];
  10628. /**
  10629. * The list of sampler names used in the shader
  10630. */
  10631. samplers?: string[];
  10632. /**
  10633. * The list of defines used in the shader
  10634. */
  10635. defines?: string[];
  10636. }
  10637. /**
  10638. * Interface to implement to create a shadow generator compatible with BJS.
  10639. */
  10640. export interface IShadowGenerator {
  10641. /**
  10642. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10643. * @returns The render target texture if present otherwise, null
  10644. */
  10645. getShadowMap(): Nullable<RenderTargetTexture>;
  10646. /**
  10647. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10648. * @returns The render target texture if the shadow map is present otherwise, null
  10649. */
  10650. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10651. /**
  10652. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10653. * @param subMesh The submesh we want to render in the shadow map
  10654. * @param useInstances Defines wether will draw in the map using instances
  10655. * @returns true if ready otherwise, false
  10656. */
  10657. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10658. /**
  10659. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10660. * @param defines Defines of the material we want to update
  10661. * @param lightIndex Index of the light in the enabled light list of the material
  10662. */
  10663. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10664. /**
  10665. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10666. * defined in the generator but impacting the effect).
  10667. * It implies the unifroms available on the materials are the standard BJS ones.
  10668. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10669. * @param effect The effect we are binfing the information for
  10670. */
  10671. bindShadowLight(lightIndex: string, effect: Effect): void;
  10672. /**
  10673. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10674. * (eq to shadow prjection matrix * light transform matrix)
  10675. * @returns The transform matrix used to create the shadow map
  10676. */
  10677. getTransformMatrix(): Matrix;
  10678. /**
  10679. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10680. * Cube and 2D textures for instance.
  10681. */
  10682. recreateShadowMap(): void;
  10683. /**
  10684. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10685. * @param onCompiled Callback triggered at the and of the effects compilation
  10686. * @param options Sets of optional options forcing the compilation with different modes
  10687. */
  10688. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10689. useInstances: boolean;
  10690. }>): void;
  10691. /**
  10692. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10693. * @param options Sets of optional options forcing the compilation with different modes
  10694. * @returns A promise that resolves when the compilation completes
  10695. */
  10696. forceCompilationAsync(options?: Partial<{
  10697. useInstances: boolean;
  10698. }>): Promise<void>;
  10699. /**
  10700. * Serializes the shadow generator setup to a json object.
  10701. * @returns The serialized JSON object
  10702. */
  10703. serialize(): any;
  10704. /**
  10705. * Disposes the Shadow map and related Textures and effects.
  10706. */
  10707. dispose(): void;
  10708. }
  10709. /**
  10710. * Default implementation IShadowGenerator.
  10711. * This is the main object responsible of generating shadows in the framework.
  10712. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10713. */
  10714. export class ShadowGenerator implements IShadowGenerator {
  10715. /**
  10716. * Shadow generator mode None: no filtering applied.
  10717. */
  10718. static readonly FILTER_NONE: number;
  10719. /**
  10720. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10721. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10722. */
  10723. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10724. /**
  10725. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10726. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10727. */
  10728. static readonly FILTER_POISSONSAMPLING: number;
  10729. /**
  10730. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10731. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10732. */
  10733. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10734. /**
  10735. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10736. * edge artifacts on steep falloff.
  10737. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10738. */
  10739. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10740. /**
  10741. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10742. * edge artifacts on steep falloff.
  10743. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10744. */
  10745. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10746. /**
  10747. * Shadow generator mode PCF: Percentage Closer Filtering
  10748. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10749. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10750. */
  10751. static readonly FILTER_PCF: number;
  10752. /**
  10753. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10754. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10755. * Contact Hardening
  10756. */
  10757. static readonly FILTER_PCSS: number;
  10758. /**
  10759. * Reserved for PCF and PCSS
  10760. * Highest Quality.
  10761. *
  10762. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10763. *
  10764. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10765. */
  10766. static readonly QUALITY_HIGH: number;
  10767. /**
  10768. * Reserved for PCF and PCSS
  10769. * Good tradeoff for quality/perf cross devices
  10770. *
  10771. * Execute PCF on a 3*3 kernel.
  10772. *
  10773. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10774. */
  10775. static readonly QUALITY_MEDIUM: number;
  10776. /**
  10777. * Reserved for PCF and PCSS
  10778. * The lowest quality but the fastest.
  10779. *
  10780. * Execute PCF on a 1*1 kernel.
  10781. *
  10782. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10783. */
  10784. static readonly QUALITY_LOW: number;
  10785. /** Gets or sets the custom shader name to use */
  10786. customShaderOptions: ICustomShaderOptions;
  10787. /**
  10788. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10789. */
  10790. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10791. private _bias;
  10792. /**
  10793. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10794. */
  10795. /**
  10796. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10797. */
  10798. bias: number;
  10799. private _normalBias;
  10800. /**
  10801. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10802. */
  10803. /**
  10804. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10805. */
  10806. normalBias: number;
  10807. private _blurBoxOffset;
  10808. /**
  10809. * Gets the blur box offset: offset applied during the blur pass.
  10810. * Only useful if useKernelBlur = false
  10811. */
  10812. /**
  10813. * Sets the blur box offset: offset applied during the blur pass.
  10814. * Only useful if useKernelBlur = false
  10815. */
  10816. blurBoxOffset: number;
  10817. private _blurScale;
  10818. /**
  10819. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10820. * 2 means half of the size.
  10821. */
  10822. /**
  10823. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10824. * 2 means half of the size.
  10825. */
  10826. blurScale: number;
  10827. private _blurKernel;
  10828. /**
  10829. * Gets the blur kernel: kernel size of the blur pass.
  10830. * Only useful if useKernelBlur = true
  10831. */
  10832. /**
  10833. * Sets the blur kernel: kernel size of the blur pass.
  10834. * Only useful if useKernelBlur = true
  10835. */
  10836. blurKernel: number;
  10837. private _useKernelBlur;
  10838. /**
  10839. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10840. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10841. */
  10842. /**
  10843. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10844. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10845. */
  10846. useKernelBlur: boolean;
  10847. private _depthScale;
  10848. /**
  10849. * Gets the depth scale used in ESM mode.
  10850. */
  10851. /**
  10852. * Sets the depth scale used in ESM mode.
  10853. * This can override the scale stored on the light.
  10854. */
  10855. depthScale: number;
  10856. private _filter;
  10857. /**
  10858. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10859. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10860. */
  10861. /**
  10862. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10863. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10864. */
  10865. filter: number;
  10866. /**
  10867. * Gets if the current filter is set to Poisson Sampling.
  10868. */
  10869. /**
  10870. * Sets the current filter to Poisson Sampling.
  10871. */
  10872. usePoissonSampling: boolean;
  10873. /**
  10874. * Gets if the current filter is set to ESM.
  10875. */
  10876. /**
  10877. * Sets the current filter is to ESM.
  10878. */
  10879. useExponentialShadowMap: boolean;
  10880. /**
  10881. * Gets if the current filter is set to filtered ESM.
  10882. */
  10883. /**
  10884. * Gets if the current filter is set to filtered ESM.
  10885. */
  10886. useBlurExponentialShadowMap: boolean;
  10887. /**
  10888. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10889. * exponential to prevent steep falloff artifacts).
  10890. */
  10891. /**
  10892. * Sets the current filter to "close ESM" (using the inverse of the
  10893. * exponential to prevent steep falloff artifacts).
  10894. */
  10895. useCloseExponentialShadowMap: boolean;
  10896. /**
  10897. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10898. * exponential to prevent steep falloff artifacts).
  10899. */
  10900. /**
  10901. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10902. * exponential to prevent steep falloff artifacts).
  10903. */
  10904. useBlurCloseExponentialShadowMap: boolean;
  10905. /**
  10906. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10907. */
  10908. /**
  10909. * Sets the current filter to "PCF" (percentage closer filtering).
  10910. */
  10911. usePercentageCloserFiltering: boolean;
  10912. private _filteringQuality;
  10913. /**
  10914. * Gets the PCF or PCSS Quality.
  10915. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10916. */
  10917. /**
  10918. * Sets the PCF or PCSS Quality.
  10919. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10920. */
  10921. filteringQuality: number;
  10922. /**
  10923. * Gets if the current filter is set to "PCSS" (contact hardening).
  10924. */
  10925. /**
  10926. * Sets the current filter to "PCSS" (contact hardening).
  10927. */
  10928. useContactHardeningShadow: boolean;
  10929. private _contactHardeningLightSizeUVRatio;
  10930. /**
  10931. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10932. * Using a ratio helps keeping shape stability independently of the map size.
  10933. *
  10934. * It does not account for the light projection as it was having too much
  10935. * instability during the light setup or during light position changes.
  10936. *
  10937. * Only valid if useContactHardeningShadow is true.
  10938. */
  10939. /**
  10940. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10941. * Using a ratio helps keeping shape stability independently of the map size.
  10942. *
  10943. * It does not account for the light projection as it was having too much
  10944. * instability during the light setup or during light position changes.
  10945. *
  10946. * Only valid if useContactHardeningShadow is true.
  10947. */
  10948. contactHardeningLightSizeUVRatio: number;
  10949. private _darkness;
  10950. /**
  10951. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10952. * 0 means strongest and 1 would means no shadow.
  10953. * @returns the darkness.
  10954. */
  10955. getDarkness(): number;
  10956. /**
  10957. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10958. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10959. * @returns the shadow generator allowing fluent coding.
  10960. */
  10961. setDarkness(darkness: number): ShadowGenerator;
  10962. private _transparencyShadow;
  10963. /**
  10964. * Sets the ability to have transparent shadow (boolean).
  10965. * @param transparent True if transparent else False
  10966. * @returns the shadow generator allowing fluent coding
  10967. */
  10968. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10969. private _shadowMap;
  10970. private _shadowMap2;
  10971. /**
  10972. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10973. * @returns The render target texture if present otherwise, null
  10974. */
  10975. getShadowMap(): Nullable<RenderTargetTexture>;
  10976. /**
  10977. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10978. * @returns The render target texture if the shadow map is present otherwise, null
  10979. */
  10980. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10981. /**
  10982. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10983. * @param mesh Mesh to add
  10984. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10985. * @returns the Shadow Generator itself
  10986. */
  10987. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10988. /**
  10989. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10990. * @param mesh Mesh to remove
  10991. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10992. * @returns the Shadow Generator itself
  10993. */
  10994. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10995. /**
  10996. * Controls the extent to which the shadows fade out at the edge of the frustum
  10997. * Used only by directionals and spots
  10998. */
  10999. frustumEdgeFalloff: number;
  11000. private _light;
  11001. /**
  11002. * Returns the associated light object.
  11003. * @returns the light generating the shadow
  11004. */
  11005. getLight(): IShadowLight;
  11006. /**
  11007. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11008. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11009. * It might on the other hand introduce peter panning.
  11010. */
  11011. forceBackFacesOnly: boolean;
  11012. private _scene;
  11013. private _lightDirection;
  11014. private _effect;
  11015. private _viewMatrix;
  11016. private _projectionMatrix;
  11017. private _transformMatrix;
  11018. private _cachedPosition;
  11019. private _cachedDirection;
  11020. private _cachedDefines;
  11021. private _currentRenderID;
  11022. private _boxBlurPostprocess;
  11023. private _kernelBlurXPostprocess;
  11024. private _kernelBlurYPostprocess;
  11025. private _blurPostProcesses;
  11026. private _mapSize;
  11027. private _currentFaceIndex;
  11028. private _currentFaceIndexCache;
  11029. private _textureType;
  11030. private _defaultTextureMatrix;
  11031. /** @hidden */
  11032. static _SceneComponentInitialization: (scene: Scene) => void;
  11033. /**
  11034. * Creates a ShadowGenerator object.
  11035. * A ShadowGenerator is the required tool to use the shadows.
  11036. * Each light casting shadows needs to use its own ShadowGenerator.
  11037. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11038. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11039. * @param light The light object generating the shadows.
  11040. * @param usefulFloatFirst 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.
  11041. */
  11042. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11043. private _initializeGenerator;
  11044. private _initializeShadowMap;
  11045. private _initializeBlurRTTAndPostProcesses;
  11046. private _renderForShadowMap;
  11047. private _renderSubMeshForShadowMap;
  11048. private _applyFilterValues;
  11049. /**
  11050. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11051. * @param onCompiled Callback triggered at the and of the effects compilation
  11052. * @param options Sets of optional options forcing the compilation with different modes
  11053. */
  11054. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11055. useInstances: boolean;
  11056. }>): void;
  11057. /**
  11058. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11059. * @param options Sets of optional options forcing the compilation with different modes
  11060. * @returns A promise that resolves when the compilation completes
  11061. */
  11062. forceCompilationAsync(options?: Partial<{
  11063. useInstances: boolean;
  11064. }>): Promise<void>;
  11065. /**
  11066. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11067. * @param subMesh The submesh we want to render in the shadow map
  11068. * @param useInstances Defines wether will draw in the map using instances
  11069. * @returns true if ready otherwise, false
  11070. */
  11071. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11072. /**
  11073. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11074. * @param defines Defines of the material we want to update
  11075. * @param lightIndex Index of the light in the enabled light list of the material
  11076. */
  11077. prepareDefines(defines: any, lightIndex: number): void;
  11078. /**
  11079. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11080. * defined in the generator but impacting the effect).
  11081. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11082. * @param effect The effect we are binfing the information for
  11083. */
  11084. bindShadowLight(lightIndex: string, effect: Effect): void;
  11085. /**
  11086. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11087. * (eq to shadow prjection matrix * light transform matrix)
  11088. * @returns The transform matrix used to create the shadow map
  11089. */
  11090. getTransformMatrix(): Matrix;
  11091. /**
  11092. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11093. * Cube and 2D textures for instance.
  11094. */
  11095. recreateShadowMap(): void;
  11096. private _disposeBlurPostProcesses;
  11097. private _disposeRTTandPostProcesses;
  11098. /**
  11099. * Disposes the ShadowGenerator.
  11100. * Returns nothing.
  11101. */
  11102. dispose(): void;
  11103. /**
  11104. * Serializes the shadow generator setup to a json object.
  11105. * @returns The serialized JSON object
  11106. */
  11107. serialize(): any;
  11108. /**
  11109. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11110. * @param parsedShadowGenerator The JSON object to parse
  11111. * @param scene The scene to create the shadow map for
  11112. * @returns The parsed shadow generator
  11113. */
  11114. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11115. }
  11116. }
  11117. declare module BABYLON {
  11118. /**
  11119. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11120. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11121. * 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.
  11122. */
  11123. export abstract class Light extends Node {
  11124. /**
  11125. * Falloff Default: light is falling off following the material specification:
  11126. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11127. */
  11128. static readonly FALLOFF_DEFAULT: number;
  11129. /**
  11130. * Falloff Physical: light is falling off following the inverse squared distance law.
  11131. */
  11132. static readonly FALLOFF_PHYSICAL: number;
  11133. /**
  11134. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11135. * to enhance interoperability with other engines.
  11136. */
  11137. static readonly FALLOFF_GLTF: number;
  11138. /**
  11139. * Falloff Standard: light is falling off like in the standard material
  11140. * to enhance interoperability with other materials.
  11141. */
  11142. static readonly FALLOFF_STANDARD: number;
  11143. /**
  11144. * If every light affecting the material is in this lightmapMode,
  11145. * material.lightmapTexture adds or multiplies
  11146. * (depends on material.useLightmapAsShadowmap)
  11147. * after every other light calculations.
  11148. */
  11149. static readonly LIGHTMAP_DEFAULT: number;
  11150. /**
  11151. * material.lightmapTexture as only diffuse lighting from this light
  11152. * adds only specular lighting from this light
  11153. * adds dynamic shadows
  11154. */
  11155. static readonly LIGHTMAP_SPECULAR: number;
  11156. /**
  11157. * material.lightmapTexture as only lighting
  11158. * no light calculation from this light
  11159. * only adds dynamic shadows from this light
  11160. */
  11161. static readonly LIGHTMAP_SHADOWSONLY: number;
  11162. /**
  11163. * Each light type uses the default quantity according to its type:
  11164. * point/spot lights use luminous intensity
  11165. * directional lights use illuminance
  11166. */
  11167. static readonly INTENSITYMODE_AUTOMATIC: number;
  11168. /**
  11169. * lumen (lm)
  11170. */
  11171. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11172. /**
  11173. * candela (lm/sr)
  11174. */
  11175. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11176. /**
  11177. * lux (lm/m^2)
  11178. */
  11179. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11180. /**
  11181. * nit (cd/m^2)
  11182. */
  11183. static readonly INTENSITYMODE_LUMINANCE: number;
  11184. /**
  11185. * Light type const id of the point light.
  11186. */
  11187. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11188. /**
  11189. * Light type const id of the directional light.
  11190. */
  11191. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11192. /**
  11193. * Light type const id of the spot light.
  11194. */
  11195. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11196. /**
  11197. * Light type const id of the hemispheric light.
  11198. */
  11199. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11200. /**
  11201. * Diffuse gives the basic color to an object.
  11202. */
  11203. diffuse: Color3;
  11204. /**
  11205. * Specular produces a highlight color on an object.
  11206. * Note: This is note affecting PBR materials.
  11207. */
  11208. specular: Color3;
  11209. /**
  11210. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11211. * falling off base on range or angle.
  11212. * This can be set to any values in Light.FALLOFF_x.
  11213. *
  11214. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11215. * other types of materials.
  11216. */
  11217. falloffType: number;
  11218. /**
  11219. * Strength of the light.
  11220. * Note: By default it is define in the framework own unit.
  11221. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11222. */
  11223. intensity: number;
  11224. private _range;
  11225. protected _inverseSquaredRange: number;
  11226. /**
  11227. * Defines how far from the source the light is impacting in scene units.
  11228. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11229. */
  11230. /**
  11231. * Defines how far from the source the light is impacting in scene units.
  11232. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11233. */
  11234. range: number;
  11235. /**
  11236. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11237. * of light.
  11238. */
  11239. private _photometricScale;
  11240. private _intensityMode;
  11241. /**
  11242. * Gets the photometric scale used to interpret the intensity.
  11243. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11244. */
  11245. /**
  11246. * Sets the photometric scale used to interpret the intensity.
  11247. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11248. */
  11249. intensityMode: number;
  11250. private _radius;
  11251. /**
  11252. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11253. */
  11254. /**
  11255. * sets the light radius used by PBR Materials to simulate soft area lights.
  11256. */
  11257. radius: number;
  11258. private _renderPriority;
  11259. /**
  11260. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11261. * exceeding the number allowed of the materials.
  11262. */
  11263. renderPriority: number;
  11264. private _shadowEnabled;
  11265. /**
  11266. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11267. * the current shadow generator.
  11268. */
  11269. /**
  11270. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11271. * the current shadow generator.
  11272. */
  11273. shadowEnabled: boolean;
  11274. private _includedOnlyMeshes;
  11275. /**
  11276. * Gets the only meshes impacted by this light.
  11277. */
  11278. /**
  11279. * Sets the only meshes impacted by this light.
  11280. */
  11281. includedOnlyMeshes: AbstractMesh[];
  11282. private _excludedMeshes;
  11283. /**
  11284. * Gets the meshes not impacted by this light.
  11285. */
  11286. /**
  11287. * Sets the meshes not impacted by this light.
  11288. */
  11289. excludedMeshes: AbstractMesh[];
  11290. private _excludeWithLayerMask;
  11291. /**
  11292. * Gets the layer id use to find what meshes are not impacted by the light.
  11293. * Inactive if 0
  11294. */
  11295. /**
  11296. * Sets the layer id use to find what meshes are not impacted by the light.
  11297. * Inactive if 0
  11298. */
  11299. excludeWithLayerMask: number;
  11300. private _includeOnlyWithLayerMask;
  11301. /**
  11302. * Gets the layer id use to find what meshes are impacted by the light.
  11303. * Inactive if 0
  11304. */
  11305. /**
  11306. * Sets the layer id use to find what meshes are impacted by the light.
  11307. * Inactive if 0
  11308. */
  11309. includeOnlyWithLayerMask: number;
  11310. private _lightmapMode;
  11311. /**
  11312. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11313. */
  11314. /**
  11315. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11316. */
  11317. lightmapMode: number;
  11318. /**
  11319. * Shadow generator associted to the light.
  11320. * @hidden Internal use only.
  11321. */
  11322. _shadowGenerator: Nullable<IShadowGenerator>;
  11323. /**
  11324. * @hidden Internal use only.
  11325. */
  11326. _excludedMeshesIds: string[];
  11327. /**
  11328. * @hidden Internal use only.
  11329. */
  11330. _includedOnlyMeshesIds: string[];
  11331. /**
  11332. * The current light unifom buffer.
  11333. * @hidden Internal use only.
  11334. */
  11335. _uniformBuffer: UniformBuffer;
  11336. /**
  11337. * Creates a Light object in the scene.
  11338. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11339. * @param name The firendly name of the light
  11340. * @param scene The scene the light belongs too
  11341. */
  11342. constructor(name: string, scene: Scene);
  11343. protected abstract _buildUniformLayout(): void;
  11344. /**
  11345. * Sets the passed Effect "effect" with the Light information.
  11346. * @param effect The effect to update
  11347. * @param lightIndex The index of the light in the effect to update
  11348. * @returns The light
  11349. */
  11350. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11351. /**
  11352. * Returns the string "Light".
  11353. * @returns the class name
  11354. */
  11355. getClassName(): string;
  11356. /** @hidden */
  11357. readonly _isLight: boolean;
  11358. /**
  11359. * Converts the light information to a readable string for debug purpose.
  11360. * @param fullDetails Supports for multiple levels of logging within scene loading
  11361. * @returns the human readable light info
  11362. */
  11363. toString(fullDetails?: boolean): string;
  11364. /** @hidden */
  11365. protected _syncParentEnabledState(): void;
  11366. /**
  11367. * Set the enabled state of this node.
  11368. * @param value - the new enabled state
  11369. */
  11370. setEnabled(value: boolean): void;
  11371. /**
  11372. * Returns the Light associated shadow generator if any.
  11373. * @return the associated shadow generator.
  11374. */
  11375. getShadowGenerator(): Nullable<IShadowGenerator>;
  11376. /**
  11377. * Returns a Vector3, the absolute light position in the World.
  11378. * @returns the world space position of the light
  11379. */
  11380. getAbsolutePosition(): Vector3;
  11381. /**
  11382. * Specifies if the light will affect the passed mesh.
  11383. * @param mesh The mesh to test against the light
  11384. * @return true the mesh is affected otherwise, false.
  11385. */
  11386. canAffectMesh(mesh: AbstractMesh): boolean;
  11387. /**
  11388. * Sort function to order lights for rendering.
  11389. * @param a First Light object to compare to second.
  11390. * @param b Second Light object to compare first.
  11391. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11392. */
  11393. static CompareLightsPriority(a: Light, b: Light): number;
  11394. /**
  11395. * Releases resources associated with this node.
  11396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11398. */
  11399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11400. /**
  11401. * Returns the light type ID (integer).
  11402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11403. */
  11404. getTypeID(): number;
  11405. /**
  11406. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11407. * @returns the scaled intensity in intensity mode unit
  11408. */
  11409. getScaledIntensity(): number;
  11410. /**
  11411. * Returns a new Light object, named "name", from the current one.
  11412. * @param name The name of the cloned light
  11413. * @returns the new created light
  11414. */
  11415. clone(name: string): Nullable<Light>;
  11416. /**
  11417. * Serializes the current light into a Serialization object.
  11418. * @returns the serialized object.
  11419. */
  11420. serialize(): any;
  11421. /**
  11422. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11423. * This new light is named "name" and added to the passed scene.
  11424. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11425. * @param name The friendly name of the light
  11426. * @param scene The scene the new light will belong to
  11427. * @returns the constructor function
  11428. */
  11429. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11430. /**
  11431. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11432. * @param parsedLight The JSON representation of the light
  11433. * @param scene The scene to create the parsed light in
  11434. * @returns the created light after parsing
  11435. */
  11436. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11437. private _hookArrayForExcluded;
  11438. private _hookArrayForIncludedOnly;
  11439. private _resyncMeshes;
  11440. /**
  11441. * Forces the meshes to update their light related information in their rendering used effects
  11442. * @hidden Internal Use Only
  11443. */
  11444. _markMeshesAsLightDirty(): void;
  11445. /**
  11446. * Recomputes the cached photometric scale if needed.
  11447. */
  11448. private _computePhotometricScale;
  11449. /**
  11450. * Returns the Photometric Scale according to the light type and intensity mode.
  11451. */
  11452. private _getPhotometricScale;
  11453. /**
  11454. * Reorder the light in the scene according to their defined priority.
  11455. * @hidden Internal Use Only
  11456. */
  11457. _reorderLightsInScene(): void;
  11458. /**
  11459. * Prepares the list of defines specific to the light type.
  11460. * @param defines the list of defines
  11461. * @param lightIndex defines the index of the light for the effect
  11462. */
  11463. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11464. }
  11465. }
  11466. declare module BABYLON {
  11467. /**
  11468. * The HemisphericLight simulates the ambient environment light,
  11469. * so the passed direction is the light reflection direction, not the incoming direction.
  11470. */
  11471. export class HemisphericLight extends Light {
  11472. /**
  11473. * The groundColor is the light in the opposite direction to the one specified during creation.
  11474. * 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.
  11475. */
  11476. groundColor: Color3;
  11477. /**
  11478. * The light reflection direction, not the incoming direction.
  11479. */
  11480. direction: Vector3;
  11481. /**
  11482. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11483. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11484. * The HemisphericLight can't cast shadows.
  11485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11486. * @param name The friendly name of the light
  11487. * @param direction The direction of the light reflection
  11488. * @param scene The scene the light belongs to
  11489. */
  11490. constructor(name: string, direction: Vector3, scene: Scene);
  11491. protected _buildUniformLayout(): void;
  11492. /**
  11493. * Returns the string "HemisphericLight".
  11494. * @return The class name
  11495. */
  11496. getClassName(): string;
  11497. /**
  11498. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11499. * Returns the updated direction.
  11500. * @param target The target the direction should point to
  11501. * @return The computed direction
  11502. */
  11503. setDirectionToTarget(target: Vector3): Vector3;
  11504. /**
  11505. * Returns the shadow generator associated to the light.
  11506. * @returns Always null for hemispheric lights because it does not support shadows.
  11507. */
  11508. getShadowGenerator(): Nullable<IShadowGenerator>;
  11509. /**
  11510. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11511. * @param effect The effect to update
  11512. * @param lightIndex The index of the light in the effect to update
  11513. * @returns The hemispheric light
  11514. */
  11515. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11516. /**
  11517. * Computes the world matrix of the node
  11518. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11519. * @param useWasUpdatedFlag defines a reserved property
  11520. * @returns the world matrix
  11521. */
  11522. computeWorldMatrix(): Matrix;
  11523. /**
  11524. * Returns the integer 3.
  11525. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11526. */
  11527. getTypeID(): number;
  11528. /**
  11529. * Prepares the list of defines specific to the light type.
  11530. * @param defines the list of defines
  11531. * @param lightIndex defines the index of the light for the effect
  11532. */
  11533. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11534. }
  11535. }
  11536. declare module BABYLON {
  11537. /**
  11538. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11539. * IMPORTANT!! The data is right-hand data.
  11540. * @export
  11541. * @interface DevicePose
  11542. */
  11543. export interface DevicePose {
  11544. /**
  11545. * The position of the device, values in array are [x,y,z].
  11546. */
  11547. readonly position: Nullable<Float32Array>;
  11548. /**
  11549. * The linearVelocity of the device, values in array are [x,y,z].
  11550. */
  11551. readonly linearVelocity: Nullable<Float32Array>;
  11552. /**
  11553. * The linearAcceleration of the device, values in array are [x,y,z].
  11554. */
  11555. readonly linearAcceleration: Nullable<Float32Array>;
  11556. /**
  11557. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11558. */
  11559. readonly orientation: Nullable<Float32Array>;
  11560. /**
  11561. * The angularVelocity of the device, values in array are [x,y,z].
  11562. */
  11563. readonly angularVelocity: Nullable<Float32Array>;
  11564. /**
  11565. * The angularAcceleration of the device, values in array are [x,y,z].
  11566. */
  11567. readonly angularAcceleration: Nullable<Float32Array>;
  11568. }
  11569. /**
  11570. * Interface representing a pose controlled object in Babylon.
  11571. * A pose controlled object has both regular pose values as well as pose values
  11572. * from an external device such as a VR head mounted display
  11573. */
  11574. export interface PoseControlled {
  11575. /**
  11576. * The position of the object in babylon space.
  11577. */
  11578. position: Vector3;
  11579. /**
  11580. * The rotation quaternion of the object in babylon space.
  11581. */
  11582. rotationQuaternion: Quaternion;
  11583. /**
  11584. * The position of the device in babylon space.
  11585. */
  11586. devicePosition?: Vector3;
  11587. /**
  11588. * The rotation quaternion of the device in babylon space.
  11589. */
  11590. deviceRotationQuaternion: Quaternion;
  11591. /**
  11592. * The raw pose coming from the device.
  11593. */
  11594. rawPose: Nullable<DevicePose>;
  11595. /**
  11596. * The scale of the device to be used when translating from device space to babylon space.
  11597. */
  11598. deviceScaleFactor: number;
  11599. /**
  11600. * Updates the poseControlled values based on the input device pose.
  11601. * @param poseData the pose data to update the object with
  11602. */
  11603. updateFromDevice(poseData: DevicePose): void;
  11604. }
  11605. /**
  11606. * Set of options to customize the webVRCamera
  11607. */
  11608. export interface WebVROptions {
  11609. /**
  11610. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11611. */
  11612. trackPosition?: boolean;
  11613. /**
  11614. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11615. */
  11616. positionScale?: number;
  11617. /**
  11618. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11619. */
  11620. displayName?: string;
  11621. /**
  11622. * Should the native controller meshes be initialized. (default: true)
  11623. */
  11624. controllerMeshes?: boolean;
  11625. /**
  11626. * Creating a default HemiLight only on controllers. (default: true)
  11627. */
  11628. defaultLightingOnControllers?: boolean;
  11629. /**
  11630. * If you don't want to use the default VR button of the helper. (default: false)
  11631. */
  11632. useCustomVRButton?: boolean;
  11633. /**
  11634. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11635. */
  11636. customVRButton?: HTMLButtonElement;
  11637. /**
  11638. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11639. */
  11640. rayLength?: number;
  11641. /**
  11642. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11643. */
  11644. defaultHeight?: number;
  11645. }
  11646. /**
  11647. * This represents a WebVR camera.
  11648. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11649. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11650. */
  11651. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11652. private webVROptions;
  11653. /**
  11654. * @hidden
  11655. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11656. */
  11657. _vrDevice: any;
  11658. /**
  11659. * The rawPose of the vrDevice.
  11660. */
  11661. rawPose: Nullable<DevicePose>;
  11662. private _onVREnabled;
  11663. private _specsVersion;
  11664. private _attached;
  11665. private _frameData;
  11666. protected _descendants: Array<Node>;
  11667. private _deviceRoomPosition;
  11668. /** @hidden */
  11669. _deviceRoomRotationQuaternion: Quaternion;
  11670. private _standingMatrix;
  11671. /**
  11672. * Represents device position in babylon space.
  11673. */
  11674. devicePosition: Vector3;
  11675. /**
  11676. * Represents device rotation in babylon space.
  11677. */
  11678. deviceRotationQuaternion: Quaternion;
  11679. /**
  11680. * The scale of the device to be used when translating from device space to babylon space.
  11681. */
  11682. deviceScaleFactor: number;
  11683. private _deviceToWorld;
  11684. private _worldToDevice;
  11685. /**
  11686. * References to the webVR controllers for the vrDevice.
  11687. */
  11688. controllers: Array<WebVRController>;
  11689. /**
  11690. * Emits an event when a controller is attached.
  11691. */
  11692. onControllersAttachedObservable: Observable<WebVRController[]>;
  11693. /**
  11694. * Emits an event when a controller's mesh has been loaded;
  11695. */
  11696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11697. /**
  11698. * Emits an event when the HMD's pose has been updated.
  11699. */
  11700. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11701. private _poseSet;
  11702. /**
  11703. * If the rig cameras be used as parent instead of this camera.
  11704. */
  11705. rigParenting: boolean;
  11706. private _lightOnControllers;
  11707. private _defaultHeight?;
  11708. /**
  11709. * Instantiates a WebVRFreeCamera.
  11710. * @param name The name of the WebVRFreeCamera
  11711. * @param position The starting anchor position for the camera
  11712. * @param scene The scene the camera belongs to
  11713. * @param webVROptions a set of customizable options for the webVRCamera
  11714. */
  11715. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11716. /**
  11717. * Gets the device distance from the ground in meters.
  11718. * @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.
  11719. */
  11720. deviceDistanceToRoomGround(): number;
  11721. /**
  11722. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11723. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11724. */
  11725. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11726. /**
  11727. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11728. * @returns A promise with a boolean set to if the standing matrix is supported.
  11729. */
  11730. useStandingMatrixAsync(): Promise<boolean>;
  11731. /**
  11732. * Disposes the camera
  11733. */
  11734. dispose(): void;
  11735. /**
  11736. * Gets a vrController by name.
  11737. * @param name The name of the controller to retreive
  11738. * @returns the controller matching the name specified or null if not found
  11739. */
  11740. getControllerByName(name: string): Nullable<WebVRController>;
  11741. private _leftController;
  11742. /**
  11743. * The controller corrisponding to the users left hand.
  11744. */
  11745. readonly leftController: Nullable<WebVRController>;
  11746. private _rightController;
  11747. /**
  11748. * The controller corrisponding to the users right hand.
  11749. */
  11750. readonly rightController: Nullable<WebVRController>;
  11751. /**
  11752. * Casts a ray forward from the vrCamera's gaze.
  11753. * @param length Length of the ray (default: 100)
  11754. * @returns the ray corrisponding to the gaze
  11755. */
  11756. getForwardRay(length?: number): Ray;
  11757. /**
  11758. * @hidden
  11759. * Updates the camera based on device's frame data
  11760. */
  11761. _checkInputs(): void;
  11762. /**
  11763. * Updates the poseControlled values based on the input device pose.
  11764. * @param poseData Pose coming from the device
  11765. */
  11766. updateFromDevice(poseData: DevicePose): void;
  11767. private _htmlElementAttached;
  11768. private _detachIfAttached;
  11769. /**
  11770. * WebVR's attach control will start broadcasting frames to the device.
  11771. * Note that in certain browsers (chrome for example) this function must be called
  11772. * within a user-interaction callback. Example:
  11773. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11774. *
  11775. * @param element html element to attach the vrDevice to
  11776. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11777. */
  11778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11779. /**
  11780. * Detaches the camera from the html element and disables VR
  11781. *
  11782. * @param element html element to detach from
  11783. */
  11784. detachControl(element: HTMLElement): void;
  11785. /**
  11786. * @returns the name of this class
  11787. */
  11788. getClassName(): string;
  11789. /**
  11790. * Calls resetPose on the vrDisplay
  11791. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11792. */
  11793. resetToCurrentRotation(): void;
  11794. /**
  11795. * @hidden
  11796. * Updates the rig cameras (left and right eye)
  11797. */
  11798. _updateRigCameras(): void;
  11799. private _workingVector;
  11800. private _oneVector;
  11801. private _workingMatrix;
  11802. private updateCacheCalled;
  11803. private _correctPositionIfNotTrackPosition;
  11804. /**
  11805. * @hidden
  11806. * Updates the cached values of the camera
  11807. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11808. */
  11809. _updateCache(ignoreParentClass?: boolean): void;
  11810. /**
  11811. * @hidden
  11812. * Get current device position in babylon world
  11813. */
  11814. _computeDevicePosition(): void;
  11815. /**
  11816. * Updates the current device position and rotation in the babylon world
  11817. */
  11818. update(): void;
  11819. /**
  11820. * @hidden
  11821. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  11822. * @returns an identity matrix
  11823. */
  11824. _getViewMatrix(): Matrix;
  11825. private _tmpMatrix;
  11826. /**
  11827. * This function is called by the two RIG cameras.
  11828. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  11829. * @hidden
  11830. */
  11831. _getWebVRViewMatrix(): Matrix;
  11832. /** @hidden */
  11833. _getWebVRProjectionMatrix(): Matrix;
  11834. private _onGamepadConnectedObserver;
  11835. private _onGamepadDisconnectedObserver;
  11836. private _updateCacheWhenTrackingDisabledObserver;
  11837. /**
  11838. * Initializes the controllers and their meshes
  11839. */
  11840. initControllers(): void;
  11841. }
  11842. }
  11843. declare module BABYLON {
  11844. /**
  11845. * Size options for a post process
  11846. */
  11847. export type PostProcessOptions = {
  11848. width: number;
  11849. height: number;
  11850. };
  11851. /**
  11852. * PostProcess can be used to apply a shader to a texture after it has been rendered
  11853. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  11854. */
  11855. export class PostProcess {
  11856. /** Name of the PostProcess. */
  11857. name: string;
  11858. /**
  11859. * Width of the texture to apply the post process on
  11860. */
  11861. width: number;
  11862. /**
  11863. * Height of the texture to apply the post process on
  11864. */
  11865. height: number;
  11866. /**
  11867. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  11868. * @hidden
  11869. */
  11870. _outputTexture: Nullable<InternalTexture>;
  11871. /**
  11872. * Sampling mode used by the shader
  11873. * See https://doc.babylonjs.com/classes/3.1/texture
  11874. */
  11875. renderTargetSamplingMode: number;
  11876. /**
  11877. * Clear color to use when screen clearing
  11878. */
  11879. clearColor: Color4;
  11880. /**
  11881. * If the buffer needs to be cleared before applying the post process. (default: true)
  11882. * Should be set to false if shader will overwrite all previous pixels.
  11883. */
  11884. autoClear: boolean;
  11885. /**
  11886. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  11887. */
  11888. alphaMode: number;
  11889. /**
  11890. * Sets the setAlphaBlendConstants of the babylon engine
  11891. */
  11892. alphaConstants: Color4;
  11893. /**
  11894. * Animations to be used for the post processing
  11895. */
  11896. animations: Animation[];
  11897. /**
  11898. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  11899. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  11900. */
  11901. enablePixelPerfectMode: boolean;
  11902. /**
  11903. * Force the postprocess to be applied without taking in account viewport
  11904. */
  11905. forceFullscreenViewport: boolean;
  11906. /**
  11907. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  11908. *
  11909. * | Value | Type | Description |
  11910. * | ----- | ----------------------------------- | ----------- |
  11911. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  11912. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  11913. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  11914. *
  11915. */
  11916. scaleMode: number;
  11917. /**
  11918. * Force textures to be a power of two (default: false)
  11919. */
  11920. alwaysForcePOT: boolean;
  11921. private _samples;
  11922. /**
  11923. * Number of sample textures (default: 1)
  11924. */
  11925. samples: number;
  11926. /**
  11927. * Modify the scale of the post process to be the same as the viewport (default: false)
  11928. */
  11929. adaptScaleToCurrentViewport: boolean;
  11930. private _camera;
  11931. private _scene;
  11932. private _engine;
  11933. private _options;
  11934. private _reusable;
  11935. private _textureType;
  11936. /**
  11937. * Smart array of input and output textures for the post process.
  11938. * @hidden
  11939. */
  11940. _textures: SmartArray<InternalTexture>;
  11941. /**
  11942. * The index in _textures that corresponds to the output texture.
  11943. * @hidden
  11944. */
  11945. _currentRenderTextureInd: number;
  11946. private _effect;
  11947. private _samplers;
  11948. private _fragmentUrl;
  11949. private _vertexUrl;
  11950. private _parameters;
  11951. private _scaleRatio;
  11952. protected _indexParameters: any;
  11953. private _shareOutputWithPostProcess;
  11954. private _texelSize;
  11955. private _forcedOutputTexture;
  11956. /**
  11957. * Returns the fragment url or shader name used in the post process.
  11958. * @returns the fragment url or name in the shader store.
  11959. */
  11960. getEffectName(): string;
  11961. /**
  11962. * An event triggered when the postprocess is activated.
  11963. */
  11964. onActivateObservable: Observable<Camera>;
  11965. private _onActivateObserver;
  11966. /**
  11967. * A function that is added to the onActivateObservable
  11968. */
  11969. onActivate: Nullable<(camera: Camera) => void>;
  11970. /**
  11971. * An event triggered when the postprocess changes its size.
  11972. */
  11973. onSizeChangedObservable: Observable<PostProcess>;
  11974. private _onSizeChangedObserver;
  11975. /**
  11976. * A function that is added to the onSizeChangedObservable
  11977. */
  11978. onSizeChanged: (postProcess: PostProcess) => void;
  11979. /**
  11980. * An event triggered when the postprocess applies its effect.
  11981. */
  11982. onApplyObservable: Observable<Effect>;
  11983. private _onApplyObserver;
  11984. /**
  11985. * A function that is added to the onApplyObservable
  11986. */
  11987. onApply: (effect: Effect) => void;
  11988. /**
  11989. * An event triggered before rendering the postprocess
  11990. */
  11991. onBeforeRenderObservable: Observable<Effect>;
  11992. private _onBeforeRenderObserver;
  11993. /**
  11994. * A function that is added to the onBeforeRenderObservable
  11995. */
  11996. onBeforeRender: (effect: Effect) => void;
  11997. /**
  11998. * An event triggered after rendering the postprocess
  11999. */
  12000. onAfterRenderObservable: Observable<Effect>;
  12001. private _onAfterRenderObserver;
  12002. /**
  12003. * A function that is added to the onAfterRenderObservable
  12004. */
  12005. onAfterRender: (efect: Effect) => void;
  12006. /**
  12007. * 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
  12008. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12009. */
  12010. inputTexture: InternalTexture;
  12011. /**
  12012. * Gets the camera which post process is applied to.
  12013. * @returns The camera the post process is applied to.
  12014. */
  12015. getCamera(): Camera;
  12016. /**
  12017. * Gets the texel size of the postprocess.
  12018. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12019. */
  12020. readonly texelSize: Vector2;
  12021. /**
  12022. * Creates a new instance PostProcess
  12023. * @param name The name of the PostProcess.
  12024. * @param fragmentUrl The url of the fragment shader to be used.
  12025. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12026. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12027. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12028. * @param camera The camera to apply the render pass to.
  12029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12030. * @param engine The engine which the post process will be applied. (default: current engine)
  12031. * @param reusable If the post process can be reused on the same frame. (default: false)
  12032. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12033. * @param textureType Type of textures used when performing the post process. (default: 0)
  12034. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12035. * @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
  12036. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12037. */
  12038. constructor(
  12039. /** Name of the PostProcess. */
  12040. 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);
  12041. /**
  12042. * Gets the engine which this post process belongs to.
  12043. * @returns The engine the post process was enabled with.
  12044. */
  12045. getEngine(): Engine;
  12046. /**
  12047. * The effect that is created when initializing the post process.
  12048. * @returns The created effect corrisponding the the postprocess.
  12049. */
  12050. getEffect(): Effect;
  12051. /**
  12052. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12053. * @param postProcess The post process to share the output with.
  12054. * @returns This post process.
  12055. */
  12056. shareOutputWith(postProcess: PostProcess): PostProcess;
  12057. /**
  12058. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12059. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12060. */
  12061. useOwnOutput(): void;
  12062. /**
  12063. * Updates the effect with the current post process compile time values and recompiles the shader.
  12064. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12065. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12066. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12067. * @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
  12068. * @param onCompiled Called when the shader has been compiled.
  12069. * @param onError Called if there is an error when compiling a shader.
  12070. */
  12071. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12072. /**
  12073. * The post process is reusable if it can be used multiple times within one frame.
  12074. * @returns If the post process is reusable
  12075. */
  12076. isReusable(): boolean;
  12077. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12078. markTextureDirty(): void;
  12079. /**
  12080. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12081. * 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.
  12082. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12083. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12084. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12085. * @returns The target texture that was bound to be written to.
  12086. */
  12087. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12088. /**
  12089. * If the post process is supported.
  12090. */
  12091. readonly isSupported: boolean;
  12092. /**
  12093. * The aspect ratio of the output texture.
  12094. */
  12095. readonly aspectRatio: number;
  12096. /**
  12097. * Get a value indicating if the post-process is ready to be used
  12098. * @returns true if the post-process is ready (shader is compiled)
  12099. */
  12100. isReady(): boolean;
  12101. /**
  12102. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12103. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12104. */
  12105. apply(): Nullable<Effect>;
  12106. private _disposeTextures;
  12107. /**
  12108. * Disposes the post process.
  12109. * @param camera The camera to dispose the post process on.
  12110. */
  12111. dispose(camera?: Camera): void;
  12112. }
  12113. }
  12114. declare module BABYLON {
  12115. /** @hidden */
  12116. export var kernelBlurVaryingDeclaration: {
  12117. name: string;
  12118. shader: string;
  12119. };
  12120. }
  12121. declare module BABYLON {
  12122. /** @hidden */
  12123. export var kernelBlurFragment: {
  12124. name: string;
  12125. shader: string;
  12126. };
  12127. }
  12128. declare module BABYLON {
  12129. /** @hidden */
  12130. export var kernelBlurFragment2: {
  12131. name: string;
  12132. shader: string;
  12133. };
  12134. }
  12135. declare module BABYLON {
  12136. /** @hidden */
  12137. export var kernelBlurPixelShader: {
  12138. name: string;
  12139. shader: string;
  12140. };
  12141. }
  12142. declare module BABYLON {
  12143. /** @hidden */
  12144. export var kernelBlurVertex: {
  12145. name: string;
  12146. shader: string;
  12147. };
  12148. }
  12149. declare module BABYLON {
  12150. /** @hidden */
  12151. export var kernelBlurVertexShader: {
  12152. name: string;
  12153. shader: string;
  12154. };
  12155. }
  12156. declare module BABYLON {
  12157. /**
  12158. * The Blur Post Process which blurs an image based on a kernel and direction.
  12159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12160. */
  12161. export class BlurPostProcess extends PostProcess {
  12162. /** The direction in which to blur the image. */
  12163. direction: Vector2;
  12164. private blockCompilation;
  12165. protected _kernel: number;
  12166. protected _idealKernel: number;
  12167. protected _packedFloat: boolean;
  12168. private _staticDefines;
  12169. /**
  12170. * Sets the length in pixels of the blur sample region
  12171. */
  12172. /**
  12173. * Gets the length in pixels of the blur sample region
  12174. */
  12175. kernel: number;
  12176. /**
  12177. * Sets wether or not the blur needs to unpack/repack floats
  12178. */
  12179. /**
  12180. * Gets wether or not the blur is unpacking/repacking floats
  12181. */
  12182. packedFloat: boolean;
  12183. /**
  12184. * Creates a new instance BlurPostProcess
  12185. * @param name The name of the effect.
  12186. * @param direction The direction in which to blur the image.
  12187. * @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.
  12188. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12189. * @param camera The camera to apply the render pass to.
  12190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12191. * @param engine The engine which the post process will be applied. (default: current engine)
  12192. * @param reusable If the post process can be reused on the same frame. (default: false)
  12193. * @param textureType Type of textures used when performing the post process. (default: 0)
  12194. * @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)
  12195. */
  12196. constructor(name: string,
  12197. /** The direction in which to blur the image. */
  12198. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12199. /**
  12200. * Updates the effect with the current post process compile time values and recompiles the shader.
  12201. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12202. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12203. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12204. * @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
  12205. * @param onCompiled Called when the shader has been compiled.
  12206. * @param onError Called if there is an error when compiling a shader.
  12207. */
  12208. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12209. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12210. /**
  12211. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12212. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12213. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12214. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12215. * The gaps between physical kernels are compensated for in the weighting of the samples
  12216. * @param idealKernel Ideal blur kernel.
  12217. * @return Nearest best kernel.
  12218. */
  12219. protected _nearestBestKernel(idealKernel: number): number;
  12220. /**
  12221. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12222. * @param x The point on the Gaussian distribution to sample.
  12223. * @return the value of the Gaussian function at x.
  12224. */
  12225. protected _gaussianWeight(x: number): number;
  12226. /**
  12227. * Generates a string that can be used as a floating point number in GLSL.
  12228. * @param x Value to print.
  12229. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12230. * @return GLSL float string.
  12231. */
  12232. protected _glslFloat(x: number, decimalFigures?: number): string;
  12233. }
  12234. }
  12235. declare module BABYLON {
  12236. /**
  12237. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12238. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12239. * You can then easily use it as a reflectionTexture on a flat surface.
  12240. * In case the surface is not a plane, please consider relying on reflection probes.
  12241. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12242. */
  12243. export class MirrorTexture extends RenderTargetTexture {
  12244. private scene;
  12245. /**
  12246. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12247. * It is possible to directly set the mirrorPlane by directly using a 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.
  12248. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12249. */
  12250. mirrorPlane: Plane;
  12251. /**
  12252. * Define the blur ratio used to blur the reflection if needed.
  12253. */
  12254. blurRatio: number;
  12255. /**
  12256. * Define the adaptive blur kernel used to blur the reflection if needed.
  12257. * This will autocompute the closest best match for the `blurKernel`
  12258. */
  12259. adaptiveBlurKernel: number;
  12260. /**
  12261. * Define the blur kernel used to blur the reflection if needed.
  12262. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12263. */
  12264. blurKernel: number;
  12265. /**
  12266. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12267. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12268. */
  12269. blurKernelX: number;
  12270. /**
  12271. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12272. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12273. */
  12274. blurKernelY: number;
  12275. private _autoComputeBlurKernel;
  12276. protected _onRatioRescale(): void;
  12277. private _updateGammaSpace;
  12278. private _imageProcessingConfigChangeObserver;
  12279. private _transformMatrix;
  12280. private _mirrorMatrix;
  12281. private _savedViewMatrix;
  12282. private _blurX;
  12283. private _blurY;
  12284. private _adaptiveBlurKernel;
  12285. private _blurKernelX;
  12286. private _blurKernelY;
  12287. private _blurRatio;
  12288. /**
  12289. * Instantiates a Mirror Texture.
  12290. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12291. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12292. * You can then easily use it as a reflectionTexture on a flat surface.
  12293. * In case the surface is not a plane, please consider relying on reflection probes.
  12294. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12295. * @param name
  12296. * @param size
  12297. * @param scene
  12298. * @param generateMipMaps
  12299. * @param type
  12300. * @param samplingMode
  12301. * @param generateDepthBuffer
  12302. */
  12303. constructor(name: string, size: number | {
  12304. width: number;
  12305. height: number;
  12306. } | {
  12307. ratio: number;
  12308. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12309. private _preparePostProcesses;
  12310. /**
  12311. * Clone the mirror texture.
  12312. * @returns the cloned texture
  12313. */
  12314. clone(): MirrorTexture;
  12315. /**
  12316. * Serialize the texture to a JSON representation you could use in Parse later on
  12317. * @returns the serialized JSON representation
  12318. */
  12319. serialize(): any;
  12320. /**
  12321. * Dispose the texture and release its associated resources.
  12322. */
  12323. dispose(): void;
  12324. }
  12325. }
  12326. declare module BABYLON {
  12327. /**
  12328. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12329. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12330. */
  12331. export class Texture extends BaseTexture {
  12332. /** @hidden */
  12333. static _AnimationParser: (jsonAnimation: any) => Animation;
  12334. /** @hidden */
  12335. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  12336. /** @hidden */
  12337. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  12338. /** @hidden */
  12339. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  12340. /** nearest is mag = nearest and min = nearest and mip = linear */
  12341. static readonly NEAREST_SAMPLINGMODE: number;
  12342. /** nearest is mag = nearest and min = nearest and mip = linear */
  12343. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12344. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12345. static readonly BILINEAR_SAMPLINGMODE: number;
  12346. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12347. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12348. /** Trilinear is mag = linear and min = linear and mip = linear */
  12349. static readonly TRILINEAR_SAMPLINGMODE: number;
  12350. /** Trilinear is mag = linear and min = linear and mip = linear */
  12351. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12352. /** mag = nearest and min = nearest and mip = nearest */
  12353. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12354. /** mag = nearest and min = linear and mip = nearest */
  12355. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12356. /** mag = nearest and min = linear and mip = linear */
  12357. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12358. /** mag = nearest and min = linear and mip = none */
  12359. static readonly NEAREST_LINEAR: number;
  12360. /** mag = nearest and min = nearest and mip = none */
  12361. static readonly NEAREST_NEAREST: number;
  12362. /** mag = linear and min = nearest and mip = nearest */
  12363. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12364. /** mag = linear and min = nearest and mip = linear */
  12365. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12366. /** mag = linear and min = linear and mip = none */
  12367. static readonly LINEAR_LINEAR: number;
  12368. /** mag = linear and min = nearest and mip = none */
  12369. static readonly LINEAR_NEAREST: number;
  12370. /** Explicit coordinates mode */
  12371. static readonly EXPLICIT_MODE: number;
  12372. /** Spherical coordinates mode */
  12373. static readonly SPHERICAL_MODE: number;
  12374. /** Planar coordinates mode */
  12375. static readonly PLANAR_MODE: number;
  12376. /** Cubic coordinates mode */
  12377. static readonly CUBIC_MODE: number;
  12378. /** Projection coordinates mode */
  12379. static readonly PROJECTION_MODE: number;
  12380. /** Inverse Cubic coordinates mode */
  12381. static readonly SKYBOX_MODE: number;
  12382. /** Inverse Cubic coordinates mode */
  12383. static readonly INVCUBIC_MODE: number;
  12384. /** Equirectangular coordinates mode */
  12385. static readonly EQUIRECTANGULAR_MODE: number;
  12386. /** Equirectangular Fixed coordinates mode */
  12387. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12388. /** Equirectangular Fixed Mirrored coordinates mode */
  12389. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12390. /** Texture is not repeating outside of 0..1 UVs */
  12391. static readonly CLAMP_ADDRESSMODE: number;
  12392. /** Texture is repeating outside of 0..1 UVs */
  12393. static readonly WRAP_ADDRESSMODE: number;
  12394. /** Texture is repeating and mirrored */
  12395. static readonly MIRROR_ADDRESSMODE: number;
  12396. /**
  12397. * 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
  12398. */
  12399. static UseSerializedUrlIfAny: boolean;
  12400. /**
  12401. * Define the url of the texture.
  12402. */
  12403. url: Nullable<string>;
  12404. /**
  12405. * Define an offset on the texture to offset the u coordinates of the UVs
  12406. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12407. */
  12408. uOffset: number;
  12409. /**
  12410. * Define an offset on the texture to offset the v coordinates of the UVs
  12411. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12412. */
  12413. vOffset: number;
  12414. /**
  12415. * Define an offset on the texture to scale the u coordinates of the UVs
  12416. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12417. */
  12418. uScale: number;
  12419. /**
  12420. * Define an offset on the texture to scale the v coordinates of the UVs
  12421. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12422. */
  12423. vScale: number;
  12424. /**
  12425. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12426. * @see http://doc.babylonjs.com/how_to/more_materials
  12427. */
  12428. uAng: number;
  12429. /**
  12430. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12431. * @see http://doc.babylonjs.com/how_to/more_materials
  12432. */
  12433. vAng: number;
  12434. /**
  12435. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12436. * @see http://doc.babylonjs.com/how_to/more_materials
  12437. */
  12438. wAng: number;
  12439. /**
  12440. * Defines the center of rotation (U)
  12441. */
  12442. uRotationCenter: number;
  12443. /**
  12444. * Defines the center of rotation (V)
  12445. */
  12446. vRotationCenter: number;
  12447. /**
  12448. * Defines the center of rotation (W)
  12449. */
  12450. wRotationCenter: number;
  12451. /**
  12452. * Are mip maps generated for this texture or not.
  12453. */
  12454. readonly noMipmap: boolean;
  12455. private _noMipmap;
  12456. /** @hidden */
  12457. _invertY: boolean;
  12458. private _rowGenerationMatrix;
  12459. private _cachedTextureMatrix;
  12460. private _projectionModeMatrix;
  12461. private _t0;
  12462. private _t1;
  12463. private _t2;
  12464. private _cachedUOffset;
  12465. private _cachedVOffset;
  12466. private _cachedUScale;
  12467. private _cachedVScale;
  12468. private _cachedUAng;
  12469. private _cachedVAng;
  12470. private _cachedWAng;
  12471. private _cachedProjectionMatrixId;
  12472. private _cachedCoordinatesMode;
  12473. /** @hidden */
  12474. protected _initialSamplingMode: number;
  12475. /** @hidden */
  12476. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12477. private _deleteBuffer;
  12478. protected _format: Nullable<number>;
  12479. private _delayedOnLoad;
  12480. private _delayedOnError;
  12481. /**
  12482. * Observable triggered once the texture has been loaded.
  12483. */
  12484. onLoadObservable: Observable<Texture>;
  12485. protected _isBlocking: boolean;
  12486. /**
  12487. * Is the texture preventing material to render while loading.
  12488. * If false, a default texture will be used instead of the loading one during the preparation step.
  12489. */
  12490. isBlocking: boolean;
  12491. /**
  12492. * Get the current sampling mode associated with the texture.
  12493. */
  12494. readonly samplingMode: number;
  12495. /**
  12496. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12497. */
  12498. readonly invertY: boolean;
  12499. /**
  12500. * Instantiates a new texture.
  12501. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12502. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12503. * @param url define the url of the picture to load as a texture
  12504. * @param scene define the scene the texture will belong to
  12505. * @param noMipmap define if the texture will require mip maps or not
  12506. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12507. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12508. * @param onLoad define a callback triggered when the texture has been loaded
  12509. * @param onError define a callback triggered when an error occurred during the loading session
  12510. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12511. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12512. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12513. */
  12514. 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);
  12515. /**
  12516. * Update the url (and optional buffer) of this texture if url was null during construction.
  12517. * @param url the url of the texture
  12518. * @param buffer the buffer of the texture (defaults to null)
  12519. * @param onLoad callback called when the texture is loaded (defaults to null)
  12520. */
  12521. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12522. /**
  12523. * Finish the loading sequence of a texture flagged as delayed load.
  12524. * @hidden
  12525. */
  12526. delayLoad(): void;
  12527. private _prepareRowForTextureGeneration;
  12528. /**
  12529. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12530. * @returns the transform matrix of the texture.
  12531. */
  12532. getTextureMatrix(): Matrix;
  12533. /**
  12534. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12535. * @returns The reflection texture transform
  12536. */
  12537. getReflectionTextureMatrix(): Matrix;
  12538. /**
  12539. * Clones the texture.
  12540. * @returns the cloned texture
  12541. */
  12542. clone(): Texture;
  12543. /**
  12544. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12545. * @returns The JSON representation of the texture
  12546. */
  12547. serialize(): any;
  12548. /**
  12549. * Get the current class name of the texture useful for serialization or dynamic coding.
  12550. * @returns "Texture"
  12551. */
  12552. getClassName(): string;
  12553. /**
  12554. * Dispose the texture and release its associated resources.
  12555. */
  12556. dispose(): void;
  12557. /**
  12558. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12559. * @param parsedTexture Define the JSON representation of the texture
  12560. * @param scene Define the scene the parsed texture should be instantiated in
  12561. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12562. * @returns The parsed texture if successful
  12563. */
  12564. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12565. /**
  12566. * Creates a texture from its base 64 representation.
  12567. * @param data Define the base64 payload without the data: prefix
  12568. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12569. * @param scene Define the scene the texture should belong to
  12570. * @param noMipmap Forces the texture to not create mip map information if true
  12571. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12572. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12573. * @param onLoad define a callback triggered when the texture has been loaded
  12574. * @param onError define a callback triggered when an error occurred during the loading session
  12575. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12576. * @returns the created texture
  12577. */
  12578. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12579. /**
  12580. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12581. * @param data Define the base64 payload without the data: prefix
  12582. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12583. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12584. * @param scene Define the scene the texture should belong to
  12585. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12586. * @param noMipmap Forces the texture to not create mip map information if true
  12587. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12588. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12589. * @param onLoad define a callback triggered when the texture has been loaded
  12590. * @param onError define a callback triggered when an error occurred during the loading session
  12591. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12592. * @returns the created texture
  12593. */
  12594. 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;
  12595. }
  12596. }
  12597. declare module BABYLON {
  12598. /**
  12599. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12600. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12601. */
  12602. export class PostProcessManager {
  12603. private _scene;
  12604. private _indexBuffer;
  12605. private _vertexBuffers;
  12606. /**
  12607. * Creates a new instance PostProcess
  12608. * @param scene The scene that the post process is associated with.
  12609. */
  12610. constructor(scene: Scene);
  12611. private _prepareBuffers;
  12612. private _buildIndexBuffer;
  12613. /**
  12614. * Rebuilds the vertex buffers of the manager.
  12615. * @hidden
  12616. */
  12617. _rebuild(): void;
  12618. /**
  12619. * Prepares a frame to be run through a post process.
  12620. * @param sourceTexture The input texture to the post procesess. (default: null)
  12621. * @param postProcesses An array of post processes to be run. (default: null)
  12622. * @returns True if the post processes were able to be run.
  12623. * @hidden
  12624. */
  12625. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12626. /**
  12627. * Manually render a set of post processes to a texture.
  12628. * @param postProcesses An array of post processes to be run.
  12629. * @param targetTexture The target texture to render to.
  12630. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12631. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12632. * @param lodLevel defines which lod of the texture to render to
  12633. */
  12634. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12635. /**
  12636. * Finalize the result of the output of the postprocesses.
  12637. * @param doNotPresent If true the result will not be displayed to the screen.
  12638. * @param targetTexture The target texture to render to.
  12639. * @param faceIndex The index of the face to bind the target texture to.
  12640. * @param postProcesses The array of post processes to render.
  12641. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12642. * @hidden
  12643. */
  12644. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12645. /**
  12646. * Disposes of the post process manager.
  12647. */
  12648. dispose(): void;
  12649. }
  12650. }
  12651. declare module BABYLON {
  12652. /**
  12653. * Groups all the scene component constants in one place to ease maintenance.
  12654. * @hidden
  12655. */
  12656. export class SceneComponentConstants {
  12657. static readonly NAME_EFFECTLAYER: string;
  12658. static readonly NAME_LAYER: string;
  12659. static readonly NAME_LENSFLARESYSTEM: string;
  12660. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12661. static readonly NAME_PARTICLESYSTEM: string;
  12662. static readonly NAME_GAMEPAD: string;
  12663. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12664. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12665. static readonly NAME_DEPTHRENDERER: string;
  12666. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12667. static readonly NAME_SPRITE: string;
  12668. static readonly NAME_OUTLINERENDERER: string;
  12669. static readonly NAME_PROCEDURALTEXTURE: string;
  12670. static readonly NAME_SHADOWGENERATOR: string;
  12671. static readonly NAME_OCTREE: string;
  12672. static readonly NAME_PHYSICSENGINE: string;
  12673. static readonly NAME_AUDIO: string;
  12674. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12675. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12676. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12677. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12678. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12679. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12680. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12681. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12682. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12683. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12684. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12685. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12686. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12687. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12688. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12689. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12690. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12691. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12692. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12693. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12694. static readonly STEP_AFTERRENDER_AUDIO: number;
  12695. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12696. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12697. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12698. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12699. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12700. static readonly STEP_POINTERMOVE_SPRITE: number;
  12701. static readonly STEP_POINTERDOWN_SPRITE: number;
  12702. static readonly STEP_POINTERUP_SPRITE: number;
  12703. }
  12704. /**
  12705. * This represents a scene component.
  12706. *
  12707. * This is used to decouple the dependency the scene is having on the different workloads like
  12708. * layers, post processes...
  12709. */
  12710. export interface ISceneComponent {
  12711. /**
  12712. * The name of the component. Each component must have a unique name.
  12713. */
  12714. name: string;
  12715. /**
  12716. * The scene the component belongs to.
  12717. */
  12718. scene: Scene;
  12719. /**
  12720. * Register the component to one instance of a scene.
  12721. */
  12722. register(): void;
  12723. /**
  12724. * Rebuilds the elements related to this component in case of
  12725. * context lost for instance.
  12726. */
  12727. rebuild(): void;
  12728. /**
  12729. * Disposes the component and the associated ressources.
  12730. */
  12731. dispose(): void;
  12732. }
  12733. /**
  12734. * This represents a SERIALIZABLE scene component.
  12735. *
  12736. * This extends Scene Component to add Serialization methods on top.
  12737. */
  12738. export interface ISceneSerializableComponent extends ISceneComponent {
  12739. /**
  12740. * Adds all the element from the container to the scene
  12741. * @param container the container holding the elements
  12742. */
  12743. addFromContainer(container: AbstractScene): void;
  12744. /**
  12745. * Removes all the elements in the container from the scene
  12746. * @param container contains the elements to remove
  12747. */
  12748. removeFromContainer(container: AbstractScene): void;
  12749. /**
  12750. * Serializes the component data to the specified json object
  12751. * @param serializationObject The object to serialize to
  12752. */
  12753. serialize(serializationObject: any): void;
  12754. }
  12755. /**
  12756. * Strong typing of a Mesh related stage step action
  12757. */
  12758. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12759. /**
  12760. * Strong typing of a Evaluate Sub Mesh related stage step action
  12761. */
  12762. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12763. /**
  12764. * Strong typing of a Active Mesh related stage step action
  12765. */
  12766. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12767. /**
  12768. * Strong typing of a Camera related stage step action
  12769. */
  12770. export type CameraStageAction = (camera: Camera) => void;
  12771. /**
  12772. * Strong typing of a Render Target related stage step action
  12773. */
  12774. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12775. /**
  12776. * Strong typing of a RenderingGroup related stage step action
  12777. */
  12778. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12779. /**
  12780. * Strong typing of a Mesh Render related stage step action
  12781. */
  12782. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12783. /**
  12784. * Strong typing of a simple stage step action
  12785. */
  12786. export type SimpleStageAction = () => void;
  12787. /**
  12788. * Strong typing of a render target action.
  12789. */
  12790. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12791. /**
  12792. * Strong typing of a pointer move action.
  12793. */
  12794. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12795. /**
  12796. * Strong typing of a pointer up/down action.
  12797. */
  12798. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12799. /**
  12800. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12801. * @hidden
  12802. */
  12803. export class Stage<T extends Function> extends Array<{
  12804. index: number;
  12805. component: ISceneComponent;
  12806. action: T;
  12807. }> {
  12808. /**
  12809. * Hide ctor from the rest of the world.
  12810. * @param items The items to add.
  12811. */
  12812. private constructor();
  12813. /**
  12814. * Creates a new Stage.
  12815. * @returns A new instance of a Stage
  12816. */
  12817. static Create<T extends Function>(): Stage<T>;
  12818. /**
  12819. * Registers a step in an ordered way in the targeted stage.
  12820. * @param index Defines the position to register the step in
  12821. * @param component Defines the component attached to the step
  12822. * @param action Defines the action to launch during the step
  12823. */
  12824. registerStep(index: number, component: ISceneComponent, action: T): void;
  12825. /**
  12826. * Clears all the steps from the stage.
  12827. */
  12828. clear(): void;
  12829. }
  12830. }
  12831. declare module BABYLON {
  12832. interface Scene {
  12833. /** @hidden */
  12834. _pointerOverSprite: Nullable<Sprite>;
  12835. /** @hidden */
  12836. _pickedDownSprite: Nullable<Sprite>;
  12837. /** @hidden */
  12838. _tempSpritePickingRay: Nullable<Ray>;
  12839. /**
  12840. * All of the sprite managers added to this scene
  12841. * @see http://doc.babylonjs.com/babylon101/sprites
  12842. */
  12843. spriteManagers: Array<ISpriteManager>;
  12844. /**
  12845. * An event triggered when sprites rendering is about to start
  12846. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12847. */
  12848. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12849. /**
  12850. * An event triggered when sprites rendering is done
  12851. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12852. */
  12853. onAfterSpritesRenderingObservable: Observable<Scene>;
  12854. /** @hidden */
  12855. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12856. /** Launch a ray to try to pick a sprite in the scene
  12857. * @param x position on screen
  12858. * @param y position on screen
  12859. * @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
  12860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12861. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12862. * @returns a PickingInfo
  12863. */
  12864. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12865. /** Use the given ray to pick a sprite in the scene
  12866. * @param ray The ray (in world space) to use to pick meshes
  12867. * @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
  12868. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12869. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12870. * @returns a PickingInfo
  12871. */
  12872. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12873. /**
  12874. * Force the sprite under the pointer
  12875. * @param sprite defines the sprite to use
  12876. */
  12877. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12878. /**
  12879. * Gets the sprite under the pointer
  12880. * @returns a Sprite or null if no sprite is under the pointer
  12881. */
  12882. getPointerOverSprite(): Nullable<Sprite>;
  12883. }
  12884. /**
  12885. * Defines the sprite scene component responsible to manage sprites
  12886. * in a given scene.
  12887. */
  12888. export class SpriteSceneComponent implements ISceneComponent {
  12889. /**
  12890. * The component name helpfull to identify the component in the list of scene components.
  12891. */
  12892. readonly name: string;
  12893. /**
  12894. * The scene the component belongs to.
  12895. */
  12896. scene: Scene;
  12897. /** @hidden */
  12898. private _spritePredicate;
  12899. /**
  12900. * Creates a new instance of the component for the given scene
  12901. * @param scene Defines the scene to register the component in
  12902. */
  12903. constructor(scene: Scene);
  12904. /**
  12905. * Registers the component in a given scene
  12906. */
  12907. register(): void;
  12908. /**
  12909. * Rebuilds the elements related to this component in case of
  12910. * context lost for instance.
  12911. */
  12912. rebuild(): void;
  12913. /**
  12914. * Disposes the component and the associated ressources.
  12915. */
  12916. dispose(): void;
  12917. private _pickSpriteButKeepRay;
  12918. private _pointerMove;
  12919. private _pointerDown;
  12920. private _pointerUp;
  12921. }
  12922. }
  12923. declare module BABYLON {
  12924. /** @hidden */
  12925. export var fogFragmentDeclaration: {
  12926. name: string;
  12927. shader: string;
  12928. };
  12929. }
  12930. declare module BABYLON {
  12931. /** @hidden */
  12932. export var fogFragment: {
  12933. name: string;
  12934. shader: string;
  12935. };
  12936. }
  12937. declare module BABYLON {
  12938. /** @hidden */
  12939. export var spritesPixelShader: {
  12940. name: string;
  12941. shader: string;
  12942. };
  12943. }
  12944. declare module BABYLON {
  12945. /** @hidden */
  12946. export var fogVertexDeclaration: {
  12947. name: string;
  12948. shader: string;
  12949. };
  12950. }
  12951. declare module BABYLON {
  12952. /** @hidden */
  12953. export var spritesVertexShader: {
  12954. name: string;
  12955. shader: string;
  12956. };
  12957. }
  12958. declare module BABYLON {
  12959. /**
  12960. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12961. */
  12962. export interface ISpriteManager extends IDisposable {
  12963. /**
  12964. * Restricts the camera to viewing objects with the same layerMask.
  12965. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12966. */
  12967. layerMask: number;
  12968. /**
  12969. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12970. */
  12971. isPickable: boolean;
  12972. /**
  12973. * Specifies the rendering group id for this mesh (0 by default)
  12974. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12975. */
  12976. renderingGroupId: number;
  12977. /**
  12978. * Defines the list of sprites managed by the manager.
  12979. */
  12980. sprites: Array<Sprite>;
  12981. /**
  12982. * Tests the intersection of a sprite with a specific ray.
  12983. * @param ray The ray we are sending to test the collision
  12984. * @param camera The camera space we are sending rays in
  12985. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12986. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12987. * @returns picking info or null.
  12988. */
  12989. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12990. /**
  12991. * Renders the list of sprites on screen.
  12992. */
  12993. render(): void;
  12994. }
  12995. /**
  12996. * Class used to manage multiple sprites on the same spritesheet
  12997. * @see http://doc.babylonjs.com/babylon101/sprites
  12998. */
  12999. export class SpriteManager implements ISpriteManager {
  13000. /** defines the manager's name */
  13001. name: string;
  13002. /** Gets the list of sprites */
  13003. sprites: Sprite[];
  13004. /** Gets or sets the rendering group id (0 by default) */
  13005. renderingGroupId: number;
  13006. /** Gets or sets camera layer mask */
  13007. layerMask: number;
  13008. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  13009. fogEnabled: boolean;
  13010. /** Gets or sets a boolean indicating if the sprites are pickable */
  13011. isPickable: boolean;
  13012. /** Defines the default width of a cell in the spritesheet */
  13013. cellWidth: number;
  13014. /** Defines the default height of a cell in the spritesheet */
  13015. cellHeight: number;
  13016. /**
  13017. * An event triggered when the manager is disposed.
  13018. */
  13019. onDisposeObservable: Observable<SpriteManager>;
  13020. private _onDisposeObserver;
  13021. /**
  13022. * Callback called when the manager is disposed
  13023. */
  13024. onDispose: () => void;
  13025. private _capacity;
  13026. private _spriteTexture;
  13027. private _epsilon;
  13028. private _scene;
  13029. private _vertexData;
  13030. private _buffer;
  13031. private _vertexBuffers;
  13032. private _indexBuffer;
  13033. private _effectBase;
  13034. private _effectFog;
  13035. /**
  13036. * Gets or sets the spritesheet texture
  13037. */
  13038. texture: Texture;
  13039. /**
  13040. * Creates a new sprite manager
  13041. * @param name defines the manager's name
  13042. * @param imgUrl defines the sprite sheet url
  13043. * @param capacity defines the maximum allowed number of sprites
  13044. * @param cellSize defines the size of a sprite cell
  13045. * @param scene defines the hosting scene
  13046. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  13047. * @param samplingMode defines the smapling mode to use with spritesheet
  13048. */
  13049. constructor(
  13050. /** defines the manager's name */
  13051. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  13052. private _appendSpriteVertex;
  13053. /**
  13054. * Intersects the sprites with a ray
  13055. * @param ray defines the ray to intersect with
  13056. * @param camera defines the current active camera
  13057. * @param predicate defines a predicate used to select candidate sprites
  13058. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  13059. * @returns null if no hit or a PickingInfo
  13060. */
  13061. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13062. /**
  13063. * Render all child sprites
  13064. */
  13065. render(): void;
  13066. /**
  13067. * Release associated resources
  13068. */
  13069. dispose(): void;
  13070. }
  13071. }
  13072. declare module BABYLON {
  13073. interface AbstractScene {
  13074. /**
  13075. * The list of layers (background and foreground) of the scene
  13076. */
  13077. layers: Array<Layer>;
  13078. }
  13079. /**
  13080. * Defines the layer scene component responsible to manage any layers
  13081. * in a given scene.
  13082. */
  13083. export class LayerSceneComponent implements ISceneComponent {
  13084. /**
  13085. * The component name helpfull to identify the component in the list of scene components.
  13086. */
  13087. readonly name: string;
  13088. /**
  13089. * The scene the component belongs to.
  13090. */
  13091. scene: Scene;
  13092. private _engine;
  13093. /**
  13094. * Creates a new instance of the component for the given scene
  13095. * @param scene Defines the scene to register the component in
  13096. */
  13097. constructor(scene: Scene);
  13098. /**
  13099. * Registers the component in a given scene
  13100. */
  13101. register(): void;
  13102. /**
  13103. * Rebuilds the elements related to this component in case of
  13104. * context lost for instance.
  13105. */
  13106. rebuild(): void;
  13107. /**
  13108. * Disposes the component and the associated ressources.
  13109. */
  13110. dispose(): void;
  13111. private _draw;
  13112. private _drawCameraPredicate;
  13113. private _drawCameraBackground;
  13114. private _drawCameraForeground;
  13115. private _drawRenderTargetPredicate;
  13116. private _drawRenderTargetBackground;
  13117. private _drawRenderTargetForeground;
  13118. }
  13119. }
  13120. declare module BABYLON {
  13121. /** @hidden */
  13122. export var layerPixelShader: {
  13123. name: string;
  13124. shader: string;
  13125. };
  13126. }
  13127. declare module BABYLON {
  13128. /** @hidden */
  13129. export var layerVertexShader: {
  13130. name: string;
  13131. shader: string;
  13132. };
  13133. }
  13134. declare module BABYLON {
  13135. /**
  13136. * This represents a full screen 2d layer.
  13137. * This can be useful to display a picture in the background of your scene for instance.
  13138. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13139. */
  13140. export class Layer {
  13141. /**
  13142. * Define the name of the layer.
  13143. */
  13144. name: string;
  13145. /**
  13146. * Define the texture the layer should display.
  13147. */
  13148. texture: Nullable<Texture>;
  13149. /**
  13150. * Is the layer in background or foreground.
  13151. */
  13152. isBackground: boolean;
  13153. /**
  13154. * Define the color of the layer (instead of texture).
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * Define the scale of the layer in order to zoom in out of the texture.
  13159. */
  13160. scale: Vector2;
  13161. /**
  13162. * Define an offset for the layer in order to shift the texture.
  13163. */
  13164. offset: Vector2;
  13165. /**
  13166. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13167. */
  13168. alphaBlendingMode: number;
  13169. /**
  13170. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13171. * Alpha test will not mix with the background color in case of transparency.
  13172. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13173. */
  13174. alphaTest: boolean;
  13175. /**
  13176. * Define a mask to restrict the layer to only some of the scene cameras.
  13177. */
  13178. layerMask: number;
  13179. /**
  13180. * Define the list of render target the layer is visible into.
  13181. */
  13182. renderTargetTextures: RenderTargetTexture[];
  13183. /**
  13184. * Define if the layer is only used in renderTarget or if it also
  13185. * renders in the main frame buffer of the canvas.
  13186. */
  13187. renderOnlyInRenderTargetTextures: boolean;
  13188. private _scene;
  13189. private _vertexBuffers;
  13190. private _indexBuffer;
  13191. private _effect;
  13192. private _alphaTestEffect;
  13193. /**
  13194. * An event triggered when the layer is disposed.
  13195. */
  13196. onDisposeObservable: Observable<Layer>;
  13197. private _onDisposeObserver;
  13198. /**
  13199. * Back compatibility with callback before the onDisposeObservable existed.
  13200. * The set callback will be triggered when the layer has been disposed.
  13201. */
  13202. onDispose: () => void;
  13203. /**
  13204. * An event triggered before rendering the scene
  13205. */
  13206. onBeforeRenderObservable: Observable<Layer>;
  13207. private _onBeforeRenderObserver;
  13208. /**
  13209. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13210. * The set callback will be triggered just before rendering the layer.
  13211. */
  13212. onBeforeRender: () => void;
  13213. /**
  13214. * An event triggered after rendering the scene
  13215. */
  13216. onAfterRenderObservable: Observable<Layer>;
  13217. private _onAfterRenderObserver;
  13218. /**
  13219. * Back compatibility with callback before the onAfterRenderObservable existed.
  13220. * The set callback will be triggered just after rendering the layer.
  13221. */
  13222. onAfterRender: () => void;
  13223. /**
  13224. * Instantiates a new layer.
  13225. * This represents a full screen 2d layer.
  13226. * This can be useful to display a picture in the background of your scene for instance.
  13227. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13228. * @param name Define the name of the layer in the scene
  13229. * @param imgUrl Define the url of the texture to display in the layer
  13230. * @param scene Define the scene the layer belongs to
  13231. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13232. * @param color Defines a color for the layer
  13233. */
  13234. constructor(
  13235. /**
  13236. * Define the name of the layer.
  13237. */
  13238. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13239. private _createIndexBuffer;
  13240. /** @hidden */
  13241. _rebuild(): void;
  13242. /**
  13243. * Renders the layer in the scene.
  13244. */
  13245. render(): void;
  13246. /**
  13247. * Disposes and releases the associated ressources.
  13248. */
  13249. dispose(): void;
  13250. }
  13251. }
  13252. declare module BABYLON {
  13253. interface AbstractScene {
  13254. /**
  13255. * The list of procedural textures added to the scene
  13256. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13257. */
  13258. proceduralTextures: Array<ProceduralTexture>;
  13259. }
  13260. /**
  13261. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13262. * in a given scene.
  13263. */
  13264. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13265. /**
  13266. * The component name helpfull to identify the component in the list of scene components.
  13267. */
  13268. readonly name: string;
  13269. /**
  13270. * The scene the component belongs to.
  13271. */
  13272. scene: Scene;
  13273. /**
  13274. * Creates a new instance of the component for the given scene
  13275. * @param scene Defines the scene to register the component in
  13276. */
  13277. constructor(scene: Scene);
  13278. /**
  13279. * Registers the component in a given scene
  13280. */
  13281. register(): void;
  13282. /**
  13283. * Rebuilds the elements related to this component in case of
  13284. * context lost for instance.
  13285. */
  13286. rebuild(): void;
  13287. /**
  13288. * Disposes the component and the associated ressources.
  13289. */
  13290. dispose(): void;
  13291. private _beforeClear;
  13292. }
  13293. }
  13294. declare module BABYLON {
  13295. /** @hidden */
  13296. export var proceduralVertexShader: {
  13297. name: string;
  13298. shader: string;
  13299. };
  13300. }
  13301. declare module BABYLON {
  13302. /**
  13303. * 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 calmpler' images.
  13304. * This is the base class of any Procedural texture and contains most of the shareable code.
  13305. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13306. */
  13307. export class ProceduralTexture extends Texture {
  13308. isCube: boolean;
  13309. /**
  13310. * Define if the texture is enabled or not (disabled texture will not render)
  13311. */
  13312. isEnabled: boolean;
  13313. /**
  13314. * Define if the texture must be cleared before rendering (default is true)
  13315. */
  13316. autoClear: boolean;
  13317. /**
  13318. * Callback called when the texture is generated
  13319. */
  13320. onGenerated: () => void;
  13321. /**
  13322. * Event raised when the texture is generated
  13323. */
  13324. onGeneratedObservable: Observable<ProceduralTexture>;
  13325. /** @hidden */
  13326. _generateMipMaps: boolean;
  13327. /** @hidden **/
  13328. _effect: Effect;
  13329. /** @hidden */
  13330. _textures: {
  13331. [key: string]: Texture;
  13332. };
  13333. private _size;
  13334. private _currentRefreshId;
  13335. private _refreshRate;
  13336. private _vertexBuffers;
  13337. private _indexBuffer;
  13338. private _uniforms;
  13339. private _samplers;
  13340. private _fragment;
  13341. private _floats;
  13342. private _ints;
  13343. private _floatsArrays;
  13344. private _colors3;
  13345. private _colors4;
  13346. private _vectors2;
  13347. private _vectors3;
  13348. private _matrices;
  13349. private _fallbackTexture;
  13350. private _fallbackTextureUsed;
  13351. private _engine;
  13352. private _cachedDefines;
  13353. private _contentUpdateId;
  13354. private _contentData;
  13355. /**
  13356. * Instantiates a new procedural texture.
  13357. * 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.
  13358. * This is the base class of any Procedural texture and contains most of the shareable code.
  13359. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13360. * @param name Define the name of the texture
  13361. * @param size Define the size of the texture to create
  13362. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13363. * @param scene Define the scene the texture belongs to
  13364. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13365. * @param generateMipMaps Define if the texture should creates mip maps or not
  13366. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13367. */
  13368. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13369. /**
  13370. * The effect that is created when initializing the post process.
  13371. * @returns The created effect corrisponding the the postprocess.
  13372. */
  13373. getEffect(): Effect;
  13374. /**
  13375. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13376. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13377. */
  13378. getContent(): Nullable<ArrayBufferView>;
  13379. private _createIndexBuffer;
  13380. /** @hidden */
  13381. _rebuild(): void;
  13382. /**
  13383. * Resets the texture in order to recreate its associated resources.
  13384. * This can be called in case of context loss
  13385. */
  13386. reset(): void;
  13387. protected _getDefines(): string;
  13388. /**
  13389. * Is the texture ready to be used ? (rendered at least once)
  13390. * @returns true if ready, otherwise, false.
  13391. */
  13392. isReady(): boolean;
  13393. /**
  13394. * Resets the refresh counter of the texture and start bak from scratch.
  13395. * Could be useful to regenerate the texture if it is setup to render only once.
  13396. */
  13397. resetRefreshCounter(): void;
  13398. /**
  13399. * Set the fragment shader to use in order to render the texture.
  13400. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13401. */
  13402. setFragment(fragment: any): void;
  13403. /**
  13404. * Define the refresh rate of the texture or the rendering frequency.
  13405. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13406. */
  13407. refreshRate: number;
  13408. /** @hidden */
  13409. _shouldRender(): boolean;
  13410. /**
  13411. * Get the size the texture is rendering at.
  13412. * @returns the size (texture is always squared)
  13413. */
  13414. getRenderSize(): number;
  13415. /**
  13416. * Resize the texture to new value.
  13417. * @param size Define the new size the texture should have
  13418. * @param generateMipMaps Define whether the new texture should create mip maps
  13419. */
  13420. resize(size: number, generateMipMaps: boolean): void;
  13421. private _checkUniform;
  13422. /**
  13423. * Set a texture in the shader program used to render.
  13424. * @param name Define the name of the uniform samplers as defined in the shader
  13425. * @param texture Define the texture to bind to this sampler
  13426. * @return the texture itself allowing "fluent" like uniform updates
  13427. */
  13428. setTexture(name: string, texture: Texture): ProceduralTexture;
  13429. /**
  13430. * Set a float in the shader.
  13431. * @param name Define the name of the uniform as defined in the shader
  13432. * @param value Define the value to give to the uniform
  13433. * @return the texture itself allowing "fluent" like uniform updates
  13434. */
  13435. setFloat(name: string, value: number): ProceduralTexture;
  13436. /**
  13437. * Set a int in the shader.
  13438. * @param name Define the name of the uniform as defined in the shader
  13439. * @param value Define the value to give to the uniform
  13440. * @return the texture itself allowing "fluent" like uniform updates
  13441. */
  13442. setInt(name: string, value: number): ProceduralTexture;
  13443. /**
  13444. * Set an array of floats in the shader.
  13445. * @param name Define the name of the uniform as defined in the shader
  13446. * @param value Define the value to give to the uniform
  13447. * @return the texture itself allowing "fluent" like uniform updates
  13448. */
  13449. setFloats(name: string, value: number[]): ProceduralTexture;
  13450. /**
  13451. * Set a vec3 in the shader from a Color3.
  13452. * @param name Define the name of the uniform as defined in the shader
  13453. * @param value Define the value to give to the uniform
  13454. * @return the texture itself allowing "fluent" like uniform updates
  13455. */
  13456. setColor3(name: string, value: Color3): ProceduralTexture;
  13457. /**
  13458. * Set a vec4 in the shader from a Color4.
  13459. * @param name Define the name of the uniform as defined in the shader
  13460. * @param value Define the value to give to the uniform
  13461. * @return the texture itself allowing "fluent" like uniform updates
  13462. */
  13463. setColor4(name: string, value: Color4): ProceduralTexture;
  13464. /**
  13465. * Set a vec2 in the shader from a Vector2.
  13466. * @param name Define the name of the uniform as defined in the shader
  13467. * @param value Define the value to give to the uniform
  13468. * @return the texture itself allowing "fluent" like uniform updates
  13469. */
  13470. setVector2(name: string, value: Vector2): ProceduralTexture;
  13471. /**
  13472. * Set a vec3 in the shader from a Vector3.
  13473. * @param name Define the name of the uniform as defined in the shader
  13474. * @param value Define the value to give to the uniform
  13475. * @return the texture itself allowing "fluent" like uniform updates
  13476. */
  13477. setVector3(name: string, value: Vector3): ProceduralTexture;
  13478. /**
  13479. * Set a mat4 in the shader from a MAtrix.
  13480. * @param name Define the name of the uniform as defined in the shader
  13481. * @param value Define the value to give to the uniform
  13482. * @return the texture itself allowing "fluent" like uniform updates
  13483. */
  13484. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13485. /**
  13486. * Render the texture to its associated render target.
  13487. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13488. */
  13489. render(useCameraPostProcess?: boolean): void;
  13490. /**
  13491. * Clone the texture.
  13492. * @returns the cloned texture
  13493. */
  13494. clone(): ProceduralTexture;
  13495. /**
  13496. * Dispose the texture and release its asoociated resources.
  13497. */
  13498. dispose(): void;
  13499. }
  13500. }
  13501. declare module BABYLON {
  13502. /**
  13503. * This represents the base class for particle system in Babylon.
  13504. * 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.
  13505. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13506. * @example https://doc.babylonjs.com/babylon101/particles
  13507. */
  13508. export class BaseParticleSystem {
  13509. /**
  13510. * Source color is added to the destination color without alpha affecting the result
  13511. */
  13512. static BLENDMODE_ONEONE: number;
  13513. /**
  13514. * Blend current color and particle color using particle’s alpha
  13515. */
  13516. static BLENDMODE_STANDARD: number;
  13517. /**
  13518. * Add current color and particle color multiplied by particle’s alpha
  13519. */
  13520. static BLENDMODE_ADD: number;
  13521. /**
  13522. * Multiply current color with particle color
  13523. */
  13524. static BLENDMODE_MULTIPLY: number;
  13525. /**
  13526. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13527. */
  13528. static BLENDMODE_MULTIPLYADD: number;
  13529. /**
  13530. * List of animations used by the particle system.
  13531. */
  13532. animations: Animation[];
  13533. /**
  13534. * The id of the Particle system.
  13535. */
  13536. id: string;
  13537. /**
  13538. * The friendly name of the Particle system.
  13539. */
  13540. name: string;
  13541. /**
  13542. * The rendering group used by the Particle system to chose when to render.
  13543. */
  13544. renderingGroupId: number;
  13545. /**
  13546. * The emitter represents the Mesh or position we are attaching the particle system to.
  13547. */
  13548. emitter: Nullable<AbstractMesh | Vector3>;
  13549. /**
  13550. * The maximum number of particles to emit per frame
  13551. */
  13552. emitRate: number;
  13553. /**
  13554. * If you want to launch only a few particles at once, that can be done, as well.
  13555. */
  13556. manualEmitCount: number;
  13557. /**
  13558. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13559. */
  13560. updateSpeed: number;
  13561. /**
  13562. * The amount of time the particle system is running (depends of the overall update speed).
  13563. */
  13564. targetStopDuration: number;
  13565. /**
  13566. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13567. */
  13568. disposeOnStop: boolean;
  13569. /**
  13570. * Minimum power of emitting particles.
  13571. */
  13572. minEmitPower: number;
  13573. /**
  13574. * Maximum power of emitting particles.
  13575. */
  13576. maxEmitPower: number;
  13577. /**
  13578. * Minimum life time of emitting particles.
  13579. */
  13580. minLifeTime: number;
  13581. /**
  13582. * Maximum life time of emitting particles.
  13583. */
  13584. maxLifeTime: number;
  13585. /**
  13586. * Minimum Size of emitting particles.
  13587. */
  13588. minSize: number;
  13589. /**
  13590. * Maximum Size of emitting particles.
  13591. */
  13592. maxSize: number;
  13593. /**
  13594. * Minimum scale of emitting particles on X axis.
  13595. */
  13596. minScaleX: number;
  13597. /**
  13598. * Maximum scale of emitting particles on X axis.
  13599. */
  13600. maxScaleX: number;
  13601. /**
  13602. * Minimum scale of emitting particles on Y axis.
  13603. */
  13604. minScaleY: number;
  13605. /**
  13606. * Maximum scale of emitting particles on Y axis.
  13607. */
  13608. maxScaleY: number;
  13609. /**
  13610. * Gets or sets the minimal initial rotation in radians.
  13611. */
  13612. minInitialRotation: number;
  13613. /**
  13614. * Gets or sets the maximal initial rotation in radians.
  13615. */
  13616. maxInitialRotation: number;
  13617. /**
  13618. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13619. */
  13620. minAngularSpeed: number;
  13621. /**
  13622. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13623. */
  13624. maxAngularSpeed: number;
  13625. /**
  13626. * The texture used to render each particle. (this can be a spritesheet)
  13627. */
  13628. particleTexture: Nullable<Texture>;
  13629. /**
  13630. * The layer mask we are rendering the particles through.
  13631. */
  13632. layerMask: number;
  13633. /**
  13634. * This can help using your own shader to render the particle system.
  13635. * The according effect will be created
  13636. */
  13637. customShader: any;
  13638. /**
  13639. * By default particle system starts as soon as they are created. This prevents the
  13640. * automatic start to happen and let you decide when to start emitting particles.
  13641. */
  13642. preventAutoStart: boolean;
  13643. private _noiseTexture;
  13644. /**
  13645. * Gets or sets a texture used to add random noise to particle positions
  13646. */
  13647. noiseTexture: Nullable<ProceduralTexture>;
  13648. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13649. noiseStrength: Vector3;
  13650. /**
  13651. * Callback triggered when the particle animation is ending.
  13652. */
  13653. onAnimationEnd: Nullable<() => void>;
  13654. /**
  13655. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13656. */
  13657. blendMode: number;
  13658. /**
  13659. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13660. * to override the particles.
  13661. */
  13662. forceDepthWrite: boolean;
  13663. /** 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 */
  13664. preWarmCycles: number;
  13665. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13666. preWarmStepOffset: number;
  13667. /**
  13668. * 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)
  13669. */
  13670. spriteCellChangeSpeed: number;
  13671. /**
  13672. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13673. */
  13674. startSpriteCellID: number;
  13675. /**
  13676. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13677. */
  13678. endSpriteCellID: number;
  13679. /**
  13680. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13681. */
  13682. spriteCellWidth: number;
  13683. /**
  13684. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13685. */
  13686. spriteCellHeight: number;
  13687. /**
  13688. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13689. */
  13690. spriteRandomStartCell: boolean;
  13691. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13692. translationPivot: Vector2;
  13693. /** @hidden */
  13694. protected _isAnimationSheetEnabled: boolean;
  13695. /**
  13696. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13697. */
  13698. beginAnimationOnStart: boolean;
  13699. /**
  13700. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13701. */
  13702. beginAnimationFrom: number;
  13703. /**
  13704. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13705. */
  13706. beginAnimationTo: number;
  13707. /**
  13708. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13709. */
  13710. beginAnimationLoop: boolean;
  13711. /**
  13712. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13713. */
  13714. isAnimationSheetEnabled: boolean;
  13715. /**
  13716. * Get hosting scene
  13717. * @returns the scene
  13718. */
  13719. getScene(): Scene;
  13720. /**
  13721. * You can use gravity if you want to give an orientation to your particles.
  13722. */
  13723. gravity: Vector3;
  13724. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13725. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13726. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13727. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13728. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13729. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13730. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13731. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13732. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  13733. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  13734. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  13735. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  13736. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  13737. /**
  13738. * Defines the delay in milliseconds before starting the system (0 by default)
  13739. */
  13740. startDelay: number;
  13741. /**
  13742. * Gets the current list of drag gradients.
  13743. * You must use addDragGradient and removeDragGradient to udpate this list
  13744. * @returns the list of drag gradients
  13745. */
  13746. getDragGradients(): Nullable<Array<FactorGradient>>;
  13747. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13748. limitVelocityDamping: number;
  13749. /**
  13750. * Gets the current list of limit velocity gradients.
  13751. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13752. * @returns the list of limit velocity gradients
  13753. */
  13754. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13755. /**
  13756. * Gets the current list of color gradients.
  13757. * You must use addColorGradient and removeColorGradient to udpate this list
  13758. * @returns the list of color gradients
  13759. */
  13760. getColorGradients(): Nullable<Array<ColorGradient>>;
  13761. /**
  13762. * Gets the current list of size gradients.
  13763. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13764. * @returns the list of size gradients
  13765. */
  13766. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13767. /**
  13768. * Gets the current list of color remap gradients.
  13769. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13770. * @returns the list of color remap gradients
  13771. */
  13772. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13773. /**
  13774. * Gets the current list of alpha remap gradients.
  13775. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13776. * @returns the list of alpha remap gradients
  13777. */
  13778. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13779. /**
  13780. * Gets the current list of life time gradients.
  13781. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13782. * @returns the list of life time gradients
  13783. */
  13784. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13785. /**
  13786. * Gets the current list of angular speed gradients.
  13787. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13788. * @returns the list of angular speed gradients
  13789. */
  13790. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13791. /**
  13792. * Gets the current list of velocity gradients.
  13793. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13794. * @returns the list of velocity gradients
  13795. */
  13796. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13797. /**
  13798. * Gets the current list of start size gradients.
  13799. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13800. * @returns the list of start size gradients
  13801. */
  13802. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13803. /**
  13804. * Gets the current list of emit rate gradients.
  13805. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13806. * @returns the list of emit rate gradients
  13807. */
  13808. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13809. /**
  13810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13811. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13812. */
  13813. direction1: Vector3;
  13814. /**
  13815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13816. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13817. */
  13818. direction2: Vector3;
  13819. /**
  13820. * 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.
  13821. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13822. */
  13823. minEmitBox: Vector3;
  13824. /**
  13825. * 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.
  13826. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13827. */
  13828. maxEmitBox: Vector3;
  13829. /**
  13830. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13831. */
  13832. color1: Color4;
  13833. /**
  13834. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13835. */
  13836. color2: Color4;
  13837. /**
  13838. * Color the particle will have at the end of its lifetime
  13839. */
  13840. colorDead: Color4;
  13841. /**
  13842. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  13843. */
  13844. textureMask: Color4;
  13845. /**
  13846. * The particle emitter type defines the emitter used by the particle system.
  13847. * It can be for example box, sphere, or cone...
  13848. */
  13849. particleEmitterType: IParticleEmitterType;
  13850. /** @hidden */
  13851. _isSubEmitter: boolean;
  13852. /**
  13853. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13854. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13855. */
  13856. billboardMode: number;
  13857. protected _isBillboardBased: boolean;
  13858. /**
  13859. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13860. */
  13861. isBillboardBased: boolean;
  13862. /**
  13863. * The scene the particle system belongs to.
  13864. */
  13865. protected _scene: Scene;
  13866. /**
  13867. * Local cache of defines for image processing.
  13868. */
  13869. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  13870. /**
  13871. * Default configuration related to image processing available in the standard Material.
  13872. */
  13873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13874. /**
  13875. * Gets the image processing configuration used either in this material.
  13876. */
  13877. /**
  13878. * Sets the Default image processing configuration used either in the this material.
  13879. *
  13880. * If sets to null, the scene one is in use.
  13881. */
  13882. imageProcessingConfiguration: ImageProcessingConfiguration;
  13883. /**
  13884. * Attaches a new image processing configuration to the Standard Material.
  13885. * @param configuration
  13886. */
  13887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13888. /** @hidden */
  13889. protected _reset(): void;
  13890. /** @hidden */
  13891. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  13892. /**
  13893. * Instantiates a particle system.
  13894. * 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.
  13895. * @param name The name of the particle system
  13896. */
  13897. constructor(name: string);
  13898. /**
  13899. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13900. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13901. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13902. * @returns the emitter
  13903. */
  13904. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13905. /**
  13906. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13907. * @param radius The radius of the hemisphere to emit from
  13908. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13909. * @returns the emitter
  13910. */
  13911. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  13912. /**
  13913. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13914. * @param radius The radius of the sphere to emit from
  13915. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13916. * @returns the emitter
  13917. */
  13918. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  13919. /**
  13920. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13921. * @param radius The radius of the sphere to emit from
  13922. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13923. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13924. * @returns the emitter
  13925. */
  13926. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  13927. /**
  13928. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13929. * @param radius The radius of the emission cylinder
  13930. * @param height The height of the emission cylinder
  13931. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13932. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13933. * @returns the emitter
  13934. */
  13935. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  13936. /**
  13937. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13938. * @param radius The radius of the cylinder to emit from
  13939. * @param height The height of the emission cylinder
  13940. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13941. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13942. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13943. * @returns the emitter
  13944. */
  13945. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  13946. /**
  13947. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13948. * @param radius The radius of the cone to emit from
  13949. * @param angle The base angle of the cone
  13950. * @returns the emitter
  13951. */
  13952. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  13953. /**
  13954. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13957. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13958. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13959. * @returns the emitter
  13960. */
  13961. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13962. }
  13963. }
  13964. declare module BABYLON {
  13965. /**
  13966. * Type of sub emitter
  13967. */
  13968. export enum SubEmitterType {
  13969. /**
  13970. * Attached to the particle over it's lifetime
  13971. */
  13972. ATTACHED = 0,
  13973. /**
  13974. * Created when the particle dies
  13975. */
  13976. END = 1
  13977. }
  13978. /**
  13979. * Sub emitter class used to emit particles from an existing particle
  13980. */
  13981. export class SubEmitter {
  13982. /**
  13983. * the particle system to be used by the sub emitter
  13984. */
  13985. particleSystem: ParticleSystem;
  13986. /**
  13987. * Type of the submitter (Default: END)
  13988. */
  13989. type: SubEmitterType;
  13990. /**
  13991. * 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)
  13992. * Note: This only is supported when using an emitter of type Mesh
  13993. */
  13994. inheritDirection: boolean;
  13995. /**
  13996. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  13997. */
  13998. inheritedVelocityAmount: number;
  13999. /**
  14000. * Creates a sub emitter
  14001. * @param particleSystem the particle system to be used by the sub emitter
  14002. */
  14003. constructor(
  14004. /**
  14005. * the particle system to be used by the sub emitter
  14006. */
  14007. particleSystem: ParticleSystem);
  14008. /**
  14009. * Clones the sub emitter
  14010. * @returns the cloned sub emitter
  14011. */
  14012. clone(): SubEmitter;
  14013. /**
  14014. * Serialize current object to a JSON object
  14015. * @returns the serialized object
  14016. */
  14017. serialize(): any;
  14018. /** @hidden */
  14019. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14020. /**
  14021. * Creates a new SubEmitter from a serialized JSON version
  14022. * @param serializationObject defines the JSON object to read from
  14023. * @param scene defines the hosting scene
  14024. * @param rootUrl defines the rootUrl for data loading
  14025. * @returns a new SubEmitter
  14026. */
  14027. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14028. /** Release associated resources */
  14029. dispose(): void;
  14030. }
  14031. }
  14032. declare module BABYLON {
  14033. /** @hidden */
  14034. export var clipPlaneFragmentDeclaration: {
  14035. name: string;
  14036. shader: string;
  14037. };
  14038. }
  14039. declare module BABYLON {
  14040. /** @hidden */
  14041. export var imageProcessingDeclaration: {
  14042. name: string;
  14043. shader: string;
  14044. };
  14045. }
  14046. declare module BABYLON {
  14047. /** @hidden */
  14048. export var imageProcessingFunctions: {
  14049. name: string;
  14050. shader: string;
  14051. };
  14052. }
  14053. declare module BABYLON {
  14054. /** @hidden */
  14055. export var clipPlaneFragment: {
  14056. name: string;
  14057. shader: string;
  14058. };
  14059. }
  14060. declare module BABYLON {
  14061. /** @hidden */
  14062. export var particlesPixelShader: {
  14063. name: string;
  14064. shader: string;
  14065. };
  14066. }
  14067. declare module BABYLON {
  14068. /** @hidden */
  14069. export var clipPlaneVertexDeclaration: {
  14070. name: string;
  14071. shader: string;
  14072. };
  14073. }
  14074. declare module BABYLON {
  14075. /** @hidden */
  14076. export var clipPlaneVertex: {
  14077. name: string;
  14078. shader: string;
  14079. };
  14080. }
  14081. declare module BABYLON {
  14082. /** @hidden */
  14083. export var particlesVertexShader: {
  14084. name: string;
  14085. shader: string;
  14086. };
  14087. }
  14088. declare module BABYLON {
  14089. /**
  14090. * This represents a particle system in Babylon.
  14091. * 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.
  14092. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14093. * @example https://doc.babylonjs.com/babylon101/particles
  14094. */
  14095. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14096. /**
  14097. * Billboard mode will only apply to Y axis
  14098. */
  14099. static readonly BILLBOARDMODE_Y: number;
  14100. /**
  14101. * Billboard mode will apply to all axes
  14102. */
  14103. static readonly BILLBOARDMODE_ALL: number;
  14104. /**
  14105. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14106. */
  14107. static readonly BILLBOARDMODE_STRETCHED: number;
  14108. /**
  14109. * This function can be defined to provide custom update for active particles.
  14110. * This function will be called instead of regular update (age, position, color, etc.).
  14111. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14112. */
  14113. updateFunction: (particles: Particle[]) => void;
  14114. private _emitterWorldMatrix;
  14115. /**
  14116. * This function can be defined to specify initial direction for every new particle.
  14117. * It by default use the emitterType defined function
  14118. */
  14119. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14120. /**
  14121. * This function can be defined to specify initial position for every new particle.
  14122. * It by default use the emitterType defined function
  14123. */
  14124. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14125. /**
  14126. * @hidden
  14127. */
  14128. _inheritedVelocityOffset: Vector3;
  14129. /**
  14130. * An event triggered when the system is disposed
  14131. */
  14132. onDisposeObservable: Observable<ParticleSystem>;
  14133. private _onDisposeObserver;
  14134. /**
  14135. * Sets a callback that will be triggered when the system is disposed
  14136. */
  14137. onDispose: () => void;
  14138. private _particles;
  14139. private _epsilon;
  14140. private _capacity;
  14141. private _stockParticles;
  14142. private _newPartsExcess;
  14143. private _vertexData;
  14144. private _vertexBuffer;
  14145. private _vertexBuffers;
  14146. private _spriteBuffer;
  14147. private _indexBuffer;
  14148. private _effect;
  14149. private _customEffect;
  14150. private _cachedDefines;
  14151. private _scaledColorStep;
  14152. private _colorDiff;
  14153. private _scaledDirection;
  14154. private _scaledGravity;
  14155. private _currentRenderId;
  14156. private _alive;
  14157. private _useInstancing;
  14158. private _started;
  14159. private _stopped;
  14160. private _actualFrame;
  14161. private _scaledUpdateSpeed;
  14162. private _vertexBufferSize;
  14163. /** @hidden */
  14164. _currentEmitRateGradient: Nullable<FactorGradient>;
  14165. /** @hidden */
  14166. _currentEmitRate1: number;
  14167. /** @hidden */
  14168. _currentEmitRate2: number;
  14169. /** @hidden */
  14170. _currentStartSizeGradient: Nullable<FactorGradient>;
  14171. /** @hidden */
  14172. _currentStartSize1: number;
  14173. /** @hidden */
  14174. _currentStartSize2: number;
  14175. private readonly _rawTextureWidth;
  14176. private _rampGradientsTexture;
  14177. private _useRampGradients;
  14178. /** Gets or sets a boolean indicating that ramp gradients must be used
  14179. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14180. */
  14181. useRampGradients: boolean;
  14182. /**
  14183. * 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.
  14184. * 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: [])
  14185. */
  14186. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14187. private _subEmitters;
  14188. /**
  14189. * @hidden
  14190. * If the particle systems emitter should be disposed when the particle system is disposed
  14191. */
  14192. _disposeEmitterOnDispose: boolean;
  14193. /**
  14194. * The current active Sub-systems, this property is used by the root particle system only.
  14195. */
  14196. activeSubSystems: Array<ParticleSystem>;
  14197. private _rootParticleSystem;
  14198. /**
  14199. * Gets the current list of active particles
  14200. */
  14201. readonly particles: Particle[];
  14202. /**
  14203. * Returns the string "ParticleSystem"
  14204. * @returns a string containing the class name
  14205. */
  14206. getClassName(): string;
  14207. /**
  14208. * Instantiates a particle system.
  14209. * 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.
  14210. * @param name The name of the particle system
  14211. * @param capacity The max number of particles alive at the same time
  14212. * @param scene The scene the particle system belongs to
  14213. * @param customEffect a custom effect used to change the way particles are rendered by default
  14214. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14215. * @param epsilon Offset used to render the particles
  14216. */
  14217. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14218. private _addFactorGradient;
  14219. private _removeFactorGradient;
  14220. /**
  14221. * Adds a new life time gradient
  14222. * @param gradient defines the gradient to use (between 0 and 1)
  14223. * @param factor defines the life time factor to affect to the specified gradient
  14224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14225. * @returns the current particle system
  14226. */
  14227. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14228. /**
  14229. * Remove a specific life time gradient
  14230. * @param gradient defines the gradient to remove
  14231. * @returns the current particle system
  14232. */
  14233. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14234. /**
  14235. * Adds a new size gradient
  14236. * @param gradient defines the gradient to use (between 0 and 1)
  14237. * @param factor defines the size factor to affect to the specified gradient
  14238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14239. * @returns the current particle system
  14240. */
  14241. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14242. /**
  14243. * Remove a specific size gradient
  14244. * @param gradient defines the gradient to remove
  14245. * @returns the current particle system
  14246. */
  14247. removeSizeGradient(gradient: number): IParticleSystem;
  14248. /**
  14249. * Adds a new color remap gradient
  14250. * @param gradient defines the gradient to use (between 0 and 1)
  14251. * @param min defines the color remap minimal range
  14252. * @param max defines the color remap maximal range
  14253. * @returns the current particle system
  14254. */
  14255. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14256. /**
  14257. * Remove a specific color remap gradient
  14258. * @param gradient defines the gradient to remove
  14259. * @returns the current particle system
  14260. */
  14261. removeColorRemapGradient(gradient: number): IParticleSystem;
  14262. /**
  14263. * Adds a new alpha remap gradient
  14264. * @param gradient defines the gradient to use (between 0 and 1)
  14265. * @param min defines the alpha remap minimal range
  14266. * @param max defines the alpha remap maximal range
  14267. * @returns the current particle system
  14268. */
  14269. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14270. /**
  14271. * Remove a specific alpha remap gradient
  14272. * @param gradient defines the gradient to remove
  14273. * @returns the current particle system
  14274. */
  14275. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14276. /**
  14277. * Adds a new angular speed gradient
  14278. * @param gradient defines the gradient to use (between 0 and 1)
  14279. * @param factor defines the angular speed to affect to the specified gradient
  14280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14281. * @returns the current particle system
  14282. */
  14283. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14284. /**
  14285. * Remove a specific angular speed gradient
  14286. * @param gradient defines the gradient to remove
  14287. * @returns the current particle system
  14288. */
  14289. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14290. /**
  14291. * Adds a new velocity gradient
  14292. * @param gradient defines the gradient to use (between 0 and 1)
  14293. * @param factor defines the velocity to affect to the specified gradient
  14294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14295. * @returns the current particle system
  14296. */
  14297. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14298. /**
  14299. * Remove a specific velocity gradient
  14300. * @param gradient defines the gradient to remove
  14301. * @returns the current particle system
  14302. */
  14303. removeVelocityGradient(gradient: number): IParticleSystem;
  14304. /**
  14305. * Adds a new limit velocity gradient
  14306. * @param gradient defines the gradient to use (between 0 and 1)
  14307. * @param factor defines the limit velocity value to affect to the specified gradient
  14308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14309. * @returns the current particle system
  14310. */
  14311. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14312. /**
  14313. * Remove a specific limit velocity gradient
  14314. * @param gradient defines the gradient to remove
  14315. * @returns the current particle system
  14316. */
  14317. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14318. /**
  14319. * Adds a new drag gradient
  14320. * @param gradient defines the gradient to use (between 0 and 1)
  14321. * @param factor defines the drag value to affect to the specified gradient
  14322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14323. * @returns the current particle system
  14324. */
  14325. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14326. /**
  14327. * Remove a specific drag gradient
  14328. * @param gradient defines the gradient to remove
  14329. * @returns the current particle system
  14330. */
  14331. removeDragGradient(gradient: number): IParticleSystem;
  14332. /**
  14333. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14334. * @param gradient defines the gradient to use (between 0 and 1)
  14335. * @param factor defines the emit rate value to affect to the specified gradient
  14336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14337. * @returns the current particle system
  14338. */
  14339. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14340. /**
  14341. * Remove a specific emit rate gradient
  14342. * @param gradient defines the gradient to remove
  14343. * @returns the current particle system
  14344. */
  14345. removeEmitRateGradient(gradient: number): IParticleSystem;
  14346. /**
  14347. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14348. * @param gradient defines the gradient to use (between 0 and 1)
  14349. * @param factor defines the start size value to affect to the specified gradient
  14350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14351. * @returns the current particle system
  14352. */
  14353. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14354. /**
  14355. * Remove a specific start size gradient
  14356. * @param gradient defines the gradient to remove
  14357. * @returns the current particle system
  14358. */
  14359. removeStartSizeGradient(gradient: number): IParticleSystem;
  14360. private _createRampGradientTexture;
  14361. /**
  14362. * Gets the current list of ramp gradients.
  14363. * You must use addRampGradient and removeRampGradient to udpate this list
  14364. * @returns the list of ramp gradients
  14365. */
  14366. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14367. /**
  14368. * Adds a new ramp gradient used to remap particle colors
  14369. * @param gradient defines the gradient to use (between 0 and 1)
  14370. * @param color defines the color to affect to the specified gradient
  14371. * @returns the current particle system
  14372. */
  14373. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14374. /**
  14375. * Remove a specific ramp gradient
  14376. * @param gradient defines the gradient to remove
  14377. * @returns the current particle system
  14378. */
  14379. removeRampGradient(gradient: number): ParticleSystem;
  14380. /**
  14381. * Adds a new color gradient
  14382. * @param gradient defines the gradient to use (between 0 and 1)
  14383. * @param color1 defines the color to affect to the specified gradient
  14384. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14385. * @returns this particle system
  14386. */
  14387. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14388. /**
  14389. * Remove a specific color gradient
  14390. * @param gradient defines the gradient to remove
  14391. * @returns this particle system
  14392. */
  14393. removeColorGradient(gradient: number): IParticleSystem;
  14394. private _fetchR;
  14395. protected _reset(): void;
  14396. private _resetEffect;
  14397. private _createVertexBuffers;
  14398. private _createIndexBuffer;
  14399. /**
  14400. * Gets the maximum number of particles active at the same time.
  14401. * @returns The max number of active particles.
  14402. */
  14403. getCapacity(): number;
  14404. /**
  14405. * Gets whether there are still active particles in the system.
  14406. * @returns True if it is alive, otherwise false.
  14407. */
  14408. isAlive(): boolean;
  14409. /**
  14410. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14411. * @returns True if it has been started, otherwise false.
  14412. */
  14413. isStarted(): boolean;
  14414. private _prepareSubEmitterInternalArray;
  14415. /**
  14416. * Starts the particle system and begins to emit
  14417. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14418. */
  14419. start(delay?: number): void;
  14420. /**
  14421. * Stops the particle system.
  14422. * @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.
  14423. */
  14424. stop(stopSubEmitters?: boolean): void;
  14425. /**
  14426. * Remove all active particles
  14427. */
  14428. reset(): void;
  14429. /**
  14430. * @hidden (for internal use only)
  14431. */
  14432. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14433. /**
  14434. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14435. * Its lifetime will start back at 0.
  14436. */
  14437. recycleParticle: (particle: Particle) => void;
  14438. private _stopSubEmitters;
  14439. private _createParticle;
  14440. private _removeFromRoot;
  14441. private _emitFromParticle;
  14442. private _update;
  14443. /** @hidden */
  14444. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14445. /** @hidden */
  14446. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14447. /** @hidden */
  14448. private _getEffect;
  14449. /**
  14450. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14451. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14452. */
  14453. animate(preWarmOnly?: boolean): void;
  14454. private _appendParticleVertices;
  14455. /**
  14456. * Rebuilds the particle system.
  14457. */
  14458. rebuild(): void;
  14459. /**
  14460. * Is this system ready to be used/rendered
  14461. * @return true if the system is ready
  14462. */
  14463. isReady(): boolean;
  14464. private _render;
  14465. /**
  14466. * Renders the particle system in its current state.
  14467. * @returns the current number of particles
  14468. */
  14469. render(): number;
  14470. /**
  14471. * Disposes the particle system and free the associated resources
  14472. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14473. */
  14474. dispose(disposeTexture?: boolean): void;
  14475. /**
  14476. * Clones the particle system.
  14477. * @param name The name of the cloned object
  14478. * @param newEmitter The new emitter to use
  14479. * @returns the cloned particle system
  14480. */
  14481. clone(name: string, newEmitter: any): ParticleSystem;
  14482. /**
  14483. * Serializes the particle system to a JSON object.
  14484. * @returns the JSON object
  14485. */
  14486. serialize(): any;
  14487. /** @hidden */
  14488. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14489. /** @hidden */
  14490. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14491. /**
  14492. * Parses a JSON object to create a particle system.
  14493. * @param parsedParticleSystem The JSON object to parse
  14494. * @param scene The scene to create the particle system in
  14495. * @param rootUrl The root url to use to load external dependencies like texture
  14496. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14497. * @returns the Parsed particle system
  14498. */
  14499. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14500. }
  14501. }
  14502. declare module BABYLON {
  14503. /**
  14504. * A particle represents one of the element emitted by a particle system.
  14505. * This is mainly define by its coordinates, direction, velocity and age.
  14506. */
  14507. export class Particle {
  14508. /**
  14509. * The particle system the particle belongs to.
  14510. */
  14511. particleSystem: ParticleSystem;
  14512. private static _Count;
  14513. /**
  14514. * Unique ID of the particle
  14515. */
  14516. id: number;
  14517. /**
  14518. * The world position of the particle in the scene.
  14519. */
  14520. position: Vector3;
  14521. /**
  14522. * The world direction of the particle in the scene.
  14523. */
  14524. direction: Vector3;
  14525. /**
  14526. * The color of the particle.
  14527. */
  14528. color: Color4;
  14529. /**
  14530. * The color change of the particle per step.
  14531. */
  14532. colorStep: Color4;
  14533. /**
  14534. * Defines how long will the life of the particle be.
  14535. */
  14536. lifeTime: number;
  14537. /**
  14538. * The current age of the particle.
  14539. */
  14540. age: number;
  14541. /**
  14542. * The current size of the particle.
  14543. */
  14544. size: number;
  14545. /**
  14546. * The current scale of the particle.
  14547. */
  14548. scale: Vector2;
  14549. /**
  14550. * The current angle of the particle.
  14551. */
  14552. angle: number;
  14553. /**
  14554. * Defines how fast is the angle changing.
  14555. */
  14556. angularSpeed: number;
  14557. /**
  14558. * Defines the cell index used by the particle to be rendered from a sprite.
  14559. */
  14560. cellIndex: number;
  14561. /**
  14562. * The information required to support color remapping
  14563. */
  14564. remapData: Vector4;
  14565. /** @hidden */
  14566. _randomCellOffset?: number;
  14567. /** @hidden */
  14568. _initialDirection: Nullable<Vector3>;
  14569. /** @hidden */
  14570. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14571. /** @hidden */
  14572. _initialStartSpriteCellID: number;
  14573. /** @hidden */
  14574. _initialEndSpriteCellID: number;
  14575. /** @hidden */
  14576. _currentColorGradient: Nullable<ColorGradient>;
  14577. /** @hidden */
  14578. _currentColor1: Color4;
  14579. /** @hidden */
  14580. _currentColor2: Color4;
  14581. /** @hidden */
  14582. _currentSizeGradient: Nullable<FactorGradient>;
  14583. /** @hidden */
  14584. _currentSize1: number;
  14585. /** @hidden */
  14586. _currentSize2: number;
  14587. /** @hidden */
  14588. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14589. /** @hidden */
  14590. _currentAngularSpeed1: number;
  14591. /** @hidden */
  14592. _currentAngularSpeed2: number;
  14593. /** @hidden */
  14594. _currentVelocityGradient: Nullable<FactorGradient>;
  14595. /** @hidden */
  14596. _currentVelocity1: number;
  14597. /** @hidden */
  14598. _currentVelocity2: number;
  14599. /** @hidden */
  14600. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14601. /** @hidden */
  14602. _currentLimitVelocity1: number;
  14603. /** @hidden */
  14604. _currentLimitVelocity2: number;
  14605. /** @hidden */
  14606. _currentDragGradient: Nullable<FactorGradient>;
  14607. /** @hidden */
  14608. _currentDrag1: number;
  14609. /** @hidden */
  14610. _currentDrag2: number;
  14611. /** @hidden */
  14612. _randomNoiseCoordinates1: Vector3;
  14613. /** @hidden */
  14614. _randomNoiseCoordinates2: Vector3;
  14615. /**
  14616. * Creates a new instance Particle
  14617. * @param particleSystem the particle system the particle belongs to
  14618. */
  14619. constructor(
  14620. /**
  14621. * The particle system the particle belongs to.
  14622. */
  14623. particleSystem: ParticleSystem);
  14624. private updateCellInfoFromSystem;
  14625. /**
  14626. * Defines how the sprite cell index is updated for the particle
  14627. */
  14628. updateCellIndex(): void;
  14629. /** @hidden */
  14630. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14631. /** @hidden */
  14632. _inheritParticleInfoToSubEmitters(): void;
  14633. /** @hidden */
  14634. _reset(): void;
  14635. /**
  14636. * Copy the properties of particle to another one.
  14637. * @param other the particle to copy the information to.
  14638. */
  14639. copyTo(other: Particle): void;
  14640. }
  14641. }
  14642. declare module BABYLON {
  14643. /**
  14644. * Particle emitter represents a volume emitting particles.
  14645. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14646. */
  14647. export interface IParticleEmitterType {
  14648. /**
  14649. * Called by the particle System when the direction is computed for the created particle.
  14650. * @param worldMatrix is the world matrix of the particle system
  14651. * @param directionToUpdate is the direction vector to update with the result
  14652. * @param particle is the particle we are computed the direction for
  14653. */
  14654. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14655. /**
  14656. * Called by the particle System when the position is computed for the created particle.
  14657. * @param worldMatrix is the world matrix of the particle system
  14658. * @param positionToUpdate is the position vector to update with the result
  14659. * @param particle is the particle we are computed the position for
  14660. */
  14661. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14662. /**
  14663. * Clones the current emitter and returns a copy of it
  14664. * @returns the new emitter
  14665. */
  14666. clone(): IParticleEmitterType;
  14667. /**
  14668. * Called by the GPUParticleSystem to setup the update shader
  14669. * @param effect defines the update shader
  14670. */
  14671. applyToShader(effect: Effect): void;
  14672. /**
  14673. * Returns a string to use to update the GPU particles update shader
  14674. * @returns the effect defines string
  14675. */
  14676. getEffectDefines(): string;
  14677. /**
  14678. * Returns a string representing the class name
  14679. * @returns a string containing the class name
  14680. */
  14681. getClassName(): string;
  14682. /**
  14683. * Serializes the particle system to a JSON object.
  14684. * @returns the JSON object
  14685. */
  14686. serialize(): any;
  14687. /**
  14688. * Parse properties from a JSON object
  14689. * @param serializationObject defines the JSON object
  14690. */
  14691. parse(serializationObject: any): void;
  14692. }
  14693. }
  14694. declare module BABYLON {
  14695. /**
  14696. * Particle emitter emitting particles from the inside of a box.
  14697. * It emits the particles randomly between 2 given directions.
  14698. */
  14699. export class BoxParticleEmitter implements IParticleEmitterType {
  14700. /**
  14701. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14702. */
  14703. direction1: Vector3;
  14704. /**
  14705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14706. */
  14707. direction2: Vector3;
  14708. /**
  14709. * 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.
  14710. */
  14711. minEmitBox: Vector3;
  14712. /**
  14713. * 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.
  14714. */
  14715. maxEmitBox: Vector3;
  14716. /**
  14717. * Creates a new instance BoxParticleEmitter
  14718. */
  14719. constructor();
  14720. /**
  14721. * Called by the particle System when the direction is computed for the created particle.
  14722. * @param worldMatrix is the world matrix of the particle system
  14723. * @param directionToUpdate is the direction vector to update with the result
  14724. * @param particle is the particle we are computed the direction for
  14725. */
  14726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14727. /**
  14728. * Called by the particle System when the position is computed for the created particle.
  14729. * @param worldMatrix is the world matrix of the particle system
  14730. * @param positionToUpdate is the position vector to update with the result
  14731. * @param particle is the particle we are computed the position for
  14732. */
  14733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14734. /**
  14735. * Clones the current emitter and returns a copy of it
  14736. * @returns the new emitter
  14737. */
  14738. clone(): BoxParticleEmitter;
  14739. /**
  14740. * Called by the GPUParticleSystem to setup the update shader
  14741. * @param effect defines the update shader
  14742. */
  14743. applyToShader(effect: Effect): void;
  14744. /**
  14745. * Returns a string to use to update the GPU particles update shader
  14746. * @returns a string containng the defines string
  14747. */
  14748. getEffectDefines(): string;
  14749. /**
  14750. * Returns the string "BoxParticleEmitter"
  14751. * @returns a string containing the class name
  14752. */
  14753. getClassName(): string;
  14754. /**
  14755. * Serializes the particle system to a JSON object.
  14756. * @returns the JSON object
  14757. */
  14758. serialize(): any;
  14759. /**
  14760. * Parse properties from a JSON object
  14761. * @param serializationObject defines the JSON object
  14762. */
  14763. parse(serializationObject: any): void;
  14764. }
  14765. }
  14766. declare module BABYLON {
  14767. /**
  14768. * Particle emitter emitting particles from the inside of a cone.
  14769. * It emits the particles alongside the cone volume from the base to the particle.
  14770. * The emission direction might be randomized.
  14771. */
  14772. export class ConeParticleEmitter implements IParticleEmitterType {
  14773. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14774. directionRandomizer: number;
  14775. private _radius;
  14776. private _angle;
  14777. private _height;
  14778. /**
  14779. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  14780. */
  14781. radiusRange: number;
  14782. /**
  14783. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  14784. */
  14785. heightRange: number;
  14786. /**
  14787. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  14788. */
  14789. emitFromSpawnPointOnly: boolean;
  14790. /**
  14791. * Gets or sets the radius of the emission cone
  14792. */
  14793. radius: number;
  14794. /**
  14795. * Gets or sets the angle of the emission cone
  14796. */
  14797. angle: number;
  14798. private _buildHeight;
  14799. /**
  14800. * Creates a new instance ConeParticleEmitter
  14801. * @param radius the radius of the emission cone (1 by default)
  14802. * @param angles the cone base angle (PI by default)
  14803. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  14804. */
  14805. constructor(radius?: number, angle?: number,
  14806. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14807. directionRandomizer?: number);
  14808. /**
  14809. * Called by the particle System when the direction is computed for the created particle.
  14810. * @param worldMatrix is the world matrix of the particle system
  14811. * @param directionToUpdate is the direction vector to update with the result
  14812. * @param particle is the particle we are computed the direction for
  14813. */
  14814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14815. /**
  14816. * Called by the particle System when the position is computed for the created particle.
  14817. * @param worldMatrix is the world matrix of the particle system
  14818. * @param positionToUpdate is the position vector to update with the result
  14819. * @param particle is the particle we are computed the position for
  14820. */
  14821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14822. /**
  14823. * Clones the current emitter and returns a copy of it
  14824. * @returns the new emitter
  14825. */
  14826. clone(): ConeParticleEmitter;
  14827. /**
  14828. * Called by the GPUParticleSystem to setup the update shader
  14829. * @param effect defines the update shader
  14830. */
  14831. applyToShader(effect: Effect): void;
  14832. /**
  14833. * Returns a string to use to update the GPU particles update shader
  14834. * @returns a string containng the defines string
  14835. */
  14836. getEffectDefines(): string;
  14837. /**
  14838. * Returns the string "ConeParticleEmitter"
  14839. * @returns a string containing the class name
  14840. */
  14841. getClassName(): string;
  14842. /**
  14843. * Serializes the particle system to a JSON object.
  14844. * @returns the JSON object
  14845. */
  14846. serialize(): any;
  14847. /**
  14848. * Parse properties from a JSON object
  14849. * @param serializationObject defines the JSON object
  14850. */
  14851. parse(serializationObject: any): void;
  14852. }
  14853. }
  14854. declare module BABYLON {
  14855. /**
  14856. * Particle emitter emitting particles from the inside of a cylinder.
  14857. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  14858. */
  14859. export class CylinderParticleEmitter implements IParticleEmitterType {
  14860. /**
  14861. * The radius of the emission cylinder.
  14862. */
  14863. radius: number;
  14864. /**
  14865. * The height of the emission cylinder.
  14866. */
  14867. height: number;
  14868. /**
  14869. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14870. */
  14871. radiusRange: number;
  14872. /**
  14873. * How much to randomize the particle direction [0-1].
  14874. */
  14875. directionRandomizer: number;
  14876. /**
  14877. * Creates a new instance CylinderParticleEmitter
  14878. * @param radius the radius of the emission cylinder (1 by default)
  14879. * @param height the height of the emission cylinder (1 by default)
  14880. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14881. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14882. */
  14883. constructor(
  14884. /**
  14885. * The radius of the emission cylinder.
  14886. */
  14887. radius?: number,
  14888. /**
  14889. * The height of the emission cylinder.
  14890. */
  14891. height?: number,
  14892. /**
  14893. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14894. */
  14895. radiusRange?: number,
  14896. /**
  14897. * How much to randomize the particle direction [0-1].
  14898. */
  14899. directionRandomizer?: number);
  14900. /**
  14901. * Called by the particle System when the direction is computed for the created particle.
  14902. * @param worldMatrix is the world matrix of the particle system
  14903. * @param directionToUpdate is the direction vector to update with the result
  14904. * @param particle is the particle we are computed the direction for
  14905. */
  14906. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14907. /**
  14908. * Called by the particle System when the position is computed for the created particle.
  14909. * @param worldMatrix is the world matrix of the particle system
  14910. * @param positionToUpdate is the position vector to update with the result
  14911. * @param particle is the particle we are computed the position for
  14912. */
  14913. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14914. /**
  14915. * Clones the current emitter and returns a copy of it
  14916. * @returns the new emitter
  14917. */
  14918. clone(): CylinderParticleEmitter;
  14919. /**
  14920. * Called by the GPUParticleSystem to setup the update shader
  14921. * @param effect defines the update shader
  14922. */
  14923. applyToShader(effect: Effect): void;
  14924. /**
  14925. * Returns a string to use to update the GPU particles update shader
  14926. * @returns a string containng the defines string
  14927. */
  14928. getEffectDefines(): string;
  14929. /**
  14930. * Returns the string "CylinderParticleEmitter"
  14931. * @returns a string containing the class name
  14932. */
  14933. getClassName(): string;
  14934. /**
  14935. * Serializes the particle system to a JSON object.
  14936. * @returns the JSON object
  14937. */
  14938. serialize(): any;
  14939. /**
  14940. * Parse properties from a JSON object
  14941. * @param serializationObject defines the JSON object
  14942. */
  14943. parse(serializationObject: any): void;
  14944. }
  14945. /**
  14946. * Particle emitter emitting particles from the inside of a cylinder.
  14947. * It emits the particles randomly between two vectors.
  14948. */
  14949. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  14950. /**
  14951. * The min limit of the emission direction.
  14952. */
  14953. direction1: Vector3;
  14954. /**
  14955. * The max limit of the emission direction.
  14956. */
  14957. direction2: Vector3;
  14958. /**
  14959. * Creates a new instance CylinderDirectedParticleEmitter
  14960. * @param radius the radius of the emission cylinder (1 by default)
  14961. * @param height the height of the emission cylinder (1 by default)
  14962. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14963. * @param direction1 the min limit of the emission direction (up vector by default)
  14964. * @param direction2 the max limit of the emission direction (up vector by default)
  14965. */
  14966. constructor(radius?: number, height?: number, radiusRange?: number,
  14967. /**
  14968. * The min limit of the emission direction.
  14969. */
  14970. direction1?: Vector3,
  14971. /**
  14972. * The max limit of the emission direction.
  14973. */
  14974. direction2?: Vector3);
  14975. /**
  14976. * Called by the particle System when the direction is computed for the created particle.
  14977. * @param worldMatrix is the world matrix of the particle system
  14978. * @param directionToUpdate is the direction vector to update with the result
  14979. * @param particle is the particle we are computed the direction for
  14980. */
  14981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14982. /**
  14983. * Clones the current emitter and returns a copy of it
  14984. * @returns the new emitter
  14985. */
  14986. clone(): CylinderDirectedParticleEmitter;
  14987. /**
  14988. * Called by the GPUParticleSystem to setup the update shader
  14989. * @param effect defines the update shader
  14990. */
  14991. applyToShader(effect: Effect): void;
  14992. /**
  14993. * Returns a string to use to update the GPU particles update shader
  14994. * @returns a string containng the defines string
  14995. */
  14996. getEffectDefines(): string;
  14997. /**
  14998. * Returns the string "CylinderDirectedParticleEmitter"
  14999. * @returns a string containing the class name
  15000. */
  15001. getClassName(): string;
  15002. /**
  15003. * Serializes the particle system to a JSON object.
  15004. * @returns the JSON object
  15005. */
  15006. serialize(): any;
  15007. /**
  15008. * Parse properties from a JSON object
  15009. * @param serializationObject defines the JSON object
  15010. */
  15011. parse(serializationObject: any): void;
  15012. }
  15013. }
  15014. declare module BABYLON {
  15015. /**
  15016. * Particle emitter emitting particles from the inside of a hemisphere.
  15017. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15018. */
  15019. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15020. /**
  15021. * The radius of the emission hemisphere.
  15022. */
  15023. radius: number;
  15024. /**
  15025. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15026. */
  15027. radiusRange: number;
  15028. /**
  15029. * How much to randomize the particle direction [0-1].
  15030. */
  15031. directionRandomizer: number;
  15032. /**
  15033. * Creates a new instance HemisphericParticleEmitter
  15034. * @param radius the radius of the emission hemisphere (1 by default)
  15035. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15036. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15037. */
  15038. constructor(
  15039. /**
  15040. * The radius of the emission hemisphere.
  15041. */
  15042. radius?: number,
  15043. /**
  15044. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15045. */
  15046. radiusRange?: number,
  15047. /**
  15048. * How much to randomize the particle direction [0-1].
  15049. */
  15050. directionRandomizer?: number);
  15051. /**
  15052. * Called by the particle System when the direction is computed for the created particle.
  15053. * @param worldMatrix is the world matrix of the particle system
  15054. * @param directionToUpdate is the direction vector to update with the result
  15055. * @param particle is the particle we are computed the direction for
  15056. */
  15057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15058. /**
  15059. * Called by the particle System when the position is computed for the created particle.
  15060. * @param worldMatrix is the world matrix of the particle system
  15061. * @param positionToUpdate is the position vector to update with the result
  15062. * @param particle is the particle we are computed the position for
  15063. */
  15064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15065. /**
  15066. * Clones the current emitter and returns a copy of it
  15067. * @returns the new emitter
  15068. */
  15069. clone(): HemisphericParticleEmitter;
  15070. /**
  15071. * Called by the GPUParticleSystem to setup the update shader
  15072. * @param effect defines the update shader
  15073. */
  15074. applyToShader(effect: Effect): void;
  15075. /**
  15076. * Returns a string to use to update the GPU particles update shader
  15077. * @returns a string containng the defines string
  15078. */
  15079. getEffectDefines(): string;
  15080. /**
  15081. * Returns the string "HemisphericParticleEmitter"
  15082. * @returns a string containing the class name
  15083. */
  15084. getClassName(): string;
  15085. /**
  15086. * Serializes the particle system to a JSON object.
  15087. * @returns the JSON object
  15088. */
  15089. serialize(): any;
  15090. /**
  15091. * Parse properties from a JSON object
  15092. * @param serializationObject defines the JSON object
  15093. */
  15094. parse(serializationObject: any): void;
  15095. }
  15096. }
  15097. declare module BABYLON {
  15098. /**
  15099. * Particle emitter emitting particles from a point.
  15100. * It emits the particles randomly between 2 given directions.
  15101. */
  15102. export class PointParticleEmitter implements IParticleEmitterType {
  15103. /**
  15104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15105. */
  15106. direction1: Vector3;
  15107. /**
  15108. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15109. */
  15110. direction2: Vector3;
  15111. /**
  15112. * Creates a new instance PointParticleEmitter
  15113. */
  15114. constructor();
  15115. /**
  15116. * Called by the particle System when the direction is computed for the created particle.
  15117. * @param worldMatrix is the world matrix of the particle system
  15118. * @param directionToUpdate is the direction vector to update with the result
  15119. * @param particle is the particle we are computed the direction for
  15120. */
  15121. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15122. /**
  15123. * Called by the particle System when the position is computed for the created particle.
  15124. * @param worldMatrix is the world matrix of the particle system
  15125. * @param positionToUpdate is the position vector to update with the result
  15126. * @param particle is the particle we are computed the position for
  15127. */
  15128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15129. /**
  15130. * Clones the current emitter and returns a copy of it
  15131. * @returns the new emitter
  15132. */
  15133. clone(): PointParticleEmitter;
  15134. /**
  15135. * Called by the GPUParticleSystem to setup the update shader
  15136. * @param effect defines the update shader
  15137. */
  15138. applyToShader(effect: Effect): void;
  15139. /**
  15140. * Returns a string to use to update the GPU particles update shader
  15141. * @returns a string containng the defines string
  15142. */
  15143. getEffectDefines(): string;
  15144. /**
  15145. * Returns the string "PointParticleEmitter"
  15146. * @returns a string containing the class name
  15147. */
  15148. getClassName(): string;
  15149. /**
  15150. * Serializes the particle system to a JSON object.
  15151. * @returns the JSON object
  15152. */
  15153. serialize(): any;
  15154. /**
  15155. * Parse properties from a JSON object
  15156. * @param serializationObject defines the JSON object
  15157. */
  15158. parse(serializationObject: any): void;
  15159. }
  15160. }
  15161. declare module BABYLON {
  15162. /**
  15163. * Particle emitter emitting particles from the inside of a sphere.
  15164. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15165. */
  15166. export class SphereParticleEmitter implements IParticleEmitterType {
  15167. /**
  15168. * The radius of the emission sphere.
  15169. */
  15170. radius: number;
  15171. /**
  15172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15173. */
  15174. radiusRange: number;
  15175. /**
  15176. * How much to randomize the particle direction [0-1].
  15177. */
  15178. directionRandomizer: number;
  15179. /**
  15180. * Creates a new instance SphereParticleEmitter
  15181. * @param radius the radius of the emission sphere (1 by default)
  15182. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15184. */
  15185. constructor(
  15186. /**
  15187. * The radius of the emission sphere.
  15188. */
  15189. radius?: number,
  15190. /**
  15191. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15192. */
  15193. radiusRange?: number,
  15194. /**
  15195. * How much to randomize the particle direction [0-1].
  15196. */
  15197. directionRandomizer?: number);
  15198. /**
  15199. * Called by the particle System when the direction is computed for the created particle.
  15200. * @param worldMatrix is the world matrix of the particle system
  15201. * @param directionToUpdate is the direction vector to update with the result
  15202. * @param particle is the particle we are computed the direction for
  15203. */
  15204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15205. /**
  15206. * Called by the particle System when the position is computed for the created particle.
  15207. * @param worldMatrix is the world matrix of the particle system
  15208. * @param positionToUpdate is the position vector to update with the result
  15209. * @param particle is the particle we are computed the position for
  15210. */
  15211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15212. /**
  15213. * Clones the current emitter and returns a copy of it
  15214. * @returns the new emitter
  15215. */
  15216. clone(): SphereParticleEmitter;
  15217. /**
  15218. * Called by the GPUParticleSystem to setup the update shader
  15219. * @param effect defines the update shader
  15220. */
  15221. applyToShader(effect: Effect): void;
  15222. /**
  15223. * Returns a string to use to update the GPU particles update shader
  15224. * @returns a string containng the defines string
  15225. */
  15226. getEffectDefines(): string;
  15227. /**
  15228. * Returns the string "SphereParticleEmitter"
  15229. * @returns a string containing the class name
  15230. */
  15231. getClassName(): string;
  15232. /**
  15233. * Serializes the particle system to a JSON object.
  15234. * @returns the JSON object
  15235. */
  15236. serialize(): any;
  15237. /**
  15238. * Parse properties from a JSON object
  15239. * @param serializationObject defines the JSON object
  15240. */
  15241. parse(serializationObject: any): void;
  15242. }
  15243. /**
  15244. * Particle emitter emitting particles from the inside of a sphere.
  15245. * It emits the particles randomly between two vectors.
  15246. */
  15247. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15248. /**
  15249. * The min limit of the emission direction.
  15250. */
  15251. direction1: Vector3;
  15252. /**
  15253. * The max limit of the emission direction.
  15254. */
  15255. direction2: Vector3;
  15256. /**
  15257. * Creates a new instance SphereDirectedParticleEmitter
  15258. * @param radius the radius of the emission sphere (1 by default)
  15259. * @param direction1 the min limit of the emission direction (up vector by default)
  15260. * @param direction2 the max limit of the emission direction (up vector by default)
  15261. */
  15262. constructor(radius?: number,
  15263. /**
  15264. * The min limit of the emission direction.
  15265. */
  15266. direction1?: Vector3,
  15267. /**
  15268. * The max limit of the emission direction.
  15269. */
  15270. direction2?: Vector3);
  15271. /**
  15272. * Called by the particle System when the direction is computed for the created particle.
  15273. * @param worldMatrix is the world matrix of the particle system
  15274. * @param directionToUpdate is the direction vector to update with the result
  15275. * @param particle is the particle we are computed the direction for
  15276. */
  15277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15278. /**
  15279. * Clones the current emitter and returns a copy of it
  15280. * @returns the new emitter
  15281. */
  15282. clone(): SphereDirectedParticleEmitter;
  15283. /**
  15284. * Called by the GPUParticleSystem to setup the update shader
  15285. * @param effect defines the update shader
  15286. */
  15287. applyToShader(effect: Effect): void;
  15288. /**
  15289. * Returns a string to use to update the GPU particles update shader
  15290. * @returns a string containng the defines string
  15291. */
  15292. getEffectDefines(): string;
  15293. /**
  15294. * Returns the string "SphereDirectedParticleEmitter"
  15295. * @returns a string containing the class name
  15296. */
  15297. getClassName(): string;
  15298. /**
  15299. * Serializes the particle system to a JSON object.
  15300. * @returns the JSON object
  15301. */
  15302. serialize(): any;
  15303. /**
  15304. * Parse properties from a JSON object
  15305. * @param serializationObject defines the JSON object
  15306. */
  15307. parse(serializationObject: any): void;
  15308. }
  15309. }
  15310. declare module BABYLON {
  15311. /**
  15312. * Interface representing a particle system in Babylon.js.
  15313. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15314. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15315. */
  15316. export interface IParticleSystem {
  15317. /**
  15318. * List of animations used by the particle system.
  15319. */
  15320. animations: Animation[];
  15321. /**
  15322. * The id of the Particle system.
  15323. */
  15324. id: string;
  15325. /**
  15326. * The name of the Particle system.
  15327. */
  15328. name: string;
  15329. /**
  15330. * The emitter represents the Mesh or position we are attaching the particle system to.
  15331. */
  15332. emitter: Nullable<AbstractMesh | Vector3>;
  15333. /**
  15334. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15335. */
  15336. isBillboardBased: boolean;
  15337. /**
  15338. * The rendering group used by the Particle system to chose when to render.
  15339. */
  15340. renderingGroupId: number;
  15341. /**
  15342. * The layer mask we are rendering the particles through.
  15343. */
  15344. layerMask: number;
  15345. /**
  15346. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15347. */
  15348. updateSpeed: number;
  15349. /**
  15350. * The amount of time the particle system is running (depends of the overall update speed).
  15351. */
  15352. targetStopDuration: number;
  15353. /**
  15354. * The texture used to render each particle. (this can be a spritesheet)
  15355. */
  15356. particleTexture: Nullable<Texture>;
  15357. /**
  15358. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15359. */
  15360. blendMode: number;
  15361. /**
  15362. * Minimum life time of emitting particles.
  15363. */
  15364. minLifeTime: number;
  15365. /**
  15366. * Maximum life time of emitting particles.
  15367. */
  15368. maxLifeTime: number;
  15369. /**
  15370. * Minimum Size of emitting particles.
  15371. */
  15372. minSize: number;
  15373. /**
  15374. * Maximum Size of emitting particles.
  15375. */
  15376. maxSize: number;
  15377. /**
  15378. * Minimum scale of emitting particles on X axis.
  15379. */
  15380. minScaleX: number;
  15381. /**
  15382. * Maximum scale of emitting particles on X axis.
  15383. */
  15384. maxScaleX: number;
  15385. /**
  15386. * Minimum scale of emitting particles on Y axis.
  15387. */
  15388. minScaleY: number;
  15389. /**
  15390. * Maximum scale of emitting particles on Y axis.
  15391. */
  15392. maxScaleY: number;
  15393. /**
  15394. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15395. */
  15396. color1: Color4;
  15397. /**
  15398. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15399. */
  15400. color2: Color4;
  15401. /**
  15402. * Color the particle will have at the end of its lifetime.
  15403. */
  15404. colorDead: Color4;
  15405. /**
  15406. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15407. */
  15408. emitRate: number;
  15409. /**
  15410. * You can use gravity if you want to give an orientation to your particles.
  15411. */
  15412. gravity: Vector3;
  15413. /**
  15414. * Minimum power of emitting particles.
  15415. */
  15416. minEmitPower: number;
  15417. /**
  15418. * Maximum power of emitting particles.
  15419. */
  15420. maxEmitPower: number;
  15421. /**
  15422. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15423. */
  15424. minAngularSpeed: number;
  15425. /**
  15426. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15427. */
  15428. maxAngularSpeed: number;
  15429. /**
  15430. * Gets or sets the minimal initial rotation in radians.
  15431. */
  15432. minInitialRotation: number;
  15433. /**
  15434. * Gets or sets the maximal initial rotation in radians.
  15435. */
  15436. maxInitialRotation: number;
  15437. /**
  15438. * The particle emitter type defines the emitter used by the particle system.
  15439. * It can be for example box, sphere, or cone...
  15440. */
  15441. particleEmitterType: Nullable<IParticleEmitterType>;
  15442. /**
  15443. * Defines the delay in milliseconds before starting the system (0 by default)
  15444. */
  15445. startDelay: number;
  15446. /**
  15447. * 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
  15448. */
  15449. preWarmCycles: number;
  15450. /**
  15451. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15452. */
  15453. preWarmStepOffset: number;
  15454. /**
  15455. * 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)
  15456. */
  15457. spriteCellChangeSpeed: number;
  15458. /**
  15459. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15460. */
  15461. startSpriteCellID: number;
  15462. /**
  15463. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15464. */
  15465. endSpriteCellID: number;
  15466. /**
  15467. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15468. */
  15469. spriteCellWidth: number;
  15470. /**
  15471. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15472. */
  15473. spriteCellHeight: number;
  15474. /**
  15475. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15476. */
  15477. spriteRandomStartCell: boolean;
  15478. /**
  15479. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15480. */
  15481. isAnimationSheetEnabled: boolean;
  15482. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15483. translationPivot: Vector2;
  15484. /**
  15485. * Gets or sets a texture used to add random noise to particle positions
  15486. */
  15487. noiseTexture: Nullable<BaseTexture>;
  15488. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15489. noiseStrength: Vector3;
  15490. /**
  15491. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15492. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15493. */
  15494. billboardMode: number;
  15495. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15496. limitVelocityDamping: number;
  15497. /**
  15498. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15499. */
  15500. beginAnimationOnStart: boolean;
  15501. /**
  15502. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15503. */
  15504. beginAnimationFrom: number;
  15505. /**
  15506. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15507. */
  15508. beginAnimationTo: number;
  15509. /**
  15510. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15511. */
  15512. beginAnimationLoop: boolean;
  15513. /**
  15514. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15515. */
  15516. disposeOnStop: boolean;
  15517. /**
  15518. * Gets the maximum number of particles active at the same time.
  15519. * @returns The max number of active particles.
  15520. */
  15521. getCapacity(): number;
  15522. /**
  15523. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15524. * @returns True if it has been started, otherwise false.
  15525. */
  15526. isStarted(): boolean;
  15527. /**
  15528. * Animates the particle system for this frame.
  15529. */
  15530. animate(): void;
  15531. /**
  15532. * Renders the particle system in its current state.
  15533. * @returns the current number of particles
  15534. */
  15535. render(): number;
  15536. /**
  15537. * Dispose the particle system and frees its associated resources.
  15538. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15539. */
  15540. dispose(disposeTexture?: boolean): void;
  15541. /**
  15542. * Clones the particle system.
  15543. * @param name The name of the cloned object
  15544. * @param newEmitter The new emitter to use
  15545. * @returns the cloned particle system
  15546. */
  15547. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15548. /**
  15549. * Serializes the particle system to a JSON object.
  15550. * @returns the JSON object
  15551. */
  15552. serialize(): any;
  15553. /**
  15554. * Rebuild the particle system
  15555. */
  15556. rebuild(): void;
  15557. /**
  15558. * Starts the particle system and begins to emit
  15559. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15560. */
  15561. start(delay?: number): void;
  15562. /**
  15563. * Stops the particle system.
  15564. */
  15565. stop(): void;
  15566. /**
  15567. * Remove all active particles
  15568. */
  15569. reset(): void;
  15570. /**
  15571. * Is this system ready to be used/rendered
  15572. * @return true if the system is ready
  15573. */
  15574. isReady(): boolean;
  15575. /**
  15576. * Adds a new color gradient
  15577. * @param gradient defines the gradient to use (between 0 and 1)
  15578. * @param color1 defines the color to affect to the specified gradient
  15579. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15580. * @returns the current particle system
  15581. */
  15582. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15583. /**
  15584. * Remove a specific color gradient
  15585. * @param gradient defines the gradient to remove
  15586. * @returns the current particle system
  15587. */
  15588. removeColorGradient(gradient: number): IParticleSystem;
  15589. /**
  15590. * Adds a new size gradient
  15591. * @param gradient defines the gradient to use (between 0 and 1)
  15592. * @param factor defines the size factor to affect to the specified gradient
  15593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15594. * @returns the current particle system
  15595. */
  15596. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15597. /**
  15598. * Remove a specific size gradient
  15599. * @param gradient defines the gradient to remove
  15600. * @returns the current particle system
  15601. */
  15602. removeSizeGradient(gradient: number): IParticleSystem;
  15603. /**
  15604. * Gets the current list of color gradients.
  15605. * You must use addColorGradient and removeColorGradient to udpate this list
  15606. * @returns the list of color gradients
  15607. */
  15608. getColorGradients(): Nullable<Array<ColorGradient>>;
  15609. /**
  15610. * Gets the current list of size gradients.
  15611. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15612. * @returns the list of size gradients
  15613. */
  15614. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15615. /**
  15616. * Gets the current list of angular speed gradients.
  15617. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15618. * @returns the list of angular speed gradients
  15619. */
  15620. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15621. /**
  15622. * Adds a new angular speed gradient
  15623. * @param gradient defines the gradient to use (between 0 and 1)
  15624. * @param factor defines the angular speed to affect to the specified gradient
  15625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15626. * @returns the current particle system
  15627. */
  15628. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15629. /**
  15630. * Remove a specific angular speed gradient
  15631. * @param gradient defines the gradient to remove
  15632. * @returns the current particle system
  15633. */
  15634. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15635. /**
  15636. * Gets the current list of velocity gradients.
  15637. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15638. * @returns the list of velocity gradients
  15639. */
  15640. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15641. /**
  15642. * Adds a new velocity gradient
  15643. * @param gradient defines the gradient to use (between 0 and 1)
  15644. * @param factor defines the velocity to affect to the specified gradient
  15645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15646. * @returns the current particle system
  15647. */
  15648. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15649. /**
  15650. * Remove a specific velocity gradient
  15651. * @param gradient defines the gradient to remove
  15652. * @returns the current particle system
  15653. */
  15654. removeVelocityGradient(gradient: number): IParticleSystem;
  15655. /**
  15656. * Gets the current list of limit velocity gradients.
  15657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15658. * @returns the list of limit velocity gradients
  15659. */
  15660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15661. /**
  15662. * Adds a new limit velocity gradient
  15663. * @param gradient defines the gradient to use (between 0 and 1)
  15664. * @param factor defines the limit velocity to affect to the specified gradient
  15665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15666. * @returns the current particle system
  15667. */
  15668. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15669. /**
  15670. * Remove a specific limit velocity gradient
  15671. * @param gradient defines the gradient to remove
  15672. * @returns the current particle system
  15673. */
  15674. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15675. /**
  15676. * Adds a new drag gradient
  15677. * @param gradient defines the gradient to use (between 0 and 1)
  15678. * @param factor defines the drag to affect to the specified gradient
  15679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15680. * @returns the current particle system
  15681. */
  15682. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15683. /**
  15684. * Remove a specific drag gradient
  15685. * @param gradient defines the gradient to remove
  15686. * @returns the current particle system
  15687. */
  15688. removeDragGradient(gradient: number): IParticleSystem;
  15689. /**
  15690. * Gets the current list of drag gradients.
  15691. * You must use addDragGradient and removeDragGradient to udpate this list
  15692. * @returns the list of drag gradients
  15693. */
  15694. getDragGradients(): Nullable<Array<FactorGradient>>;
  15695. /**
  15696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15697. * @param gradient defines the gradient to use (between 0 and 1)
  15698. * @param factor defines the emit rate to affect to the specified gradient
  15699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15700. * @returns the current particle system
  15701. */
  15702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15703. /**
  15704. * Remove a specific emit rate gradient
  15705. * @param gradient defines the gradient to remove
  15706. * @returns the current particle system
  15707. */
  15708. removeEmitRateGradient(gradient: number): IParticleSystem;
  15709. /**
  15710. * Gets the current list of emit rate gradients.
  15711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15712. * @returns the list of emit rate gradients
  15713. */
  15714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15715. /**
  15716. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15717. * @param gradient defines the gradient to use (between 0 and 1)
  15718. * @param factor defines the start size to affect to the specified gradient
  15719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15720. * @returns the current particle system
  15721. */
  15722. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15723. /**
  15724. * Remove a specific start size gradient
  15725. * @param gradient defines the gradient to remove
  15726. * @returns the current particle system
  15727. */
  15728. removeStartSizeGradient(gradient: number): IParticleSystem;
  15729. /**
  15730. * Gets the current list of start size gradients.
  15731. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15732. * @returns the list of start size gradients
  15733. */
  15734. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15735. /**
  15736. * Adds a new life time gradient
  15737. * @param gradient defines the gradient to use (between 0 and 1)
  15738. * @param factor defines the life time factor to affect to the specified gradient
  15739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15740. * @returns the current particle system
  15741. */
  15742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15743. /**
  15744. * Remove a specific life time gradient
  15745. * @param gradient defines the gradient to remove
  15746. * @returns the current particle system
  15747. */
  15748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15749. /**
  15750. * Gets the current list of life time gradients.
  15751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15752. * @returns the list of life time gradients
  15753. */
  15754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15755. /**
  15756. * Gets the current list of color gradients.
  15757. * You must use addColorGradient and removeColorGradient to udpate this list
  15758. * @returns the list of color gradients
  15759. */
  15760. getColorGradients(): Nullable<Array<ColorGradient>>;
  15761. /**
  15762. * Adds a new ramp gradient used to remap particle colors
  15763. * @param gradient defines the gradient to use (between 0 and 1)
  15764. * @param color defines the color to affect to the specified gradient
  15765. * @returns the current particle system
  15766. */
  15767. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15768. /**
  15769. * Gets the current list of ramp gradients.
  15770. * You must use addRampGradient and removeRampGradient to udpate this list
  15771. * @returns the list of ramp gradients
  15772. */
  15773. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15774. /** Gets or sets a boolean indicating that ramp gradients must be used
  15775. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15776. */
  15777. useRampGradients: boolean;
  15778. /**
  15779. * Adds a new color remap gradient
  15780. * @param gradient defines the gradient to use (between 0 and 1)
  15781. * @param min defines the color remap minimal range
  15782. * @param max defines the color remap maximal range
  15783. * @returns the current particle system
  15784. */
  15785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15786. /**
  15787. * Gets the current list of color remap gradients.
  15788. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15789. * @returns the list of color remap gradients
  15790. */
  15791. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15792. /**
  15793. * Adds a new alpha remap gradient
  15794. * @param gradient defines the gradient to use (between 0 and 1)
  15795. * @param min defines the alpha remap minimal range
  15796. * @param max defines the alpha remap maximal range
  15797. * @returns the current particle system
  15798. */
  15799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15800. /**
  15801. * Gets the current list of alpha remap gradients.
  15802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15803. * @returns the list of alpha remap gradients
  15804. */
  15805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15806. /**
  15807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15810. * @returns the emitter
  15811. */
  15812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15813. /**
  15814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15815. * @param radius The radius of the hemisphere to emit from
  15816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15817. * @returns the emitter
  15818. */
  15819. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15820. /**
  15821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15822. * @param radius The radius of the sphere to emit from
  15823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15824. * @returns the emitter
  15825. */
  15826. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15827. /**
  15828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15829. * @param radius The radius of the sphere to emit from
  15830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15832. * @returns the emitter
  15833. */
  15834. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15835. /**
  15836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15837. * @param radius The radius of the emission cylinder
  15838. * @param height The height of the emission cylinder
  15839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15841. * @returns the emitter
  15842. */
  15843. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15844. /**
  15845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15846. * @param radius The radius of the cylinder to emit from
  15847. * @param height The height of the emission cylinder
  15848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15851. * @returns the emitter
  15852. */
  15853. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15854. /**
  15855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15856. * @param radius The radius of the cone to emit from
  15857. * @param angle The base angle of the cone
  15858. * @returns the emitter
  15859. */
  15860. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15861. /**
  15862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15867. * @returns the emitter
  15868. */
  15869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15870. /**
  15871. * Get hosting scene
  15872. * @returns the scene
  15873. */
  15874. getScene(): Scene;
  15875. }
  15876. }
  15877. declare module BABYLON {
  15878. /**
  15879. * Creates an instance based on a source mesh.
  15880. */
  15881. export class InstancedMesh extends AbstractMesh {
  15882. private _sourceMesh;
  15883. private _currentLOD;
  15884. /** @hidden */
  15885. _indexInSourceMeshInstanceArray: number;
  15886. constructor(name: string, source: Mesh);
  15887. /**
  15888. * Returns the string "InstancedMesh".
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * If the source mesh receives shadows
  15893. */
  15894. readonly receiveShadows: boolean;
  15895. /**
  15896. * The material of the source mesh
  15897. */
  15898. readonly material: Nullable<Material>;
  15899. /**
  15900. * Visibility of the source mesh
  15901. */
  15902. readonly visibility: number;
  15903. /**
  15904. * Skeleton of the source mesh
  15905. */
  15906. readonly skeleton: Nullable<Skeleton>;
  15907. /**
  15908. * Rendering ground id of the source mesh
  15909. */
  15910. renderingGroupId: number;
  15911. /**
  15912. * Returns the total number of vertices (integer).
  15913. */
  15914. getTotalVertices(): number;
  15915. /**
  15916. * Returns a positive integer : the total number of indices in this mesh geometry.
  15917. * @returns the numner of indices or zero if the mesh has no geometry.
  15918. */
  15919. getTotalIndices(): number;
  15920. /**
  15921. * The source mesh of the instance
  15922. */
  15923. readonly sourceMesh: Mesh;
  15924. /**
  15925. * Is this node ready to be used/rendered
  15926. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15927. * @return {boolean} is it ready
  15928. */
  15929. isReady(completeCheck?: boolean): boolean;
  15930. /**
  15931. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15932. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15933. * @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.
  15934. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15935. */
  15936. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15937. /**
  15938. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15939. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15940. * The `data` are either a numeric array either a Float32Array.
  15941. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15942. * 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).
  15943. * Note that a new underlying VertexBuffer object is created each call.
  15944. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15945. *
  15946. * Possible `kind` values :
  15947. * - VertexBuffer.PositionKind
  15948. * - VertexBuffer.UVKind
  15949. * - VertexBuffer.UV2Kind
  15950. * - VertexBuffer.UV3Kind
  15951. * - VertexBuffer.UV4Kind
  15952. * - VertexBuffer.UV5Kind
  15953. * - VertexBuffer.UV6Kind
  15954. * - VertexBuffer.ColorKind
  15955. * - VertexBuffer.MatricesIndicesKind
  15956. * - VertexBuffer.MatricesIndicesExtraKind
  15957. * - VertexBuffer.MatricesWeightsKind
  15958. * - VertexBuffer.MatricesWeightsExtraKind
  15959. *
  15960. * Returns the Mesh.
  15961. */
  15962. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15963. /**
  15964. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15965. * If the mesh has no geometry, it is simply returned as it is.
  15966. * The `data` are either a numeric array either a Float32Array.
  15967. * No new underlying VertexBuffer object is created.
  15968. * 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.
  15969. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15970. *
  15971. * Possible `kind` values :
  15972. * - VertexBuffer.PositionKind
  15973. * - VertexBuffer.UVKind
  15974. * - VertexBuffer.UV2Kind
  15975. * - VertexBuffer.UV3Kind
  15976. * - VertexBuffer.UV4Kind
  15977. * - VertexBuffer.UV5Kind
  15978. * - VertexBuffer.UV6Kind
  15979. * - VertexBuffer.ColorKind
  15980. * - VertexBuffer.MatricesIndicesKind
  15981. * - VertexBuffer.MatricesIndicesExtraKind
  15982. * - VertexBuffer.MatricesWeightsKind
  15983. * - VertexBuffer.MatricesWeightsExtraKind
  15984. *
  15985. * Returns the Mesh.
  15986. */
  15987. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15988. /**
  15989. * Sets the mesh indices.
  15990. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15991. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15992. * This method creates a new index buffer each call.
  15993. * Returns the Mesh.
  15994. */
  15995. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15996. /**
  15997. * Boolean : True if the mesh owns the requested kind of data.
  15998. */
  15999. isVerticesDataPresent(kind: string): boolean;
  16000. /**
  16001. * Returns an array of indices (IndicesArray).
  16002. */
  16003. getIndices(): Nullable<IndicesArray>;
  16004. readonly _positions: Nullable<Vector3[]>;
  16005. /**
  16006. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16007. * This means the mesh underlying bounding box and sphere are recomputed.
  16008. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16009. * @returns the current mesh
  16010. */
  16011. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16012. /** @hidden */
  16013. _preActivate(): InstancedMesh;
  16014. /** @hidden */
  16015. _activate(renderId: number): InstancedMesh;
  16016. /**
  16017. * Returns the current associated LOD AbstractMesh.
  16018. */
  16019. getLOD(camera: Camera): AbstractMesh;
  16020. /** @hidden */
  16021. _syncSubMeshes(): InstancedMesh;
  16022. /** @hidden */
  16023. _generatePointsArray(): boolean;
  16024. /**
  16025. * Creates a new InstancedMesh from the current mesh.
  16026. * - name (string) : the cloned mesh name
  16027. * - newParent (optional Node) : the optional Node to parent the clone to.
  16028. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16029. *
  16030. * Returns the clone.
  16031. */
  16032. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16033. /**
  16034. * Disposes the InstancedMesh.
  16035. * Returns nothing.
  16036. */
  16037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16038. }
  16039. }
  16040. declare module BABYLON {
  16041. /**
  16042. * Defines the options associated with the creation of a shader material.
  16043. */
  16044. export interface IShaderMaterialOptions {
  16045. /**
  16046. * Does the material work in alpha blend mode
  16047. */
  16048. needAlphaBlending: boolean;
  16049. /**
  16050. * Does the material work in alpha test mode
  16051. */
  16052. needAlphaTesting: boolean;
  16053. /**
  16054. * The list of attribute names used in the shader
  16055. */
  16056. attributes: string[];
  16057. /**
  16058. * The list of unifrom names used in the shader
  16059. */
  16060. uniforms: string[];
  16061. /**
  16062. * The list of UBO names used in the shader
  16063. */
  16064. uniformBuffers: string[];
  16065. /**
  16066. * The list of sampler names used in the shader
  16067. */
  16068. samplers: string[];
  16069. /**
  16070. * The list of defines used in the shader
  16071. */
  16072. defines: string[];
  16073. }
  16074. /**
  16075. * 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.
  16076. *
  16077. * This returned material effects how the mesh will look based on the code in the shaders.
  16078. *
  16079. * @see http://doc.babylonjs.com/how_to/shader_material
  16080. */
  16081. export class ShaderMaterial extends Material {
  16082. private _shaderPath;
  16083. private _options;
  16084. private _textures;
  16085. private _textureArrays;
  16086. private _floats;
  16087. private _ints;
  16088. private _floatsArrays;
  16089. private _colors3;
  16090. private _colors3Arrays;
  16091. private _colors4;
  16092. private _vectors2;
  16093. private _vectors3;
  16094. private _vectors4;
  16095. private _matrices;
  16096. private _matrices3x3;
  16097. private _matrices2x2;
  16098. private _vectors2Arrays;
  16099. private _vectors3Arrays;
  16100. private _cachedWorldViewMatrix;
  16101. private _renderId;
  16102. /**
  16103. * Instantiate a new shader material.
  16104. * 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.
  16105. * This returned material effects how the mesh will look based on the code in the shaders.
  16106. * @see http://doc.babylonjs.com/how_to/shader_material
  16107. * @param name Define the name of the material in the scene
  16108. * @param scene Define the scene the material belongs to
  16109. * @param shaderPath Defines the route to the shader code in one of three ways:
  16110. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16111. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16112. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16113. * @param options Define the options used to create the shader
  16114. */
  16115. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16116. /**
  16117. * Gets the current class name of the material e.g. "ShaderMaterial"
  16118. * Mainly use in serialization.
  16119. * @returns the class name
  16120. */
  16121. getClassName(): string;
  16122. /**
  16123. * Specifies if the material will require alpha blending
  16124. * @returns a boolean specifying if alpha blending is needed
  16125. */
  16126. needAlphaBlending(): boolean;
  16127. /**
  16128. * Specifies if this material should be rendered in alpha test mode
  16129. * @returns a boolean specifying if an alpha test is needed.
  16130. */
  16131. needAlphaTesting(): boolean;
  16132. private _checkUniform;
  16133. /**
  16134. * Set a texture in the shader.
  16135. * @param name Define the name of the uniform samplers as defined in the shader
  16136. * @param texture Define the texture to bind to this sampler
  16137. * @return the material itself allowing "fluent" like uniform updates
  16138. */
  16139. setTexture(name: string, texture: Texture): ShaderMaterial;
  16140. /**
  16141. * Set a texture array in the shader.
  16142. * @param name Define the name of the uniform sampler array as defined in the shader
  16143. * @param textures Define the list of textures to bind to this sampler
  16144. * @return the material itself allowing "fluent" like uniform updates
  16145. */
  16146. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16147. /**
  16148. * Set a float in the shader.
  16149. * @param name Define the name of the uniform as defined in the shader
  16150. * @param value Define the value to give to the uniform
  16151. * @return the material itself allowing "fluent" like uniform updates
  16152. */
  16153. setFloat(name: string, value: number): ShaderMaterial;
  16154. /**
  16155. * Set a int in the shader.
  16156. * @param name Define the name of the uniform as defined in the shader
  16157. * @param value Define the value to give to the uniform
  16158. * @return the material itself allowing "fluent" like uniform updates
  16159. */
  16160. setInt(name: string, value: number): ShaderMaterial;
  16161. /**
  16162. * Set an array of floats in the shader.
  16163. * @param name Define the name of the uniform as defined in the shader
  16164. * @param value Define the value to give to the uniform
  16165. * @return the material itself allowing "fluent" like uniform updates
  16166. */
  16167. setFloats(name: string, value: number[]): ShaderMaterial;
  16168. /**
  16169. * Set a vec3 in the shader from a Color3.
  16170. * @param name Define the name of the uniform as defined in the shader
  16171. * @param value Define the value to give to the uniform
  16172. * @return the material itself allowing "fluent" like uniform updates
  16173. */
  16174. setColor3(name: string, value: Color3): ShaderMaterial;
  16175. /**
  16176. * Set a vec3 array in the shader from a Color3 array.
  16177. * @param name Define the name of the uniform as defined in the shader
  16178. * @param value Define the value to give to the uniform
  16179. * @return the material itself allowing "fluent" like uniform updates
  16180. */
  16181. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16182. /**
  16183. * Set a vec4 in the shader from a Color4.
  16184. * @param name Define the name of the uniform as defined in the shader
  16185. * @param value Define the value to give to the uniform
  16186. * @return the material itself allowing "fluent" like uniform updates
  16187. */
  16188. setColor4(name: string, value: Color4): ShaderMaterial;
  16189. /**
  16190. * Set a vec2 in the shader from a Vector2.
  16191. * @param name Define the name of the uniform as defined in the shader
  16192. * @param value Define the value to give to the uniform
  16193. * @return the material itself allowing "fluent" like uniform updates
  16194. */
  16195. setVector2(name: string, value: Vector2): ShaderMaterial;
  16196. /**
  16197. * Set a vec3 in the shader from a Vector3.
  16198. * @param name Define the name of the uniform as defined in the shader
  16199. * @param value Define the value to give to the uniform
  16200. * @return the material itself allowing "fluent" like uniform updates
  16201. */
  16202. setVector3(name: string, value: Vector3): ShaderMaterial;
  16203. /**
  16204. * Set a vec4 in the shader from a Vector4.
  16205. * @param name Define the name of the uniform as defined in the shader
  16206. * @param value Define the value to give to the uniform
  16207. * @return the material itself allowing "fluent" like uniform updates
  16208. */
  16209. setVector4(name: string, value: Vector4): ShaderMaterial;
  16210. /**
  16211. * Set a mat4 in the shader from a Matrix.
  16212. * @param name Define the name of the uniform as defined in the shader
  16213. * @param value Define the value to give to the uniform
  16214. * @return the material itself allowing "fluent" like uniform updates
  16215. */
  16216. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16217. /**
  16218. * Set a mat3 in the shader from a Float32Array.
  16219. * @param name Define the name of the uniform as defined in the shader
  16220. * @param value Define the value to give to the uniform
  16221. * @return the material itself allowing "fluent" like uniform updates
  16222. */
  16223. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16224. /**
  16225. * Set a mat2 in the shader from a Float32Array.
  16226. * @param name Define the name of the uniform as defined in the shader
  16227. * @param value Define the value to give to the uniform
  16228. * @return the material itself allowing "fluent" like uniform updates
  16229. */
  16230. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16231. /**
  16232. * Set a vec2 array in the shader from a number array.
  16233. * @param name Define the name of the uniform as defined in the shader
  16234. * @param value Define the value to give to the uniform
  16235. * @return the material itself allowing "fluent" like uniform updates
  16236. */
  16237. setArray2(name: string, value: number[]): ShaderMaterial;
  16238. /**
  16239. * Set a vec3 array in the shader from a number array.
  16240. * @param name Define the name of the uniform as defined in the shader
  16241. * @param value Define the value to give to the uniform
  16242. * @return the material itself allowing "fluent" like uniform updates
  16243. */
  16244. setArray3(name: string, value: number[]): ShaderMaterial;
  16245. private _checkCache;
  16246. /**
  16247. * Checks if the material is ready to render the requested mesh
  16248. * @param mesh Define the mesh to render
  16249. * @param useInstances Define whether or not the material is used with instances
  16250. * @returns true if ready, otherwise false
  16251. */
  16252. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16253. /**
  16254. * Binds the world matrix to the material
  16255. * @param world defines the world transformation matrix
  16256. */
  16257. bindOnlyWorldMatrix(world: Matrix): void;
  16258. /**
  16259. * Binds the material to the mesh
  16260. * @param world defines the world transformation matrix
  16261. * @param mesh defines the mesh to bind the material to
  16262. */
  16263. bind(world: Matrix, mesh?: Mesh): void;
  16264. /**
  16265. * Gets the active textures from the material
  16266. * @returns an array of textures
  16267. */
  16268. getActiveTextures(): BaseTexture[];
  16269. /**
  16270. * Specifies if the material uses a texture
  16271. * @param texture defines the texture to check against the material
  16272. * @returns a boolean specifying if the material uses the texture
  16273. */
  16274. hasTexture(texture: BaseTexture): boolean;
  16275. /**
  16276. * Makes a duplicate of the material, and gives it a new name
  16277. * @param name defines the new name for the duplicated material
  16278. * @returns the cloned material
  16279. */
  16280. clone(name: string): ShaderMaterial;
  16281. /**
  16282. * Disposes the material
  16283. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16284. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16285. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16286. */
  16287. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16288. /**
  16289. * Serializes this material in a JSON representation
  16290. * @returns the serialized material object
  16291. */
  16292. serialize(): any;
  16293. /**
  16294. * Creates a shader material from parsed shader material data
  16295. * @param source defines the JSON represnetation of the material
  16296. * @param scene defines the hosting scene
  16297. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16298. * @returns a new material
  16299. */
  16300. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16301. }
  16302. }
  16303. declare module BABYLON {
  16304. /** @hidden */
  16305. export var colorPixelShader: {
  16306. name: string;
  16307. shader: string;
  16308. };
  16309. }
  16310. declare module BABYLON {
  16311. /** @hidden */
  16312. export var colorVertexShader: {
  16313. name: string;
  16314. shader: string;
  16315. };
  16316. }
  16317. declare module BABYLON {
  16318. /**
  16319. * Line mesh
  16320. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16321. */
  16322. export class LinesMesh extends Mesh {
  16323. /**
  16324. * If vertex color should be applied to the mesh
  16325. */
  16326. useVertexColor?: boolean | undefined;
  16327. /**
  16328. * If vertex alpha should be applied to the mesh
  16329. */
  16330. useVertexAlpha?: boolean | undefined;
  16331. /**
  16332. * Color of the line (Default: White)
  16333. */
  16334. color: Color3;
  16335. /**
  16336. * Alpha of the line (Default: 1)
  16337. */
  16338. alpha: number;
  16339. /**
  16340. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16341. * This margin is expressed in world space coordinates, so its value may vary.
  16342. * Default value is 0.1
  16343. */
  16344. intersectionThreshold: number;
  16345. private _colorShader;
  16346. /**
  16347. * Creates a new LinesMesh
  16348. * @param name defines the name
  16349. * @param scene defines the hosting scene
  16350. * @param parent defines the parent mesh if any
  16351. * @param source defines the optional source LinesMesh used to clone data from
  16352. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16353. * When false, achieved by calling a clone(), also passing False.
  16354. * This will make creation of children, recursive.
  16355. * @param useVertexColor defines if this LinesMesh supports vertex color
  16356. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16357. */
  16358. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16359. /**
  16360. * If vertex color should be applied to the mesh
  16361. */
  16362. useVertexColor?: boolean | undefined,
  16363. /**
  16364. * If vertex alpha should be applied to the mesh
  16365. */
  16366. useVertexAlpha?: boolean | undefined);
  16367. /**
  16368. * Returns the string "LineMesh"
  16369. */
  16370. getClassName(): string;
  16371. /**
  16372. * @hidden
  16373. */
  16374. /**
  16375. * @hidden
  16376. */
  16377. material: Material;
  16378. /**
  16379. * @hidden
  16380. */
  16381. readonly checkCollisions: boolean;
  16382. /** @hidden */
  16383. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16384. /** @hidden */
  16385. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16386. /**
  16387. * Disposes of the line mesh
  16388. * @param doNotRecurse If children should be disposed
  16389. */
  16390. dispose(doNotRecurse?: boolean): void;
  16391. /**
  16392. * Returns a new LineMesh object cloned from the current one.
  16393. */
  16394. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16395. /**
  16396. * Creates a new InstancedLinesMesh object from the mesh model.
  16397. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16398. * @param name defines the name of the new instance
  16399. * @returns a new InstancedLinesMesh
  16400. */
  16401. createInstance(name: string): InstancedLinesMesh;
  16402. }
  16403. /**
  16404. * Creates an instance based on a source LinesMesh
  16405. */
  16406. export class InstancedLinesMesh extends InstancedMesh {
  16407. /**
  16408. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16409. * This margin is expressed in world space coordinates, so its value may vary.
  16410. * Initilized with the intersectionThreshold value of the source LinesMesh
  16411. */
  16412. intersectionThreshold: number;
  16413. constructor(name: string, source: LinesMesh);
  16414. /**
  16415. * Returns the string "InstancedLinesMesh".
  16416. */
  16417. getClassName(): string;
  16418. }
  16419. }
  16420. declare module BABYLON {
  16421. /** @hidden */
  16422. export var linePixelShader: {
  16423. name: string;
  16424. shader: string;
  16425. };
  16426. }
  16427. declare module BABYLON {
  16428. /** @hidden */
  16429. export var lineVertexShader: {
  16430. name: string;
  16431. shader: string;
  16432. };
  16433. }
  16434. declare module BABYLON {
  16435. interface AbstractMesh {
  16436. /**
  16437. * Disables the mesh edge rendering mode
  16438. * @returns the currentAbstractMesh
  16439. */
  16440. disableEdgesRendering(): AbstractMesh;
  16441. /**
  16442. * Enables the edge rendering mode on the mesh.
  16443. * This mode makes the mesh edges visible
  16444. * @param epsilon defines the maximal distance between two angles to detect a face
  16445. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16446. * @returns the currentAbstractMesh
  16447. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16448. */
  16449. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16450. /**
  16451. * Gets the edgesRenderer associated with the mesh
  16452. */
  16453. edgesRenderer: Nullable<EdgesRenderer>;
  16454. }
  16455. interface LinesMesh {
  16456. /**
  16457. * Enables the edge rendering mode on the mesh.
  16458. * This mode makes the mesh edges visible
  16459. * @param epsilon defines the maximal distance between two angles to detect a face
  16460. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16461. * @returns the currentAbstractMesh
  16462. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16463. */
  16464. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16465. }
  16466. interface InstancedLinesMesh {
  16467. /**
  16468. * Enables the edge rendering mode on the mesh.
  16469. * This mode makes the mesh edges visible
  16470. * @param epsilon defines the maximal distance between two angles to detect a face
  16471. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16472. * @returns the current InstancedLinesMesh
  16473. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16474. */
  16475. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16476. }
  16477. /**
  16478. * Defines the minimum contract an Edges renderer should follow.
  16479. */
  16480. export interface IEdgesRenderer extends IDisposable {
  16481. /**
  16482. * Gets or sets a boolean indicating if the edgesRenderer is active
  16483. */
  16484. isEnabled: boolean;
  16485. /**
  16486. * Renders the edges of the attached mesh,
  16487. */
  16488. render(): void;
  16489. /**
  16490. * Checks wether or not the edges renderer is ready to render.
  16491. * @return true if ready, otherwise false.
  16492. */
  16493. isReady(): boolean;
  16494. }
  16495. /**
  16496. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16497. */
  16498. export class EdgesRenderer implements IEdgesRenderer {
  16499. /**
  16500. * Define the size of the edges with an orthographic camera
  16501. */
  16502. edgesWidthScalerForOrthographic: number;
  16503. /**
  16504. * Define the size of the edges with a perspective camera
  16505. */
  16506. edgesWidthScalerForPerspective: number;
  16507. protected _source: AbstractMesh;
  16508. protected _linesPositions: number[];
  16509. protected _linesNormals: number[];
  16510. protected _linesIndices: number[];
  16511. protected _epsilon: number;
  16512. protected _indicesCount: number;
  16513. protected _lineShader: ShaderMaterial;
  16514. protected _ib: WebGLBuffer;
  16515. protected _buffers: {
  16516. [key: string]: Nullable<VertexBuffer>;
  16517. };
  16518. protected _checkVerticesInsteadOfIndices: boolean;
  16519. private _meshRebuildObserver;
  16520. private _meshDisposeObserver;
  16521. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16522. isEnabled: boolean;
  16523. /**
  16524. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16525. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16526. * @param source Mesh used to create edges
  16527. * @param epsilon sum of angles in adjacency to check for edge
  16528. * @param checkVerticesInsteadOfIndices
  16529. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16530. */
  16531. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16532. protected _prepareRessources(): void;
  16533. /** @hidden */
  16534. _rebuild(): void;
  16535. /**
  16536. * Releases the required resources for the edges renderer
  16537. */
  16538. dispose(): void;
  16539. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16540. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16541. /**
  16542. * Checks if the pair of p0 and p1 is en edge
  16543. * @param faceIndex
  16544. * @param edge
  16545. * @param faceNormals
  16546. * @param p0
  16547. * @param p1
  16548. * @private
  16549. */
  16550. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16551. /**
  16552. * push line into the position, normal and index buffer
  16553. * @protected
  16554. */
  16555. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16556. /**
  16557. * Generates lines edges from adjacencjes
  16558. * @private
  16559. */
  16560. _generateEdgesLines(): void;
  16561. /**
  16562. * Checks wether or not the edges renderer is ready to render.
  16563. * @return true if ready, otherwise false.
  16564. */
  16565. isReady(): boolean;
  16566. /**
  16567. * Renders the edges of the attached mesh,
  16568. */
  16569. render(): void;
  16570. }
  16571. /**
  16572. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16573. */
  16574. export class LineEdgesRenderer extends EdgesRenderer {
  16575. /**
  16576. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16577. * @param source LineMesh used to generate edges
  16578. * @param epsilon not important (specified angle for edge detection)
  16579. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16580. */
  16581. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16582. /**
  16583. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16584. */
  16585. _generateEdgesLines(): void;
  16586. }
  16587. }
  16588. declare module BABYLON {
  16589. /**
  16590. * This represents the object necessary to create a rendering group.
  16591. * This is exclusively used and created by the rendering manager.
  16592. * To modify the behavior, you use the available helpers in your scene or meshes.
  16593. * @hidden
  16594. */
  16595. export class RenderingGroup {
  16596. index: number;
  16597. private _scene;
  16598. private _opaqueSubMeshes;
  16599. private _transparentSubMeshes;
  16600. private _alphaTestSubMeshes;
  16601. private _depthOnlySubMeshes;
  16602. private _particleSystems;
  16603. private _spriteManagers;
  16604. private _opaqueSortCompareFn;
  16605. private _alphaTestSortCompareFn;
  16606. private _transparentSortCompareFn;
  16607. private _renderOpaque;
  16608. private _renderAlphaTest;
  16609. private _renderTransparent;
  16610. private _edgesRenderers;
  16611. onBeforeTransparentRendering: () => void;
  16612. /**
  16613. * Set the opaque sort comparison function.
  16614. * If null the sub meshes will be render in the order they were created
  16615. */
  16616. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16617. /**
  16618. * Set the alpha test sort comparison function.
  16619. * If null the sub meshes will be render in the order they were created
  16620. */
  16621. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16622. /**
  16623. * Set the transparent sort comparison function.
  16624. * If null the sub meshes will be render in the order they were created
  16625. */
  16626. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16627. /**
  16628. * Creates a new rendering group.
  16629. * @param index The rendering group index
  16630. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16631. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16632. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16633. */
  16634. 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>);
  16635. /**
  16636. * Render all the sub meshes contained in the group.
  16637. * @param customRenderFunction Used to override the default render behaviour of the group.
  16638. * @returns true if rendered some submeshes.
  16639. */
  16640. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16641. /**
  16642. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16643. * @param subMeshes The submeshes to render
  16644. */
  16645. private renderOpaqueSorted;
  16646. /**
  16647. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16648. * @param subMeshes The submeshes to render
  16649. */
  16650. private renderAlphaTestSorted;
  16651. /**
  16652. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16653. * @param subMeshes The submeshes to render
  16654. */
  16655. private renderTransparentSorted;
  16656. /**
  16657. * Renders the submeshes in a specified order.
  16658. * @param subMeshes The submeshes to sort before render
  16659. * @param sortCompareFn The comparison function use to sort
  16660. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16661. * @param transparent Specifies to activate blending if true
  16662. */
  16663. private static renderSorted;
  16664. /**
  16665. * Renders the submeshes in the order they were dispatched (no sort applied).
  16666. * @param subMeshes The submeshes to render
  16667. */
  16668. private static renderUnsorted;
  16669. /**
  16670. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16671. * are rendered back to front if in the same alpha index.
  16672. *
  16673. * @param a The first submesh
  16674. * @param b The second submesh
  16675. * @returns The result of the comparison
  16676. */
  16677. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16678. /**
  16679. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16680. * are rendered back to front.
  16681. *
  16682. * @param a The first submesh
  16683. * @param b The second submesh
  16684. * @returns The result of the comparison
  16685. */
  16686. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16687. /**
  16688. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16689. * are rendered front to back (prevent overdraw).
  16690. *
  16691. * @param a The first submesh
  16692. * @param b The second submesh
  16693. * @returns The result of the comparison
  16694. */
  16695. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16696. /**
  16697. * Resets the different lists of submeshes to prepare a new frame.
  16698. */
  16699. prepare(): void;
  16700. dispose(): void;
  16701. /**
  16702. * Inserts the submesh in its correct queue depending on its material.
  16703. * @param subMesh The submesh to dispatch
  16704. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16705. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16706. */
  16707. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16708. dispatchSprites(spriteManager: ISpriteManager): void;
  16709. dispatchParticles(particleSystem: IParticleSystem): void;
  16710. private _renderParticles;
  16711. private _renderSprites;
  16712. }
  16713. }
  16714. declare module BABYLON {
  16715. /**
  16716. * Interface describing the different options available in the rendering manager
  16717. * regarding Auto Clear between groups.
  16718. */
  16719. export interface IRenderingManagerAutoClearSetup {
  16720. /**
  16721. * Defines whether or not autoclear is enable.
  16722. */
  16723. autoClear: boolean;
  16724. /**
  16725. * Defines whether or not to autoclear the depth buffer.
  16726. */
  16727. depth: boolean;
  16728. /**
  16729. * Defines whether or not to autoclear the stencil buffer.
  16730. */
  16731. stencil: boolean;
  16732. }
  16733. /**
  16734. * This class is used by the onRenderingGroupObservable
  16735. */
  16736. export class RenderingGroupInfo {
  16737. /**
  16738. * The Scene that being rendered
  16739. */
  16740. scene: Scene;
  16741. /**
  16742. * The camera currently used for the rendering pass
  16743. */
  16744. camera: Nullable<Camera>;
  16745. /**
  16746. * The ID of the renderingGroup being processed
  16747. */
  16748. renderingGroupId: number;
  16749. }
  16750. /**
  16751. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16752. * It is enable to manage the different groups as well as the different necessary sort functions.
  16753. * This should not be used directly aside of the few static configurations
  16754. */
  16755. export class RenderingManager {
  16756. /**
  16757. * The max id used for rendering groups (not included)
  16758. */
  16759. static MAX_RENDERINGGROUPS: number;
  16760. /**
  16761. * The min id used for rendering groups (included)
  16762. */
  16763. static MIN_RENDERINGGROUPS: number;
  16764. /**
  16765. * Used to globally prevent autoclearing scenes.
  16766. */
  16767. static AUTOCLEAR: boolean;
  16768. /**
  16769. * @hidden
  16770. */
  16771. _useSceneAutoClearSetup: boolean;
  16772. private _scene;
  16773. private _renderingGroups;
  16774. private _depthStencilBufferAlreadyCleaned;
  16775. private _autoClearDepthStencil;
  16776. private _customOpaqueSortCompareFn;
  16777. private _customAlphaTestSortCompareFn;
  16778. private _customTransparentSortCompareFn;
  16779. private _renderingGroupInfo;
  16780. /**
  16781. * Instantiates a new rendering group for a particular scene
  16782. * @param scene Defines the scene the groups belongs to
  16783. */
  16784. constructor(scene: Scene);
  16785. private _clearDepthStencilBuffer;
  16786. /**
  16787. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16788. * @hidden
  16789. */
  16790. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16791. /**
  16792. * Resets the different information of the group to prepare a new frame
  16793. * @hidden
  16794. */
  16795. reset(): void;
  16796. /**
  16797. * Dispose and release the group and its associated resources.
  16798. * @hidden
  16799. */
  16800. dispose(): void;
  16801. /**
  16802. * Clear the info related to rendering groups preventing retention points during dispose.
  16803. */
  16804. freeRenderingGroups(): void;
  16805. private _prepareRenderingGroup;
  16806. /**
  16807. * Add a sprite manager to the rendering manager in order to render it this frame.
  16808. * @param spriteManager Define the sprite manager to render
  16809. */
  16810. dispatchSprites(spriteManager: ISpriteManager): void;
  16811. /**
  16812. * Add a particle system to the rendering manager in order to render it this frame.
  16813. * @param particleSystem Define the particle system to render
  16814. */
  16815. dispatchParticles(particleSystem: IParticleSystem): void;
  16816. /**
  16817. * Add a submesh to the manager in order to render it this frame
  16818. * @param subMesh The submesh to dispatch
  16819. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16820. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16821. */
  16822. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16823. /**
  16824. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16825. * This allowed control for front to back rendering or reversly depending of the special needs.
  16826. *
  16827. * @param renderingGroupId The rendering group id corresponding to its index
  16828. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16829. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16830. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16831. */
  16832. 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;
  16833. /**
  16834. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16835. *
  16836. * @param renderingGroupId The rendering group id corresponding to its index
  16837. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16838. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16839. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16840. */
  16841. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16842. /**
  16843. * Gets the current auto clear configuration for one rendering group of the rendering
  16844. * manager.
  16845. * @param index the rendering group index to get the information for
  16846. * @returns The auto clear setup for the requested rendering group
  16847. */
  16848. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16849. }
  16850. }
  16851. declare module BABYLON {
  16852. /**
  16853. * This Helps creating a texture that will be created from a camera in your scene.
  16854. * It is basically a dynamic texture that could be used to create special effects for instance.
  16855. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16856. */
  16857. export class RenderTargetTexture extends Texture {
  16858. isCube: boolean;
  16859. /**
  16860. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16861. */
  16862. static readonly REFRESHRATE_RENDER_ONCE: number;
  16863. /**
  16864. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16865. */
  16866. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16867. /**
  16868. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16869. * the central point of your effect and can save a lot of performances.
  16870. */
  16871. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16872. /**
  16873. * Use this predicate to dynamically define the list of mesh you want to render.
  16874. * If set, the renderList property will be overwritten.
  16875. */
  16876. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16877. private _renderList;
  16878. /**
  16879. * Use this list to define the list of mesh you want to render.
  16880. */
  16881. renderList: Nullable<Array<AbstractMesh>>;
  16882. private _hookArray;
  16883. /**
  16884. * Define if particles should be rendered in your texture.
  16885. */
  16886. renderParticles: boolean;
  16887. /**
  16888. * Define if sprites should be rendered in your texture.
  16889. */
  16890. renderSprites: boolean;
  16891. /**
  16892. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16893. */
  16894. coordinatesMode: number;
  16895. /**
  16896. * Define the camera used to render the texture.
  16897. */
  16898. activeCamera: Nullable<Camera>;
  16899. /**
  16900. * Override the render function of the texture with your own one.
  16901. */
  16902. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16903. /**
  16904. * Define if camera post processes should be use while rendering the texture.
  16905. */
  16906. useCameraPostProcesses: boolean;
  16907. /**
  16908. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16909. */
  16910. ignoreCameraViewport: boolean;
  16911. private _postProcessManager;
  16912. private _postProcesses;
  16913. private _resizeObserver;
  16914. /**
  16915. * An event triggered when the texture is unbind.
  16916. */
  16917. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16918. /**
  16919. * An event triggered when the texture is unbind.
  16920. */
  16921. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16922. private _onAfterUnbindObserver;
  16923. /**
  16924. * Set a after unbind callback in the texture.
  16925. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16926. */
  16927. onAfterUnbind: () => void;
  16928. /**
  16929. * An event triggered before rendering the texture
  16930. */
  16931. onBeforeRenderObservable: Observable<number>;
  16932. private _onBeforeRenderObserver;
  16933. /**
  16934. * Set a before render callback in the texture.
  16935. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16936. */
  16937. onBeforeRender: (faceIndex: number) => void;
  16938. /**
  16939. * An event triggered after rendering the texture
  16940. */
  16941. onAfterRenderObservable: Observable<number>;
  16942. private _onAfterRenderObserver;
  16943. /**
  16944. * Set a after render callback in the texture.
  16945. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16946. */
  16947. onAfterRender: (faceIndex: number) => void;
  16948. /**
  16949. * An event triggered after the texture clear
  16950. */
  16951. onClearObservable: Observable<Engine>;
  16952. private _onClearObserver;
  16953. /**
  16954. * Set a clear callback in the texture.
  16955. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16956. */
  16957. onClear: (Engine: Engine) => void;
  16958. /**
  16959. * Define the clear color of the Render Target if it should be different from the scene.
  16960. */
  16961. clearColor: Color4;
  16962. protected _size: number | {
  16963. width: number;
  16964. height: number;
  16965. };
  16966. protected _initialSizeParameter: number | {
  16967. width: number;
  16968. height: number;
  16969. } | {
  16970. ratio: number;
  16971. };
  16972. protected _sizeRatio: Nullable<number>;
  16973. /** @hidden */
  16974. _generateMipMaps: boolean;
  16975. protected _renderingManager: RenderingManager;
  16976. /** @hidden */
  16977. _waitingRenderList: string[];
  16978. protected _doNotChangeAspectRatio: boolean;
  16979. protected _currentRefreshId: number;
  16980. protected _refreshRate: number;
  16981. protected _textureMatrix: Matrix;
  16982. protected _samples: number;
  16983. protected _renderTargetOptions: RenderTargetCreationOptions;
  16984. /**
  16985. * Gets render target creation options that were used.
  16986. */
  16987. readonly renderTargetOptions: RenderTargetCreationOptions;
  16988. protected _engine: Engine;
  16989. protected _onRatioRescale(): void;
  16990. /**
  16991. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16992. * It must define where the camera used to render the texture is set
  16993. */
  16994. boundingBoxPosition: Vector3;
  16995. private _boundingBoxSize;
  16996. /**
  16997. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16998. * When defined, the cubemap will switch to local mode
  16999. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17000. * @example https://www.babylonjs-playground.com/#RNASML
  17001. */
  17002. boundingBoxSize: Vector3;
  17003. /**
  17004. * In case the RTT has been created with a depth texture, get the associated
  17005. * depth texture.
  17006. * Otherwise, return null.
  17007. */
  17008. depthStencilTexture: Nullable<InternalTexture>;
  17009. /**
  17010. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17011. * or used a shadow, depth texture...
  17012. * @param name The friendly name of the texture
  17013. * @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)
  17014. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17015. * @param generateMipMaps True if mip maps need to be generated after render.
  17016. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17017. * @param type The type of the buffer in the RTT (int, half float, float...)
  17018. * @param isCube True if a cube texture needs to be created
  17019. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17020. * @param generateDepthBuffer True to generate a depth buffer
  17021. * @param generateStencilBuffer True to generate a stencil buffer
  17022. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17023. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17024. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17025. */
  17026. constructor(name: string, size: number | {
  17027. width: number;
  17028. height: number;
  17029. } | {
  17030. ratio: number;
  17031. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17032. /**
  17033. * Creates a depth stencil texture.
  17034. * This is only available in WebGL 2 or with the depth texture extension available.
  17035. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17036. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17037. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17038. */
  17039. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17040. private _processSizeParameter;
  17041. /**
  17042. * Define the number of samples to use in case of MSAA.
  17043. * It defaults to one meaning no MSAA has been enabled.
  17044. */
  17045. samples: number;
  17046. /**
  17047. * Resets the refresh counter of the texture and start bak from scratch.
  17048. * Could be useful to regenerate the texture if it is setup to render only once.
  17049. */
  17050. resetRefreshCounter(): void;
  17051. /**
  17052. * Define the refresh rate of the texture or the rendering frequency.
  17053. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17054. */
  17055. refreshRate: number;
  17056. /**
  17057. * Adds a post process to the render target rendering passes.
  17058. * @param postProcess define the post process to add
  17059. */
  17060. addPostProcess(postProcess: PostProcess): void;
  17061. /**
  17062. * Clear all the post processes attached to the render target
  17063. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17064. */
  17065. clearPostProcesses(dispose?: boolean): void;
  17066. /**
  17067. * Remove one of the post process from the list of attached post processes to the texture
  17068. * @param postProcess define the post process to remove from the list
  17069. */
  17070. removePostProcess(postProcess: PostProcess): void;
  17071. /** @hidden */
  17072. _shouldRender(): boolean;
  17073. /**
  17074. * Gets the actual render size of the texture.
  17075. * @returns the width of the render size
  17076. */
  17077. getRenderSize(): number;
  17078. /**
  17079. * Gets the actual render width of the texture.
  17080. * @returns the width of the render size
  17081. */
  17082. getRenderWidth(): number;
  17083. /**
  17084. * Gets the actual render height of the texture.
  17085. * @returns the height of the render size
  17086. */
  17087. getRenderHeight(): number;
  17088. /**
  17089. * Get if the texture can be rescaled or not.
  17090. */
  17091. readonly canRescale: boolean;
  17092. /**
  17093. * Resize the texture using a ratio.
  17094. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17095. */
  17096. scale(ratio: number): void;
  17097. /**
  17098. * Get the texture reflection matrix used to rotate/transform the reflection.
  17099. * @returns the reflection matrix
  17100. */
  17101. getReflectionTextureMatrix(): Matrix;
  17102. /**
  17103. * Resize the texture to a new desired size.
  17104. * Be carrefull as it will recreate all the data in the new texture.
  17105. * @param size Define the new size. It can be:
  17106. * - a number for squared texture,
  17107. * - an object containing { width: number, height: number }
  17108. * - or an object containing a ratio { ratio: number }
  17109. */
  17110. resize(size: number | {
  17111. width: number;
  17112. height: number;
  17113. } | {
  17114. ratio: number;
  17115. }): void;
  17116. /**
  17117. * Renders all the objects from the render list into the texture.
  17118. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17119. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17120. */
  17121. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17122. private _bestReflectionRenderTargetDimension;
  17123. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17124. private renderToTarget;
  17125. /**
  17126. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17127. * This allowed control for front to back rendering or reversly depending of the special needs.
  17128. *
  17129. * @param renderingGroupId The rendering group id corresponding to its index
  17130. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17131. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17132. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17133. */
  17134. 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;
  17135. /**
  17136. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17137. *
  17138. * @param renderingGroupId The rendering group id corresponding to its index
  17139. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17140. */
  17141. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17142. /**
  17143. * Clones the texture.
  17144. * @returns the cloned texture
  17145. */
  17146. clone(): RenderTargetTexture;
  17147. /**
  17148. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17149. * @returns The JSON representation of the texture
  17150. */
  17151. serialize(): any;
  17152. /**
  17153. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17154. */
  17155. disposeFramebufferObjects(): void;
  17156. /**
  17157. * Dispose the texture and release its associated resources.
  17158. */
  17159. dispose(): void;
  17160. /** @hidden */
  17161. _rebuild(): void;
  17162. /**
  17163. * Clear the info related to rendering groups preventing retention point in material dispose.
  17164. */
  17165. freeRenderingGroups(): void;
  17166. }
  17167. }
  17168. declare module BABYLON {
  17169. /**
  17170. * Base class for the main features of a material in Babylon.js
  17171. */
  17172. export class Material implements IAnimatable {
  17173. /**
  17174. * Returns the triangle fill mode
  17175. */
  17176. static readonly TriangleFillMode: number;
  17177. /**
  17178. * Returns the wireframe mode
  17179. */
  17180. static readonly WireFrameFillMode: number;
  17181. /**
  17182. * Returns the point fill mode
  17183. */
  17184. static readonly PointFillMode: number;
  17185. /**
  17186. * Returns the point list draw mode
  17187. */
  17188. static readonly PointListDrawMode: number;
  17189. /**
  17190. * Returns the line list draw mode
  17191. */
  17192. static readonly LineListDrawMode: number;
  17193. /**
  17194. * Returns the line loop draw mode
  17195. */
  17196. static readonly LineLoopDrawMode: number;
  17197. /**
  17198. * Returns the line strip draw mode
  17199. */
  17200. static readonly LineStripDrawMode: number;
  17201. /**
  17202. * Returns the triangle strip draw mode
  17203. */
  17204. static readonly TriangleStripDrawMode: number;
  17205. /**
  17206. * Returns the triangle fan draw mode
  17207. */
  17208. static readonly TriangleFanDrawMode: number;
  17209. /**
  17210. * Stores the clock-wise side orientation
  17211. */
  17212. static readonly ClockWiseSideOrientation: number;
  17213. /**
  17214. * Stores the counter clock-wise side orientation
  17215. */
  17216. static readonly CounterClockWiseSideOrientation: number;
  17217. /**
  17218. * The dirty texture flag value
  17219. */
  17220. static readonly TextureDirtyFlag: number;
  17221. /**
  17222. * The dirty light flag value
  17223. */
  17224. static readonly LightDirtyFlag: number;
  17225. /**
  17226. * The dirty fresnel flag value
  17227. */
  17228. static readonly FresnelDirtyFlag: number;
  17229. /**
  17230. * The dirty attribute flag value
  17231. */
  17232. static readonly AttributesDirtyFlag: number;
  17233. /**
  17234. * The dirty misc flag value
  17235. */
  17236. static readonly MiscDirtyFlag: number;
  17237. /**
  17238. * The all dirty flag value
  17239. */
  17240. static readonly AllDirtyFlag: number;
  17241. /**
  17242. * The ID of the material
  17243. */
  17244. id: string;
  17245. /**
  17246. * Gets or sets the unique id of the material
  17247. */
  17248. uniqueId: number;
  17249. /**
  17250. * The name of the material
  17251. */
  17252. name: string;
  17253. /**
  17254. * Gets or sets user defined metadata
  17255. */
  17256. metadata: any;
  17257. /**
  17258. * For internal use only. Please do not use.
  17259. */
  17260. reservedDataStore: any;
  17261. /**
  17262. * Specifies if the ready state should be checked on each call
  17263. */
  17264. checkReadyOnEveryCall: boolean;
  17265. /**
  17266. * Specifies if the ready state should be checked once
  17267. */
  17268. checkReadyOnlyOnce: boolean;
  17269. /**
  17270. * The state of the material
  17271. */
  17272. state: string;
  17273. /**
  17274. * The alpha value of the material
  17275. */
  17276. protected _alpha: number;
  17277. /**
  17278. * Sets the alpha value of the material
  17279. */
  17280. /**
  17281. * Gets the alpha value of the material
  17282. */
  17283. alpha: number;
  17284. /**
  17285. * Specifies if back face culling is enabled
  17286. */
  17287. protected _backFaceCulling: boolean;
  17288. /**
  17289. * Sets the back-face culling state
  17290. */
  17291. /**
  17292. * Gets the back-face culling state
  17293. */
  17294. backFaceCulling: boolean;
  17295. /**
  17296. * Stores the value for side orientation
  17297. */
  17298. sideOrientation: number;
  17299. /**
  17300. * Callback triggered when the material is compiled
  17301. */
  17302. onCompiled: (effect: Effect) => void;
  17303. /**
  17304. * Callback triggered when an error occurs
  17305. */
  17306. onError: (effect: Effect, errors: string) => void;
  17307. /**
  17308. * Callback triggered to get the render target textures
  17309. */
  17310. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17311. /**
  17312. * Gets a boolean indicating that current material needs to register RTT
  17313. */
  17314. readonly hasRenderTargetTextures: boolean;
  17315. /**
  17316. * Specifies if the material should be serialized
  17317. */
  17318. doNotSerialize: boolean;
  17319. /**
  17320. * @hidden
  17321. */
  17322. _storeEffectOnSubMeshes: boolean;
  17323. /**
  17324. * Stores the animations for the material
  17325. */
  17326. animations: Array<Animation>;
  17327. /**
  17328. * An event triggered when the material is disposed
  17329. */
  17330. onDisposeObservable: Observable<Material>;
  17331. /**
  17332. * An observer which watches for dispose events
  17333. */
  17334. private _onDisposeObserver;
  17335. private _onUnBindObservable;
  17336. /**
  17337. * Called during a dispose event
  17338. */
  17339. onDispose: () => void;
  17340. private _onBindObservable;
  17341. /**
  17342. * An event triggered when the material is bound
  17343. */
  17344. readonly onBindObservable: Observable<AbstractMesh>;
  17345. /**
  17346. * An observer which watches for bind events
  17347. */
  17348. private _onBindObserver;
  17349. /**
  17350. * Called during a bind event
  17351. */
  17352. onBind: (Mesh: AbstractMesh) => void;
  17353. /**
  17354. * An event triggered when the material is unbound
  17355. */
  17356. readonly onUnBindObservable: Observable<Material>;
  17357. /**
  17358. * Stores the value of the alpha mode
  17359. */
  17360. private _alphaMode;
  17361. /**
  17362. * Sets the value of the alpha mode.
  17363. *
  17364. * | Value | Type | Description |
  17365. * | --- | --- | --- |
  17366. * | 0 | ALPHA_DISABLE | |
  17367. * | 1 | ALPHA_ADD | |
  17368. * | 2 | ALPHA_COMBINE | |
  17369. * | 3 | ALPHA_SUBTRACT | |
  17370. * | 4 | ALPHA_MULTIPLY | |
  17371. * | 5 | ALPHA_MAXIMIZED | |
  17372. * | 6 | ALPHA_ONEONE | |
  17373. * | 7 | ALPHA_PREMULTIPLIED | |
  17374. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17375. * | 9 | ALPHA_INTERPOLATE | |
  17376. * | 10 | ALPHA_SCREENMODE | |
  17377. *
  17378. */
  17379. /**
  17380. * Gets the value of the alpha mode
  17381. */
  17382. alphaMode: number;
  17383. /**
  17384. * Stores the state of the need depth pre-pass value
  17385. */
  17386. private _needDepthPrePass;
  17387. /**
  17388. * Sets the need depth pre-pass value
  17389. */
  17390. /**
  17391. * Gets the depth pre-pass value
  17392. */
  17393. needDepthPrePass: boolean;
  17394. /**
  17395. * Specifies if depth writing should be disabled
  17396. */
  17397. disableDepthWrite: boolean;
  17398. /**
  17399. * Specifies if depth writing should be forced
  17400. */
  17401. forceDepthWrite: boolean;
  17402. /**
  17403. * Specifies if there should be a separate pass for culling
  17404. */
  17405. separateCullingPass: boolean;
  17406. /**
  17407. * Stores the state specifing if fog should be enabled
  17408. */
  17409. private _fogEnabled;
  17410. /**
  17411. * Sets the state for enabling fog
  17412. */
  17413. /**
  17414. * Gets the value of the fog enabled state
  17415. */
  17416. fogEnabled: boolean;
  17417. /**
  17418. * Stores the size of points
  17419. */
  17420. pointSize: number;
  17421. /**
  17422. * Stores the z offset value
  17423. */
  17424. zOffset: number;
  17425. /**
  17426. * Gets a value specifying if wireframe mode is enabled
  17427. */
  17428. /**
  17429. * Sets the state of wireframe mode
  17430. */
  17431. wireframe: boolean;
  17432. /**
  17433. * Gets the value specifying if point clouds are enabled
  17434. */
  17435. /**
  17436. * Sets the state of point cloud mode
  17437. */
  17438. pointsCloud: boolean;
  17439. /**
  17440. * Gets the material fill mode
  17441. */
  17442. /**
  17443. * Sets the material fill mode
  17444. */
  17445. fillMode: number;
  17446. /**
  17447. * @hidden
  17448. * Stores the effects for the material
  17449. */
  17450. _effect: Nullable<Effect>;
  17451. /**
  17452. * @hidden
  17453. * Specifies if the material was previously ready
  17454. */
  17455. _wasPreviouslyReady: boolean;
  17456. /**
  17457. * Specifies if uniform buffers should be used
  17458. */
  17459. private _useUBO;
  17460. /**
  17461. * Stores a reference to the scene
  17462. */
  17463. private _scene;
  17464. /**
  17465. * Stores the fill mode state
  17466. */
  17467. private _fillMode;
  17468. /**
  17469. * Specifies if the depth write state should be cached
  17470. */
  17471. private _cachedDepthWriteState;
  17472. /**
  17473. * Stores the uniform buffer
  17474. */
  17475. protected _uniformBuffer: UniformBuffer;
  17476. /** @hidden */
  17477. _indexInSceneMaterialArray: number;
  17478. /** @hidden */
  17479. meshMap: Nullable<{
  17480. [id: string]: AbstractMesh | undefined;
  17481. }>;
  17482. /**
  17483. * Creates a material instance
  17484. * @param name defines the name of the material
  17485. * @param scene defines the scene to reference
  17486. * @param doNotAdd specifies if the material should be added to the scene
  17487. */
  17488. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17489. /**
  17490. * Returns a string representation of the current material
  17491. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17492. * @returns a string with material information
  17493. */
  17494. toString(fullDetails?: boolean): string;
  17495. /**
  17496. * Gets the class name of the material
  17497. * @returns a string with the class name of the material
  17498. */
  17499. getClassName(): string;
  17500. /**
  17501. * Specifies if updates for the material been locked
  17502. */
  17503. readonly isFrozen: boolean;
  17504. /**
  17505. * Locks updates for the material
  17506. */
  17507. freeze(): void;
  17508. /**
  17509. * Unlocks updates for the material
  17510. */
  17511. unfreeze(): void;
  17512. /**
  17513. * Specifies if the material is ready to be used
  17514. * @param mesh defines the mesh to check
  17515. * @param useInstances specifies if instances should be used
  17516. * @returns a boolean indicating if the material is ready to be used
  17517. */
  17518. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17519. /**
  17520. * Specifies that the submesh is ready to be used
  17521. * @param mesh defines the mesh to check
  17522. * @param subMesh defines which submesh to check
  17523. * @param useInstances specifies that instances should be used
  17524. * @returns a boolean indicating that the submesh is ready or not
  17525. */
  17526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17527. /**
  17528. * Returns the material effect
  17529. * @returns the effect associated with the material
  17530. */
  17531. getEffect(): Nullable<Effect>;
  17532. /**
  17533. * Returns the current scene
  17534. * @returns a Scene
  17535. */
  17536. getScene(): Scene;
  17537. /**
  17538. * Specifies if the material will require alpha blending
  17539. * @returns a boolean specifying if alpha blending is needed
  17540. */
  17541. needAlphaBlending(): boolean;
  17542. /**
  17543. * Specifies if the mesh will require alpha blending
  17544. * @param mesh defines the mesh to check
  17545. * @returns a boolean specifying if alpha blending is needed for the mesh
  17546. */
  17547. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17548. /**
  17549. * Specifies if this material should be rendered in alpha test mode
  17550. * @returns a boolean specifying if an alpha test is needed.
  17551. */
  17552. needAlphaTesting(): boolean;
  17553. /**
  17554. * Gets the texture used for the alpha test
  17555. * @returns the texture to use for alpha testing
  17556. */
  17557. getAlphaTestTexture(): Nullable<BaseTexture>;
  17558. /**
  17559. * Marks the material to indicate that it needs to be re-calculated
  17560. */
  17561. markDirty(): void;
  17562. /** @hidden */
  17563. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17564. /**
  17565. * Binds the material to the mesh
  17566. * @param world defines the world transformation matrix
  17567. * @param mesh defines the mesh to bind the material to
  17568. */
  17569. bind(world: Matrix, mesh?: Mesh): void;
  17570. /**
  17571. * Binds the submesh to the material
  17572. * @param world defines the world transformation matrix
  17573. * @param mesh defines the mesh containing the submesh
  17574. * @param subMesh defines the submesh to bind the material to
  17575. */
  17576. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17577. /**
  17578. * Binds the world matrix to the material
  17579. * @param world defines the world transformation matrix
  17580. */
  17581. bindOnlyWorldMatrix(world: Matrix): void;
  17582. /**
  17583. * Binds the scene's uniform buffer to the effect.
  17584. * @param effect defines the effect to bind to the scene uniform buffer
  17585. * @param sceneUbo defines the uniform buffer storing scene data
  17586. */
  17587. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17588. /**
  17589. * Binds the view matrix to the effect
  17590. * @param effect defines the effect to bind the view matrix to
  17591. */
  17592. bindView(effect: Effect): void;
  17593. /**
  17594. * Binds the view projection matrix to the effect
  17595. * @param effect defines the effect to bind the view projection matrix to
  17596. */
  17597. bindViewProjection(effect: Effect): void;
  17598. /**
  17599. * Specifies if material alpha testing should be turned on for the mesh
  17600. * @param mesh defines the mesh to check
  17601. */
  17602. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17603. /**
  17604. * Processes to execute after binding the material to a mesh
  17605. * @param mesh defines the rendered mesh
  17606. */
  17607. protected _afterBind(mesh?: Mesh): void;
  17608. /**
  17609. * Unbinds the material from the mesh
  17610. */
  17611. unbind(): void;
  17612. /**
  17613. * Gets the active textures from the material
  17614. * @returns an array of textures
  17615. */
  17616. getActiveTextures(): BaseTexture[];
  17617. /**
  17618. * Specifies if the material uses a texture
  17619. * @param texture defines the texture to check against the material
  17620. * @returns a boolean specifying if the material uses the texture
  17621. */
  17622. hasTexture(texture: BaseTexture): boolean;
  17623. /**
  17624. * Makes a duplicate of the material, and gives it a new name
  17625. * @param name defines the new name for the duplicated material
  17626. * @returns the cloned material
  17627. */
  17628. clone(name: string): Nullable<Material>;
  17629. /**
  17630. * Gets the meshes bound to the material
  17631. * @returns an array of meshes bound to the material
  17632. */
  17633. getBindedMeshes(): AbstractMesh[];
  17634. /**
  17635. * Force shader compilation
  17636. * @param mesh defines the mesh associated with this material
  17637. * @param onCompiled defines a function to execute once the material is compiled
  17638. * @param options defines the options to configure the compilation
  17639. */
  17640. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17641. clipPlane: boolean;
  17642. }>): void;
  17643. /**
  17644. * Force shader compilation
  17645. * @param mesh defines the mesh that will use this material
  17646. * @param options defines additional options for compiling the shaders
  17647. * @returns a promise that resolves when the compilation completes
  17648. */
  17649. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17650. clipPlane: boolean;
  17651. }>): Promise<void>;
  17652. private static readonly _ImageProcessingDirtyCallBack;
  17653. private static readonly _TextureDirtyCallBack;
  17654. private static readonly _FresnelDirtyCallBack;
  17655. private static readonly _MiscDirtyCallBack;
  17656. private static readonly _LightsDirtyCallBack;
  17657. private static readonly _AttributeDirtyCallBack;
  17658. private static _FresnelAndMiscDirtyCallBack;
  17659. private static _TextureAndMiscDirtyCallBack;
  17660. private static readonly _DirtyCallbackArray;
  17661. private static readonly _RunDirtyCallBacks;
  17662. /**
  17663. * Marks a define in the material to indicate that it needs to be re-computed
  17664. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17665. */
  17666. markAsDirty(flag: number): void;
  17667. /**
  17668. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17669. * @param func defines a function which checks material defines against the submeshes
  17670. */
  17671. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17672. /**
  17673. * Indicates that image processing needs to be re-calculated for all submeshes
  17674. */
  17675. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17676. /**
  17677. * Indicates that textures need to be re-calculated for all submeshes
  17678. */
  17679. protected _markAllSubMeshesAsTexturesDirty(): void;
  17680. /**
  17681. * Indicates that fresnel needs to be re-calculated for all submeshes
  17682. */
  17683. protected _markAllSubMeshesAsFresnelDirty(): void;
  17684. /**
  17685. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17686. */
  17687. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17688. /**
  17689. * Indicates that lights need to be re-calculated for all submeshes
  17690. */
  17691. protected _markAllSubMeshesAsLightsDirty(): void;
  17692. /**
  17693. * Indicates that attributes need to be re-calculated for all submeshes
  17694. */
  17695. protected _markAllSubMeshesAsAttributesDirty(): void;
  17696. /**
  17697. * Indicates that misc needs to be re-calculated for all submeshes
  17698. */
  17699. protected _markAllSubMeshesAsMiscDirty(): void;
  17700. /**
  17701. * Indicates that textures and misc need to be re-calculated for all submeshes
  17702. */
  17703. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17704. /**
  17705. * Disposes the material
  17706. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17707. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17708. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17709. */
  17710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17711. /** @hidden */
  17712. private releaseVertexArrayObject;
  17713. /**
  17714. * Serializes this material
  17715. * @returns the serialized material object
  17716. */
  17717. serialize(): any;
  17718. /**
  17719. * Creates a material from parsed material data
  17720. * @param parsedMaterial defines parsed material data
  17721. * @param scene defines the hosting scene
  17722. * @param rootUrl defines the root URL to use to load textures
  17723. * @returns a new material
  17724. */
  17725. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17726. }
  17727. }
  17728. declare module BABYLON {
  17729. /**
  17730. * Class used to represent data loading progression
  17731. */
  17732. export class SceneLoaderFlags {
  17733. private static _ForceFullSceneLoadingForIncremental;
  17734. private static _ShowLoadingScreen;
  17735. private static _CleanBoneMatrixWeights;
  17736. private static _loggingLevel;
  17737. /**
  17738. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  17739. */
  17740. static ForceFullSceneLoadingForIncremental: boolean;
  17741. /**
  17742. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  17743. */
  17744. static ShowLoadingScreen: boolean;
  17745. /**
  17746. * Defines the current logging level (while loading the scene)
  17747. * @ignorenaming
  17748. */
  17749. static loggingLevel: number;
  17750. /**
  17751. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  17752. */
  17753. static CleanBoneMatrixWeights: boolean;
  17754. }
  17755. }
  17756. declare module BABYLON {
  17757. /**
  17758. * Defines a target to use with MorphTargetManager
  17759. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17760. */
  17761. export class MorphTarget implements IAnimatable {
  17762. /** defines the name of the target */
  17763. name: string;
  17764. /**
  17765. * Gets or sets the list of animations
  17766. */
  17767. animations: Animation[];
  17768. private _scene;
  17769. private _positions;
  17770. private _normals;
  17771. private _tangents;
  17772. private _influence;
  17773. /**
  17774. * Observable raised when the influence changes
  17775. */
  17776. onInfluenceChanged: Observable<boolean>;
  17777. /** @hidden */
  17778. _onDataLayoutChanged: Observable<void>;
  17779. /**
  17780. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17781. */
  17782. influence: number;
  17783. /**
  17784. * Gets or sets the id of the morph Target
  17785. */
  17786. id: string;
  17787. private _animationPropertiesOverride;
  17788. /**
  17789. * Gets or sets the animation properties override
  17790. */
  17791. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  17792. /**
  17793. * Creates a new MorphTarget
  17794. * @param name defines the name of the target
  17795. * @param influence defines the influence to use
  17796. */
  17797. constructor(
  17798. /** defines the name of the target */
  17799. name: string, influence?: number, scene?: Nullable<Scene>);
  17800. /**
  17801. * Gets a boolean defining if the target contains position data
  17802. */
  17803. readonly hasPositions: boolean;
  17804. /**
  17805. * Gets a boolean defining if the target contains normal data
  17806. */
  17807. readonly hasNormals: boolean;
  17808. /**
  17809. * Gets a boolean defining if the target contains tangent data
  17810. */
  17811. readonly hasTangents: boolean;
  17812. /**
  17813. * Affects position data to this target
  17814. * @param data defines the position data to use
  17815. */
  17816. setPositions(data: Nullable<FloatArray>): void;
  17817. /**
  17818. * Gets the position data stored in this target
  17819. * @returns a FloatArray containing the position data (or null if not present)
  17820. */
  17821. getPositions(): Nullable<FloatArray>;
  17822. /**
  17823. * Affects normal data to this target
  17824. * @param data defines the normal data to use
  17825. */
  17826. setNormals(data: Nullable<FloatArray>): void;
  17827. /**
  17828. * Gets the normal data stored in this target
  17829. * @returns a FloatArray containing the normal data (or null if not present)
  17830. */
  17831. getNormals(): Nullable<FloatArray>;
  17832. /**
  17833. * Affects tangent data to this target
  17834. * @param data defines the tangent data to use
  17835. */
  17836. setTangents(data: Nullable<FloatArray>): void;
  17837. /**
  17838. * Gets the tangent data stored in this target
  17839. * @returns a FloatArray containing the tangent data (or null if not present)
  17840. */
  17841. getTangents(): Nullable<FloatArray>;
  17842. /**
  17843. * Serializes the current target into a Serialization object
  17844. * @returns the serialized object
  17845. */
  17846. serialize(): any;
  17847. /**
  17848. * Returns the string "MorphTarget"
  17849. * @returns "MorphTarget"
  17850. */
  17851. getClassName(): string;
  17852. /**
  17853. * Creates a new target from serialized data
  17854. * @param serializationObject defines the serialized data to use
  17855. * @returns a new MorphTarget
  17856. */
  17857. static Parse(serializationObject: any): MorphTarget;
  17858. /**
  17859. * Creates a MorphTarget from mesh data
  17860. * @param mesh defines the source mesh
  17861. * @param name defines the name to use for the new target
  17862. * @param influence defines the influence to attach to the target
  17863. * @returns a new MorphTarget
  17864. */
  17865. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17866. }
  17867. }
  17868. declare module BABYLON {
  17869. /**
  17870. * This class is used to deform meshes using morphing between different targets
  17871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17872. */
  17873. export class MorphTargetManager {
  17874. private _targets;
  17875. private _targetInfluenceChangedObservers;
  17876. private _targetDataLayoutChangedObservers;
  17877. private _activeTargets;
  17878. private _scene;
  17879. private _influences;
  17880. private _supportsNormals;
  17881. private _supportsTangents;
  17882. private _vertexCount;
  17883. private _uniqueId;
  17884. private _tempInfluences;
  17885. /**
  17886. * Creates a new MorphTargetManager
  17887. * @param scene defines the current scene
  17888. */
  17889. constructor(scene?: Nullable<Scene>);
  17890. /**
  17891. * Gets the unique ID of this manager
  17892. */
  17893. readonly uniqueId: number;
  17894. /**
  17895. * Gets the number of vertices handled by this manager
  17896. */
  17897. readonly vertexCount: number;
  17898. /**
  17899. * Gets a boolean indicating if this manager supports morphing of normals
  17900. */
  17901. readonly supportsNormals: boolean;
  17902. /**
  17903. * Gets a boolean indicating if this manager supports morphing of tangents
  17904. */
  17905. readonly supportsTangents: boolean;
  17906. /**
  17907. * Gets the number of targets stored in this manager
  17908. */
  17909. readonly numTargets: number;
  17910. /**
  17911. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17912. */
  17913. readonly numInfluencers: number;
  17914. /**
  17915. * Gets the list of influences (one per target)
  17916. */
  17917. readonly influences: Float32Array;
  17918. /**
  17919. * Gets the active target at specified index. An active target is a target with an influence > 0
  17920. * @param index defines the index to check
  17921. * @returns the requested target
  17922. */
  17923. getActiveTarget(index: number): MorphTarget;
  17924. /**
  17925. * Gets the target at specified index
  17926. * @param index defines the index to check
  17927. * @returns the requested target
  17928. */
  17929. getTarget(index: number): MorphTarget;
  17930. /**
  17931. * Add a new target to this manager
  17932. * @param target defines the target to add
  17933. */
  17934. addTarget(target: MorphTarget): void;
  17935. /**
  17936. * Removes a target from the manager
  17937. * @param target defines the target to remove
  17938. */
  17939. removeTarget(target: MorphTarget): void;
  17940. /**
  17941. * Serializes the current manager into a Serialization object
  17942. * @returns the serialized object
  17943. */
  17944. serialize(): any;
  17945. private _syncActiveTargets;
  17946. /**
  17947. * Syncrhonize the targets with all the meshes using this morph target manager
  17948. */
  17949. synchronize(): void;
  17950. /**
  17951. * Creates a new MorphTargetManager from serialized data
  17952. * @param serializationObject defines the serialized data
  17953. * @param scene defines the hosting scene
  17954. * @returns the new MorphTargetManager
  17955. */
  17956. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17957. }
  17958. }
  17959. declare module BABYLON {
  17960. /**
  17961. * Interface for Physics-Joint data
  17962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17963. */
  17964. export interface PhysicsJointData {
  17965. /**
  17966. * The main pivot of the joint
  17967. */
  17968. mainPivot?: Vector3;
  17969. /**
  17970. * The connected pivot of the joint
  17971. */
  17972. connectedPivot?: Vector3;
  17973. /**
  17974. * The main axis of the joint
  17975. */
  17976. mainAxis?: Vector3;
  17977. /**
  17978. * The connected axis of the joint
  17979. */
  17980. connectedAxis?: Vector3;
  17981. /**
  17982. * The collision of the joint
  17983. */
  17984. collision?: boolean;
  17985. /**
  17986. * Native Oimo/Cannon/Energy data
  17987. */
  17988. nativeParams?: any;
  17989. }
  17990. /**
  17991. * This is a holder class for the physics joint created by the physics plugin
  17992. * It holds a set of functions to control the underlying joint
  17993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17994. */
  17995. export class PhysicsJoint {
  17996. /**
  17997. * The type of the physics joint
  17998. */
  17999. type: number;
  18000. /**
  18001. * The data for the physics joint
  18002. */
  18003. jointData: PhysicsJointData;
  18004. private _physicsJoint;
  18005. protected _physicsPlugin: IPhysicsEnginePlugin;
  18006. /**
  18007. * Initializes the physics joint
  18008. * @param type The type of the physics joint
  18009. * @param jointData The data for the physics joint
  18010. */
  18011. constructor(
  18012. /**
  18013. * The type of the physics joint
  18014. */
  18015. type: number,
  18016. /**
  18017. * The data for the physics joint
  18018. */
  18019. jointData: PhysicsJointData);
  18020. /**
  18021. * Gets the physics joint
  18022. */
  18023. /**
  18024. * Sets the physics joint
  18025. */
  18026. physicsJoint: any;
  18027. /**
  18028. * Sets the physics plugin
  18029. */
  18030. physicsPlugin: IPhysicsEnginePlugin;
  18031. /**
  18032. * Execute a function that is physics-plugin specific.
  18033. * @param {Function} func the function that will be executed.
  18034. * It accepts two parameters: the physics world and the physics joint
  18035. */
  18036. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18037. /**
  18038. * Distance-Joint type
  18039. */
  18040. static DistanceJoint: number;
  18041. /**
  18042. * Hinge-Joint type
  18043. */
  18044. static HingeJoint: number;
  18045. /**
  18046. * Ball-and-Socket joint type
  18047. */
  18048. static BallAndSocketJoint: number;
  18049. /**
  18050. * Wheel-Joint type
  18051. */
  18052. static WheelJoint: number;
  18053. /**
  18054. * Slider-Joint type
  18055. */
  18056. static SliderJoint: number;
  18057. /**
  18058. * Prismatic-Joint type
  18059. */
  18060. static PrismaticJoint: number;
  18061. /**
  18062. * Universal-Joint type
  18063. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18064. */
  18065. static UniversalJoint: number;
  18066. /**
  18067. * Hinge-Joint 2 type
  18068. */
  18069. static Hinge2Joint: number;
  18070. /**
  18071. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18072. */
  18073. static PointToPointJoint: number;
  18074. /**
  18075. * Spring-Joint type
  18076. */
  18077. static SpringJoint: number;
  18078. /**
  18079. * Lock-Joint type
  18080. */
  18081. static LockJoint: number;
  18082. }
  18083. /**
  18084. * A class representing a physics distance joint
  18085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18086. */
  18087. export class DistanceJoint extends PhysicsJoint {
  18088. /**
  18089. *
  18090. * @param jointData The data for the Distance-Joint
  18091. */
  18092. constructor(jointData: DistanceJointData);
  18093. /**
  18094. * Update the predefined distance.
  18095. * @param maxDistance The maximum preferred distance
  18096. * @param minDistance The minimum preferred distance
  18097. */
  18098. updateDistance(maxDistance: number, minDistance?: number): void;
  18099. }
  18100. /**
  18101. * Represents a Motor-Enabled Joint
  18102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18103. */
  18104. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18105. /**
  18106. * Initializes the Motor-Enabled Joint
  18107. * @param type The type of the joint
  18108. * @param jointData The physica joint data for the joint
  18109. */
  18110. constructor(type: number, jointData: PhysicsJointData);
  18111. /**
  18112. * Set the motor values.
  18113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18114. * @param force the force to apply
  18115. * @param maxForce max force for this motor.
  18116. */
  18117. setMotor(force?: number, maxForce?: number): void;
  18118. /**
  18119. * Set the motor's limits.
  18120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18121. * @param upperLimit The upper limit of the motor
  18122. * @param lowerLimit The lower limit of the motor
  18123. */
  18124. setLimit(upperLimit: number, lowerLimit?: number): void;
  18125. }
  18126. /**
  18127. * This class represents a single physics Hinge-Joint
  18128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18129. */
  18130. export class HingeJoint extends MotorEnabledJoint {
  18131. /**
  18132. * Initializes the Hinge-Joint
  18133. * @param jointData The joint data for the Hinge-Joint
  18134. */
  18135. constructor(jointData: PhysicsJointData);
  18136. /**
  18137. * Set the motor values.
  18138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18139. * @param {number} force the force to apply
  18140. * @param {number} maxForce max force for this motor.
  18141. */
  18142. setMotor(force?: number, maxForce?: number): void;
  18143. /**
  18144. * Set the motor's limits.
  18145. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18146. * @param upperLimit The upper limit of the motor
  18147. * @param lowerLimit The lower limit of the motor
  18148. */
  18149. setLimit(upperLimit: number, lowerLimit?: number): void;
  18150. }
  18151. /**
  18152. * This class represents a dual hinge physics joint (same as wheel joint)
  18153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18154. */
  18155. export class Hinge2Joint extends MotorEnabledJoint {
  18156. /**
  18157. * Initializes the Hinge2-Joint
  18158. * @param jointData The joint data for the Hinge2-Joint
  18159. */
  18160. constructor(jointData: PhysicsJointData);
  18161. /**
  18162. * Set the motor values.
  18163. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18164. * @param {number} force the force to apply
  18165. * @param {number} maxForce max force for this motor.
  18166. * @param {motorIndex} the motor's index, 0 or 1.
  18167. */
  18168. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18169. /**
  18170. * Set the motor limits.
  18171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18172. * @param {number} upperLimit the upper limit
  18173. * @param {number} lowerLimit lower limit
  18174. * @param {motorIndex} the motor's index, 0 or 1.
  18175. */
  18176. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18177. }
  18178. /**
  18179. * Interface for a motor enabled joint
  18180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18181. */
  18182. export interface IMotorEnabledJoint {
  18183. /**
  18184. * Physics joint
  18185. */
  18186. physicsJoint: any;
  18187. /**
  18188. * Sets the motor of the motor-enabled joint
  18189. * @param force The force of the motor
  18190. * @param maxForce The maximum force of the motor
  18191. * @param motorIndex The index of the motor
  18192. */
  18193. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18194. /**
  18195. * Sets the limit of the motor
  18196. * @param upperLimit The upper limit of the motor
  18197. * @param lowerLimit The lower limit of the motor
  18198. * @param motorIndex The index of the motor
  18199. */
  18200. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18201. }
  18202. /**
  18203. * Joint data for a Distance-Joint
  18204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18205. */
  18206. export interface DistanceJointData extends PhysicsJointData {
  18207. /**
  18208. * Max distance the 2 joint objects can be apart
  18209. */
  18210. maxDistance: number;
  18211. }
  18212. /**
  18213. * Joint data from a spring joint
  18214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18215. */
  18216. export interface SpringJointData extends PhysicsJointData {
  18217. /**
  18218. * Length of the spring
  18219. */
  18220. length: number;
  18221. /**
  18222. * Stiffness of the spring
  18223. */
  18224. stiffness: number;
  18225. /**
  18226. * Damping of the spring
  18227. */
  18228. damping: number;
  18229. /** this callback will be called when applying the force to the impostors. */
  18230. forceApplicationCallback: () => void;
  18231. }
  18232. }
  18233. declare module BABYLON {
  18234. /**
  18235. * Interface used to describe a physics joint
  18236. */
  18237. export interface PhysicsImpostorJoint {
  18238. /** Defines the main impostor to which the joint is linked */
  18239. mainImpostor: PhysicsImpostor;
  18240. /** Defines the impostor that is connected to the main impostor using this joint */
  18241. connectedImpostor: PhysicsImpostor;
  18242. /** Defines the joint itself */
  18243. joint: PhysicsJoint;
  18244. }
  18245. /** @hidden */
  18246. export interface IPhysicsEnginePlugin {
  18247. world: any;
  18248. name: string;
  18249. setGravity(gravity: Vector3): void;
  18250. setTimeStep(timeStep: number): void;
  18251. getTimeStep(): number;
  18252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18253. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18254. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18255. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18256. removePhysicsBody(impostor: PhysicsImpostor): void;
  18257. generateJoint(joint: PhysicsImpostorJoint): void;
  18258. removeJoint(joint: PhysicsImpostorJoint): void;
  18259. isSupported(): boolean;
  18260. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18262. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18263. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18264. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18265. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18266. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18267. getBodyMass(impostor: PhysicsImpostor): number;
  18268. getBodyFriction(impostor: PhysicsImpostor): number;
  18269. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18270. getBodyRestitution(impostor: PhysicsImpostor): number;
  18271. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18272. sleepBody(impostor: PhysicsImpostor): void;
  18273. wakeUpBody(impostor: PhysicsImpostor): void;
  18274. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18275. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18276. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18277. getRadius(impostor: PhysicsImpostor): number;
  18278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18279. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18280. dispose(): void;
  18281. }
  18282. /**
  18283. * Interface used to define a physics engine
  18284. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18285. */
  18286. export interface IPhysicsEngine {
  18287. /**
  18288. * Gets the gravity vector used by the simulation
  18289. */
  18290. gravity: Vector3;
  18291. /**
  18292. * Sets the gravity vector used by the simulation
  18293. * @param gravity defines the gravity vector to use
  18294. */
  18295. setGravity(gravity: Vector3): void;
  18296. /**
  18297. * Set the time step of the physics engine.
  18298. * Default is 1/60.
  18299. * To slow it down, enter 1/600 for example.
  18300. * To speed it up, 1/30
  18301. * @param newTimeStep the new timestep to apply to this world.
  18302. */
  18303. setTimeStep(newTimeStep: number): void;
  18304. /**
  18305. * Get the time step of the physics engine.
  18306. * @returns the current time step
  18307. */
  18308. getTimeStep(): number;
  18309. /**
  18310. * Release all resources
  18311. */
  18312. dispose(): void;
  18313. /**
  18314. * Gets the name of the current physics plugin
  18315. * @returns the name of the plugin
  18316. */
  18317. getPhysicsPluginName(): string;
  18318. /**
  18319. * Adding a new impostor for the impostor tracking.
  18320. * This will be done by the impostor itself.
  18321. * @param impostor the impostor to add
  18322. */
  18323. addImpostor(impostor: PhysicsImpostor): void;
  18324. /**
  18325. * Remove an impostor from the engine.
  18326. * This impostor and its mesh will not longer be updated by the physics engine.
  18327. * @param impostor the impostor to remove
  18328. */
  18329. removeImpostor(impostor: PhysicsImpostor): void;
  18330. /**
  18331. * Add a joint to the physics engine
  18332. * @param mainImpostor defines the main impostor to which the joint is added.
  18333. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18334. * @param joint defines the joint that will connect both impostors.
  18335. */
  18336. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18337. /**
  18338. * Removes a joint from the simulation
  18339. * @param mainImpostor defines the impostor used with the joint
  18340. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18341. * @param joint defines the joint to remove
  18342. */
  18343. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18344. /**
  18345. * Gets the current plugin used to run the simulation
  18346. * @returns current plugin
  18347. */
  18348. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18349. /**
  18350. * Gets the list of physic impostors
  18351. * @returns an array of PhysicsImpostor
  18352. */
  18353. getImpostors(): Array<PhysicsImpostor>;
  18354. /**
  18355. * Gets the impostor for a physics enabled object
  18356. * @param object defines the object impersonated by the impostor
  18357. * @returns the PhysicsImpostor or null if not found
  18358. */
  18359. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18360. /**
  18361. * Gets the impostor for a physics body object
  18362. * @param body defines physics body used by the impostor
  18363. * @returns the PhysicsImpostor or null if not found
  18364. */
  18365. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18366. /**
  18367. * Called by the scene. No need to call it.
  18368. * @param delta defines the timespam between frames
  18369. */
  18370. _step(delta: number): void;
  18371. }
  18372. }
  18373. declare module BABYLON {
  18374. /**
  18375. * The interface for the physics imposter parameters
  18376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18377. */
  18378. export interface PhysicsImpostorParameters {
  18379. /**
  18380. * The mass of the physics imposter
  18381. */
  18382. mass: number;
  18383. /**
  18384. * The friction of the physics imposter
  18385. */
  18386. friction?: number;
  18387. /**
  18388. * The coefficient of restitution of the physics imposter
  18389. */
  18390. restitution?: number;
  18391. /**
  18392. * The native options of the physics imposter
  18393. */
  18394. nativeOptions?: any;
  18395. /**
  18396. * Specifies if the parent should be ignored
  18397. */
  18398. ignoreParent?: boolean;
  18399. /**
  18400. * Specifies if bi-directional transformations should be disabled
  18401. */
  18402. disableBidirectionalTransformation?: boolean;
  18403. }
  18404. /**
  18405. * Interface for a physics-enabled object
  18406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18407. */
  18408. export interface IPhysicsEnabledObject {
  18409. /**
  18410. * The position of the physics-enabled object
  18411. */
  18412. position: Vector3;
  18413. /**
  18414. * The rotation of the physics-enabled object
  18415. */
  18416. rotationQuaternion: Nullable<Quaternion>;
  18417. /**
  18418. * The scale of the physics-enabled object
  18419. */
  18420. scaling: Vector3;
  18421. /**
  18422. * The rotation of the physics-enabled object
  18423. */
  18424. rotation?: Vector3;
  18425. /**
  18426. * The parent of the physics-enabled object
  18427. */
  18428. parent?: any;
  18429. /**
  18430. * The bounding info of the physics-enabled object
  18431. * @returns The bounding info of the physics-enabled object
  18432. */
  18433. getBoundingInfo(): BoundingInfo;
  18434. /**
  18435. * Computes the world matrix
  18436. * @param force Specifies if the world matrix should be computed by force
  18437. * @returns A world matrix
  18438. */
  18439. computeWorldMatrix(force: boolean): Matrix;
  18440. /**
  18441. * Gets the world matrix
  18442. * @returns A world matrix
  18443. */
  18444. getWorldMatrix?(): Matrix;
  18445. /**
  18446. * Gets the child meshes
  18447. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18448. * @returns An array of abstract meshes
  18449. */
  18450. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18451. /**
  18452. * Gets the vertex data
  18453. * @param kind The type of vertex data
  18454. * @returns A nullable array of numbers, or a float32 array
  18455. */
  18456. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18457. /**
  18458. * Gets the indices from the mesh
  18459. * @returns A nullable array of index arrays
  18460. */
  18461. getIndices?(): Nullable<IndicesArray>;
  18462. /**
  18463. * Gets the scene from the mesh
  18464. * @returns the indices array or null
  18465. */
  18466. getScene?(): Scene;
  18467. /**
  18468. * Gets the absolute position from the mesh
  18469. * @returns the absolute position
  18470. */
  18471. getAbsolutePosition(): Vector3;
  18472. /**
  18473. * Gets the absolute pivot point from the mesh
  18474. * @returns the absolute pivot point
  18475. */
  18476. getAbsolutePivotPoint(): Vector3;
  18477. /**
  18478. * Rotates the mesh
  18479. * @param axis The axis of rotation
  18480. * @param amount The amount of rotation
  18481. * @param space The space of the rotation
  18482. * @returns The rotation transform node
  18483. */
  18484. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18485. /**
  18486. * Translates the mesh
  18487. * @param axis The axis of translation
  18488. * @param distance The distance of translation
  18489. * @param space The space of the translation
  18490. * @returns The transform node
  18491. */
  18492. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18493. /**
  18494. * Sets the absolute position of the mesh
  18495. * @param absolutePosition The absolute position of the mesh
  18496. * @returns The transform node
  18497. */
  18498. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18499. /**
  18500. * Gets the class name of the mesh
  18501. * @returns The class name
  18502. */
  18503. getClassName(): string;
  18504. }
  18505. /**
  18506. * Represents a physics imposter
  18507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18508. */
  18509. export class PhysicsImpostor {
  18510. /**
  18511. * The physics-enabled object used as the physics imposter
  18512. */
  18513. object: IPhysicsEnabledObject;
  18514. /**
  18515. * The type of the physics imposter
  18516. */
  18517. type: number;
  18518. private _options;
  18519. private _scene?;
  18520. /**
  18521. * The default object size of the imposter
  18522. */
  18523. static DEFAULT_OBJECT_SIZE: Vector3;
  18524. /**
  18525. * The identity quaternion of the imposter
  18526. */
  18527. static IDENTITY_QUATERNION: Quaternion;
  18528. /** @hidden */
  18529. _pluginData: any;
  18530. private _physicsEngine;
  18531. private _physicsBody;
  18532. private _bodyUpdateRequired;
  18533. private _onBeforePhysicsStepCallbacks;
  18534. private _onAfterPhysicsStepCallbacks;
  18535. /** @hidden */
  18536. _onPhysicsCollideCallbacks: Array<{
  18537. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18538. otherImpostors: Array<PhysicsImpostor>;
  18539. }>;
  18540. private _deltaPosition;
  18541. private _deltaRotation;
  18542. private _deltaRotationConjugated;
  18543. private _parent;
  18544. private _isDisposed;
  18545. private static _tmpVecs;
  18546. private static _tmpQuat;
  18547. /**
  18548. * Specifies if the physics imposter is disposed
  18549. */
  18550. readonly isDisposed: boolean;
  18551. /**
  18552. * Gets the mass of the physics imposter
  18553. */
  18554. mass: number;
  18555. /**
  18556. * Gets the coefficient of friction
  18557. */
  18558. /**
  18559. * Sets the coefficient of friction
  18560. */
  18561. friction: number;
  18562. /**
  18563. * Gets the coefficient of restitution
  18564. */
  18565. /**
  18566. * Sets the coefficient of restitution
  18567. */
  18568. restitution: number;
  18569. /**
  18570. * The unique id of the physics imposter
  18571. * set by the physics engine when adding this impostor to the array
  18572. */
  18573. uniqueId: number;
  18574. private _joints;
  18575. /**
  18576. * Initializes the physics imposter
  18577. * @param object The physics-enabled object used as the physics imposter
  18578. * @param type The type of the physics imposter
  18579. * @param _options The options for the physics imposter
  18580. * @param _scene The Babylon scene
  18581. */
  18582. constructor(
  18583. /**
  18584. * The physics-enabled object used as the physics imposter
  18585. */
  18586. object: IPhysicsEnabledObject,
  18587. /**
  18588. * The type of the physics imposter
  18589. */
  18590. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18591. /**
  18592. * This function will completly initialize this impostor.
  18593. * It will create a new body - but only if this mesh has no parent.
  18594. * If it has, this impostor will not be used other than to define the impostor
  18595. * of the child mesh.
  18596. * @hidden
  18597. */
  18598. _init(): void;
  18599. private _getPhysicsParent;
  18600. /**
  18601. * Should a new body be generated.
  18602. * @returns boolean specifying if body initialization is required
  18603. */
  18604. isBodyInitRequired(): boolean;
  18605. /**
  18606. * Sets the updated scaling
  18607. * @param updated Specifies if the scaling is updated
  18608. */
  18609. setScalingUpdated(): void;
  18610. /**
  18611. * Force a regeneration of this or the parent's impostor's body.
  18612. * Use under cautious - This will remove all joints already implemented.
  18613. */
  18614. forceUpdate(): void;
  18615. /**
  18616. * Gets the body that holds this impostor. Either its own, or its parent.
  18617. */
  18618. /**
  18619. * Set the physics body. Used mainly by the physics engine/plugin
  18620. */
  18621. physicsBody: any;
  18622. /**
  18623. * Get the parent of the physics imposter
  18624. * @returns Physics imposter or null
  18625. */
  18626. /**
  18627. * Sets the parent of the physics imposter
  18628. */
  18629. parent: Nullable<PhysicsImpostor>;
  18630. /**
  18631. * Resets the update flags
  18632. */
  18633. resetUpdateFlags(): void;
  18634. /**
  18635. * Gets the object extend size
  18636. * @returns the object extend size
  18637. */
  18638. getObjectExtendSize(): Vector3;
  18639. /**
  18640. * Gets the object center
  18641. * @returns The object center
  18642. */
  18643. getObjectCenter(): Vector3;
  18644. /**
  18645. * Get a specific parametes from the options parameter
  18646. * @param paramName The object parameter name
  18647. * @returns The object parameter
  18648. */
  18649. getParam(paramName: string): any;
  18650. /**
  18651. * Sets a specific parameter in the options given to the physics plugin
  18652. * @param paramName The parameter name
  18653. * @param value The value of the parameter
  18654. */
  18655. setParam(paramName: string, value: number): void;
  18656. /**
  18657. * Specifically change the body's mass option. Won't recreate the physics body object
  18658. * @param mass The mass of the physics imposter
  18659. */
  18660. setMass(mass: number): void;
  18661. /**
  18662. * Gets the linear velocity
  18663. * @returns linear velocity or null
  18664. */
  18665. getLinearVelocity(): Nullable<Vector3>;
  18666. /**
  18667. * Sets the linear velocity
  18668. * @param velocity linear velocity or null
  18669. */
  18670. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18671. /**
  18672. * Gets the angular velocity
  18673. * @returns angular velocity or null
  18674. */
  18675. getAngularVelocity(): Nullable<Vector3>;
  18676. /**
  18677. * Sets the angular velocity
  18678. * @param velocity The velocity or null
  18679. */
  18680. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18681. /**
  18682. * Execute a function with the physics plugin native code
  18683. * Provide a function the will have two variables - the world object and the physics body object
  18684. * @param func The function to execute with the physics plugin native code
  18685. */
  18686. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18687. /**
  18688. * Register a function that will be executed before the physics world is stepping forward
  18689. * @param func The function to execute before the physics world is stepped forward
  18690. */
  18691. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18692. /**
  18693. * Unregister a function that will be executed before the physics world is stepping forward
  18694. * @param func The function to execute before the physics world is stepped forward
  18695. */
  18696. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18697. /**
  18698. * Register a function that will be executed after the physics step
  18699. * @param func The function to execute after physics step
  18700. */
  18701. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18702. /**
  18703. * Unregisters a function that will be executed after the physics step
  18704. * @param func The function to execute after physics step
  18705. */
  18706. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18707. /**
  18708. * register a function that will be executed when this impostor collides against a different body
  18709. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18710. * @param func Callback that is executed on collision
  18711. */
  18712. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18713. /**
  18714. * Unregisters the physics imposter on contact
  18715. * @param collideAgainst The physics object to collide against
  18716. * @param func Callback to execute on collision
  18717. */
  18718. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18719. private _tmpQuat;
  18720. private _tmpQuat2;
  18721. /**
  18722. * Get the parent rotation
  18723. * @returns The parent rotation
  18724. */
  18725. getParentsRotation(): Quaternion;
  18726. /**
  18727. * this function is executed by the physics engine.
  18728. */
  18729. beforeStep: () => void;
  18730. /**
  18731. * this function is executed by the physics engine
  18732. */
  18733. afterStep: () => void;
  18734. /**
  18735. * Legacy collision detection event support
  18736. */
  18737. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18738. /**
  18739. * event and body object due to cannon's event-based architecture.
  18740. */
  18741. onCollide: (e: {
  18742. body: any;
  18743. }) => void;
  18744. /**
  18745. * Apply a force
  18746. * @param force The force to apply
  18747. * @param contactPoint The contact point for the force
  18748. * @returns The physics imposter
  18749. */
  18750. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18751. /**
  18752. * Apply an impulse
  18753. * @param force The impulse force
  18754. * @param contactPoint The contact point for the impulse force
  18755. * @returns The physics imposter
  18756. */
  18757. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18758. /**
  18759. * A help function to create a joint
  18760. * @param otherImpostor A physics imposter used to create a joint
  18761. * @param jointType The type of joint
  18762. * @param jointData The data for the joint
  18763. * @returns The physics imposter
  18764. */
  18765. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18766. /**
  18767. * Add a joint to this impostor with a different impostor
  18768. * @param otherImpostor A physics imposter used to add a joint
  18769. * @param joint The joint to add
  18770. * @returns The physics imposter
  18771. */
  18772. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18773. /**
  18774. * Will keep this body still, in a sleep mode.
  18775. * @returns the physics imposter
  18776. */
  18777. sleep(): PhysicsImpostor;
  18778. /**
  18779. * Wake the body up.
  18780. * @returns The physics imposter
  18781. */
  18782. wakeUp(): PhysicsImpostor;
  18783. /**
  18784. * Clones the physics imposter
  18785. * @param newObject The physics imposter clones to this physics-enabled object
  18786. * @returns A nullable physics imposter
  18787. */
  18788. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18789. /**
  18790. * Disposes the physics imposter
  18791. */
  18792. dispose(): void;
  18793. /**
  18794. * Sets the delta position
  18795. * @param position The delta position amount
  18796. */
  18797. setDeltaPosition(position: Vector3): void;
  18798. /**
  18799. * Sets the delta rotation
  18800. * @param rotation The delta rotation amount
  18801. */
  18802. setDeltaRotation(rotation: Quaternion): void;
  18803. /**
  18804. * Gets the box size of the physics imposter and stores the result in the input parameter
  18805. * @param result Stores the box size
  18806. * @returns The physics imposter
  18807. */
  18808. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18809. /**
  18810. * Gets the radius of the physics imposter
  18811. * @returns Radius of the physics imposter
  18812. */
  18813. getRadius(): number;
  18814. /**
  18815. * Sync a bone with this impostor
  18816. * @param bone The bone to sync to the impostor.
  18817. * @param boneMesh The mesh that the bone is influencing.
  18818. * @param jointPivot The pivot of the joint / bone in local space.
  18819. * @param distToJoint Optional distance from the impostor to the joint.
  18820. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18821. */
  18822. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18823. /**
  18824. * Sync impostor to a bone
  18825. * @param bone The bone that the impostor will be synced to.
  18826. * @param boneMesh The mesh that the bone is influencing.
  18827. * @param jointPivot The pivot of the joint / bone in local space.
  18828. * @param distToJoint Optional distance from the impostor to the joint.
  18829. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18830. * @param boneAxis Optional vector3 axis the bone is aligned with
  18831. */
  18832. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18833. /**
  18834. * No-Imposter type
  18835. */
  18836. static NoImpostor: number;
  18837. /**
  18838. * Sphere-Imposter type
  18839. */
  18840. static SphereImpostor: number;
  18841. /**
  18842. * Box-Imposter type
  18843. */
  18844. static BoxImpostor: number;
  18845. /**
  18846. * Plane-Imposter type
  18847. */
  18848. static PlaneImpostor: number;
  18849. /**
  18850. * Mesh-imposter type
  18851. */
  18852. static MeshImpostor: number;
  18853. /**
  18854. * Cylinder-Imposter type
  18855. */
  18856. static CylinderImpostor: number;
  18857. /**
  18858. * Particle-Imposter type
  18859. */
  18860. static ParticleImpostor: number;
  18861. /**
  18862. * Heightmap-Imposter type
  18863. */
  18864. static HeightmapImpostor: number;
  18865. }
  18866. }
  18867. declare module BABYLON {
  18868. /**
  18869. * Mesh representing the gorund
  18870. */
  18871. export class GroundMesh extends Mesh {
  18872. /** If octree should be generated */
  18873. generateOctree: boolean;
  18874. private _heightQuads;
  18875. /** @hidden */
  18876. _subdivisionsX: number;
  18877. /** @hidden */
  18878. _subdivisionsY: number;
  18879. /** @hidden */
  18880. _width: number;
  18881. /** @hidden */
  18882. _height: number;
  18883. /** @hidden */
  18884. _minX: number;
  18885. /** @hidden */
  18886. _maxX: number;
  18887. /** @hidden */
  18888. _minZ: number;
  18889. /** @hidden */
  18890. _maxZ: number;
  18891. constructor(name: string, scene: Scene);
  18892. /**
  18893. * "GroundMesh"
  18894. * @returns "GroundMesh"
  18895. */
  18896. getClassName(): string;
  18897. /**
  18898. * The minimum of x and y subdivisions
  18899. */
  18900. readonly subdivisions: number;
  18901. /**
  18902. * X subdivisions
  18903. */
  18904. readonly subdivisionsX: number;
  18905. /**
  18906. * Y subdivisions
  18907. */
  18908. readonly subdivisionsY: number;
  18909. /**
  18910. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18911. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18912. * @param chunksCount the number of subdivisions for x and y
  18913. * @param octreeBlocksSize (Default: 32)
  18914. */
  18915. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18916. /**
  18917. * Returns a height (y) value in the Worl system :
  18918. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18919. * @param x x coordinate
  18920. * @param z z coordinate
  18921. * @returns the ground y position if (x, z) are outside the ground surface.
  18922. */
  18923. getHeightAtCoordinates(x: number, z: number): number;
  18924. /**
  18925. * Returns a normalized vector (Vector3) orthogonal to the ground
  18926. * at the ground coordinates (x, z) expressed in the World system.
  18927. * @param x x coordinate
  18928. * @param z z coordinate
  18929. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18930. */
  18931. getNormalAtCoordinates(x: number, z: number): Vector3;
  18932. /**
  18933. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18934. * at the ground coordinates (x, z) expressed in the World system.
  18935. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18936. * @param x x coordinate
  18937. * @param z z coordinate
  18938. * @param ref vector to store the result
  18939. * @returns the GroundMesh.
  18940. */
  18941. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18942. /**
  18943. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18944. * if the ground has been updated.
  18945. * This can be used in the render loop.
  18946. * @returns the GroundMesh.
  18947. */
  18948. updateCoordinateHeights(): GroundMesh;
  18949. private _getFacetAt;
  18950. private _initHeightQuads;
  18951. private _computeHeightQuads;
  18952. /**
  18953. * Serializes this ground mesh
  18954. * @param serializationObject object to write serialization to
  18955. */
  18956. serialize(serializationObject: any): void;
  18957. /**
  18958. * Parses a serialized ground mesh
  18959. * @param parsedMesh the serialized mesh
  18960. * @param scene the scene to create the ground mesh in
  18961. * @returns the created ground mesh
  18962. */
  18963. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18964. }
  18965. }
  18966. declare module BABYLON {
  18967. /**
  18968. * Class used to represent a specific level of detail of a mesh
  18969. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18970. */
  18971. export class MeshLODLevel {
  18972. /** Defines the distance where this level should star being displayed */
  18973. distance: number;
  18974. /** Defines the mesh to use to render this level */
  18975. mesh: Nullable<Mesh>;
  18976. /**
  18977. * Creates a new LOD level
  18978. * @param distance defines the distance where this level should star being displayed
  18979. * @param mesh defines the mesh to use to render this level
  18980. */
  18981. constructor(
  18982. /** Defines the distance where this level should star being displayed */
  18983. distance: number,
  18984. /** Defines the mesh to use to render this level */
  18985. mesh: Nullable<Mesh>);
  18986. }
  18987. /**
  18988. * @hidden
  18989. **/
  18990. export class _CreationDataStorage {
  18991. closePath?: boolean;
  18992. closeArray?: boolean;
  18993. idx: number[];
  18994. dashSize: number;
  18995. gapSize: number;
  18996. path3D: Path3D;
  18997. pathArray: Vector3[][];
  18998. arc: number;
  18999. radius: number;
  19000. cap: number;
  19001. tessellation: number;
  19002. }
  19003. /**
  19004. * @hidden
  19005. **/
  19006. class _InstanceDataStorage {
  19007. visibleInstances: any;
  19008. renderIdForInstances: number[];
  19009. batchCache: _InstancesBatch;
  19010. instancesBufferSize: number;
  19011. instancesBuffer: Nullable<Buffer>;
  19012. instancesData: Float32Array;
  19013. overridenInstanceCount: number;
  19014. }
  19015. /**
  19016. * @hidden
  19017. **/
  19018. export class _InstancesBatch {
  19019. mustReturn: boolean;
  19020. visibleInstances: Nullable<InstancedMesh[]>[];
  19021. renderSelf: boolean[];
  19022. }
  19023. /**
  19024. * Class used to represent renderable models
  19025. */
  19026. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19027. /**
  19028. * Mesh side orientation : usually the external or front surface
  19029. */
  19030. static readonly FRONTSIDE: number;
  19031. /**
  19032. * Mesh side orientation : usually the internal or back surface
  19033. */
  19034. static readonly BACKSIDE: number;
  19035. /**
  19036. * Mesh side orientation : both internal and external or front and back surfaces
  19037. */
  19038. static readonly DOUBLESIDE: number;
  19039. /**
  19040. * Mesh side orientation : by default, `FRONTSIDE`
  19041. */
  19042. static readonly DEFAULTSIDE: number;
  19043. /**
  19044. * Mesh cap setting : no cap
  19045. */
  19046. static readonly NO_CAP: number;
  19047. /**
  19048. * Mesh cap setting : one cap at the beginning of the mesh
  19049. */
  19050. static readonly CAP_START: number;
  19051. /**
  19052. * Mesh cap setting : one cap at the end of the mesh
  19053. */
  19054. static readonly CAP_END: number;
  19055. /**
  19056. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19057. */
  19058. static readonly CAP_ALL: number;
  19059. private _onBeforeRenderObservable;
  19060. private _onAfterRenderObservable;
  19061. private _onBeforeDrawObservable;
  19062. /**
  19063. * An event triggered before rendering the mesh
  19064. */
  19065. readonly onBeforeRenderObservable: Observable<Mesh>;
  19066. /**
  19067. * An event triggered after rendering the mesh
  19068. */
  19069. readonly onAfterRenderObservable: Observable<Mesh>;
  19070. /**
  19071. * An event triggered before drawing the mesh
  19072. */
  19073. readonly onBeforeDrawObservable: Observable<Mesh>;
  19074. private _onBeforeDrawObserver;
  19075. /**
  19076. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19077. */
  19078. onBeforeDraw: () => void;
  19079. /**
  19080. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19081. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19082. */
  19083. delayLoadState: number;
  19084. /**
  19085. * Gets the list of instances created from this mesh
  19086. * it is not supposed to be modified manually.
  19087. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19088. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19089. */
  19090. instances: InstancedMesh[];
  19091. /**
  19092. * Gets the file containing delay loading data for this mesh
  19093. */
  19094. delayLoadingFile: string;
  19095. /** @hidden */
  19096. _binaryInfo: any;
  19097. private _LODLevels;
  19098. /**
  19099. * User defined function used to change how LOD level selection is done
  19100. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19101. */
  19102. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19103. private _morphTargetManager;
  19104. /**
  19105. * Gets or sets the morph target manager
  19106. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19107. */
  19108. morphTargetManager: Nullable<MorphTargetManager>;
  19109. /** @hidden */
  19110. _creationDataStorage: Nullable<_CreationDataStorage>;
  19111. /** @hidden */
  19112. _geometry: Nullable<Geometry>;
  19113. /** @hidden */
  19114. _delayInfo: Array<string>;
  19115. /** @hidden */
  19116. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19117. /** @hidden */
  19118. _instanceDataStorage: _InstanceDataStorage;
  19119. private _effectiveMaterial;
  19120. /** @hidden */
  19121. _shouldGenerateFlatShading: boolean;
  19122. private _preActivateId;
  19123. /** @hidden */
  19124. _originalBuilderSideOrientation: number;
  19125. /**
  19126. * Use this property to change the original side orientation defined at construction time
  19127. */
  19128. overrideMaterialSideOrientation: Nullable<number>;
  19129. private _areNormalsFrozen;
  19130. private _sourcePositions;
  19131. private _sourceNormals;
  19132. private _source;
  19133. private meshMap;
  19134. /**
  19135. * Gets the source mesh (the one used to clone this one from)
  19136. */
  19137. readonly source: Nullable<Mesh>;
  19138. /**
  19139. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19140. */
  19141. isUnIndexed: boolean;
  19142. /**
  19143. * @constructor
  19144. * @param name The value used by scene.getMeshByName() to do a lookup.
  19145. * @param scene The scene to add this mesh to.
  19146. * @param parent The parent of this mesh, if it has one
  19147. * @param source An optional Mesh from which geometry is shared, cloned.
  19148. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19149. * When false, achieved by calling a clone(), also passing False.
  19150. * This will make creation of children, recursive.
  19151. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19152. */
  19153. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19154. /**
  19155. * Gets the class name
  19156. * @returns the string "Mesh".
  19157. */
  19158. getClassName(): string;
  19159. /** @hidden */
  19160. readonly _isMesh: boolean;
  19161. /**
  19162. * Returns a description of this mesh
  19163. * @param fullDetails define if full details about this mesh must be used
  19164. * @returns a descriptive string representing this mesh
  19165. */
  19166. toString(fullDetails?: boolean): string;
  19167. /** @hidden */
  19168. _unBindEffect(): void;
  19169. /**
  19170. * Gets a boolean indicating if this mesh has LOD
  19171. */
  19172. readonly hasLODLevels: boolean;
  19173. /**
  19174. * Gets the list of MeshLODLevel associated with the current mesh
  19175. * @returns an array of MeshLODLevel
  19176. */
  19177. getLODLevels(): MeshLODLevel[];
  19178. private _sortLODLevels;
  19179. /**
  19180. * Add a mesh as LOD level triggered at the given distance.
  19181. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19182. * @param distance The distance from the center of the object to show this level
  19183. * @param mesh The mesh to be added as LOD level (can be null)
  19184. * @return This mesh (for chaining)
  19185. */
  19186. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19187. /**
  19188. * Returns the LOD level mesh at the passed distance or null if not found.
  19189. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19190. * @param distance The distance from the center of the object to show this level
  19191. * @returns a Mesh or `null`
  19192. */
  19193. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19194. /**
  19195. * Remove a mesh from the LOD array
  19196. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19197. * @param mesh defines the mesh to be removed
  19198. * @return This mesh (for chaining)
  19199. */
  19200. removeLODLevel(mesh: Mesh): Mesh;
  19201. /**
  19202. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19203. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19204. * @param camera defines the camera to use to compute distance
  19205. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19206. * @return This mesh (for chaining)
  19207. */
  19208. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19209. /**
  19210. * Gets the mesh internal Geometry object
  19211. */
  19212. readonly geometry: Nullable<Geometry>;
  19213. /**
  19214. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19215. * @returns the total number of vertices
  19216. */
  19217. getTotalVertices(): number;
  19218. /**
  19219. * Returns the content of an associated vertex buffer
  19220. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19221. * - VertexBuffer.PositionKind
  19222. * - VertexBuffer.UVKind
  19223. * - VertexBuffer.UV2Kind
  19224. * - VertexBuffer.UV3Kind
  19225. * - VertexBuffer.UV4Kind
  19226. * - VertexBuffer.UV5Kind
  19227. * - VertexBuffer.UV6Kind
  19228. * - VertexBuffer.ColorKind
  19229. * - VertexBuffer.MatricesIndicesKind
  19230. * - VertexBuffer.MatricesIndicesExtraKind
  19231. * - VertexBuffer.MatricesWeightsKind
  19232. * - VertexBuffer.MatricesWeightsExtraKind
  19233. * @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
  19234. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19235. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19236. */
  19237. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19238. /**
  19239. * Returns the mesh VertexBuffer object from the requested `kind`
  19240. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19241. * - VertexBuffer.PositionKind
  19242. * - VertexBuffer.UVKind
  19243. * - VertexBuffer.UV2Kind
  19244. * - VertexBuffer.UV3Kind
  19245. * - VertexBuffer.UV4Kind
  19246. * - VertexBuffer.UV5Kind
  19247. * - VertexBuffer.UV6Kind
  19248. * - VertexBuffer.ColorKind
  19249. * - VertexBuffer.MatricesIndicesKind
  19250. * - VertexBuffer.MatricesIndicesExtraKind
  19251. * - VertexBuffer.MatricesWeightsKind
  19252. * - VertexBuffer.MatricesWeightsExtraKind
  19253. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19254. */
  19255. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19256. /**
  19257. * Tests if a specific vertex buffer is associated with this mesh
  19258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19259. * - VertexBuffer.PositionKind
  19260. * - VertexBuffer.UVKind
  19261. * - VertexBuffer.UV2Kind
  19262. * - VertexBuffer.UV3Kind
  19263. * - VertexBuffer.UV4Kind
  19264. * - VertexBuffer.UV5Kind
  19265. * - VertexBuffer.UV6Kind
  19266. * - VertexBuffer.ColorKind
  19267. * - VertexBuffer.MatricesIndicesKind
  19268. * - VertexBuffer.MatricesIndicesExtraKind
  19269. * - VertexBuffer.MatricesWeightsKind
  19270. * - VertexBuffer.MatricesWeightsExtraKind
  19271. * @returns a boolean
  19272. */
  19273. isVerticesDataPresent(kind: string): boolean;
  19274. /**
  19275. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19276. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19277. * - VertexBuffer.PositionKind
  19278. * - VertexBuffer.UVKind
  19279. * - VertexBuffer.UV2Kind
  19280. * - VertexBuffer.UV3Kind
  19281. * - VertexBuffer.UV4Kind
  19282. * - VertexBuffer.UV5Kind
  19283. * - VertexBuffer.UV6Kind
  19284. * - VertexBuffer.ColorKind
  19285. * - VertexBuffer.MatricesIndicesKind
  19286. * - VertexBuffer.MatricesIndicesExtraKind
  19287. * - VertexBuffer.MatricesWeightsKind
  19288. * - VertexBuffer.MatricesWeightsExtraKind
  19289. * @returns a boolean
  19290. */
  19291. isVertexBufferUpdatable(kind: string): boolean;
  19292. /**
  19293. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19294. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19295. * - VertexBuffer.PositionKind
  19296. * - VertexBuffer.UVKind
  19297. * - VertexBuffer.UV2Kind
  19298. * - VertexBuffer.UV3Kind
  19299. * - VertexBuffer.UV4Kind
  19300. * - VertexBuffer.UV5Kind
  19301. * - VertexBuffer.UV6Kind
  19302. * - VertexBuffer.ColorKind
  19303. * - VertexBuffer.MatricesIndicesKind
  19304. * - VertexBuffer.MatricesIndicesExtraKind
  19305. * - VertexBuffer.MatricesWeightsKind
  19306. * - VertexBuffer.MatricesWeightsExtraKind
  19307. * @returns an array of strings
  19308. */
  19309. getVerticesDataKinds(): string[];
  19310. /**
  19311. * Returns a positive integer : the total number of indices in this mesh geometry.
  19312. * @returns the numner of indices or zero if the mesh has no geometry.
  19313. */
  19314. getTotalIndices(): number;
  19315. /**
  19316. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19317. * @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.
  19318. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19319. * @returns the indices array or an empty array if the mesh has no geometry
  19320. */
  19321. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19322. readonly isBlocked: boolean;
  19323. /**
  19324. * Determine if the current mesh is ready to be rendered
  19325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19326. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19327. * @returns true if all associated assets are ready (material, textures, shaders)
  19328. */
  19329. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19330. /**
  19331. * 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.
  19332. */
  19333. readonly areNormalsFrozen: boolean;
  19334. /**
  19335. * 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.
  19336. * @returns the current mesh
  19337. */
  19338. freezeNormals(): Mesh;
  19339. /**
  19340. * 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
  19341. * @returns the current mesh
  19342. */
  19343. unfreezeNormals(): Mesh;
  19344. /**
  19345. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19346. */
  19347. overridenInstanceCount: number;
  19348. /** @hidden */
  19349. _preActivate(): Mesh;
  19350. /** @hidden */
  19351. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19352. /** @hidden */
  19353. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19354. /**
  19355. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19356. * This means the mesh underlying bounding box and sphere are recomputed.
  19357. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19358. * @returns the current mesh
  19359. */
  19360. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19361. /** @hidden */
  19362. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19363. /**
  19364. * This function will subdivide the mesh into multiple submeshes
  19365. * @param count defines the expected number of submeshes
  19366. */
  19367. subdivide(count: number): void;
  19368. /**
  19369. * Copy a FloatArray into a specific associated vertex buffer
  19370. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19371. * - VertexBuffer.PositionKind
  19372. * - VertexBuffer.UVKind
  19373. * - VertexBuffer.UV2Kind
  19374. * - VertexBuffer.UV3Kind
  19375. * - VertexBuffer.UV4Kind
  19376. * - VertexBuffer.UV5Kind
  19377. * - VertexBuffer.UV6Kind
  19378. * - VertexBuffer.ColorKind
  19379. * - VertexBuffer.MatricesIndicesKind
  19380. * - VertexBuffer.MatricesIndicesExtraKind
  19381. * - VertexBuffer.MatricesWeightsKind
  19382. * - VertexBuffer.MatricesWeightsExtraKind
  19383. * @param data defines the data source
  19384. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19385. * @param stride defines the data stride size (can be null)
  19386. * @returns the current mesh
  19387. */
  19388. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19389. /**
  19390. * Flags an associated vertex buffer as updatable
  19391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19392. * - VertexBuffer.PositionKind
  19393. * - VertexBuffer.UVKind
  19394. * - VertexBuffer.UV2Kind
  19395. * - VertexBuffer.UV3Kind
  19396. * - VertexBuffer.UV4Kind
  19397. * - VertexBuffer.UV5Kind
  19398. * - VertexBuffer.UV6Kind
  19399. * - VertexBuffer.ColorKind
  19400. * - VertexBuffer.MatricesIndicesKind
  19401. * - VertexBuffer.MatricesIndicesExtraKind
  19402. * - VertexBuffer.MatricesWeightsKind
  19403. * - VertexBuffer.MatricesWeightsExtraKind
  19404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19405. */
  19406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19407. /**
  19408. * Sets the mesh global Vertex Buffer
  19409. * @param buffer defines the buffer to use
  19410. * @returns the current mesh
  19411. */
  19412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19413. /**
  19414. * Update a specific associated vertex buffer
  19415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19416. * - VertexBuffer.PositionKind
  19417. * - VertexBuffer.UVKind
  19418. * - VertexBuffer.UV2Kind
  19419. * - VertexBuffer.UV3Kind
  19420. * - VertexBuffer.UV4Kind
  19421. * - VertexBuffer.UV5Kind
  19422. * - VertexBuffer.UV6Kind
  19423. * - VertexBuffer.ColorKind
  19424. * - VertexBuffer.MatricesIndicesKind
  19425. * - VertexBuffer.MatricesIndicesExtraKind
  19426. * - VertexBuffer.MatricesWeightsKind
  19427. * - VertexBuffer.MatricesWeightsExtraKind
  19428. * @param data defines the data source
  19429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19430. * @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)
  19431. * @returns the current mesh
  19432. */
  19433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19434. /**
  19435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19439. * @returns the current mesh
  19440. */
  19441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19442. /**
  19443. * Creates a un-shared specific occurence of the geometry for the mesh.
  19444. * @returns the current mesh
  19445. */
  19446. makeGeometryUnique(): Mesh;
  19447. /**
  19448. * Set the index buffer of this mesh
  19449. * @param indices defines the source data
  19450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19452. * @returns the current mesh
  19453. */
  19454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19455. /**
  19456. * Update the current index buffer
  19457. * @param indices defines the source data
  19458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19459. * @returns the current mesh
  19460. */
  19461. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19462. /**
  19463. * Invert the geometry to move from a right handed system to a left handed one.
  19464. * @returns the current mesh
  19465. */
  19466. toLeftHanded(): Mesh;
  19467. /** @hidden */
  19468. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19469. /** @hidden */
  19470. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19471. /**
  19472. * Registers for this mesh a javascript function called just before the rendering process
  19473. * @param func defines the function to call before rendering this mesh
  19474. * @returns the current mesh
  19475. */
  19476. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19477. /**
  19478. * Disposes a previously registered javascript function called before the rendering
  19479. * @param func defines the function to remove
  19480. * @returns the current mesh
  19481. */
  19482. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19483. /**
  19484. * Registers for this mesh a javascript function called just after the rendering is complete
  19485. * @param func defines the function to call after rendering this mesh
  19486. * @returns the current mesh
  19487. */
  19488. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19489. /**
  19490. * Disposes a previously registered javascript function called after the rendering.
  19491. * @param func defines the function to remove
  19492. * @returns the current mesh
  19493. */
  19494. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19495. /** @hidden */
  19496. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19497. /** @hidden */
  19498. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19499. /** @hidden */
  19500. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19501. /**
  19502. * 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
  19503. * @param subMesh defines the subMesh to render
  19504. * @param enableAlphaMode defines if alpha mode can be changed
  19505. * @returns the current mesh
  19506. */
  19507. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19508. private _onBeforeDraw;
  19509. /**
  19510. * Renormalize the mesh and patch it up if there are no weights
  19511. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19512. * However in the case of zero weights then we set just a single influence to 1.
  19513. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19514. */
  19515. cleanMatrixWeights(): void;
  19516. private normalizeSkinFourWeights;
  19517. private normalizeSkinWeightsAndExtra;
  19518. /**
  19519. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19520. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19521. * the user know there was an issue with importing the mesh
  19522. * @returns a validation object with skinned, valid and report string
  19523. */
  19524. validateSkinning(): {
  19525. skinned: boolean;
  19526. valid: boolean;
  19527. report: string;
  19528. };
  19529. /** @hidden */
  19530. _checkDelayState(): Mesh;
  19531. private _queueLoad;
  19532. /**
  19533. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19534. * A mesh is in the frustum if its bounding box intersects the frustum
  19535. * @param frustumPlanes defines the frustum to test
  19536. * @returns true if the mesh is in the frustum planes
  19537. */
  19538. isInFrustum(frustumPlanes: Plane[]): boolean;
  19539. /**
  19540. * Sets the mesh material by the material or multiMaterial `id` property
  19541. * @param id is a string identifying the material or the multiMaterial
  19542. * @returns the current mesh
  19543. */
  19544. setMaterialByID(id: string): Mesh;
  19545. /**
  19546. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19547. * @returns an array of IAnimatable
  19548. */
  19549. getAnimatables(): IAnimatable[];
  19550. /**
  19551. * Modifies the mesh geometry according to the passed transformation matrix.
  19552. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19553. * The mesh normals are modified using the same transformation.
  19554. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19555. * @param transform defines the transform matrix to use
  19556. * @see http://doc.babylonjs.com/resources/baking_transformations
  19557. * @returns the current mesh
  19558. */
  19559. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19560. /**
  19561. * Modifies the mesh geometry according to its own current World Matrix.
  19562. * The mesh World Matrix is then reset.
  19563. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19564. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19565. * @see http://doc.babylonjs.com/resources/baking_transformations
  19566. * @returns the current mesh
  19567. */
  19568. bakeCurrentTransformIntoVertices(): Mesh;
  19569. /** @hidden */
  19570. readonly _positions: Nullable<Vector3[]>;
  19571. /** @hidden */
  19572. _resetPointsArrayCache(): Mesh;
  19573. /** @hidden */
  19574. _generatePointsArray(): boolean;
  19575. /**
  19576. * Returns a new Mesh object generated from the current mesh properties.
  19577. * This method must not get confused with createInstance()
  19578. * @param name is a string, the name given to the new mesh
  19579. * @param newParent can be any Node object (default `null`)
  19580. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19581. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19582. * @returns a new mesh
  19583. */
  19584. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19585. /**
  19586. * Releases resources associated with this mesh.
  19587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19589. */
  19590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19591. /**
  19592. * Modifies the mesh geometry according to a displacement map.
  19593. * 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.
  19594. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19595. * @param url is a string, the URL from the image file is to be downloaded.
  19596. * @param minHeight is the lower limit of the displacement.
  19597. * @param maxHeight is the upper limit of the displacement.
  19598. * @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.
  19599. * @param uvOffset is an optional vector2 used to offset UV.
  19600. * @param uvScale is an optional vector2 used to scale UV.
  19601. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  19602. * @returns the Mesh.
  19603. */
  19604. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19605. /**
  19606. * Modifies the mesh geometry according to a displacementMap buffer.
  19607. * 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.
  19608. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19609. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19610. * @param heightMapWidth is the width of the buffer image.
  19611. * @param heightMapHeight is the height of the buffer image.
  19612. * @param minHeight is the lower limit of the displacement.
  19613. * @param maxHeight is the upper limit of the displacement.
  19614. * @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.
  19615. * @param uvOffset is an optional vector2 used to offset UV.
  19616. * @param uvScale is an optional vector2 used to scale UV.
  19617. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  19618. * @returns the Mesh.
  19619. */
  19620. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19621. /**
  19622. * Modify the mesh to get a flat shading rendering.
  19623. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19624. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19625. * @returns current mesh
  19626. */
  19627. convertToFlatShadedMesh(): Mesh;
  19628. /**
  19629. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19630. * In other words, more vertices, no more indices and a single bigger VBO.
  19631. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19632. * @returns current mesh
  19633. */
  19634. convertToUnIndexedMesh(): Mesh;
  19635. /**
  19636. * Inverses facet orientations.
  19637. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19638. * @param flipNormals will also inverts the normals
  19639. * @returns current mesh
  19640. */
  19641. flipFaces(flipNormals?: boolean): Mesh;
  19642. /** @hidden */
  19643. static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  19644. /**
  19645. * Creates a new InstancedMesh object from the mesh model.
  19646. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19647. * @param name defines the name of the new instance
  19648. * @returns a new InstancedMesh
  19649. */
  19650. createInstance(name: string): InstancedMesh;
  19651. /**
  19652. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19653. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19654. * @returns the current mesh
  19655. */
  19656. synchronizeInstances(): Mesh;
  19657. /**
  19658. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19659. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19660. * This should be used together with the simplification to avoid disappearing triangles.
  19661. * @param successCallback an optional success callback to be called after the optimization finished.
  19662. * @returns the current mesh
  19663. */
  19664. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19665. /**
  19666. * Serialize current mesh
  19667. * @param serializationObject defines the object which will receive the serialization data
  19668. */
  19669. serialize(serializationObject: any): void;
  19670. /** @hidden */
  19671. _syncGeometryWithMorphTargetManager(): void;
  19672. /** @hidden */
  19673. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19674. /**
  19675. * Returns a new Mesh object parsed from the source provided.
  19676. * @param parsedMesh is the source
  19677. * @param scene defines the hosting scene
  19678. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19679. * @returns a new Mesh
  19680. */
  19681. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19682. /**
  19683. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19684. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19685. * @param name defines the name of the mesh to create
  19686. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19687. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19688. * @param closePath creates a seam between the first and the last points of each path of the path array
  19689. * @param offset is taken in account only if the `pathArray` is containing a single path
  19690. * @param scene defines the hosting scene
  19691. * @param updatable defines if the mesh must be flagged as updatable
  19692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19693. * @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)
  19694. * @returns a new Mesh
  19695. */
  19696. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19697. /**
  19698. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19699. * @param name defines the name of the mesh to create
  19700. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19701. * @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
  19702. * @param scene defines the hosting scene
  19703. * @param updatable defines if the mesh must be flagged as updatable
  19704. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19705. * @returns a new Mesh
  19706. */
  19707. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19708. /**
  19709. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19710. * @param name defines the name of the mesh to create
  19711. * @param size sets the size (float) of each box side (default 1)
  19712. * @param scene defines the hosting scene
  19713. * @param updatable defines if the mesh must be flagged as updatable
  19714. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19715. * @returns a new Mesh
  19716. */
  19717. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19718. /**
  19719. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19720. * @param name defines the name of the mesh to create
  19721. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19722. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19723. * @param scene defines the hosting scene
  19724. * @param updatable defines if the mesh must be flagged as updatable
  19725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19726. * @returns a new Mesh
  19727. */
  19728. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19729. /**
  19730. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19731. * @param name defines the name of the mesh to create
  19732. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19733. * @param diameterTop set the top cap diameter (floats, default 1)
  19734. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19735. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19736. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19737. * @param scene defines the hosting scene
  19738. * @param updatable defines if the mesh must be flagged as updatable
  19739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19740. * @returns a new Mesh
  19741. */
  19742. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19743. /**
  19744. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19745. * @param name defines the name of the mesh to create
  19746. * @param diameter sets the diameter size (float) of the torus (default 1)
  19747. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19748. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19749. * @param scene defines the hosting scene
  19750. * @param updatable defines if the mesh must be flagged as updatable
  19751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19752. * @returns a new Mesh
  19753. */
  19754. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19755. /**
  19756. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19757. * @param name defines the name of the mesh to create
  19758. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19759. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19760. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19761. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19762. * @param p the number of windings on X axis (positive integers, default 2)
  19763. * @param q the number of windings on Y axis (positive integers, default 3)
  19764. * @param scene defines the hosting scene
  19765. * @param updatable defines if the mesh must be flagged as updatable
  19766. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19767. * @returns a new Mesh
  19768. */
  19769. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19770. /**
  19771. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19772. * @param name defines the name of the mesh to create
  19773. * @param points is an array successive Vector3
  19774. * @param scene defines the hosting scene
  19775. * @param updatable defines if the mesh must be flagged as updatable
  19776. * @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).
  19777. * @returns a new Mesh
  19778. */
  19779. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19780. /**
  19781. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19782. * @param name defines the name of the mesh to create
  19783. * @param points is an array successive Vector3
  19784. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19785. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19786. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19787. * @param scene defines the hosting scene
  19788. * @param updatable defines if the mesh must be flagged as updatable
  19789. * @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)
  19790. * @returns a new Mesh
  19791. */
  19792. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19793. /**
  19794. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19795. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19796. * 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.
  19797. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19798. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19799. * Remember you can only change the shape positions, not their number when updating a polygon.
  19800. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19801. * @param name defines the name of the mesh to create
  19802. * @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
  19803. * @param scene defines the hosting scene
  19804. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19805. * @param updatable defines if the mesh must be flagged as updatable
  19806. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19807. * @returns a new Mesh
  19808. */
  19809. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  19810. /**
  19811. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19812. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19813. * @param name defines the name of the mesh to create
  19814. * @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
  19815. * @param depth defines the height of extrusion
  19816. * @param scene defines the hosting scene
  19817. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19818. * @param updatable defines if the mesh must be flagged as updatable
  19819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19820. * @returns a new Mesh
  19821. */
  19822. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  19823. /**
  19824. * Creates an extruded shape mesh.
  19825. * 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
  19826. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19827. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19828. * @param name defines the name of the mesh to create
  19829. * @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
  19830. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19831. * @param scale is the value to scale the shape
  19832. * @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
  19833. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19834. * @param scene defines the hosting scene
  19835. * @param updatable defines if the mesh must be flagged as updatable
  19836. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19837. * @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)
  19838. * @returns a new Mesh
  19839. */
  19840. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19841. /**
  19842. * Creates an custom extruded shape mesh.
  19843. * The custom extrusion is a parametric shape.
  19844. * It has no predefined shape. Its final shape will depend on the input parameters.
  19845. * Please consider using the same method from the MeshBuilder class instead
  19846. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19847. * @param name defines the name of the mesh to create
  19848. * @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
  19849. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19850. * @param scaleFunction is a custom Javascript function called on each path point
  19851. * @param rotationFunction is a custom Javascript function called on each path point
  19852. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19853. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19854. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19855. * @param scene defines the hosting scene
  19856. * @param updatable defines if the mesh must be flagged as updatable
  19857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19858. * @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)
  19859. * @returns a new Mesh
  19860. */
  19861. 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;
  19862. /**
  19863. * Creates lathe mesh.
  19864. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19865. * Please consider using the same method from the MeshBuilder class instead
  19866. * @param name defines the name of the mesh to create
  19867. * @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
  19868. * @param radius is the radius value of the lathe
  19869. * @param tessellation is the side number of the lathe.
  19870. * @param scene defines the hosting scene
  19871. * @param updatable defines if the mesh must be flagged as updatable
  19872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19873. * @returns a new Mesh
  19874. */
  19875. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19876. /**
  19877. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19878. * @param name defines the name of the mesh to create
  19879. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19880. * @param scene defines the hosting scene
  19881. * @param updatable defines if the mesh must be flagged as updatable
  19882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19883. * @returns a new Mesh
  19884. */
  19885. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19886. /**
  19887. * Creates a ground mesh.
  19888. * Please consider using the same method from the MeshBuilder class instead
  19889. * @param name defines the name of the mesh to create
  19890. * @param width set the width of the ground
  19891. * @param height set the height of the ground
  19892. * @param subdivisions sets the number of subdivisions per side
  19893. * @param scene defines the hosting scene
  19894. * @param updatable defines if the mesh must be flagged as updatable
  19895. * @returns a new Mesh
  19896. */
  19897. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19898. /**
  19899. * Creates a tiled ground mesh.
  19900. * Please consider using the same method from the MeshBuilder class instead
  19901. * @param name defines the name of the mesh to create
  19902. * @param xmin set the ground minimum X coordinate
  19903. * @param zmin set the ground minimum Y coordinate
  19904. * @param xmax set the ground maximum X coordinate
  19905. * @param zmax set the ground maximum Z coordinate
  19906. * @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
  19907. * @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
  19908. * @param scene defines the hosting scene
  19909. * @param updatable defines if the mesh must be flagged as updatable
  19910. * @returns a new Mesh
  19911. */
  19912. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19913. w: number;
  19914. h: number;
  19915. }, precision: {
  19916. w: number;
  19917. h: number;
  19918. }, scene: Scene, updatable?: boolean): Mesh;
  19919. /**
  19920. * Creates a ground mesh from a height map.
  19921. * Please consider using the same method from the MeshBuilder class instead
  19922. * @see http://doc.babylonjs.com/babylon101/height_map
  19923. * @param name defines the name of the mesh to create
  19924. * @param url sets the URL of the height map image resource
  19925. * @param width set the ground width size
  19926. * @param height set the ground height size
  19927. * @param subdivisions sets the number of subdivision per side
  19928. * @param minHeight is the minimum altitude on the ground
  19929. * @param maxHeight is the maximum altitude on the ground
  19930. * @param scene defines the hosting scene
  19931. * @param updatable defines if the mesh must be flagged as updatable
  19932. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19933. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19934. * @returns a new Mesh
  19935. */
  19936. 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;
  19937. /**
  19938. * Creates a tube mesh.
  19939. * The tube is a parametric shape.
  19940. * It has no predefined shape. Its final shape will depend on the input parameters.
  19941. * Please consider using the same method from the MeshBuilder class instead
  19942. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19943. * @param name defines the name of the mesh to create
  19944. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19945. * @param radius sets the tube radius size
  19946. * @param tessellation is the number of sides on the tubular surface
  19947. * @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
  19948. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19949. * @param scene defines the hosting scene
  19950. * @param updatable defines if the mesh must be flagged as updatable
  19951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19952. * @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)
  19953. * @returns a new Mesh
  19954. */
  19955. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19956. (i: number, distance: number): number;
  19957. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19958. /**
  19959. * Creates a polyhedron mesh.
  19960. * Please consider using the same method from the MeshBuilder class instead.
  19961. * * 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
  19962. * * The parameter `size` (positive float, default 1) sets the polygon size
  19963. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19964. * * 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`
  19965. * * 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
  19966. * * 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)`)
  19967. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  19968. * * 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
  19969. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19970. * * 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
  19971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19972. * @param name defines the name of the mesh to create
  19973. * @param options defines the options used to create the mesh
  19974. * @param scene defines the hosting scene
  19975. * @returns a new Mesh
  19976. */
  19977. static CreatePolyhedron(name: string, options: {
  19978. type?: number;
  19979. size?: number;
  19980. sizeX?: number;
  19981. sizeY?: number;
  19982. sizeZ?: number;
  19983. custom?: any;
  19984. faceUV?: Vector4[];
  19985. faceColors?: Color4[];
  19986. updatable?: boolean;
  19987. sideOrientation?: number;
  19988. }, scene: Scene): Mesh;
  19989. /**
  19990. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19991. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19992. * * 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`)
  19993. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19994. * * 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
  19995. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19996. * * 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
  19997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19998. * @param name defines the name of the mesh
  19999. * @param options defines the options used to create the mesh
  20000. * @param scene defines the hosting scene
  20001. * @returns a new Mesh
  20002. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20003. */
  20004. static CreateIcoSphere(name: string, options: {
  20005. radius?: number;
  20006. flat?: boolean;
  20007. subdivisions?: number;
  20008. sideOrientation?: number;
  20009. updatable?: boolean;
  20010. }, scene: Scene): Mesh;
  20011. /**
  20012. * Creates a decal mesh.
  20013. * Please consider using the same method from the MeshBuilder class instead.
  20014. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20015. * @param name defines the name of the mesh
  20016. * @param sourceMesh defines the mesh receiving the decal
  20017. * @param position sets the position of the decal in world coordinates
  20018. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20019. * @param size sets the decal scaling
  20020. * @param angle sets the angle to rotate the decal
  20021. * @returns a new Mesh
  20022. */
  20023. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20024. /**
  20025. * Prepare internal position array for software CPU skinning
  20026. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20027. */
  20028. setPositionsForCPUSkinning(): Float32Array;
  20029. /**
  20030. * Prepare internal normal array for software CPU skinning
  20031. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20032. */
  20033. setNormalsForCPUSkinning(): Float32Array;
  20034. /**
  20035. * Updates the vertex buffer by applying transformation from the bones
  20036. * @param skeleton defines the skeleton to apply to current mesh
  20037. * @returns the current mesh
  20038. */
  20039. applySkeleton(skeleton: Skeleton): Mesh;
  20040. /**
  20041. * 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
  20042. * @param meshes defines the list of meshes to scan
  20043. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20044. */
  20045. static MinMax(meshes: AbstractMesh[]): {
  20046. min: Vector3;
  20047. max: Vector3;
  20048. };
  20049. /**
  20050. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20051. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20052. * @returns a vector3
  20053. */
  20054. static Center(meshesOrMinMaxVector: {
  20055. min: Vector3;
  20056. max: Vector3;
  20057. } | AbstractMesh[]): Vector3;
  20058. /**
  20059. * Merge the array of meshes into a single mesh for performance reasons.
  20060. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20061. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20062. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20063. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20064. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20065. * @returns a new mesh
  20066. */
  20067. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20068. /** @hidden */
  20069. addInstance(instance: InstancedMesh): void;
  20070. /** @hidden */
  20071. removeInstance(instance: InstancedMesh): void;
  20072. }
  20073. }
  20074. declare module BABYLON {
  20075. /**
  20076. * The action to be carried out following a trigger
  20077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  20078. */
  20079. export class Action {
  20080. /** the trigger, with or without parameters, for the action */
  20081. triggerOptions: any;
  20082. /**
  20083. * Trigger for the action
  20084. */
  20085. trigger: number;
  20086. /**
  20087. * Internal only - manager for action
  20088. * @hidden
  20089. */
  20090. _actionManager: ActionManager;
  20091. private _nextActiveAction;
  20092. private _child;
  20093. private _condition?;
  20094. private _triggerParameter;
  20095. /**
  20096. * An event triggered prior to action being executed.
  20097. */
  20098. onBeforeExecuteObservable: Observable<Action>;
  20099. /**
  20100. * Creates a new Action
  20101. * @param triggerOptions the trigger, with or without parameters, for the action
  20102. * @param condition an optional determinant of action
  20103. */
  20104. constructor(
  20105. /** the trigger, with or without parameters, for the action */
  20106. triggerOptions: any, condition?: Condition);
  20107. /**
  20108. * Internal only
  20109. * @hidden
  20110. */
  20111. _prepare(): void;
  20112. /**
  20113. * Gets the trigger parameters
  20114. * @returns the trigger parameters
  20115. */
  20116. getTriggerParameter(): any;
  20117. /**
  20118. * Internal only - executes current action event
  20119. * @hidden
  20120. */
  20121. _executeCurrent(evt?: ActionEvent): void;
  20122. /**
  20123. * Execute placeholder for child classes
  20124. * @param evt optional action event
  20125. */
  20126. execute(evt?: ActionEvent): void;
  20127. /**
  20128. * Skips to next active action
  20129. */
  20130. skipToNextActiveAction(): void;
  20131. /**
  20132. * Adds action to chain of actions, may be a DoNothingAction
  20133. * @param action defines the next action to execute
  20134. * @returns The action passed in
  20135. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20136. */
  20137. then(action: Action): Action;
  20138. /**
  20139. * Internal only
  20140. * @hidden
  20141. */
  20142. _getProperty(propertyPath: string): string;
  20143. /**
  20144. * Internal only
  20145. * @hidden
  20146. */
  20147. _getEffectiveTarget(target: any, propertyPath: string): any;
  20148. /**
  20149. * Serialize placeholder for child classes
  20150. * @param parent of child
  20151. * @returns the serialized object
  20152. */
  20153. serialize(parent: any): any;
  20154. /**
  20155. * Internal only called by serialize
  20156. * @hidden
  20157. */
  20158. protected _serialize(serializedAction: any, parent?: any): any;
  20159. /**
  20160. * Internal only
  20161. * @hidden
  20162. */
  20163. static _SerializeValueAsString: (value: any) => string;
  20164. /**
  20165. * Internal only
  20166. * @hidden
  20167. */
  20168. static _GetTargetProperty: (target: Scene | Node) => {
  20169. name: string;
  20170. targetType: string;
  20171. value: string;
  20172. };
  20173. }
  20174. }
  20175. declare module BABYLON {
  20176. /**
  20177. * A Condition applied to an Action
  20178. */
  20179. export class Condition {
  20180. /**
  20181. * Internal only - manager for action
  20182. * @hidden
  20183. */
  20184. _actionManager: ActionManager;
  20185. /**
  20186. * Internal only
  20187. * @hidden
  20188. */
  20189. _evaluationId: number;
  20190. /**
  20191. * Internal only
  20192. * @hidden
  20193. */
  20194. _currentResult: boolean;
  20195. /**
  20196. * Creates a new Condition
  20197. * @param actionManager the manager of the action the condition is applied to
  20198. */
  20199. constructor(actionManager: ActionManager);
  20200. /**
  20201. * Check if the current condition is valid
  20202. * @returns a boolean
  20203. */
  20204. isValid(): boolean;
  20205. /**
  20206. * Internal only
  20207. * @hidden
  20208. */
  20209. _getProperty(propertyPath: string): string;
  20210. /**
  20211. * Internal only
  20212. * @hidden
  20213. */
  20214. _getEffectiveTarget(target: any, propertyPath: string): any;
  20215. /**
  20216. * Serialize placeholder for child classes
  20217. * @returns the serialized object
  20218. */
  20219. serialize(): any;
  20220. /**
  20221. * Internal only
  20222. * @hidden
  20223. */
  20224. protected _serialize(serializedCondition: any): any;
  20225. }
  20226. /**
  20227. * Defines specific conditional operators as extensions of Condition
  20228. */
  20229. export class ValueCondition extends Condition {
  20230. /** path to specify the property of the target the conditional operator uses */
  20231. propertyPath: string;
  20232. /** the value compared by the conditional operator against the current value of the property */
  20233. value: any;
  20234. /** the conditional operator, default ValueCondition.IsEqual */
  20235. operator: number;
  20236. /**
  20237. * Internal only
  20238. * @hidden
  20239. */
  20240. private static _IsEqual;
  20241. /**
  20242. * Internal only
  20243. * @hidden
  20244. */
  20245. private static _IsDifferent;
  20246. /**
  20247. * Internal only
  20248. * @hidden
  20249. */
  20250. private static _IsGreater;
  20251. /**
  20252. * Internal only
  20253. * @hidden
  20254. */
  20255. private static _IsLesser;
  20256. /**
  20257. * returns the number for IsEqual
  20258. */
  20259. static readonly IsEqual: number;
  20260. /**
  20261. * Returns the number for IsDifferent
  20262. */
  20263. static readonly IsDifferent: number;
  20264. /**
  20265. * Returns the number for IsGreater
  20266. */
  20267. static readonly IsGreater: number;
  20268. /**
  20269. * Returns the number for IsLesser
  20270. */
  20271. static readonly IsLesser: number;
  20272. /**
  20273. * Internal only The action manager for the condition
  20274. * @hidden
  20275. */
  20276. _actionManager: ActionManager;
  20277. /**
  20278. * Internal only
  20279. * @hidden
  20280. */
  20281. private _target;
  20282. /**
  20283. * Internal only
  20284. * @hidden
  20285. */
  20286. private _effectiveTarget;
  20287. /**
  20288. * Internal only
  20289. * @hidden
  20290. */
  20291. private _property;
  20292. /**
  20293. * Creates a new ValueCondition
  20294. * @param actionManager manager for the action the condition applies to
  20295. * @param target for the action
  20296. * @param propertyPath path to specify the property of the target the conditional operator uses
  20297. * @param value the value compared by the conditional operator against the current value of the property
  20298. * @param operator the conditional operator, default ValueCondition.IsEqual
  20299. */
  20300. constructor(actionManager: ActionManager, target: any,
  20301. /** path to specify the property of the target the conditional operator uses */
  20302. propertyPath: string,
  20303. /** the value compared by the conditional operator against the current value of the property */
  20304. value: any,
  20305. /** the conditional operator, default ValueCondition.IsEqual */
  20306. operator?: number);
  20307. /**
  20308. * Compares the given value with the property value for the specified conditional operator
  20309. * @returns the result of the comparison
  20310. */
  20311. isValid(): boolean;
  20312. /**
  20313. * Serialize the ValueCondition into a JSON compatible object
  20314. * @returns serialization object
  20315. */
  20316. serialize(): any;
  20317. /**
  20318. * Gets the name of the conditional operator for the ValueCondition
  20319. * @param operator the conditional operator
  20320. * @returns the name
  20321. */
  20322. static GetOperatorName(operator: number): string;
  20323. }
  20324. /**
  20325. * Defines a predicate condition as an extension of Condition
  20326. */
  20327. export class PredicateCondition extends Condition {
  20328. /** defines the predicate function used to validate the condition */
  20329. predicate: () => boolean;
  20330. /**
  20331. * Internal only - manager for action
  20332. * @hidden
  20333. */
  20334. _actionManager: ActionManager;
  20335. /**
  20336. * Creates a new PredicateCondition
  20337. * @param actionManager manager for the action the condition applies to
  20338. * @param predicate defines the predicate function used to validate the condition
  20339. */
  20340. constructor(actionManager: ActionManager,
  20341. /** defines the predicate function used to validate the condition */
  20342. predicate: () => boolean);
  20343. /**
  20344. * @returns the validity of the predicate condition
  20345. */
  20346. isValid(): boolean;
  20347. }
  20348. /**
  20349. * Defines a state condition as an extension of Condition
  20350. */
  20351. export class StateCondition extends Condition {
  20352. /** Value to compare with target state */
  20353. value: string;
  20354. /**
  20355. * Internal only - manager for action
  20356. * @hidden
  20357. */
  20358. _actionManager: ActionManager;
  20359. /**
  20360. * Internal only
  20361. * @hidden
  20362. */
  20363. private _target;
  20364. /**
  20365. * Creates a new StateCondition
  20366. * @param actionManager manager for the action the condition applies to
  20367. * @param target of the condition
  20368. * @param value to compare with target state
  20369. */
  20370. constructor(actionManager: ActionManager, target: any,
  20371. /** Value to compare with target state */
  20372. value: string);
  20373. /**
  20374. * Gets a boolean indicating if the current condition is met
  20375. * @returns the validity of the state
  20376. */
  20377. isValid(): boolean;
  20378. /**
  20379. * Serialize the StateCondition into a JSON compatible object
  20380. * @returns serialization object
  20381. */
  20382. serialize(): any;
  20383. }
  20384. }
  20385. declare module BABYLON {
  20386. /**
  20387. * This defines an action responsible to toggle a boolean once triggered.
  20388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20389. */
  20390. export class SwitchBooleanAction extends Action {
  20391. /**
  20392. * The path to the boolean property in the target object
  20393. */
  20394. propertyPath: string;
  20395. private _target;
  20396. private _effectiveTarget;
  20397. private _property;
  20398. /**
  20399. * Instantiate the action
  20400. * @param triggerOptions defines the trigger options
  20401. * @param target defines the object containing the boolean
  20402. * @param propertyPath defines the path to the boolean property in the target object
  20403. * @param condition defines the trigger related conditions
  20404. */
  20405. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20406. /** @hidden */
  20407. _prepare(): void;
  20408. /**
  20409. * Execute the action toggle the boolean value.
  20410. */
  20411. execute(): void;
  20412. /**
  20413. * Serializes the actions and its related information.
  20414. * @param parent defines the object to serialize in
  20415. * @returns the serialized object
  20416. */
  20417. serialize(parent: any): any;
  20418. }
  20419. /**
  20420. * This defines an action responsible to set a the state field of the target
  20421. * to a desired value once triggered.
  20422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20423. */
  20424. export class SetStateAction extends Action {
  20425. /**
  20426. * The value to store in the state field.
  20427. */
  20428. value: string;
  20429. private _target;
  20430. /**
  20431. * Instantiate the action
  20432. * @param triggerOptions defines the trigger options
  20433. * @param target defines the object containing the state property
  20434. * @param value defines the value to store in the state field
  20435. * @param condition defines the trigger related conditions
  20436. */
  20437. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  20438. /**
  20439. * Execute the action and store the value on the target state property.
  20440. */
  20441. execute(): void;
  20442. /**
  20443. * Serializes the actions and its related information.
  20444. * @param parent defines the object to serialize in
  20445. * @returns the serialized object
  20446. */
  20447. serialize(parent: any): any;
  20448. }
  20449. /**
  20450. * This defines an action responsible to set a property of the target
  20451. * to a desired value once triggered.
  20452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20453. */
  20454. export class SetValueAction extends Action {
  20455. /**
  20456. * The path of the property to set in the target.
  20457. */
  20458. propertyPath: string;
  20459. /**
  20460. * The value to set in the property
  20461. */
  20462. value: any;
  20463. private _target;
  20464. private _effectiveTarget;
  20465. private _property;
  20466. /**
  20467. * Instantiate the action
  20468. * @param triggerOptions defines the trigger options
  20469. * @param target defines the object containing the property
  20470. * @param propertyPath defines the path of the property to set in the target
  20471. * @param value defines the value to set in the property
  20472. * @param condition defines the trigger related conditions
  20473. */
  20474. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20475. /** @hidden */
  20476. _prepare(): void;
  20477. /**
  20478. * Execute the action and set the targetted property to the desired value.
  20479. */
  20480. execute(): void;
  20481. /**
  20482. * Serializes the actions and its related information.
  20483. * @param parent defines the object to serialize in
  20484. * @returns the serialized object
  20485. */
  20486. serialize(parent: any): any;
  20487. }
  20488. /**
  20489. * This defines an action responsible to increment the target value
  20490. * to a desired value once triggered.
  20491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20492. */
  20493. export class IncrementValueAction extends Action {
  20494. /**
  20495. * The path of the property to increment in the target.
  20496. */
  20497. propertyPath: string;
  20498. /**
  20499. * The value we should increment the property by.
  20500. */
  20501. value: any;
  20502. private _target;
  20503. private _effectiveTarget;
  20504. private _property;
  20505. /**
  20506. * Instantiate the action
  20507. * @param triggerOptions defines the trigger options
  20508. * @param target defines the object containing the property
  20509. * @param propertyPath defines the path of the property to increment in the target
  20510. * @param value defines the value value we should increment the property by
  20511. * @param condition defines the trigger related conditions
  20512. */
  20513. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20514. /** @hidden */
  20515. _prepare(): void;
  20516. /**
  20517. * Execute the action and increment the target of the value amount.
  20518. */
  20519. execute(): void;
  20520. /**
  20521. * Serializes the actions and its related information.
  20522. * @param parent defines the object to serialize in
  20523. * @returns the serialized object
  20524. */
  20525. serialize(parent: any): any;
  20526. }
  20527. /**
  20528. * This defines an action responsible to start an animation once triggered.
  20529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20530. */
  20531. export class PlayAnimationAction extends Action {
  20532. /**
  20533. * Where the animation should start (animation frame)
  20534. */
  20535. from: number;
  20536. /**
  20537. * Where the animation should stop (animation frame)
  20538. */
  20539. to: number;
  20540. /**
  20541. * Define if the animation should loop or stop after the first play.
  20542. */
  20543. loop?: boolean;
  20544. private _target;
  20545. /**
  20546. * Instantiate the action
  20547. * @param triggerOptions defines the trigger options
  20548. * @param target defines the target animation or animation name
  20549. * @param from defines from where the animation should start (animation frame)
  20550. * @param end defines where the animation should stop (animation frame)
  20551. * @param loop defines if the animation should loop or stop after the first play
  20552. * @param condition defines the trigger related conditions
  20553. */
  20554. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  20555. /** @hidden */
  20556. _prepare(): void;
  20557. /**
  20558. * Execute the action and play the animation.
  20559. */
  20560. execute(): void;
  20561. /**
  20562. * Serializes the actions and its related information.
  20563. * @param parent defines the object to serialize in
  20564. * @returns the serialized object
  20565. */
  20566. serialize(parent: any): any;
  20567. }
  20568. /**
  20569. * This defines an action responsible to stop an animation once triggered.
  20570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20571. */
  20572. export class StopAnimationAction extends Action {
  20573. private _target;
  20574. /**
  20575. * Instantiate the action
  20576. * @param triggerOptions defines the trigger options
  20577. * @param target defines the target animation or animation name
  20578. * @param condition defines the trigger related conditions
  20579. */
  20580. constructor(triggerOptions: any, target: any, condition?: Condition);
  20581. /** @hidden */
  20582. _prepare(): void;
  20583. /**
  20584. * Execute the action and stop the animation.
  20585. */
  20586. execute(): void;
  20587. /**
  20588. * Serializes the actions and its related information.
  20589. * @param parent defines the object to serialize in
  20590. * @returns the serialized object
  20591. */
  20592. serialize(parent: any): any;
  20593. }
  20594. /**
  20595. * This defines an action responsible that does nothing once triggered.
  20596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20597. */
  20598. export class DoNothingAction extends Action {
  20599. /**
  20600. * Instantiate the action
  20601. * @param triggerOptions defines the trigger options
  20602. * @param condition defines the trigger related conditions
  20603. */
  20604. constructor(triggerOptions?: any, condition?: Condition);
  20605. /**
  20606. * Execute the action and do nothing.
  20607. */
  20608. execute(): void;
  20609. /**
  20610. * Serializes the actions and its related information.
  20611. * @param parent defines the object to serialize in
  20612. * @returns the serialized object
  20613. */
  20614. serialize(parent: any): any;
  20615. }
  20616. /**
  20617. * This defines an action responsible to trigger several actions once triggered.
  20618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20619. */
  20620. export class CombineAction extends Action {
  20621. /**
  20622. * The list of aggregated animations to run.
  20623. */
  20624. children: Action[];
  20625. /**
  20626. * Instantiate the action
  20627. * @param triggerOptions defines the trigger options
  20628. * @param children defines the list of aggregated animations to run
  20629. * @param condition defines the trigger related conditions
  20630. */
  20631. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  20632. /** @hidden */
  20633. _prepare(): void;
  20634. /**
  20635. * Execute the action and executes all the aggregated actions.
  20636. */
  20637. execute(evt: ActionEvent): void;
  20638. /**
  20639. * Serializes the actions and its related information.
  20640. * @param parent defines the object to serialize in
  20641. * @returns the serialized object
  20642. */
  20643. serialize(parent: any): any;
  20644. }
  20645. /**
  20646. * This defines an action responsible to run code (external event) once triggered.
  20647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20648. */
  20649. export class ExecuteCodeAction extends Action {
  20650. /**
  20651. * The callback function to run.
  20652. */
  20653. func: (evt: ActionEvent) => void;
  20654. /**
  20655. * Instantiate the action
  20656. * @param triggerOptions defines the trigger options
  20657. * @param func defines the callback function to run
  20658. * @param condition defines the trigger related conditions
  20659. */
  20660. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  20661. /**
  20662. * Execute the action and run the attached code.
  20663. */
  20664. execute(evt: ActionEvent): void;
  20665. }
  20666. /**
  20667. * This defines an action responsible to set the parent property of the target once triggered.
  20668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20669. */
  20670. export class SetParentAction extends Action {
  20671. private _parent;
  20672. private _target;
  20673. /**
  20674. * Instantiate the action
  20675. * @param triggerOptions defines the trigger options
  20676. * @param target defines the target containing the parent property
  20677. * @param parent defines from where the animation should start (animation frame)
  20678. * @param condition defines the trigger related conditions
  20679. */
  20680. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  20681. /** @hidden */
  20682. _prepare(): void;
  20683. /**
  20684. * Execute the action and set the parent property.
  20685. */
  20686. execute(): void;
  20687. /**
  20688. * Serializes the actions and its related information.
  20689. * @param parent defines the object to serialize in
  20690. * @returns the serialized object
  20691. */
  20692. serialize(parent: any): any;
  20693. }
  20694. }
  20695. declare module BABYLON {
  20696. /**
  20697. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  20698. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  20699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20700. */
  20701. export class ActionManager {
  20702. /**
  20703. * Nothing
  20704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20705. */
  20706. static readonly NothingTrigger: number;
  20707. /**
  20708. * On pick
  20709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20710. */
  20711. static readonly OnPickTrigger: number;
  20712. /**
  20713. * On left pick
  20714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20715. */
  20716. static readonly OnLeftPickTrigger: number;
  20717. /**
  20718. * On right pick
  20719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20720. */
  20721. static readonly OnRightPickTrigger: number;
  20722. /**
  20723. * On center pick
  20724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20725. */
  20726. static readonly OnCenterPickTrigger: number;
  20727. /**
  20728. * On pick down
  20729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20730. */
  20731. static readonly OnPickDownTrigger: number;
  20732. /**
  20733. * On double pick
  20734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20735. */
  20736. static readonly OnDoublePickTrigger: number;
  20737. /**
  20738. * On pick up
  20739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20740. */
  20741. static readonly OnPickUpTrigger: number;
  20742. /**
  20743. * On pick out.
  20744. * This trigger will only be raised if you also declared a OnPickDown
  20745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20746. */
  20747. static readonly OnPickOutTrigger: number;
  20748. /**
  20749. * On long press
  20750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20751. */
  20752. static readonly OnLongPressTrigger: number;
  20753. /**
  20754. * On pointer over
  20755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20756. */
  20757. static readonly OnPointerOverTrigger: number;
  20758. /**
  20759. * On pointer out
  20760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20761. */
  20762. static readonly OnPointerOutTrigger: number;
  20763. /**
  20764. * On every frame
  20765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20766. */
  20767. static readonly OnEveryFrameTrigger: number;
  20768. /**
  20769. * On intersection enter
  20770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20771. */
  20772. static readonly OnIntersectionEnterTrigger: number;
  20773. /**
  20774. * On intersection exit
  20775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20776. */
  20777. static readonly OnIntersectionExitTrigger: number;
  20778. /**
  20779. * On key down
  20780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20781. */
  20782. static readonly OnKeyDownTrigger: number;
  20783. /**
  20784. * On key up
  20785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20786. */
  20787. static readonly OnKeyUpTrigger: number;
  20788. /** Gets the list of active triggers */
  20789. static Triggers: {
  20790. [key: string]: number;
  20791. };
  20792. /** Gets the list of actions */
  20793. actions: Action[];
  20794. /** Gets the cursor to use when hovering items */
  20795. hoverCursor: string;
  20796. private _scene;
  20797. /**
  20798. * Creates a new action manager
  20799. * @param scene defines the hosting scene
  20800. */
  20801. constructor(scene: Scene);
  20802. /**
  20803. * Releases all associated resources
  20804. */
  20805. dispose(): void;
  20806. /**
  20807. * Gets hosting scene
  20808. * @returns the hosting scene
  20809. */
  20810. getScene(): Scene;
  20811. /**
  20812. * Does this action manager handles actions of any of the given triggers
  20813. * @param triggers defines the triggers to be tested
  20814. * @return a boolean indicating whether one (or more) of the triggers is handled
  20815. */
  20816. hasSpecificTriggers(triggers: number[]): boolean;
  20817. /**
  20818. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20819. * speed.
  20820. * @param triggerA defines the trigger to be tested
  20821. * @param triggerB defines the trigger to be tested
  20822. * @return a boolean indicating whether one (or more) of the triggers is handled
  20823. */
  20824. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20825. /**
  20826. * Does this action manager handles actions of a given trigger
  20827. * @param trigger defines the trigger to be tested
  20828. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20829. * @return whether the trigger is handled
  20830. */
  20831. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20832. /**
  20833. * Does this action manager has pointer triggers
  20834. */
  20835. readonly hasPointerTriggers: boolean;
  20836. /**
  20837. * Does this action manager has pick triggers
  20838. */
  20839. readonly hasPickTriggers: boolean;
  20840. /**
  20841. * Does exist one action manager with at least one trigger
  20842. **/
  20843. static readonly HasTriggers: boolean;
  20844. /**
  20845. * Does exist one action manager with at least one pick trigger
  20846. **/
  20847. static readonly HasPickTriggers: boolean;
  20848. /**
  20849. * Does exist one action manager that handles actions of a given trigger
  20850. * @param trigger defines the trigger to be tested
  20851. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  20852. **/
  20853. static HasSpecificTrigger(trigger: number): boolean;
  20854. /**
  20855. * Registers an action to this action manager
  20856. * @param action defines the action to be registered
  20857. * @return the action amended (prepared) after registration
  20858. */
  20859. registerAction(action: Action): Nullable<Action>;
  20860. /**
  20861. * Unregisters an action to this action manager
  20862. * @param action defines the action to be unregistered
  20863. * @return a boolean indicating whether the action has been unregistered
  20864. */
  20865. unregisterAction(action: Action): Boolean;
  20866. /**
  20867. * Process a specific trigger
  20868. * @param trigger defines the trigger to process
  20869. * @param evt defines the event details to be processed
  20870. */
  20871. processTrigger(trigger: number, evt?: ActionEvent): void;
  20872. /** @hidden */
  20873. _getEffectiveTarget(target: any, propertyPath: string): any;
  20874. /** @hidden */
  20875. _getProperty(propertyPath: string): string;
  20876. /**
  20877. * Serialize this manager to a JSON object
  20878. * @param name defines the property name to store this manager
  20879. * @returns a JSON representation of this manager
  20880. */
  20881. serialize(name: string): any;
  20882. /**
  20883. * Creates a new ActionManager from a JSON data
  20884. * @param parsedActions defines the JSON data to read from
  20885. * @param object defines the hosting mesh
  20886. * @param scene defines the hosting scene
  20887. */
  20888. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  20889. /**
  20890. * Get a trigger name by index
  20891. * @param trigger defines the trigger index
  20892. * @returns a trigger name
  20893. */
  20894. static GetTriggerName(trigger: number): string;
  20895. }
  20896. }
  20897. declare module BABYLON {
  20898. /**
  20899. * Class used to represent a sprite
  20900. * @see http://doc.babylonjs.com/babylon101/sprites
  20901. */
  20902. export class Sprite {
  20903. /** defines the name */
  20904. name: string;
  20905. /** Gets or sets the current world position */
  20906. position: Vector3;
  20907. /** Gets or sets the main color */
  20908. color: Color4;
  20909. /** Gets or sets the width */
  20910. width: number;
  20911. /** Gets or sets the height */
  20912. height: number;
  20913. /** Gets or sets rotation angle */
  20914. angle: number;
  20915. /** Gets or sets the cell index in the sprite sheet */
  20916. cellIndex: number;
  20917. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  20918. invertU: number;
  20919. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  20920. invertV: number;
  20921. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  20922. disposeWhenFinishedAnimating: boolean;
  20923. /** Gets the list of attached animations */
  20924. animations: Animation[];
  20925. /** Gets or sets a boolean indicating if the sprite can be picked */
  20926. isPickable: boolean;
  20927. /**
  20928. * Gets or sets the associated action manager
  20929. */
  20930. actionManager: Nullable<ActionManager>;
  20931. private _animationStarted;
  20932. private _loopAnimation;
  20933. private _fromIndex;
  20934. private _toIndex;
  20935. private _delay;
  20936. private _direction;
  20937. private _manager;
  20938. private _time;
  20939. private _onAnimationEnd;
  20940. /**
  20941. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  20942. */
  20943. isVisible: boolean;
  20944. /**
  20945. * Gets or sets the sprite size
  20946. */
  20947. size: number;
  20948. /**
  20949. * Creates a new Sprite
  20950. * @param name defines the name
  20951. * @param manager defines the manager
  20952. */
  20953. constructor(
  20954. /** defines the name */
  20955. name: string, manager: ISpriteManager);
  20956. /**
  20957. * Starts an animation
  20958. * @param from defines the initial key
  20959. * @param to defines the end key
  20960. * @param loop defines if the animation must loop
  20961. * @param delay defines the start delay (in ms)
  20962. * @param onAnimationEnd defines a callback to call when animation ends
  20963. */
  20964. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20965. /** Stops current animation (if any) */
  20966. stopAnimation(): void;
  20967. /** @hidden */
  20968. _animate(deltaTime: number): void;
  20969. /** Release associated resources */
  20970. dispose(): void;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * Information about the result of picking within a scene
  20976. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  20977. */
  20978. export class PickingInfo {
  20979. /**
  20980. * If the pick collided with an object
  20981. */
  20982. hit: boolean;
  20983. /**
  20984. * Distance away where the pick collided
  20985. */
  20986. distance: number;
  20987. /**
  20988. * The location of pick collision
  20989. */
  20990. pickedPoint: Nullable<Vector3>;
  20991. /**
  20992. * The mesh corresponding the the pick collision
  20993. */
  20994. pickedMesh: Nullable<AbstractMesh>;
  20995. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  20996. bu: number;
  20997. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  20998. bv: number;
  20999. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  21000. faceId: number;
  21001. /** Id of the the submesh that was picked */
  21002. subMeshId: number;
  21003. /** If a sprite was picked, this will be the sprite the pick collided with */
  21004. pickedSprite: Nullable<Sprite>;
  21005. /**
  21006. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  21007. */
  21008. originMesh: Nullable<AbstractMesh>;
  21009. /**
  21010. * The ray that was used to perform the picking.
  21011. */
  21012. ray: Nullable<Ray>;
  21013. /**
  21014. * Gets the normal correspodning to the face the pick collided with
  21015. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  21016. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  21017. * @returns The normal correspodning to the face the pick collided with
  21018. */
  21019. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  21020. /**
  21021. * Gets the texture coordinates of where the pick occured
  21022. * @returns the vector containing the coordnates of the texture
  21023. */
  21024. getTextureCoordinates(): Nullable<Vector2>;
  21025. }
  21026. }
  21027. declare module BABYLON {
  21028. /**
  21029. * Class representing a ray with position and direction
  21030. */
  21031. export class Ray {
  21032. /** origin point */
  21033. origin: Vector3;
  21034. /** direction */
  21035. direction: Vector3;
  21036. /** length of the ray */
  21037. length: number;
  21038. private static readonly TmpVector3;
  21039. private _tmpRay;
  21040. /**
  21041. * Creates a new ray
  21042. * @param origin origin point
  21043. * @param direction direction
  21044. * @param length length of the ray
  21045. */
  21046. constructor(
  21047. /** origin point */
  21048. origin: Vector3,
  21049. /** direction */
  21050. direction: Vector3,
  21051. /** length of the ray */
  21052. length?: number);
  21053. /**
  21054. * Checks if the ray intersects a box
  21055. * @param minimum bound of the box
  21056. * @param maximum bound of the box
  21057. * @param intersectionTreshold extra extend to be added to the box in all direction
  21058. * @returns if the box was hit
  21059. */
  21060. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21061. /**
  21062. * Checks if the ray intersects a box
  21063. * @param box the bounding box to check
  21064. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21065. * @returns if the box was hit
  21066. */
  21067. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21068. /**
  21069. * If the ray hits a sphere
  21070. * @param sphere the bounding sphere to check
  21071. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21072. * @returns true if it hits the sphere
  21073. */
  21074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21075. /**
  21076. * If the ray hits a triange
  21077. * @param vertex0 triangle vertex
  21078. * @param vertex1 triangle vertex
  21079. * @param vertex2 triangle vertex
  21080. * @returns intersection information if hit
  21081. */
  21082. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21083. /**
  21084. * Checks if ray intersects a plane
  21085. * @param plane the plane to check
  21086. * @returns the distance away it was hit
  21087. */
  21088. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21089. /**
  21090. * Checks if ray intersects a mesh
  21091. * @param mesh the mesh to check
  21092. * @param fastCheck if only the bounding box should checked
  21093. * @returns picking info of the intersecton
  21094. */
  21095. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21096. /**
  21097. * Checks if ray intersects a mesh
  21098. * @param meshes the meshes to check
  21099. * @param fastCheck if only the bounding box should checked
  21100. * @param results array to store result in
  21101. * @returns Array of picking infos
  21102. */
  21103. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21104. private _comparePickingInfo;
  21105. private static smallnum;
  21106. private static rayl;
  21107. /**
  21108. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21109. * @param sega the first point of the segment to test the intersection against
  21110. * @param segb the second point of the segment to test the intersection against
  21111. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21112. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21113. */
  21114. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21115. /**
  21116. * Update the ray from viewport position
  21117. * @param x position
  21118. * @param y y position
  21119. * @param viewportWidth viewport width
  21120. * @param viewportHeight viewport height
  21121. * @param world world matrix
  21122. * @param view view matrix
  21123. * @param projection projection matrix
  21124. * @returns this ray updated
  21125. */
  21126. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21127. /**
  21128. * Creates a ray with origin and direction of 0,0,0
  21129. * @returns the new ray
  21130. */
  21131. static Zero(): Ray;
  21132. /**
  21133. * Creates a new ray from screen space and viewport
  21134. * @param x position
  21135. * @param y y position
  21136. * @param viewportWidth viewport width
  21137. * @param viewportHeight viewport height
  21138. * @param world world matrix
  21139. * @param view view matrix
  21140. * @param projection projection matrix
  21141. * @returns new ray
  21142. */
  21143. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21144. /**
  21145. * 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
  21146. * transformed to the given world matrix.
  21147. * @param origin The origin point
  21148. * @param end The end point
  21149. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21150. * @returns the new ray
  21151. */
  21152. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21153. /**
  21154. * Transforms a ray by a matrix
  21155. * @param ray ray to transform
  21156. * @param matrix matrix to apply
  21157. * @returns the resulting new ray
  21158. */
  21159. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21160. /**
  21161. * Transforms a ray by a matrix
  21162. * @param ray ray to transform
  21163. * @param matrix matrix to apply
  21164. * @param result ray to store result in
  21165. */
  21166. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21167. /**
  21168. * Unproject a ray from screen space to object space
  21169. * @param sourceX defines the screen space x coordinate to use
  21170. * @param sourceY defines the screen space y coordinate to use
  21171. * @param viewportWidth defines the current width of the viewport
  21172. * @param viewportHeight defines the current height of the viewport
  21173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21174. * @param view defines the view matrix to use
  21175. * @param projection defines the projection matrix to use
  21176. */
  21177. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21178. }
  21179. }
  21180. declare module BABYLON {
  21181. /**
  21182. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21183. * separate meshes. This can be use to improve performances.
  21184. * @see http://doc.babylonjs.com/how_to/multi_materials
  21185. */
  21186. export class MultiMaterial extends Material {
  21187. private _subMaterials;
  21188. /**
  21189. * Gets or Sets the list of Materials used within the multi material.
  21190. * They need to be ordered according to the submeshes order in the associated mesh
  21191. */
  21192. subMaterials: Nullable<Material>[];
  21193. /**
  21194. * Function used to align with Node.getChildren()
  21195. * @returns the list of Materials used within the multi material
  21196. */
  21197. getChildren(): Nullable<Material>[];
  21198. /**
  21199. * Instantiates a new Multi Material
  21200. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21201. * separate meshes. This can be use to improve performances.
  21202. * @see http://doc.babylonjs.com/how_to/multi_materials
  21203. * @param name Define the name in the scene
  21204. * @param scene Define the scene the material belongs to
  21205. */
  21206. constructor(name: string, scene: Scene);
  21207. private _hookArray;
  21208. /**
  21209. * Get one of the submaterial by its index in the submaterials array
  21210. * @param index The index to look the sub material at
  21211. * @returns The Material if the index has been defined
  21212. */
  21213. getSubMaterial(index: number): Nullable<Material>;
  21214. /**
  21215. * Get the list of active textures for the whole sub materials list.
  21216. * @returns All the textures that will be used during the rendering
  21217. */
  21218. getActiveTextures(): BaseTexture[];
  21219. /**
  21220. * Gets the current class name of the material e.g. "MultiMaterial"
  21221. * Mainly use in serialization.
  21222. * @returns the class name
  21223. */
  21224. getClassName(): string;
  21225. /**
  21226. * Checks if the material is ready to render the requested sub mesh
  21227. * @param mesh Define the mesh the submesh belongs to
  21228. * @param subMesh Define the sub mesh to look readyness for
  21229. * @param useInstances Define whether or not the material is used with instances
  21230. * @returns true if ready, otherwise false
  21231. */
  21232. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21233. /**
  21234. * Clones the current material and its related sub materials
  21235. * @param name Define the name of the newly cloned material
  21236. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21237. * @returns the cloned material
  21238. */
  21239. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21240. /**
  21241. * Serializes the materials into a JSON representation.
  21242. * @returns the JSON representation
  21243. */
  21244. serialize(): any;
  21245. /**
  21246. * Dispose the material and release its associated resources
  21247. * @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)
  21248. * @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)
  21249. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21250. */
  21251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21252. /**
  21253. * Creates a MultiMaterial from parsed MultiMaterial data.
  21254. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21255. * @param scene defines the hosting scene
  21256. * @returns a new MultiMaterial
  21257. */
  21258. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21259. }
  21260. }
  21261. declare module BABYLON {
  21262. /**
  21263. * Base class for submeshes
  21264. */
  21265. export class BaseSubMesh {
  21266. /** @hidden */
  21267. _materialDefines: Nullable<MaterialDefines>;
  21268. /** @hidden */
  21269. _materialEffect: Nullable<Effect>;
  21270. /**
  21271. * Gets associated effect
  21272. */
  21273. readonly effect: Nullable<Effect>;
  21274. /**
  21275. * Sets associated effect (effect used to render this submesh)
  21276. * @param effect defines the effect to associate with
  21277. * @param defines defines the set of defines used to compile this effect
  21278. */
  21279. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21280. }
  21281. /**
  21282. * Defines a subdivision inside a mesh
  21283. */
  21284. export class SubMesh extends BaseSubMesh implements ICullable {
  21285. /** the material index to use */
  21286. materialIndex: number;
  21287. /** vertex index start */
  21288. verticesStart: number;
  21289. /** vertices count */
  21290. verticesCount: number;
  21291. /** index start */
  21292. indexStart: number;
  21293. /** indices count */
  21294. indexCount: number;
  21295. /** @hidden */
  21296. _linesIndexCount: number;
  21297. private _mesh;
  21298. private _renderingMesh;
  21299. private _boundingInfo;
  21300. private _linesIndexBuffer;
  21301. /** @hidden */
  21302. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21303. /** @hidden */
  21304. _trianglePlanes: Plane[];
  21305. /** @hidden */
  21306. _lastColliderTransformMatrix: Matrix;
  21307. /** @hidden */
  21308. _renderId: number;
  21309. /** @hidden */
  21310. _alphaIndex: number;
  21311. /** @hidden */
  21312. _distanceToCamera: number;
  21313. /** @hidden */
  21314. _id: number;
  21315. private _currentMaterial;
  21316. /**
  21317. * Add a new submesh to a mesh
  21318. * @param materialIndex defines the material index to use
  21319. * @param verticesStart defines vertex index start
  21320. * @param verticesCount defines vertices count
  21321. * @param indexStart defines index start
  21322. * @param indexCount defines indices count
  21323. * @param mesh defines the parent mesh
  21324. * @param renderingMesh defines an optional rendering mesh
  21325. * @param createBoundingBox defines if bounding box should be created for this submesh
  21326. * @returns the new submesh
  21327. */
  21328. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21329. /**
  21330. * Creates a new submesh
  21331. * @param materialIndex defines the material index to use
  21332. * @param verticesStart defines vertex index start
  21333. * @param verticesCount defines vertices count
  21334. * @param indexStart defines index start
  21335. * @param indexCount defines indices count
  21336. * @param mesh defines the parent mesh
  21337. * @param renderingMesh defines an optional rendering mesh
  21338. * @param createBoundingBox defines if bounding box should be created for this submesh
  21339. */
  21340. constructor(
  21341. /** the material index to use */
  21342. materialIndex: number,
  21343. /** vertex index start */
  21344. verticesStart: number,
  21345. /** vertices count */
  21346. verticesCount: number,
  21347. /** index start */
  21348. indexStart: number,
  21349. /** indices count */
  21350. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21351. /**
  21352. * Returns true if this submesh covers the entire parent mesh
  21353. * @ignorenaming
  21354. */
  21355. readonly IsGlobal: boolean;
  21356. /**
  21357. * Returns the submesh BoudingInfo object
  21358. * @returns current bounding info (or mesh's one if the submesh is global)
  21359. */
  21360. getBoundingInfo(): BoundingInfo;
  21361. /**
  21362. * Sets the submesh BoundingInfo
  21363. * @param boundingInfo defines the new bounding info to use
  21364. * @returns the SubMesh
  21365. */
  21366. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21367. /**
  21368. * Returns the mesh of the current submesh
  21369. * @return the parent mesh
  21370. */
  21371. getMesh(): AbstractMesh;
  21372. /**
  21373. * Returns the rendering mesh of the submesh
  21374. * @returns the rendering mesh (could be different from parent mesh)
  21375. */
  21376. getRenderingMesh(): Mesh;
  21377. /**
  21378. * Returns the submesh material
  21379. * @returns null or the current material
  21380. */
  21381. getMaterial(): Nullable<Material>;
  21382. /**
  21383. * Sets a new updated BoundingInfo object to the submesh
  21384. * @returns the SubMesh
  21385. */
  21386. refreshBoundingInfo(): SubMesh;
  21387. /** @hidden */
  21388. _checkCollision(collider: Collider): boolean;
  21389. /**
  21390. * Updates the submesh BoundingInfo
  21391. * @param world defines the world matrix to use to update the bounding info
  21392. * @returns the submesh
  21393. */
  21394. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21395. /**
  21396. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21397. * @param frustumPlanes defines the frustum planes
  21398. * @returns true if the submesh is intersecting with the frustum
  21399. */
  21400. isInFrustum(frustumPlanes: Plane[]): boolean;
  21401. /**
  21402. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21403. * @param frustumPlanes defines the frustum planes
  21404. * @returns true if the submesh is inside the frustum
  21405. */
  21406. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21407. /**
  21408. * Renders the submesh
  21409. * @param enableAlphaMode defines if alpha needs to be used
  21410. * @returns the submesh
  21411. */
  21412. render(enableAlphaMode: boolean): SubMesh;
  21413. /**
  21414. * @hidden
  21415. */
  21416. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21417. /**
  21418. * Checks if the submesh intersects with a ray
  21419. * @param ray defines the ray to test
  21420. * @returns true is the passed ray intersects the submesh bounding box
  21421. */
  21422. canIntersects(ray: Ray): boolean;
  21423. /**
  21424. * Intersects current submesh with a ray
  21425. * @param ray defines the ray to test
  21426. * @param positions defines mesh's positions array
  21427. * @param indices defines mesh's indices array
  21428. * @param fastCheck defines if only bounding info should be used
  21429. * @returns intersection info or null if no intersection
  21430. */
  21431. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21432. /** @hidden */
  21433. private _intersectLines;
  21434. /** @hidden */
  21435. private _intersectTriangles;
  21436. /** @hidden */
  21437. _rebuild(): void;
  21438. /**
  21439. * Creates a new submesh from the passed mesh
  21440. * @param newMesh defines the new hosting mesh
  21441. * @param newRenderingMesh defines an optional rendering mesh
  21442. * @returns the new submesh
  21443. */
  21444. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21445. /**
  21446. * Release associated resources
  21447. */
  21448. dispose(): void;
  21449. /**
  21450. * Gets the class name
  21451. * @returns the string "SubMesh".
  21452. */
  21453. getClassName(): string;
  21454. /**
  21455. * Creates a new submesh from indices data
  21456. * @param materialIndex the index of the main mesh material
  21457. * @param startIndex the index where to start the copy in the mesh indices array
  21458. * @param indexCount the number of indices to copy then from the startIndex
  21459. * @param mesh the main mesh to create the submesh from
  21460. * @param renderingMesh the optional rendering mesh
  21461. * @returns a new submesh
  21462. */
  21463. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21464. }
  21465. }
  21466. declare module BABYLON {
  21467. /**
  21468. * Class used to store geometry data (vertex buffers + index buffer)
  21469. */
  21470. export class Geometry implements IGetSetVerticesData {
  21471. /**
  21472. * Gets or sets the ID of the geometry
  21473. */
  21474. id: string;
  21475. /**
  21476. * Gets or sets the unique ID of the geometry
  21477. */
  21478. uniqueId: number;
  21479. /**
  21480. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21481. */
  21482. delayLoadState: number;
  21483. /**
  21484. * Gets the file containing the data to load when running in delay load state
  21485. */
  21486. delayLoadingFile: Nullable<string>;
  21487. /**
  21488. * Callback called when the geometry is updated
  21489. */
  21490. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21491. private _scene;
  21492. private _engine;
  21493. private _meshes;
  21494. private _totalVertices;
  21495. /** @hidden */
  21496. _indices: IndicesArray;
  21497. /** @hidden */
  21498. _vertexBuffers: {
  21499. [key: string]: VertexBuffer;
  21500. };
  21501. private _isDisposed;
  21502. private _extend;
  21503. private _boundingBias;
  21504. /** @hidden */
  21505. _delayInfo: Array<string>;
  21506. private _indexBuffer;
  21507. private _indexBufferIsUpdatable;
  21508. /** @hidden */
  21509. _boundingInfo: Nullable<BoundingInfo>;
  21510. /** @hidden */
  21511. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21512. /** @hidden */
  21513. _softwareSkinningFrameId: number;
  21514. private _vertexArrayObjects;
  21515. private _updatable;
  21516. /** @hidden */
  21517. _positions: Nullable<Vector3[]>;
  21518. /**
  21519. * 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
  21520. */
  21521. /**
  21522. * 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
  21523. */
  21524. boundingBias: Vector2;
  21525. /**
  21526. * Static function used to attach a new empty geometry to a mesh
  21527. * @param mesh defines the mesh to attach the geometry to
  21528. * @returns the new Geometry
  21529. */
  21530. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21531. /**
  21532. * Creates a new geometry
  21533. * @param id defines the unique ID
  21534. * @param scene defines the hosting scene
  21535. * @param vertexData defines the VertexData used to get geometry data
  21536. * @param updatable defines if geometry must be updatable (false by default)
  21537. * @param mesh defines the mesh that will be associated with the geometry
  21538. */
  21539. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21540. /**
  21541. * Gets the current extend of the geometry
  21542. */
  21543. readonly extend: {
  21544. minimum: Vector3;
  21545. maximum: Vector3;
  21546. };
  21547. /**
  21548. * Gets the hosting scene
  21549. * @returns the hosting Scene
  21550. */
  21551. getScene(): Scene;
  21552. /**
  21553. * Gets the hosting engine
  21554. * @returns the hosting Engine
  21555. */
  21556. getEngine(): Engine;
  21557. /**
  21558. * Defines if the geometry is ready to use
  21559. * @returns true if the geometry is ready to be used
  21560. */
  21561. isReady(): boolean;
  21562. /**
  21563. * Gets a value indicating that the geometry should not be serialized
  21564. */
  21565. readonly doNotSerialize: boolean;
  21566. /** @hidden */
  21567. _rebuild(): void;
  21568. /**
  21569. * Affects all geometry data in one call
  21570. * @param vertexData defines the geometry data
  21571. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21572. */
  21573. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21574. /**
  21575. * Set specific vertex data
  21576. * @param kind defines the data kind (Position, normal, etc...)
  21577. * @param data defines the vertex data to use
  21578. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21579. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21580. */
  21581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21582. /**
  21583. * Removes a specific vertex data
  21584. * @param kind defines the data kind (Position, normal, etc...)
  21585. */
  21586. removeVerticesData(kind: string): void;
  21587. /**
  21588. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21589. * @param buffer defines the vertex buffer to use
  21590. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21591. */
  21592. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21593. /**
  21594. * Update a specific vertex buffer
  21595. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21596. * It will do nothing if the buffer is not updatable
  21597. * @param kind defines the data kind (Position, normal, etc...)
  21598. * @param data defines the data to use
  21599. * @param offset defines the offset in the target buffer where to store the data
  21600. * @param useBytes set to true if the offset is in bytes
  21601. */
  21602. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21603. /**
  21604. * Update a specific vertex buffer
  21605. * This function will create a new buffer if the current one is not updatable
  21606. * @param kind defines the data kind (Position, normal, etc...)
  21607. * @param data defines the data to use
  21608. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21609. */
  21610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21611. private _updateBoundingInfo;
  21612. /** @hidden */
  21613. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21614. /**
  21615. * Gets total number of vertices
  21616. * @returns the total number of vertices
  21617. */
  21618. getTotalVertices(): number;
  21619. /**
  21620. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21621. * @param kind defines the data kind (Position, normal, etc...)
  21622. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21623. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21624. * @returns a float array containing vertex data
  21625. */
  21626. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21627. /**
  21628. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21629. * @param kind defines the data kind (Position, normal, etc...)
  21630. * @returns true if the vertex buffer with the specified kind is updatable
  21631. */
  21632. isVertexBufferUpdatable(kind: string): boolean;
  21633. /**
  21634. * Gets a specific vertex buffer
  21635. * @param kind defines the data kind (Position, normal, etc...)
  21636. * @returns a VertexBuffer
  21637. */
  21638. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21639. /**
  21640. * Returns all vertex buffers
  21641. * @return an object holding all vertex buffers indexed by kind
  21642. */
  21643. getVertexBuffers(): Nullable<{
  21644. [key: string]: VertexBuffer;
  21645. }>;
  21646. /**
  21647. * Gets a boolean indicating if specific vertex buffer is present
  21648. * @param kind defines the data kind (Position, normal, etc...)
  21649. * @returns true if data is present
  21650. */
  21651. isVerticesDataPresent(kind: string): boolean;
  21652. /**
  21653. * Gets a list of all attached data kinds (Position, normal, etc...)
  21654. * @returns a list of string containing all kinds
  21655. */
  21656. getVerticesDataKinds(): string[];
  21657. /**
  21658. * Update index buffer
  21659. * @param indices defines the indices to store in the index buffer
  21660. * @param offset defines the offset in the target buffer where to store the data
  21661. */
  21662. updateIndices(indices: IndicesArray, offset?: number): void;
  21663. /**
  21664. * Creates a new index buffer
  21665. * @param indices defines the indices to store in the index buffer
  21666. * @param totalVertices defines the total number of vertices (could be null)
  21667. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21668. */
  21669. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21670. /**
  21671. * Return the total number of indices
  21672. * @returns the total number of indices
  21673. */
  21674. getTotalIndices(): number;
  21675. /**
  21676. * Gets the index buffer array
  21677. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21678. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21679. * @returns the index buffer array
  21680. */
  21681. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21682. /**
  21683. * Gets the index buffer
  21684. * @return the index buffer
  21685. */
  21686. getIndexBuffer(): Nullable<WebGLBuffer>;
  21687. /** @hidden */
  21688. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21689. /**
  21690. * Release the associated resources for a specific mesh
  21691. * @param mesh defines the source mesh
  21692. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21693. */
  21694. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21695. /**
  21696. * Apply current geometry to a given mesh
  21697. * @param mesh defines the mesh to apply geometry to
  21698. */
  21699. applyToMesh(mesh: Mesh): void;
  21700. private _updateExtend;
  21701. private _applyToMesh;
  21702. private notifyUpdate;
  21703. /**
  21704. * Load the geometry if it was flagged as delay loaded
  21705. * @param scene defines the hosting scene
  21706. * @param onLoaded defines a callback called when the geometry is loaded
  21707. */
  21708. load(scene: Scene, onLoaded?: () => void): void;
  21709. private _queueLoad;
  21710. /**
  21711. * Invert the geometry to move from a right handed system to a left handed one.
  21712. */
  21713. toLeftHanded(): void;
  21714. /** @hidden */
  21715. _resetPointsArrayCache(): void;
  21716. /** @hidden */
  21717. _generatePointsArray(): boolean;
  21718. /**
  21719. * Gets a value indicating if the geometry is disposed
  21720. * @returns true if the geometry was disposed
  21721. */
  21722. isDisposed(): boolean;
  21723. private _disposeVertexArrayObjects;
  21724. /**
  21725. * Free all associated resources
  21726. */
  21727. dispose(): void;
  21728. /**
  21729. * Clone the current geometry into a new geometry
  21730. * @param id defines the unique ID of the new geometry
  21731. * @returns a new geometry object
  21732. */
  21733. copy(id: string): Geometry;
  21734. /**
  21735. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21736. * @return a JSON representation of the current geometry data (without the vertices data)
  21737. */
  21738. serialize(): any;
  21739. private toNumberArray;
  21740. /**
  21741. * Serialize all vertices data into a JSON oject
  21742. * @returns a JSON representation of the current geometry data
  21743. */
  21744. serializeVerticeData(): any;
  21745. /**
  21746. * Extracts a clone of a mesh geometry
  21747. * @param mesh defines the source mesh
  21748. * @param id defines the unique ID of the new geometry object
  21749. * @returns the new geometry object
  21750. */
  21751. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21752. /**
  21753. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21754. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21755. * Be aware Math.random() could cause collisions, but:
  21756. * "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"
  21757. * @returns a string containing a new GUID
  21758. */
  21759. static RandomId(): string;
  21760. /** @hidden */
  21761. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21762. private static _CleanMatricesWeights;
  21763. /**
  21764. * Create a new geometry from persisted data (Using .babylon file format)
  21765. * @param parsedVertexData defines the persisted data
  21766. * @param scene defines the hosting scene
  21767. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21768. * @returns the new geometry object
  21769. */
  21770. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21771. }
  21772. /**
  21773. * Abstract class used to provide common services for all typed geometries
  21774. * @hidden
  21775. */
  21776. export class _PrimitiveGeometry extends Geometry {
  21777. private _canBeRegenerated;
  21778. private _beingRegenerated;
  21779. /**
  21780. * Creates a new typed geometry
  21781. * @param id defines the unique ID of the geometry
  21782. * @param scene defines the hosting scene
  21783. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21784. * @param mesh defines the hosting mesh (can be null)
  21785. */
  21786. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21787. /**
  21788. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  21789. * @returns true if the geometry can be regenerated
  21790. */
  21791. canBeRegenerated(): boolean;
  21792. /**
  21793. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  21794. */
  21795. regenerate(): void;
  21796. /**
  21797. * Clone the geometry
  21798. * @param id defines the unique ID of the new geometry
  21799. * @returns the new geometry
  21800. */
  21801. asNewGeometry(id: string): Geometry;
  21802. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21803. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  21804. /** @hidden */
  21805. _regenerateVertexData(): VertexData;
  21806. copy(id: string): Geometry;
  21807. serialize(): any;
  21808. }
  21809. /**
  21810. * Creates a ribbon geometry
  21811. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  21812. */
  21813. export class RibbonGeometry extends _PrimitiveGeometry {
  21814. /**
  21815. * Defines the array of paths to use
  21816. */
  21817. pathArray: Vector3[][];
  21818. /**
  21819. * Defines if the last and first points of each path in your pathArray must be joined
  21820. */
  21821. closeArray: boolean;
  21822. /**
  21823. * Defines if the last and first points of each path in your pathArray must be joined
  21824. */
  21825. closePath: boolean;
  21826. /**
  21827. * Defines the offset between points
  21828. */
  21829. offset: number;
  21830. /**
  21831. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21832. */
  21833. side: number;
  21834. /**
  21835. * Creates a ribbon geometry
  21836. * @param id defines the unique ID of the geometry
  21837. * @param scene defines the hosting scene
  21838. * @param pathArray defines the array of paths to use
  21839. * @param closeArray defines if the last path and the first path must be joined
  21840. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  21841. * @param offset defines the offset between points
  21842. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21843. * @param mesh defines the hosting mesh (can be null)
  21844. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21845. */
  21846. constructor(id: string, scene: Scene,
  21847. /**
  21848. * Defines the array of paths to use
  21849. */
  21850. pathArray: Vector3[][],
  21851. /**
  21852. * Defines if the last and first points of each path in your pathArray must be joined
  21853. */
  21854. closeArray: boolean,
  21855. /**
  21856. * Defines if the last and first points of each path in your pathArray must be joined
  21857. */
  21858. closePath: boolean,
  21859. /**
  21860. * Defines the offset between points
  21861. */
  21862. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  21863. /**
  21864. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21865. */
  21866. side?: number);
  21867. /** @hidden */
  21868. _regenerateVertexData(): VertexData;
  21869. copy(id: string): Geometry;
  21870. }
  21871. /**
  21872. * Creates a box geometry
  21873. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  21874. */
  21875. export class BoxGeometry extends _PrimitiveGeometry {
  21876. /**
  21877. * Defines the zise of the box (width, height and depth are the same)
  21878. */
  21879. size: number;
  21880. /**
  21881. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21882. */
  21883. side: number;
  21884. /**
  21885. * Creates a box geometry
  21886. * @param id defines the unique ID of the geometry
  21887. * @param scene defines the hosting scene
  21888. * @param size defines the zise of the box (width, height and depth are the same)
  21889. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21890. * @param mesh defines the hosting mesh (can be null)
  21891. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21892. */
  21893. constructor(id: string, scene: Scene,
  21894. /**
  21895. * Defines the zise of the box (width, height and depth are the same)
  21896. */
  21897. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21898. /**
  21899. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21900. */
  21901. side?: number);
  21902. /** @hidden */
  21903. _regenerateVertexData(): VertexData;
  21904. copy(id: string): Geometry;
  21905. serialize(): any;
  21906. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  21907. }
  21908. /**
  21909. * Creates a sphere geometry
  21910. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  21911. */
  21912. export class SphereGeometry extends _PrimitiveGeometry {
  21913. /**
  21914. * Defines the number of segments to use to create the sphere
  21915. */
  21916. segments: number;
  21917. /**
  21918. * Defines the diameter of the sphere
  21919. */
  21920. diameter: number;
  21921. /**
  21922. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21923. */
  21924. side: number;
  21925. /**
  21926. * Create a new sphere geometry
  21927. * @param id defines the unique ID of the geometry
  21928. * @param scene defines the hosting scene
  21929. * @param segments defines the number of segments to use to create the sphere
  21930. * @param diameter defines the diameter of the sphere
  21931. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21932. * @param mesh defines the hosting mesh (can be null)
  21933. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21934. */
  21935. constructor(id: string, scene: Scene,
  21936. /**
  21937. * Defines the number of segments to use to create the sphere
  21938. */
  21939. segments: number,
  21940. /**
  21941. * Defines the diameter of the sphere
  21942. */
  21943. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21944. /**
  21945. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21946. */
  21947. side?: number);
  21948. /** @hidden */
  21949. _regenerateVertexData(): VertexData;
  21950. copy(id: string): Geometry;
  21951. serialize(): any;
  21952. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  21953. }
  21954. /**
  21955. * Creates a disc geometry
  21956. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21957. */
  21958. export class DiscGeometry extends _PrimitiveGeometry {
  21959. /**
  21960. * Defines the radius of the disc
  21961. */
  21962. radius: number;
  21963. /**
  21964. * Defines the tesselation factor to apply to the disc
  21965. */
  21966. tessellation: number;
  21967. /**
  21968. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21969. */
  21970. side: number;
  21971. /**
  21972. * Creates a new disc geometry
  21973. * @param id defines the unique ID of the geometry
  21974. * @param scene defines the hosting scene
  21975. * @param radius defines the radius of the disc
  21976. * @param tessellation defines the tesselation factor to apply to the disc
  21977. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21978. * @param mesh defines the hosting mesh (can be null)
  21979. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21980. */
  21981. constructor(id: string, scene: Scene,
  21982. /**
  21983. * Defines the radius of the disc
  21984. */
  21985. radius: number,
  21986. /**
  21987. * Defines the tesselation factor to apply to the disc
  21988. */
  21989. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21990. /**
  21991. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21992. */
  21993. side?: number);
  21994. /** @hidden */
  21995. _regenerateVertexData(): VertexData;
  21996. copy(id: string): Geometry;
  21997. }
  21998. /**
  21999. * Creates a new cylinder geometry
  22000. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22001. */
  22002. export class CylinderGeometry extends _PrimitiveGeometry {
  22003. /**
  22004. * Defines the height of the cylinder
  22005. */
  22006. height: number;
  22007. /**
  22008. * Defines the diameter of the cylinder's top cap
  22009. */
  22010. diameterTop: number;
  22011. /**
  22012. * Defines the diameter of the cylinder's bottom cap
  22013. */
  22014. diameterBottom: number;
  22015. /**
  22016. * Defines the tessellation factor to apply to the cylinder
  22017. */
  22018. tessellation: number;
  22019. /**
  22020. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22021. */
  22022. subdivisions: number;
  22023. /**
  22024. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22025. */
  22026. side: number;
  22027. /**
  22028. * Creates a new cylinder geometry
  22029. * @param id defines the unique ID of the geometry
  22030. * @param scene defines the hosting scene
  22031. * @param height defines the height of the cylinder
  22032. * @param diameterTop defines the diameter of the cylinder's top cap
  22033. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22034. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22035. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22036. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22037. * @param mesh defines the hosting mesh (can be null)
  22038. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22039. */
  22040. constructor(id: string, scene: Scene,
  22041. /**
  22042. * Defines the height of the cylinder
  22043. */
  22044. height: number,
  22045. /**
  22046. * Defines the diameter of the cylinder's top cap
  22047. */
  22048. diameterTop: number,
  22049. /**
  22050. * Defines the diameter of the cylinder's bottom cap
  22051. */
  22052. diameterBottom: number,
  22053. /**
  22054. * Defines the tessellation factor to apply to the cylinder
  22055. */
  22056. tessellation: number,
  22057. /**
  22058. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22059. */
  22060. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22061. /**
  22062. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22063. */
  22064. side?: number);
  22065. /** @hidden */
  22066. _regenerateVertexData(): VertexData;
  22067. copy(id: string): Geometry;
  22068. serialize(): any;
  22069. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22070. }
  22071. /**
  22072. * Creates a new torus geometry
  22073. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22074. */
  22075. export class TorusGeometry extends _PrimitiveGeometry {
  22076. /**
  22077. * Defines the diameter of the torus
  22078. */
  22079. diameter: number;
  22080. /**
  22081. * Defines the thickness of the torus (ie. internal diameter)
  22082. */
  22083. thickness: number;
  22084. /**
  22085. * Defines the tesselation factor to apply to the torus
  22086. */
  22087. tessellation: number;
  22088. /**
  22089. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22090. */
  22091. side: number;
  22092. /**
  22093. * Creates a new torus geometry
  22094. * @param id defines the unique ID of the geometry
  22095. * @param scene defines the hosting scene
  22096. * @param diameter defines the diameter of the torus
  22097. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22098. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22099. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22100. * @param mesh defines the hosting mesh (can be null)
  22101. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22102. */
  22103. constructor(id: string, scene: Scene,
  22104. /**
  22105. * Defines the diameter of the torus
  22106. */
  22107. diameter: number,
  22108. /**
  22109. * Defines the thickness of the torus (ie. internal diameter)
  22110. */
  22111. thickness: number,
  22112. /**
  22113. * Defines the tesselation factor to apply to the torus
  22114. */
  22115. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22116. /**
  22117. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22118. */
  22119. side?: number);
  22120. /** @hidden */
  22121. _regenerateVertexData(): VertexData;
  22122. copy(id: string): Geometry;
  22123. serialize(): any;
  22124. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22125. }
  22126. /**
  22127. * Creates a new ground geometry
  22128. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22129. */
  22130. export class GroundGeometry extends _PrimitiveGeometry {
  22131. /**
  22132. * Defines the width of the ground
  22133. */
  22134. width: number;
  22135. /**
  22136. * Defines the height of the ground
  22137. */
  22138. height: number;
  22139. /**
  22140. * Defines the subdivisions to apply to the ground
  22141. */
  22142. subdivisions: number;
  22143. /**
  22144. * Creates a new ground geometry
  22145. * @param id defines the unique ID of the geometry
  22146. * @param scene defines the hosting scene
  22147. * @param width defines the width of the ground
  22148. * @param height defines the height of the ground
  22149. * @param subdivisions defines the subdivisions to apply to the ground
  22150. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22151. * @param mesh defines the hosting mesh (can be null)
  22152. */
  22153. constructor(id: string, scene: Scene,
  22154. /**
  22155. * Defines the width of the ground
  22156. */
  22157. width: number,
  22158. /**
  22159. * Defines the height of the ground
  22160. */
  22161. height: number,
  22162. /**
  22163. * Defines the subdivisions to apply to the ground
  22164. */
  22165. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22166. /** @hidden */
  22167. _regenerateVertexData(): VertexData;
  22168. copy(id: string): Geometry;
  22169. serialize(): any;
  22170. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22171. }
  22172. /**
  22173. * Creates a tiled ground geometry
  22174. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22175. */
  22176. export class TiledGroundGeometry extends _PrimitiveGeometry {
  22177. /**
  22178. * Defines the minimum value on X axis
  22179. */
  22180. xmin: number;
  22181. /**
  22182. * Defines the minimum value on Z axis
  22183. */
  22184. zmin: number;
  22185. /**
  22186. * Defines the maximum value on X axis
  22187. */
  22188. xmax: number;
  22189. /**
  22190. * Defines the maximum value on Z axis
  22191. */
  22192. zmax: number;
  22193. /**
  22194. * Defines the subdivisions to apply to the ground
  22195. */
  22196. subdivisions: {
  22197. w: number;
  22198. h: number;
  22199. };
  22200. /**
  22201. * Defines the precision to use when computing the tiles
  22202. */
  22203. precision: {
  22204. w: number;
  22205. h: number;
  22206. };
  22207. /**
  22208. * Creates a tiled ground geometry
  22209. * @param id defines the unique ID of the geometry
  22210. * @param scene defines the hosting scene
  22211. * @param xmin defines the minimum value on X axis
  22212. * @param zmin defines the minimum value on Z axis
  22213. * @param xmax defines the maximum value on X axis
  22214. * @param zmax defines the maximum value on Z axis
  22215. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22216. * @param precision defines the precision to use when computing the tiles
  22217. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22218. * @param mesh defines the hosting mesh (can be null)
  22219. */
  22220. constructor(id: string, scene: Scene,
  22221. /**
  22222. * Defines the minimum value on X axis
  22223. */
  22224. xmin: number,
  22225. /**
  22226. * Defines the minimum value on Z axis
  22227. */
  22228. zmin: number,
  22229. /**
  22230. * Defines the maximum value on X axis
  22231. */
  22232. xmax: number,
  22233. /**
  22234. * Defines the maximum value on Z axis
  22235. */
  22236. zmax: number,
  22237. /**
  22238. * Defines the subdivisions to apply to the ground
  22239. */
  22240. subdivisions: {
  22241. w: number;
  22242. h: number;
  22243. },
  22244. /**
  22245. * Defines the precision to use when computing the tiles
  22246. */
  22247. precision: {
  22248. w: number;
  22249. h: number;
  22250. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22251. /** @hidden */
  22252. _regenerateVertexData(): VertexData;
  22253. copy(id: string): Geometry;
  22254. }
  22255. /**
  22256. * Creates a plane geometry
  22257. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22258. */
  22259. export class PlaneGeometry extends _PrimitiveGeometry {
  22260. /**
  22261. * Defines the size of the plane (width === height)
  22262. */
  22263. size: number;
  22264. /**
  22265. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22266. */
  22267. side: number;
  22268. /**
  22269. * Creates a plane geometry
  22270. * @param id defines the unique ID of the geometry
  22271. * @param scene defines the hosting scene
  22272. * @param size defines the size of the plane (width === height)
  22273. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22274. * @param mesh defines the hosting mesh (can be null)
  22275. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22276. */
  22277. constructor(id: string, scene: Scene,
  22278. /**
  22279. * Defines the size of the plane (width === height)
  22280. */
  22281. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22282. /**
  22283. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22284. */
  22285. side?: number);
  22286. /** @hidden */
  22287. _regenerateVertexData(): VertexData;
  22288. copy(id: string): Geometry;
  22289. serialize(): any;
  22290. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  22291. }
  22292. /**
  22293. * Creates a torus knot geometry
  22294. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  22295. */
  22296. export class TorusKnotGeometry extends _PrimitiveGeometry {
  22297. /**
  22298. * Defines the radius of the torus knot
  22299. */
  22300. radius: number;
  22301. /**
  22302. * Defines the thickness of the torus knot tube
  22303. */
  22304. tube: number;
  22305. /**
  22306. * Defines the number of radial segments
  22307. */
  22308. radialSegments: number;
  22309. /**
  22310. * Defines the number of tubular segments
  22311. */
  22312. tubularSegments: number;
  22313. /**
  22314. * Defines the first number of windings
  22315. */
  22316. p: number;
  22317. /**
  22318. * Defines the second number of windings
  22319. */
  22320. q: number;
  22321. /**
  22322. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22323. */
  22324. side: number;
  22325. /**
  22326. * Creates a torus knot geometry
  22327. * @param id defines the unique ID of the geometry
  22328. * @param scene defines the hosting scene
  22329. * @param radius defines the radius of the torus knot
  22330. * @param tube defines the thickness of the torus knot tube
  22331. * @param radialSegments defines the number of radial segments
  22332. * @param tubularSegments defines the number of tubular segments
  22333. * @param p defines the first number of windings
  22334. * @param q defines the second number of windings
  22335. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22336. * @param mesh defines the hosting mesh (can be null)
  22337. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22338. */
  22339. constructor(id: string, scene: Scene,
  22340. /**
  22341. * Defines the radius of the torus knot
  22342. */
  22343. radius: number,
  22344. /**
  22345. * Defines the thickness of the torus knot tube
  22346. */
  22347. tube: number,
  22348. /**
  22349. * Defines the number of radial segments
  22350. */
  22351. radialSegments: number,
  22352. /**
  22353. * Defines the number of tubular segments
  22354. */
  22355. tubularSegments: number,
  22356. /**
  22357. * Defines the first number of windings
  22358. */
  22359. p: number,
  22360. /**
  22361. * Defines the second number of windings
  22362. */
  22363. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22364. /**
  22365. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22366. */
  22367. side?: number);
  22368. /** @hidden */
  22369. _regenerateVertexData(): VertexData;
  22370. copy(id: string): Geometry;
  22371. serialize(): any;
  22372. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  22373. }
  22374. }
  22375. declare module BABYLON {
  22376. /**
  22377. * Define an interface for all classes that will get and set the data on vertices
  22378. */
  22379. export interface IGetSetVerticesData {
  22380. /**
  22381. * Gets a boolean indicating if specific vertex data is present
  22382. * @param kind defines the vertex data kind to use
  22383. * @returns true is data kind is present
  22384. */
  22385. isVerticesDataPresent(kind: string): boolean;
  22386. /**
  22387. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22388. * @param kind defines the data kind (Position, normal, etc...)
  22389. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22390. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22391. * @returns a float array containing vertex data
  22392. */
  22393. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22394. /**
  22395. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22396. * @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.
  22397. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22398. * @returns the indices array or an empty array if the mesh has no geometry
  22399. */
  22400. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22401. /**
  22402. * Set specific vertex data
  22403. * @param kind defines the data kind (Position, normal, etc...)
  22404. * @param data defines the vertex data to use
  22405. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22406. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22407. */
  22408. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22409. /**
  22410. * Update a specific associated vertex buffer
  22411. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22412. * - VertexBuffer.PositionKind
  22413. * - VertexBuffer.UVKind
  22414. * - VertexBuffer.UV2Kind
  22415. * - VertexBuffer.UV3Kind
  22416. * - VertexBuffer.UV4Kind
  22417. * - VertexBuffer.UV5Kind
  22418. * - VertexBuffer.UV6Kind
  22419. * - VertexBuffer.ColorKind
  22420. * - VertexBuffer.MatricesIndicesKind
  22421. * - VertexBuffer.MatricesIndicesExtraKind
  22422. * - VertexBuffer.MatricesWeightsKind
  22423. * - VertexBuffer.MatricesWeightsExtraKind
  22424. * @param data defines the data source
  22425. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22426. * @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)
  22427. */
  22428. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22429. /**
  22430. * Creates a new index buffer
  22431. * @param indices defines the indices to store in the index buffer
  22432. * @param totalVertices defines the total number of vertices (could be null)
  22433. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22434. */
  22435. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22436. }
  22437. /**
  22438. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22439. */
  22440. export class VertexData {
  22441. /**
  22442. * Mesh side orientation : usually the external or front surface
  22443. */
  22444. static readonly FRONTSIDE: number;
  22445. /**
  22446. * Mesh side orientation : usually the internal or back surface
  22447. */
  22448. static readonly BACKSIDE: number;
  22449. /**
  22450. * Mesh side orientation : both internal and external or front and back surfaces
  22451. */
  22452. static readonly DOUBLESIDE: number;
  22453. /**
  22454. * Mesh side orientation : by default, `FRONTSIDE`
  22455. */
  22456. static readonly DEFAULTSIDE: number;
  22457. /**
  22458. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22459. */
  22460. positions: Nullable<FloatArray>;
  22461. /**
  22462. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22463. */
  22464. normals: Nullable<FloatArray>;
  22465. /**
  22466. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22467. */
  22468. tangents: Nullable<FloatArray>;
  22469. /**
  22470. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22471. */
  22472. uvs: Nullable<FloatArray>;
  22473. /**
  22474. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22475. */
  22476. uvs2: Nullable<FloatArray>;
  22477. /**
  22478. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22479. */
  22480. uvs3: Nullable<FloatArray>;
  22481. /**
  22482. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22483. */
  22484. uvs4: Nullable<FloatArray>;
  22485. /**
  22486. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22487. */
  22488. uvs5: Nullable<FloatArray>;
  22489. /**
  22490. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22491. */
  22492. uvs6: Nullable<FloatArray>;
  22493. /**
  22494. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22495. */
  22496. colors: Nullable<FloatArray>;
  22497. /**
  22498. * 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).
  22499. */
  22500. matricesIndices: Nullable<FloatArray>;
  22501. /**
  22502. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22503. */
  22504. matricesWeights: Nullable<FloatArray>;
  22505. /**
  22506. * An array extending the number of possible indices
  22507. */
  22508. matricesIndicesExtra: Nullable<FloatArray>;
  22509. /**
  22510. * An array extending the number of possible weights when the number of indices is extended
  22511. */
  22512. matricesWeightsExtra: Nullable<FloatArray>;
  22513. /**
  22514. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22515. */
  22516. indices: Nullable<IndicesArray>;
  22517. /**
  22518. * Uses the passed data array to set the set the values for the specified kind of data
  22519. * @param data a linear array of floating numbers
  22520. * @param kind the type of data that is being set, eg positions, colors etc
  22521. */
  22522. set(data: FloatArray, kind: string): void;
  22523. /**
  22524. * Associates the vertexData to the passed Mesh.
  22525. * Sets it as updatable or not (default `false`)
  22526. * @param mesh the mesh the vertexData is applied to
  22527. * @param updatable when used and having the value true allows new data to update the vertexData
  22528. * @returns the VertexData
  22529. */
  22530. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22531. /**
  22532. * Associates the vertexData to the passed Geometry.
  22533. * Sets it as updatable or not (default `false`)
  22534. * @param geometry the geometry the vertexData is applied to
  22535. * @param updatable when used and having the value true allows new data to update the vertexData
  22536. * @returns VertexData
  22537. */
  22538. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22539. /**
  22540. * Updates the associated mesh
  22541. * @param mesh the mesh to be updated
  22542. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22543. * @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
  22544. * @returns VertexData
  22545. */
  22546. updateMesh(mesh: Mesh): VertexData;
  22547. /**
  22548. * Updates the associated geometry
  22549. * @param geometry the geometry to be updated
  22550. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22551. * @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
  22552. * @returns VertexData.
  22553. */
  22554. updateGeometry(geometry: Geometry): VertexData;
  22555. private _applyTo;
  22556. private _update;
  22557. /**
  22558. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22559. * @param matrix the transforming matrix
  22560. * @returns the VertexData
  22561. */
  22562. transform(matrix: Matrix): VertexData;
  22563. /**
  22564. * Merges the passed VertexData into the current one
  22565. * @param other the VertexData to be merged into the current one
  22566. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22567. * @returns the modified VertexData
  22568. */
  22569. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22570. private _mergeElement;
  22571. private _validate;
  22572. /**
  22573. * Serializes the VertexData
  22574. * @returns a serialized object
  22575. */
  22576. serialize(): any;
  22577. /**
  22578. * Extracts the vertexData from a mesh
  22579. * @param mesh the mesh from which to extract the VertexData
  22580. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22581. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22582. * @returns the object VertexData associated to the passed mesh
  22583. */
  22584. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22585. /**
  22586. * Extracts the vertexData from the geometry
  22587. * @param geometry the geometry from which to extract the VertexData
  22588. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22589. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22590. * @returns the object VertexData associated to the passed mesh
  22591. */
  22592. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22593. private static _ExtractFrom;
  22594. /**
  22595. * Creates the VertexData for a Ribbon
  22596. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22597. * * pathArray array of paths, each of which an array of successive Vector3
  22598. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22599. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22600. * * 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
  22601. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22602. * * 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)
  22603. * * 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)
  22604. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22605. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22606. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22607. * @returns the VertexData of the ribbon
  22608. */
  22609. static CreateRibbon(options: {
  22610. pathArray: Vector3[][];
  22611. closeArray?: boolean;
  22612. closePath?: boolean;
  22613. offset?: number;
  22614. sideOrientation?: number;
  22615. frontUVs?: Vector4;
  22616. backUVs?: Vector4;
  22617. invertUV?: boolean;
  22618. uvs?: Vector2[];
  22619. colors?: Color4[];
  22620. }): VertexData;
  22621. /**
  22622. * Creates the VertexData for a box
  22623. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22624. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22625. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22626. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22627. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22628. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22629. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22631. * * 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)
  22632. * * 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)
  22633. * @returns the VertexData of the box
  22634. */
  22635. static CreateBox(options: {
  22636. size?: number;
  22637. width?: number;
  22638. height?: number;
  22639. depth?: number;
  22640. faceUV?: Vector4[];
  22641. faceColors?: Color4[];
  22642. sideOrientation?: number;
  22643. frontUVs?: Vector4;
  22644. backUVs?: Vector4;
  22645. }): VertexData;
  22646. /**
  22647. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22648. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22649. * * segments sets the number of horizontal strips optional, default 32
  22650. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22651. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22652. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22653. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22654. * * 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
  22655. * * 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
  22656. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22657. * * 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)
  22658. * * 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)
  22659. * @returns the VertexData of the ellipsoid
  22660. */
  22661. static CreateSphere(options: {
  22662. segments?: number;
  22663. diameter?: number;
  22664. diameterX?: number;
  22665. diameterY?: number;
  22666. diameterZ?: number;
  22667. arc?: number;
  22668. slice?: number;
  22669. sideOrientation?: number;
  22670. frontUVs?: Vector4;
  22671. backUVs?: Vector4;
  22672. }): VertexData;
  22673. /**
  22674. * Creates the VertexData for a cylinder, cone or prism
  22675. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22676. * * height sets the height (y direction) of the cylinder, optional, default 2
  22677. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22678. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22679. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22680. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22681. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22682. * * 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
  22683. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22684. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22685. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22686. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22688. * * 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)
  22689. * * 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)
  22690. * @returns the VertexData of the cylinder, cone or prism
  22691. */
  22692. static CreateCylinder(options: {
  22693. height?: number;
  22694. diameterTop?: number;
  22695. diameterBottom?: number;
  22696. diameter?: number;
  22697. tessellation?: number;
  22698. subdivisions?: number;
  22699. arc?: number;
  22700. faceColors?: Color4[];
  22701. faceUV?: Vector4[];
  22702. hasRings?: boolean;
  22703. enclose?: boolean;
  22704. sideOrientation?: number;
  22705. frontUVs?: Vector4;
  22706. backUVs?: Vector4;
  22707. }): VertexData;
  22708. /**
  22709. * Creates the VertexData for a torus
  22710. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22711. * * diameter the diameter of the torus, optional default 1
  22712. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22713. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22715. * * 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)
  22716. * * 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)
  22717. * @returns the VertexData of the torus
  22718. */
  22719. static CreateTorus(options: {
  22720. diameter?: number;
  22721. thickness?: number;
  22722. tessellation?: number;
  22723. sideOrientation?: number;
  22724. frontUVs?: Vector4;
  22725. backUVs?: Vector4;
  22726. }): VertexData;
  22727. /**
  22728. * Creates the VertexData of the LineSystem
  22729. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22730. * - lines an array of lines, each line being an array of successive Vector3
  22731. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22732. * @returns the VertexData of the LineSystem
  22733. */
  22734. static CreateLineSystem(options: {
  22735. lines: Vector3[][];
  22736. colors?: Nullable<Color4[][]>;
  22737. }): VertexData;
  22738. /**
  22739. * Create the VertexData for a DashedLines
  22740. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22741. * - points an array successive Vector3
  22742. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22743. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22744. * - dashNb the intended total number of dashes, optional, default 200
  22745. * @returns the VertexData for the DashedLines
  22746. */
  22747. static CreateDashedLines(options: {
  22748. points: Vector3[];
  22749. dashSize?: number;
  22750. gapSize?: number;
  22751. dashNb?: number;
  22752. }): VertexData;
  22753. /**
  22754. * Creates the VertexData for a Ground
  22755. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22756. * - width the width (x direction) of the ground, optional, default 1
  22757. * - height the height (z direction) of the ground, optional, default 1
  22758. * - subdivisions the number of subdivisions per side, optional, default 1
  22759. * @returns the VertexData of the Ground
  22760. */
  22761. static CreateGround(options: {
  22762. width?: number;
  22763. height?: number;
  22764. subdivisions?: number;
  22765. subdivisionsX?: number;
  22766. subdivisionsY?: number;
  22767. }): VertexData;
  22768. /**
  22769. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22770. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22771. * * xmin the ground minimum X coordinate, optional, default -1
  22772. * * zmin the ground minimum Z coordinate, optional, default -1
  22773. * * xmax the ground maximum X coordinate, optional, default 1
  22774. * * zmax the ground maximum Z coordinate, optional, default 1
  22775. * * 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}
  22776. * * 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}
  22777. * @returns the VertexData of the TiledGround
  22778. */
  22779. static CreateTiledGround(options: {
  22780. xmin: number;
  22781. zmin: number;
  22782. xmax: number;
  22783. zmax: number;
  22784. subdivisions?: {
  22785. w: number;
  22786. h: number;
  22787. };
  22788. precision?: {
  22789. w: number;
  22790. h: number;
  22791. };
  22792. }): VertexData;
  22793. /**
  22794. * Creates the VertexData of the Ground designed from a heightmap
  22795. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22796. * * width the width (x direction) of the ground
  22797. * * height the height (z direction) of the ground
  22798. * * subdivisions the number of subdivisions per side
  22799. * * minHeight the minimum altitude on the ground, optional, default 0
  22800. * * maxHeight the maximum altitude on the ground, optional default 1
  22801. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22802. * * buffer the array holding the image color data
  22803. * * bufferWidth the width of image
  22804. * * bufferHeight the height of image
  22805. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22806. * @returns the VertexData of the Ground designed from a heightmap
  22807. */
  22808. static CreateGroundFromHeightMap(options: {
  22809. width: number;
  22810. height: number;
  22811. subdivisions: number;
  22812. minHeight: number;
  22813. maxHeight: number;
  22814. colorFilter: Color3;
  22815. buffer: Uint8Array;
  22816. bufferWidth: number;
  22817. bufferHeight: number;
  22818. alphaFilter: number;
  22819. }): VertexData;
  22820. /**
  22821. * Creates the VertexData for a Plane
  22822. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22823. * * size sets the width and height of the plane to the value of size, optional default 1
  22824. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22825. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22827. * * 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)
  22828. * * 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)
  22829. * @returns the VertexData of the box
  22830. */
  22831. static CreatePlane(options: {
  22832. size?: number;
  22833. width?: number;
  22834. height?: number;
  22835. sideOrientation?: number;
  22836. frontUVs?: Vector4;
  22837. backUVs?: Vector4;
  22838. }): VertexData;
  22839. /**
  22840. * Creates the VertexData of the Disc or regular Polygon
  22841. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22842. * * radius the radius of the disc, optional default 0.5
  22843. * * tessellation the number of polygon sides, optional, default 64
  22844. * * 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
  22845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22846. * * 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)
  22847. * * 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)
  22848. * @returns the VertexData of the box
  22849. */
  22850. static CreateDisc(options: {
  22851. radius?: number;
  22852. tessellation?: number;
  22853. arc?: number;
  22854. sideOrientation?: number;
  22855. frontUVs?: Vector4;
  22856. backUVs?: Vector4;
  22857. }): VertexData;
  22858. /**
  22859. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22860. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22861. * @param polygon a mesh built from polygonTriangulation.build()
  22862. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22863. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22864. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22865. * @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)
  22866. * @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)
  22867. * @returns the VertexData of the Polygon
  22868. */
  22869. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22870. /**
  22871. * Creates the VertexData of the IcoSphere
  22872. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22873. * * radius the radius of the IcoSphere, optional default 1
  22874. * * radiusX allows stretching in the x direction, optional, default radius
  22875. * * radiusY allows stretching in the y direction, optional, default radius
  22876. * * radiusZ allows stretching in the z direction, optional, default radius
  22877. * * flat when true creates a flat shaded mesh, optional, default true
  22878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22880. * * 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)
  22881. * * 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)
  22882. * @returns the VertexData of the IcoSphere
  22883. */
  22884. static CreateIcoSphere(options: {
  22885. radius?: number;
  22886. radiusX?: number;
  22887. radiusY?: number;
  22888. radiusZ?: number;
  22889. flat?: boolean;
  22890. subdivisions?: number;
  22891. sideOrientation?: number;
  22892. frontUVs?: Vector4;
  22893. backUVs?: Vector4;
  22894. }): VertexData;
  22895. /**
  22896. * Creates the VertexData for a Polyhedron
  22897. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22898. * * type provided types are:
  22899. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22900. * * 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)
  22901. * * size the size of the IcoSphere, optional default 1
  22902. * * sizeX allows stretching in the x direction, optional, default size
  22903. * * sizeY allows stretching in the y direction, optional, default size
  22904. * * sizeZ allows stretching in the z direction, optional, default size
  22905. * * 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
  22906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22907. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22908. * * flat when true creates a flat shaded mesh, optional, default true
  22909. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22911. * * 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)
  22912. * * 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)
  22913. * @returns the VertexData of the Polyhedron
  22914. */
  22915. static CreatePolyhedron(options: {
  22916. type?: number;
  22917. size?: number;
  22918. sizeX?: number;
  22919. sizeY?: number;
  22920. sizeZ?: number;
  22921. custom?: any;
  22922. faceUV?: Vector4[];
  22923. faceColors?: Color4[];
  22924. flat?: boolean;
  22925. sideOrientation?: number;
  22926. frontUVs?: Vector4;
  22927. backUVs?: Vector4;
  22928. }): VertexData;
  22929. /**
  22930. * Creates the VertexData for a TorusKnot
  22931. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22932. * * radius the radius of the torus knot, optional, default 2
  22933. * * tube the thickness of the tube, optional, default 0.5
  22934. * * radialSegments the number of sides on each tube segments, optional, default 32
  22935. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22936. * * p the number of windings around the z axis, optional, default 2
  22937. * * q the number of windings around the x axis, optional, default 3
  22938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22939. * * 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)
  22940. * * 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)
  22941. * @returns the VertexData of the Torus Knot
  22942. */
  22943. static CreateTorusKnot(options: {
  22944. radius?: number;
  22945. tube?: number;
  22946. radialSegments?: number;
  22947. tubularSegments?: number;
  22948. p?: number;
  22949. q?: number;
  22950. sideOrientation?: number;
  22951. frontUVs?: Vector4;
  22952. backUVs?: Vector4;
  22953. }): VertexData;
  22954. /**
  22955. * Compute normals for given positions and indices
  22956. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22957. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22958. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22959. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22960. * * facetNormals : optional array of facet normals (vector3)
  22961. * * facetPositions : optional array of facet positions (vector3)
  22962. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22963. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22964. * * bInfo : optional bounding info, required for facetPartitioning computation
  22965. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22966. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22967. * * useRightHandedSystem: optional boolean to for right handed system computation
  22968. * * depthSort : optional boolean to enable the facet depth sort computation
  22969. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22970. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22971. */
  22972. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22973. facetNormals?: any;
  22974. facetPositions?: any;
  22975. facetPartitioning?: any;
  22976. ratio?: number;
  22977. bInfo?: any;
  22978. bbSize?: Vector3;
  22979. subDiv?: any;
  22980. useRightHandedSystem?: boolean;
  22981. depthSort?: boolean;
  22982. distanceTo?: Vector3;
  22983. depthSortedFacets?: any;
  22984. }): void;
  22985. private static _ComputeSides;
  22986. /**
  22987. * Applies VertexData created from the imported parameters to the geometry
  22988. * @param parsedVertexData the parsed data from an imported file
  22989. * @param geometry the geometry to apply the VertexData to
  22990. */
  22991. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22992. }
  22993. }
  22994. declare module BABYLON {
  22995. /**
  22996. * Polygon
  22997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22998. */
  22999. export class Polygon {
  23000. /**
  23001. * Creates a rectangle
  23002. * @param xmin bottom X coord
  23003. * @param ymin bottom Y coord
  23004. * @param xmax top X coord
  23005. * @param ymax top Y coord
  23006. * @returns points that make the resulting rectation
  23007. */
  23008. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23009. /**
  23010. * Creates a circle
  23011. * @param radius radius of circle
  23012. * @param cx scale in x
  23013. * @param cy scale in y
  23014. * @param numberOfSides number of sides that make up the circle
  23015. * @returns points that make the resulting circle
  23016. */
  23017. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23018. /**
  23019. * Creates a polygon from input string
  23020. * @param input Input polygon data
  23021. * @returns the parsed points
  23022. */
  23023. static Parse(input: string): Vector2[];
  23024. /**
  23025. * Starts building a polygon from x and y coordinates
  23026. * @param x x coordinate
  23027. * @param y y coordinate
  23028. * @returns the started path2
  23029. */
  23030. static StartingAt(x: number, y: number): Path2;
  23031. }
  23032. /**
  23033. * Builds a polygon
  23034. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  23035. */
  23036. export class PolygonMeshBuilder {
  23037. private _points;
  23038. private _outlinepoints;
  23039. private _holes;
  23040. private _name;
  23041. private _scene;
  23042. private _epoints;
  23043. private _eholes;
  23044. private _addToepoint;
  23045. /**
  23046. * Babylon reference to the earcut plugin.
  23047. */
  23048. bjsEarcut: any;
  23049. /**
  23050. * Creates a PolygonMeshBuilder
  23051. * @param name name of the builder
  23052. * @param contours Path of the polygon
  23053. * @param scene scene to add to
  23054. */
  23055. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  23056. /**
  23057. * Adds a whole within the polygon
  23058. * @param hole Array of points defining the hole
  23059. * @returns this
  23060. */
  23061. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23062. /**
  23063. * Creates the polygon
  23064. * @param updatable If the mesh should be updatable
  23065. * @param depth The depth of the mesh created
  23066. * @returns the created mesh
  23067. */
  23068. build(updatable?: boolean, depth?: number): Mesh;
  23069. /**
  23070. * Adds a side to the polygon
  23071. * @param positions points that make the polygon
  23072. * @param normals normals of the polygon
  23073. * @param uvs uvs of the polygon
  23074. * @param indices indices of the polygon
  23075. * @param bounds bounds of the polygon
  23076. * @param points points of the polygon
  23077. * @param depth depth of the polygon
  23078. * @param flip flip of the polygon
  23079. */
  23080. private addSide;
  23081. }
  23082. }
  23083. declare module BABYLON {
  23084. /**
  23085. * Class containing static functions to help procedurally build meshes
  23086. */
  23087. export class MeshBuilder {
  23088. private static _UpdateSideOrientation;
  23089. /**
  23090. * Creates a box mesh
  23091. * * The parameter `size` sets the size (float) of each box side (default 1)
  23092. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  23093. * * 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)
  23094. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23096. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23098. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  23099. * @param name defines the name of the mesh
  23100. * @param options defines the options used to create the mesh
  23101. * @param scene defines the hosting scene
  23102. * @returns the box mesh
  23103. */
  23104. static CreateBox(name: string, options: {
  23105. size?: number;
  23106. width?: number;
  23107. height?: number;
  23108. depth?: number;
  23109. faceUV?: Vector4[];
  23110. faceColors?: Color4[];
  23111. sideOrientation?: number;
  23112. frontUVs?: Vector4;
  23113. backUVs?: Vector4;
  23114. updatable?: boolean;
  23115. }, scene?: Nullable<Scene>): Mesh;
  23116. /**
  23117. * Creates a sphere mesh
  23118. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23119. * * 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`)
  23120. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23121. * * 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
  23122. * * 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)
  23123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23124. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23126. * @param name defines the name of the mesh
  23127. * @param options defines the options used to create the mesh
  23128. * @param scene defines the hosting scene
  23129. * @returns the sphere mesh
  23130. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  23131. */
  23132. static CreateSphere(name: string, options: {
  23133. segments?: number;
  23134. diameter?: number;
  23135. diameterX?: number;
  23136. diameterY?: number;
  23137. diameterZ?: number;
  23138. arc?: number;
  23139. slice?: number;
  23140. sideOrientation?: number;
  23141. frontUVs?: Vector4;
  23142. backUVs?: Vector4;
  23143. updatable?: boolean;
  23144. }, scene: any): Mesh;
  23145. /**
  23146. * Creates a plane polygonal mesh. By default, this is a disc
  23147. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23148. * * 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
  23149. * * 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
  23150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23151. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23153. * @param name defines the name of the mesh
  23154. * @param options defines the options used to create the mesh
  23155. * @param scene defines the hosting scene
  23156. * @returns the plane polygonal mesh
  23157. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23158. */
  23159. static CreateDisc(name: string, options: {
  23160. radius?: number;
  23161. tessellation?: number;
  23162. arc?: number;
  23163. updatable?: boolean;
  23164. sideOrientation?: number;
  23165. frontUVs?: Vector4;
  23166. backUVs?: Vector4;
  23167. }, scene?: Nullable<Scene>): Mesh;
  23168. /**
  23169. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23170. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23171. * * 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`)
  23172. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23173. * * 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
  23174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23175. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23177. * @param name defines the name of the mesh
  23178. * @param options defines the options used to create the mesh
  23179. * @param scene defines the hosting scene
  23180. * @returns the icosahedron mesh
  23181. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23182. */
  23183. static CreateIcoSphere(name: string, options: {
  23184. radius?: number;
  23185. radiusX?: number;
  23186. radiusY?: number;
  23187. radiusZ?: number;
  23188. flat?: boolean;
  23189. subdivisions?: number;
  23190. sideOrientation?: number;
  23191. frontUVs?: Vector4;
  23192. backUVs?: Vector4;
  23193. updatable?: boolean;
  23194. }, scene: Scene): Mesh;
  23195. /**
  23196. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23197. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23198. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23199. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23200. * * 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
  23201. * * 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
  23202. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  23203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23204. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23206. * * 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
  23207. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23208. * * 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
  23209. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23211. * @param name defines the name of the mesh
  23212. * @param options defines the options used to create the mesh
  23213. * @param scene defines the hosting scene
  23214. * @returns the ribbon mesh
  23215. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  23216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23217. */
  23218. static CreateRibbon(name: string, options: {
  23219. pathArray: Vector3[][];
  23220. closeArray?: boolean;
  23221. closePath?: boolean;
  23222. offset?: number;
  23223. updatable?: boolean;
  23224. sideOrientation?: number;
  23225. frontUVs?: Vector4;
  23226. backUVs?: Vector4;
  23227. instance?: Mesh;
  23228. invertUV?: boolean;
  23229. uvs?: Vector2[];
  23230. colors?: Color4[];
  23231. }, scene?: Nullable<Scene>): Mesh;
  23232. /**
  23233. * Creates a cylinder or a cone mesh
  23234. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23235. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23236. * * 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.
  23237. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23238. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23239. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23240. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23241. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23242. * * 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).
  23243. * * 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
  23244. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23245. * * 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
  23246. * * 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.
  23247. * * If `enclose` is false, a ring surface is one element.
  23248. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23249. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  23250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23251. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23253. * @param name defines the name of the mesh
  23254. * @param options defines the options used to create the mesh
  23255. * @param scene defines the hosting scene
  23256. * @returns the cylinder mesh
  23257. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23258. */
  23259. static CreateCylinder(name: string, options: {
  23260. height?: number;
  23261. diameterTop?: number;
  23262. diameterBottom?: number;
  23263. diameter?: number;
  23264. tessellation?: number;
  23265. subdivisions?: number;
  23266. arc?: number;
  23267. faceColors?: Color4[];
  23268. faceUV?: Vector4[];
  23269. updatable?: boolean;
  23270. hasRings?: boolean;
  23271. enclose?: boolean;
  23272. sideOrientation?: number;
  23273. frontUVs?: Vector4;
  23274. backUVs?: Vector4;
  23275. }, scene: any): Mesh;
  23276. /**
  23277. * Creates a torus mesh
  23278. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23279. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23280. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23282. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23284. * @param name defines the name of the mesh
  23285. * @param options defines the options used to create the mesh
  23286. * @param scene defines the hosting scene
  23287. * @returns the torus mesh
  23288. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  23289. */
  23290. static CreateTorus(name: string, options: {
  23291. diameter?: number;
  23292. thickness?: number;
  23293. tessellation?: number;
  23294. updatable?: boolean;
  23295. sideOrientation?: number;
  23296. frontUVs?: Vector4;
  23297. backUVs?: Vector4;
  23298. }, scene: any): Mesh;
  23299. /**
  23300. * Creates a torus knot mesh
  23301. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23302. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23303. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23304. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23306. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23308. * @param name defines the name of the mesh
  23309. * @param options defines the options used to create the mesh
  23310. * @param scene defines the hosting scene
  23311. * @returns the torus knot mesh
  23312. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23313. */
  23314. static CreateTorusKnot(name: string, options: {
  23315. radius?: number;
  23316. tube?: number;
  23317. radialSegments?: number;
  23318. tubularSegments?: number;
  23319. p?: number;
  23320. q?: number;
  23321. updatable?: boolean;
  23322. sideOrientation?: number;
  23323. frontUVs?: Vector4;
  23324. backUVs?: Vector4;
  23325. }, scene: any): Mesh;
  23326. /**
  23327. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23328. * * 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
  23329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23330. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23331. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23332. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23334. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  23335. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23338. * @param name defines the name of the new line system
  23339. * @param options defines the options used to create the line system
  23340. * @param scene defines the hosting scene
  23341. * @returns a new line system mesh
  23342. */
  23343. static CreateLineSystem(name: string, options: {
  23344. lines: Vector3[][];
  23345. updatable?: boolean;
  23346. instance?: Nullable<LinesMesh>;
  23347. colors?: Nullable<Color4[][]>;
  23348. useVertexAlpha?: boolean;
  23349. }, scene: Nullable<Scene>): LinesMesh;
  23350. /**
  23351. * Creates a line mesh
  23352. * 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
  23353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23354. * * The parameter `points` is an array successive Vector3
  23355. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  23356. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23357. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23358. * * When updating an instance, remember that only point positions can change, not the number of points
  23359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  23361. * @param name defines the name of the new line system
  23362. * @param options defines the options used to create the line system
  23363. * @param scene defines the hosting scene
  23364. * @returns a new line mesh
  23365. */
  23366. static CreateLines(name: string, options: {
  23367. points: Vector3[];
  23368. updatable?: boolean;
  23369. instance?: Nullable<LinesMesh>;
  23370. colors?: Color4[];
  23371. useVertexAlpha?: boolean;
  23372. }, scene?: Nullable<Scene>): LinesMesh;
  23373. /**
  23374. * Creates a dashed line mesh
  23375. * * 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
  23376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23377. * * The parameter `points` is an array successive Vector3
  23378. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23379. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23380. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23381. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  23382. * * When updating an instance, remember that only point positions can change, not the number of points
  23383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23384. * @param name defines the name of the mesh
  23385. * @param options defines the options used to create the mesh
  23386. * @param scene defines the hosting scene
  23387. * @returns the dashed line mesh
  23388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23389. */
  23390. static CreateDashedLines(name: string, options: {
  23391. points: Vector3[];
  23392. dashSize?: number;
  23393. gapSize?: number;
  23394. dashNb?: number;
  23395. updatable?: boolean;
  23396. instance?: LinesMesh;
  23397. }, scene?: Nullable<Scene>): LinesMesh;
  23398. /**
  23399. * 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.
  23400. * * 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.
  23401. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23402. * * 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.
  23403. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23404. * * 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
  23405. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  23406. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23408. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23411. * @param name defines the name of the mesh
  23412. * @param options defines the options used to create the mesh
  23413. * @param scene defines the hosting scene
  23414. * @returns the extruded shape mesh
  23415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23417. */
  23418. static ExtrudeShape(name: string, options: {
  23419. shape: Vector3[];
  23420. path: Vector3[];
  23421. scale?: number;
  23422. rotation?: number;
  23423. cap?: number;
  23424. updatable?: boolean;
  23425. sideOrientation?: number;
  23426. frontUVs?: Vector4;
  23427. backUVs?: Vector4;
  23428. instance?: Mesh;
  23429. invertUV?: boolean;
  23430. }, scene?: Nullable<Scene>): Mesh;
  23431. /**
  23432. * Creates an custom extruded shape mesh.
  23433. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23434. * * 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.
  23435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23436. * * 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
  23437. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23438. * * 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
  23439. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23440. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23441. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23442. * * 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
  23443. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  23444. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23446. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23449. * @param name defines the name of the mesh
  23450. * @param options defines the options used to create the mesh
  23451. * @param scene defines the hosting scene
  23452. * @returns the custom extruded shape mesh
  23453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23456. */
  23457. static ExtrudeShapeCustom(name: string, options: {
  23458. shape: Vector3[];
  23459. path: Vector3[];
  23460. scaleFunction?: any;
  23461. rotationFunction?: any;
  23462. ribbonCloseArray?: boolean;
  23463. ribbonClosePath?: boolean;
  23464. cap?: number;
  23465. updatable?: boolean;
  23466. sideOrientation?: number;
  23467. frontUVs?: Vector4;
  23468. backUVs?: Vector4;
  23469. instance?: Mesh;
  23470. invertUV?: boolean;
  23471. }, scene: Scene): Mesh;
  23472. /**
  23473. * Creates lathe mesh.
  23474. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23475. * * 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
  23476. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23477. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23478. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23479. * * 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
  23480. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23481. * * 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
  23482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23483. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23486. * @param name defines the name of the mesh
  23487. * @param options defines the options used to create the mesh
  23488. * @param scene defines the hosting scene
  23489. * @returns the lathe mesh
  23490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23491. */
  23492. static CreateLathe(name: string, options: {
  23493. shape: Vector3[];
  23494. radius?: number;
  23495. tessellation?: number;
  23496. clip?: number;
  23497. arc?: number;
  23498. closed?: boolean;
  23499. updatable?: boolean;
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. cap?: number;
  23504. invertUV?: boolean;
  23505. }, scene: Scene): Mesh;
  23506. /**
  23507. * Creates a plane mesh
  23508. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23509. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  23510. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23512. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23514. * @param name defines the name of the mesh
  23515. * @param options defines the options used to create the mesh
  23516. * @param scene defines the hosting scene
  23517. * @returns the plane mesh
  23518. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  23519. */
  23520. static CreatePlane(name: string, options: {
  23521. size?: number;
  23522. width?: number;
  23523. height?: number;
  23524. sideOrientation?: number;
  23525. frontUVs?: Vector4;
  23526. backUVs?: Vector4;
  23527. updatable?: boolean;
  23528. sourcePlane?: Plane;
  23529. }, scene: Scene): Mesh;
  23530. /**
  23531. * Creates a ground mesh
  23532. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23533. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23535. * @param name defines the name of the mesh
  23536. * @param options defines the options used to create the mesh
  23537. * @param scene defines the hosting scene
  23538. * @returns the ground mesh
  23539. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  23540. */
  23541. static CreateGround(name: string, options: {
  23542. width?: number;
  23543. height?: number;
  23544. subdivisions?: number;
  23545. subdivisionsX?: number;
  23546. subdivisionsY?: number;
  23547. updatable?: boolean;
  23548. }, scene: any): Mesh;
  23549. /**
  23550. * Creates a tiled ground mesh
  23551. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23552. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23553. * * 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
  23554. * * 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
  23555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23556. * @param name defines the name of the mesh
  23557. * @param options defines the options used to create the mesh
  23558. * @param scene defines the hosting scene
  23559. * @returns the tiled ground mesh
  23560. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  23561. */
  23562. static CreateTiledGround(name: string, options: {
  23563. xmin: number;
  23564. zmin: number;
  23565. xmax: number;
  23566. zmax: number;
  23567. subdivisions?: {
  23568. w: number;
  23569. h: number;
  23570. };
  23571. precision?: {
  23572. w: number;
  23573. h: number;
  23574. };
  23575. updatable?: boolean;
  23576. }, scene: Scene): Mesh;
  23577. /**
  23578. * Creates a ground mesh from a height map
  23579. * * The parameter `url` sets the URL of the height map image resource.
  23580. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23581. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23582. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23583. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23584. * * 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.
  23585. * * 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).
  23586. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23588. * @param name defines the name of the mesh
  23589. * @param url defines the url to the height map
  23590. * @param options defines the options used to create the mesh
  23591. * @param scene defines the hosting scene
  23592. * @returns the ground mesh
  23593. * @see https://doc.babylonjs.com/babylon101/height_map
  23594. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  23595. */
  23596. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23597. width?: number;
  23598. height?: number;
  23599. subdivisions?: number;
  23600. minHeight?: number;
  23601. maxHeight?: number;
  23602. colorFilter?: Color3;
  23603. alphaFilter?: number;
  23604. updatable?: boolean;
  23605. onReady?: (mesh: GroundMesh) => void;
  23606. }, scene: Scene): GroundMesh;
  23607. /**
  23608. * Creates a polygon mesh
  23609. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23610. * * 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
  23611. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23613. * * 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)
  23614. * * Remember you can only change the shape positions, not their number when updating a polygon
  23615. * @param name defines the name of the mesh
  23616. * @param options defines the options used to create the mesh
  23617. * @param scene defines the hosting scene
  23618. * @returns the polygon mesh
  23619. */
  23620. static CreatePolygon(name: string, options: {
  23621. shape: Vector3[];
  23622. holes?: Vector3[][];
  23623. depth?: number;
  23624. faceUV?: Vector4[];
  23625. faceColors?: Color4[];
  23626. updatable?: boolean;
  23627. sideOrientation?: number;
  23628. frontUVs?: Vector4;
  23629. backUVs?: Vector4;
  23630. }, scene: Scene): Mesh;
  23631. /**
  23632. * Creates an extruded polygon mesh, with depth in the Y direction.
  23633. * * 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)
  23634. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23635. * @param name defines the name of the mesh
  23636. * @param options defines the options used to create the mesh
  23637. * @param scene defines the hosting scene
  23638. * @returns the polygon mesh
  23639. */
  23640. static ExtrudePolygon(name: string, options: {
  23641. shape: Vector3[];
  23642. holes?: Vector3[][];
  23643. depth?: number;
  23644. faceUV?: Vector4[];
  23645. faceColors?: Color4[];
  23646. updatable?: boolean;
  23647. sideOrientation?: number;
  23648. frontUVs?: Vector4;
  23649. backUVs?: Vector4;
  23650. }, scene: Scene): Mesh;
  23651. /**
  23652. * Creates a tube mesh.
  23653. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23654. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23655. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23656. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23657. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23658. * * 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)
  23659. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23660. * * 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
  23661. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  23662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23663. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23666. * @param name defines the name of the mesh
  23667. * @param options defines the options used to create the mesh
  23668. * @param scene defines the hosting scene
  23669. * @returns the tube mesh
  23670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23671. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  23672. */
  23673. static CreateTube(name: string, options: {
  23674. path: Vector3[];
  23675. radius?: number;
  23676. tessellation?: number;
  23677. radiusFunction?: {
  23678. (i: number, distance: number): number;
  23679. };
  23680. cap?: number;
  23681. arc?: number;
  23682. updatable?: boolean;
  23683. sideOrientation?: number;
  23684. frontUVs?: Vector4;
  23685. backUVs?: Vector4;
  23686. instance?: Mesh;
  23687. invertUV?: boolean;
  23688. }, scene: Scene): Mesh;
  23689. /**
  23690. * Creates a polyhedron mesh
  23691. * * 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
  23692. * * The parameter `size` (positive float, default 1) sets the polygon size
  23693. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23694. * * 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`
  23695. * * 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
  23696. * * 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)`)
  23697. * * 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 : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23698. * * 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
  23699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23700. * * 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 : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23702. * @param name defines the name of the mesh
  23703. * @param options defines the options used to create the mesh
  23704. * @param scene defines the hosting scene
  23705. * @returns the polyhedron mesh
  23706. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  23707. */
  23708. static CreatePolyhedron(name: string, options: {
  23709. type?: number;
  23710. size?: number;
  23711. sizeX?: number;
  23712. sizeY?: number;
  23713. sizeZ?: number;
  23714. custom?: any;
  23715. faceUV?: Vector4[];
  23716. faceColors?: Color4[];
  23717. flat?: boolean;
  23718. updatable?: boolean;
  23719. sideOrientation?: number;
  23720. frontUVs?: Vector4;
  23721. backUVs?: Vector4;
  23722. }, scene: Scene): Mesh;
  23723. /**
  23724. * Creates a decal mesh.
  23725. * 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
  23726. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23727. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23728. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23729. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23730. * @param name defines the name of the mesh
  23731. * @param sourceMesh defines the mesh where the decal must be applied
  23732. * @param options defines the options used to create the mesh
  23733. * @param scene defines the hosting scene
  23734. * @returns the decal mesh
  23735. * @see https://doc.babylonjs.com/how_to/decals
  23736. */
  23737. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23738. position?: Vector3;
  23739. normal?: Vector3;
  23740. size?: Vector3;
  23741. angle?: number;
  23742. }): Mesh;
  23743. private static _ExtrudeShapeGeneric;
  23744. }
  23745. }
  23746. declare module BABYLON {
  23747. /**
  23748. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23749. *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.
  23750. * The SPS is also a particle system. It provides some methods to manage the particles.
  23751. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23752. *
  23753. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23754. */
  23755. export class SolidParticleSystem implements IDisposable {
  23756. /**
  23757. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23758. * Example : var p = SPS.particles[i];
  23759. */
  23760. particles: SolidParticle[];
  23761. /**
  23762. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23763. */
  23764. nbParticles: number;
  23765. /**
  23766. * If the particles must ever face the camera (default false). Useful for planar particles.
  23767. */
  23768. billboard: boolean;
  23769. /**
  23770. * Recompute normals when adding a shape
  23771. */
  23772. recomputeNormals: boolean;
  23773. /**
  23774. * This a counter ofr your own usage. It's not set by any SPS functions.
  23775. */
  23776. counter: number;
  23777. /**
  23778. * The SPS name. This name is also given to the underlying mesh.
  23779. */
  23780. name: string;
  23781. /**
  23782. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23783. */
  23784. mesh: Mesh;
  23785. /**
  23786. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23787. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23788. */
  23789. vars: any;
  23790. /**
  23791. * This array is populated when the SPS is set as 'pickable'.
  23792. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23793. * Each element of this array is an object `{idx: int, faceId: int}`.
  23794. * `idx` is the picked particle index in the `SPS.particles` array
  23795. * `faceId` is the picked face index counted within this particle.
  23796. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23797. */
  23798. pickedParticles: {
  23799. idx: number;
  23800. faceId: number;
  23801. }[];
  23802. /**
  23803. * This array is populated when `enableDepthSort` is set to true.
  23804. * Each element of this array is an instance of the class DepthSortedParticle.
  23805. */
  23806. depthSortedParticles: DepthSortedParticle[];
  23807. /**
  23808. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23809. * @hidden
  23810. */
  23811. _bSphereOnly: boolean;
  23812. /**
  23813. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23814. * @hidden
  23815. */
  23816. _bSphereRadiusFactor: number;
  23817. private _scene;
  23818. private _positions;
  23819. private _indices;
  23820. private _normals;
  23821. private _colors;
  23822. private _uvs;
  23823. private _indices32;
  23824. private _positions32;
  23825. private _normals32;
  23826. private _fixedNormal32;
  23827. private _colors32;
  23828. private _uvs32;
  23829. private _index;
  23830. private _updatable;
  23831. private _pickable;
  23832. private _isVisibilityBoxLocked;
  23833. private _alwaysVisible;
  23834. private _depthSort;
  23835. private _shapeCounter;
  23836. private _copy;
  23837. private _color;
  23838. private _computeParticleColor;
  23839. private _computeParticleTexture;
  23840. private _computeParticleRotation;
  23841. private _computeParticleVertex;
  23842. private _computeBoundingBox;
  23843. private _depthSortParticles;
  23844. private _camera;
  23845. private _mustUnrotateFixedNormals;
  23846. private _particlesIntersect;
  23847. private _needs32Bits;
  23848. /**
  23849. * Creates a SPS (Solid Particle System) object.
  23850. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23851. * @param scene (Scene) is the scene in which the SPS is added.
  23852. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23853. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23854. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23855. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23856. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23857. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23858. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23859. */
  23860. constructor(name: string, scene: Scene, options?: {
  23861. updatable?: boolean;
  23862. isPickable?: boolean;
  23863. enableDepthSort?: boolean;
  23864. particleIntersection?: boolean;
  23865. boundingSphereOnly?: boolean;
  23866. bSphereRadiusFactor?: number;
  23867. });
  23868. /**
  23869. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23870. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23871. * @returns the created mesh
  23872. */
  23873. buildMesh(): Mesh;
  23874. /**
  23875. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23876. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23877. * Thus the particles generated from `digest()` have their property `position` set yet.
  23878. * @param mesh ( Mesh ) is the mesh to be digested
  23879. * @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
  23880. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23881. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23882. * @returns the current SPS
  23883. */
  23884. digest(mesh: Mesh, options?: {
  23885. facetNb?: number;
  23886. number?: number;
  23887. delta?: number;
  23888. }): SolidParticleSystem;
  23889. private _unrotateFixedNormals;
  23890. private _resetCopy;
  23891. private _meshBuilder;
  23892. private _posToShape;
  23893. private _uvsToShapeUV;
  23894. private _addParticle;
  23895. /**
  23896. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23897. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23898. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23899. * @param nb (positive integer) the number of particles to be created from this model
  23900. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23901. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23902. * @returns the number of shapes in the system
  23903. */
  23904. addShape(mesh: Mesh, nb: number, options?: {
  23905. positionFunction?: any;
  23906. vertexFunction?: any;
  23907. }): number;
  23908. private _rebuildParticle;
  23909. /**
  23910. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23911. * @returns the SPS.
  23912. */
  23913. rebuildMesh(): SolidParticleSystem;
  23914. /**
  23915. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23916. * This method calls `updateParticle()` for each particle of the SPS.
  23917. * For an animated SPS, it is usually called within the render loop.
  23918. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23919. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23920. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23921. * @returns the SPS.
  23922. */
  23923. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23924. /**
  23925. * Disposes the SPS.
  23926. */
  23927. dispose(): void;
  23928. /**
  23929. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23930. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23931. * @returns the SPS.
  23932. */
  23933. refreshVisibleSize(): SolidParticleSystem;
  23934. /**
  23935. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23936. * @param size the size (float) of the visibility box
  23937. * note : this doesn't lock the SPS mesh bounding box.
  23938. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23939. */
  23940. setVisibilityBox(size: number): void;
  23941. /**
  23942. * Gets whether the SPS as always visible or not
  23943. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23944. */
  23945. /**
  23946. * Sets the SPS as always visible or not
  23947. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23948. */
  23949. isAlwaysVisible: boolean;
  23950. /**
  23951. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23952. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23953. */
  23954. /**
  23955. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23957. */
  23958. isVisibilityBoxLocked: boolean;
  23959. /**
  23960. * Tells to `setParticles()` to compute the particle rotations or not.
  23961. * Default value : true. The SPS is faster when it's set to false.
  23962. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23963. */
  23964. /**
  23965. * Gets if `setParticles()` computes the particle rotations or not.
  23966. * Default value : true. The SPS is faster when it's set to false.
  23967. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23968. */
  23969. computeParticleRotation: boolean;
  23970. /**
  23971. * Tells to `setParticles()` to compute the particle colors or not.
  23972. * Default value : true. The SPS is faster when it's set to false.
  23973. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23974. */
  23975. /**
  23976. * Gets if `setParticles()` computes the particle colors or not.
  23977. * Default value : true. The SPS is faster when it's set to false.
  23978. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23979. */
  23980. computeParticleColor: boolean;
  23981. /**
  23982. * Gets if `setParticles()` computes the particle textures or not.
  23983. * Default value : true. The SPS is faster when it's set to false.
  23984. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23985. */
  23986. computeParticleTexture: boolean;
  23987. /**
  23988. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23989. * Default value : false. The SPS is faster when it's set to false.
  23990. * Note : the particle custom vertex positions aren't stored values.
  23991. */
  23992. /**
  23993. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23994. * Default value : false. The SPS is faster when it's set to false.
  23995. * Note : the particle custom vertex positions aren't stored values.
  23996. */
  23997. computeParticleVertex: boolean;
  23998. /**
  23999. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24000. */
  24001. /**
  24002. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24003. */
  24004. computeBoundingBox: boolean;
  24005. /**
  24006. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24007. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24008. * Default : `true`
  24009. */
  24010. /**
  24011. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24012. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24013. * Default : `true`
  24014. */
  24015. depthSortParticles: boolean;
  24016. /**
  24017. * This function does nothing. It may be overwritten to set all the particle first values.
  24018. * The SPS doesn't call this function, you may have to call it by your own.
  24019. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24020. */
  24021. initParticles(): void;
  24022. /**
  24023. * This function does nothing. It may be overwritten to recycle a particle.
  24024. * The SPS doesn't call this function, you may have to call it by your own.
  24025. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24026. * @param particle The particle to recycle
  24027. * @returns the recycled particle
  24028. */
  24029. recycleParticle(particle: SolidParticle): SolidParticle;
  24030. /**
  24031. * Updates a particle : this function should be overwritten by the user.
  24032. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24033. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24034. * @example : just set a particle position or velocity and recycle conditions
  24035. * @param particle The particle to update
  24036. * @returns the updated particle
  24037. */
  24038. updateParticle(particle: SolidParticle): SolidParticle;
  24039. /**
  24040. * Updates a vertex of a particle : it can be overwritten by the user.
  24041. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24042. * @param particle the current particle
  24043. * @param vertex the current index of the current particle
  24044. * @param pt the index of the current vertex in the particle shape
  24045. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24046. * @example : just set a vertex particle position
  24047. * @returns the updated vertex
  24048. */
  24049. updateParticleVertex(vertex: Vector3): Vector3;
  24050. /**
  24051. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24052. * This does nothing and may be overwritten by the user.
  24053. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24054. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24055. * @param update the boolean update value actually passed to setParticles()
  24056. */
  24057. beforeUpdateParticles(): void;
  24058. /**
  24059. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24060. * This will be passed three parameters.
  24061. * This does nothing and may be overwritten by the user.
  24062. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24063. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24064. * @param update the boolean update value actually passed to setParticles()
  24065. */
  24066. afterUpdateParticles(): void;
  24067. }
  24068. }
  24069. declare module BABYLON {
  24070. /**
  24071. * Represents one particle of a solid particle system.
  24072. */
  24073. export class SolidParticle {
  24074. /**
  24075. * particle global index
  24076. */
  24077. idx: number;
  24078. /**
  24079. * The color of the particle
  24080. */
  24081. color: Nullable<Color4>;
  24082. /**
  24083. * The world space position of the particle.
  24084. */
  24085. position: Vector3;
  24086. /**
  24087. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24088. */
  24089. rotation: Vector3;
  24090. /**
  24091. * The world space rotation quaternion of the particle.
  24092. */
  24093. rotationQuaternion: Nullable<Quaternion>;
  24094. /**
  24095. * The scaling of the particle.
  24096. */
  24097. scaling: Vector3;
  24098. /**
  24099. * The uvs of the particle.
  24100. */
  24101. uvs: Vector4;
  24102. /**
  24103. * The current speed of the particle.
  24104. */
  24105. velocity: Vector3;
  24106. /**
  24107. * The pivot point in the particle local space.
  24108. */
  24109. pivot: Vector3;
  24110. /**
  24111. * Must the particle be translated from its pivot point in its local space ?
  24112. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24113. * Default : false
  24114. */
  24115. translateFromPivot: boolean;
  24116. /**
  24117. * Is the particle active or not ?
  24118. */
  24119. alive: boolean;
  24120. /**
  24121. * Is the particle visible or not ?
  24122. */
  24123. isVisible: boolean;
  24124. /**
  24125. * Index of this particle in the global "positions" array (Internal use)
  24126. * @hidden
  24127. */
  24128. _pos: number;
  24129. /**
  24130. * @hidden Index of this particle in the global "indices" array (Internal use)
  24131. */
  24132. _ind: number;
  24133. /**
  24134. * @hidden ModelShape of this particle (Internal use)
  24135. */
  24136. _model: ModelShape;
  24137. /**
  24138. * ModelShape id of this particle
  24139. */
  24140. shapeId: number;
  24141. /**
  24142. * Index of the particle in its shape id (Internal use)
  24143. */
  24144. idxInShape: number;
  24145. /**
  24146. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24147. */
  24148. _modelBoundingInfo: BoundingInfo;
  24149. /**
  24150. * @hidden Particle BoundingInfo object (Internal use)
  24151. */
  24152. _boundingInfo: BoundingInfo;
  24153. /**
  24154. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24155. */
  24156. _sps: SolidParticleSystem;
  24157. /**
  24158. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24159. */
  24160. _stillInvisible: boolean;
  24161. /**
  24162. * @hidden Last computed particle rotation matrix
  24163. */
  24164. _rotationMatrix: number[];
  24165. /**
  24166. * Parent particle Id, if any.
  24167. * Default null.
  24168. */
  24169. parentId: Nullable<number>;
  24170. /**
  24171. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24172. * The possible values are :
  24173. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24174. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24175. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24176. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24177. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24178. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24179. * */
  24180. cullingStrategy: number;
  24181. /**
  24182. * @hidden Internal global position in the SPS.
  24183. */
  24184. _globalPosition: Vector3;
  24185. /**
  24186. * Creates a Solid Particle object.
  24187. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24188. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24189. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24190. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24191. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24192. * @param shapeId (integer) is the model shape identifier in the SPS.
  24193. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24194. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24195. */
  24196. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24197. /**
  24198. * Legacy support, changed scale to scaling
  24199. */
  24200. /**
  24201. * Legacy support, changed scale to scaling
  24202. */
  24203. scale: Vector3;
  24204. /**
  24205. * Legacy support, changed quaternion to rotationQuaternion
  24206. */
  24207. /**
  24208. * Legacy support, changed quaternion to rotationQuaternion
  24209. */
  24210. quaternion: Nullable<Quaternion>;
  24211. /**
  24212. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24213. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24214. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24215. * @returns true if it intersects
  24216. */
  24217. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24218. /**
  24219. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24220. * A particle is in the frustum if its bounding box intersects the frustum
  24221. * @param frustumPlanes defines the frustum to test
  24222. * @returns true if the particle is in the frustum planes
  24223. */
  24224. isInFrustum(frustumPlanes: Plane[]): boolean;
  24225. /**
  24226. * get the rotation matrix of the particle
  24227. * @hidden
  24228. */
  24229. getRotationMatrix(m: Matrix): void;
  24230. }
  24231. /**
  24232. * Represents the shape of the model used by one particle of a solid particle system.
  24233. * SPS internal tool, don't use it manually.
  24234. */
  24235. export class ModelShape {
  24236. /**
  24237. * The shape id
  24238. * @hidden
  24239. */
  24240. shapeID: number;
  24241. /**
  24242. * flat array of model positions (internal use)
  24243. * @hidden
  24244. */
  24245. _shape: Vector3[];
  24246. /**
  24247. * flat array of model UVs (internal use)
  24248. * @hidden
  24249. */
  24250. _shapeUV: number[];
  24251. /**
  24252. * length of the shape in the model indices array (internal use)
  24253. * @hidden
  24254. */
  24255. _indicesLength: number;
  24256. /**
  24257. * Custom position function (internal use)
  24258. * @hidden
  24259. */
  24260. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24261. /**
  24262. * Custom vertex function (internal use)
  24263. * @hidden
  24264. */
  24265. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24266. /**
  24267. * 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.
  24268. * SPS internal tool, don't use it manually.
  24269. * @hidden
  24270. */
  24271. 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>);
  24272. }
  24273. /**
  24274. * Represents a Depth Sorted Particle in the solid particle system.
  24275. */
  24276. export class DepthSortedParticle {
  24277. /**
  24278. * Index of the particle in the "indices" array
  24279. */
  24280. ind: number;
  24281. /**
  24282. * Length of the particle shape in the "indices" array
  24283. */
  24284. indicesLength: number;
  24285. /**
  24286. * Squared distance from the particle to the camera
  24287. */
  24288. sqDistance: number;
  24289. }
  24290. }
  24291. declare module BABYLON {
  24292. /**
  24293. * Class used to store all common mesh properties
  24294. */
  24295. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24296. /** No occlusion */
  24297. static OCCLUSION_TYPE_NONE: number;
  24298. /** Occlusion set to optimisitic */
  24299. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24300. /** Occlusion set to strict */
  24301. static OCCLUSION_TYPE_STRICT: number;
  24302. /** Use an accurante occlusion algorithm */
  24303. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24304. /** Use a conservative occlusion algorithm */
  24305. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24306. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24307. * Test order :
  24308. * Is the bounding sphere outside the frustum ?
  24309. * If not, are the bounding box vertices outside the frustum ?
  24310. * It not, then the cullable object is in the frustum.
  24311. */
  24312. static readonly CULLINGSTRATEGY_STANDARD: number;
  24313. /** Culling strategy : Bounding Sphere Only.
  24314. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24315. * It's also less accurate than the standard because some not visible objects can still be selected.
  24316. * Test : is the bounding sphere outside the frustum ?
  24317. * If not, then the cullable object is in the frustum.
  24318. */
  24319. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24320. /** Culling strategy : Optimistic Inclusion.
  24321. * This in an inclusion test first, then the standard exclusion test.
  24322. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24323. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  24324. * Anyway, it's as accurate as the standard strategy.
  24325. * Test :
  24326. * Is the cullable object bounding sphere center in the frustum ?
  24327. * If not, apply the default culling strategy.
  24328. */
  24329. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24330. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24331. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24332. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24333. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  24334. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24335. * Test :
  24336. * Is the cullable object bounding sphere center in the frustum ?
  24337. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24338. */
  24339. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24340. /**
  24341. * No billboard
  24342. */
  24343. static readonly BILLBOARDMODE_NONE: number;
  24344. /** Billboard on X axis */
  24345. static readonly BILLBOARDMODE_X: number;
  24346. /** Billboard on Y axis */
  24347. static readonly BILLBOARDMODE_Y: number;
  24348. /** Billboard on Z axis */
  24349. static readonly BILLBOARDMODE_Z: number;
  24350. /** Billboard on all axes */
  24351. static readonly BILLBOARDMODE_ALL: number;
  24352. private _facetData;
  24353. /**
  24354. * The culling strategy to use to check whether the mesh must be rendered or not.
  24355. * This value can be changed at any time and will be used on the next render mesh selection.
  24356. * The possible values are :
  24357. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24358. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24359. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24360. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24361. * Please read each static variable documentation to get details about the culling process.
  24362. * */
  24363. cullingStrategy: number;
  24364. /**
  24365. * Gets the number of facets in the mesh
  24366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24367. */
  24368. readonly facetNb: number;
  24369. /**
  24370. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24372. */
  24373. partitioningSubdivisions: number;
  24374. /**
  24375. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24376. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24378. */
  24379. partitioningBBoxRatio: number;
  24380. /**
  24381. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24382. * Works only for updatable meshes.
  24383. * Doesn't work with multi-materials
  24384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24385. */
  24386. mustDepthSortFacets: boolean;
  24387. /**
  24388. * The location (Vector3) where the facet depth sort must be computed from.
  24389. * By default, the active camera position.
  24390. * Used only when facet depth sort is enabled
  24391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24392. */
  24393. facetDepthSortFrom: Vector3;
  24394. /**
  24395. * gets a boolean indicating if facetData is enabled
  24396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24397. */
  24398. readonly isFacetDataEnabled: boolean;
  24399. /** @hidden */
  24400. _updateNonUniformScalingState(value: boolean): boolean;
  24401. /**
  24402. * An event triggered when this mesh collides with another one
  24403. */
  24404. onCollideObservable: Observable<AbstractMesh>;
  24405. private _onCollideObserver;
  24406. /** Set a function to call when this mesh collides with another one */
  24407. onCollide: () => void;
  24408. /**
  24409. * An event triggered when the collision's position changes
  24410. */
  24411. onCollisionPositionChangeObservable: Observable<Vector3>;
  24412. private _onCollisionPositionChangeObserver;
  24413. /** Set a function to call when the collision's position changes */
  24414. onCollisionPositionChange: () => void;
  24415. /**
  24416. * An event triggered when material is changed
  24417. */
  24418. onMaterialChangedObservable: Observable<AbstractMesh>;
  24419. /**
  24420. * Gets or sets the orientation for POV movement & rotation
  24421. */
  24422. definedFacingForward: boolean;
  24423. /** @hidden */
  24424. _occlusionQuery: Nullable<WebGLQuery>;
  24425. private _visibility;
  24426. /**
  24427. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24428. */
  24429. /**
  24430. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24431. */
  24432. visibility: number;
  24433. /** Gets or sets the alpha index used to sort transparent meshes
  24434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24435. */
  24436. alphaIndex: number;
  24437. /**
  24438. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24439. */
  24440. isVisible: boolean;
  24441. /**
  24442. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24443. */
  24444. isPickable: boolean;
  24445. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24446. showSubMeshesBoundingBox: boolean;
  24447. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24448. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24449. */
  24450. isBlocker: boolean;
  24451. /**
  24452. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24453. */
  24454. enablePointerMoveEvents: boolean;
  24455. /**
  24456. * Specifies the rendering group id for this mesh (0 by default)
  24457. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24458. */
  24459. renderingGroupId: number;
  24460. private _material;
  24461. /** Gets or sets current material */
  24462. material: Nullable<Material>;
  24463. private _receiveShadows;
  24464. /**
  24465. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24466. * @see http://doc.babylonjs.com/babylon101/shadows
  24467. */
  24468. receiveShadows: boolean;
  24469. /** Defines color to use when rendering outline */
  24470. outlineColor: Color3;
  24471. /** Define width to use when rendering outline */
  24472. outlineWidth: number;
  24473. /** Defines color to use when rendering overlay */
  24474. overlayColor: Color3;
  24475. /** Defines alpha to use when rendering overlay */
  24476. overlayAlpha: number;
  24477. private _hasVertexAlpha;
  24478. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24479. hasVertexAlpha: boolean;
  24480. private _useVertexColors;
  24481. /** 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) */
  24482. useVertexColors: boolean;
  24483. private _computeBonesUsingShaders;
  24484. /**
  24485. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24486. */
  24487. computeBonesUsingShaders: boolean;
  24488. private _numBoneInfluencers;
  24489. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24490. numBoneInfluencers: number;
  24491. private _applyFog;
  24492. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24493. applyFog: boolean;
  24494. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24495. useOctreeForRenderingSelection: boolean;
  24496. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24497. useOctreeForPicking: boolean;
  24498. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24499. useOctreeForCollisions: boolean;
  24500. private _layerMask;
  24501. /**
  24502. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24503. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24504. */
  24505. layerMask: number;
  24506. /**
  24507. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24508. */
  24509. alwaysSelectAsActiveMesh: boolean;
  24510. /**
  24511. * Gets or sets the current action manager
  24512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24513. */
  24514. actionManager: Nullable<ActionManager>;
  24515. private _checkCollisions;
  24516. private _collisionMask;
  24517. private _collisionGroup;
  24518. /**
  24519. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24520. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24521. */
  24522. ellipsoid: Vector3;
  24523. /**
  24524. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24526. */
  24527. ellipsoidOffset: Vector3;
  24528. private _collider;
  24529. private _oldPositionForCollisions;
  24530. private _diffPositionForCollisions;
  24531. /**
  24532. * Gets or sets a collision mask used to mask collisions (default is -1).
  24533. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24534. */
  24535. collisionMask: number;
  24536. /**
  24537. * Gets or sets the current collision group mask (-1 by default).
  24538. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24539. */
  24540. collisionGroup: number;
  24541. /**
  24542. * Defines edge width used when edgesRenderer is enabled
  24543. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24544. */
  24545. edgesWidth: number;
  24546. /**
  24547. * Defines edge color used when edgesRenderer is enabled
  24548. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24549. */
  24550. edgesColor: Color4;
  24551. /** @hidden */
  24552. _edgesRenderer: Nullable<IEdgesRenderer>;
  24553. /** @hidden */
  24554. _masterMesh: Nullable<AbstractMesh>;
  24555. /** @hidden */
  24556. _boundingInfo: Nullable<BoundingInfo>;
  24557. /** @hidden */
  24558. _renderId: number;
  24559. /**
  24560. * Gets or sets the list of subMeshes
  24561. * @see http://doc.babylonjs.com/how_to/multi_materials
  24562. */
  24563. subMeshes: SubMesh[];
  24564. /** @hidden */
  24565. _intersectionsInProgress: AbstractMesh[];
  24566. /** @hidden */
  24567. _unIndexed: boolean;
  24568. /** @hidden */
  24569. _lightSources: Light[];
  24570. /** @hidden */
  24571. readonly _positions: Nullable<Vector3[]>;
  24572. /** @hidden */
  24573. _waitingActions: any;
  24574. /** @hidden */
  24575. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24576. private _skeleton;
  24577. /** @hidden */
  24578. _bonesTransformMatrices: Nullable<Float32Array>;
  24579. /**
  24580. * Gets or sets a skeleton to apply skining transformations
  24581. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24582. */
  24583. skeleton: Nullable<Skeleton>;
  24584. /**
  24585. * An event triggered when the mesh is rebuilt.
  24586. */
  24587. onRebuildObservable: Observable<AbstractMesh>;
  24588. /**
  24589. * Creates a new AbstractMesh
  24590. * @param name defines the name of the mesh
  24591. * @param scene defines the hosting scene
  24592. */
  24593. constructor(name: string, scene?: Nullable<Scene>);
  24594. /**
  24595. * Returns the string "AbstractMesh"
  24596. * @returns "AbstractMesh"
  24597. */
  24598. getClassName(): string;
  24599. /**
  24600. * Gets a string representation of the current mesh
  24601. * @param fullDetails defines a boolean indicating if full details must be included
  24602. * @returns a string representation of the current mesh
  24603. */
  24604. toString(fullDetails?: boolean): string;
  24605. /** @hidden */
  24606. _rebuild(): void;
  24607. /** @hidden */
  24608. _resyncLightSources(): void;
  24609. /** @hidden */
  24610. _resyncLighSource(light: Light): void;
  24611. /** @hidden */
  24612. _unBindEffect(): void;
  24613. /** @hidden */
  24614. _removeLightSource(light: Light): void;
  24615. private _markSubMeshesAsDirty;
  24616. /** @hidden */
  24617. _markSubMeshesAsLightDirty(): void;
  24618. /** @hidden */
  24619. _markSubMeshesAsAttributesDirty(): void;
  24620. /** @hidden */
  24621. _markSubMeshesAsMiscDirty(): void;
  24622. /**
  24623. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24624. */
  24625. scaling: Vector3;
  24626. /**
  24627. * Returns true if the mesh is blocked. Implemented by child classes
  24628. */
  24629. readonly isBlocked: boolean;
  24630. /**
  24631. * Returns the mesh itself by default. Implemented by child classes
  24632. * @param camera defines the camera to use to pick the right LOD level
  24633. * @returns the currentAbstractMesh
  24634. */
  24635. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24636. /**
  24637. * Returns 0 by default. Implemented by child classes
  24638. * @returns an integer
  24639. */
  24640. getTotalVertices(): number;
  24641. /**
  24642. * Returns a positive integer : the total number of indices in this mesh geometry.
  24643. * @returns the numner of indices or zero if the mesh has no geometry.
  24644. */
  24645. getTotalIndices(): number;
  24646. /**
  24647. * Returns null by default. Implemented by child classes
  24648. * @returns null
  24649. */
  24650. getIndices(): Nullable<IndicesArray>;
  24651. /**
  24652. * Returns the array of the requested vertex data kind. Implemented by child classes
  24653. * @param kind defines the vertex data kind to use
  24654. * @returns null
  24655. */
  24656. getVerticesData(kind: string): Nullable<FloatArray>;
  24657. /**
  24658. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24659. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24660. * Note that a new underlying VertexBuffer object is created each call.
  24661. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24662. * @param kind defines vertex data kind:
  24663. * * VertexBuffer.PositionKind
  24664. * * VertexBuffer.UVKind
  24665. * * VertexBuffer.UV2Kind
  24666. * * VertexBuffer.UV3Kind
  24667. * * VertexBuffer.UV4Kind
  24668. * * VertexBuffer.UV5Kind
  24669. * * VertexBuffer.UV6Kind
  24670. * * VertexBuffer.ColorKind
  24671. * * VertexBuffer.MatricesIndicesKind
  24672. * * VertexBuffer.MatricesIndicesExtraKind
  24673. * * VertexBuffer.MatricesWeightsKind
  24674. * * VertexBuffer.MatricesWeightsExtraKind
  24675. * @param data defines the data source
  24676. * @param updatable defines if the data must be flagged as updatable (or static)
  24677. * @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
  24678. * @returns the current mesh
  24679. */
  24680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24681. /**
  24682. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24683. * If the mesh has no geometry, it is simply returned as it is.
  24684. * @param kind defines vertex data kind:
  24685. * * VertexBuffer.PositionKind
  24686. * * VertexBuffer.UVKind
  24687. * * VertexBuffer.UV2Kind
  24688. * * VertexBuffer.UV3Kind
  24689. * * VertexBuffer.UV4Kind
  24690. * * VertexBuffer.UV5Kind
  24691. * * VertexBuffer.UV6Kind
  24692. * * VertexBuffer.ColorKind
  24693. * * VertexBuffer.MatricesIndicesKind
  24694. * * VertexBuffer.MatricesIndicesExtraKind
  24695. * * VertexBuffer.MatricesWeightsKind
  24696. * * VertexBuffer.MatricesWeightsExtraKind
  24697. * @param data defines the data source
  24698. * @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
  24699. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24700. * @returns the current mesh
  24701. */
  24702. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24703. /**
  24704. * Sets the mesh indices,
  24705. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24706. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24707. * @param totalVertices Defines the total number of vertices
  24708. * @returns the current mesh
  24709. */
  24710. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24711. /**
  24712. * Gets a boolean indicating if specific vertex data is present
  24713. * @param kind defines the vertex data kind to use
  24714. * @returns true is data kind is present
  24715. */
  24716. isVerticesDataPresent(kind: string): boolean;
  24717. /**
  24718. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24719. * @returns a BoundingInfo
  24720. */
  24721. getBoundingInfo(): BoundingInfo;
  24722. /**
  24723. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24724. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24725. * @returns the current mesh
  24726. */
  24727. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24728. /**
  24729. * Overwrite the current bounding info
  24730. * @param boundingInfo defines the new bounding info
  24731. * @returns the current mesh
  24732. */
  24733. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24734. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24735. readonly useBones: boolean;
  24736. /** @hidden */
  24737. _preActivate(): void;
  24738. /** @hidden */
  24739. _preActivateForIntermediateRendering(renderId: number): void;
  24740. /** @hidden */
  24741. _activate(renderId: number): void;
  24742. /**
  24743. * Gets the current world matrix
  24744. * @returns a Matrix
  24745. */
  24746. getWorldMatrix(): Matrix;
  24747. /** @hidden */
  24748. _getWorldMatrixDeterminant(): number;
  24749. /**
  24750. * Perform relative position change from the point of view of behind the front of the mesh.
  24751. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24752. * Supports definition of mesh facing forward or backward
  24753. * @param amountRight defines the distance on the right axis
  24754. * @param amountUp defines the distance on the up axis
  24755. * @param amountForward defines the distance on the forward axis
  24756. * @returns the current mesh
  24757. */
  24758. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24759. /**
  24760. * Calculate relative position change from the point of view of behind the front of the mesh.
  24761. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24762. * Supports definition of mesh facing forward or backward
  24763. * @param amountRight defines the distance on the right axis
  24764. * @param amountUp defines the distance on the up axis
  24765. * @param amountForward defines the distance on the forward axis
  24766. * @returns the new displacement vector
  24767. */
  24768. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24769. /**
  24770. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24771. * Supports definition of mesh facing forward or backward
  24772. * @param flipBack defines the flip
  24773. * @param twirlClockwise defines the twirl
  24774. * @param tiltRight defines the tilt
  24775. * @returns the current mesh
  24776. */
  24777. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24778. /**
  24779. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24780. * Supports definition of mesh facing forward or backward.
  24781. * @param flipBack defines the flip
  24782. * @param twirlClockwise defines the twirl
  24783. * @param tiltRight defines the tilt
  24784. * @returns the new rotation vector
  24785. */
  24786. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24787. /**
  24788. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24789. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24790. * @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
  24791. * @returns the new bounding vectors
  24792. */
  24793. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24794. min: Vector3;
  24795. max: Vector3;
  24796. };
  24797. /**
  24798. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24799. * This means the mesh underlying bounding box and sphere are recomputed.
  24800. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24801. * @returns the current mesh
  24802. */
  24803. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24804. /** @hidden */
  24805. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24806. /** @hidden */
  24807. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24808. /** @hidden */
  24809. _updateBoundingInfo(): AbstractMesh;
  24810. /** @hidden */
  24811. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24812. /** @hidden */
  24813. protected _afterComputeWorldMatrix(): void;
  24814. /**
  24815. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24816. * A mesh is in the frustum if its bounding box intersects the frustum
  24817. * @param frustumPlanes defines the frustum to test
  24818. * @returns true if the mesh is in the frustum planes
  24819. */
  24820. isInFrustum(frustumPlanes: Plane[]): boolean;
  24821. /**
  24822. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24823. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24824. * @param frustumPlanes defines the frustum to test
  24825. * @returns true if the mesh is completely in the frustum planes
  24826. */
  24827. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24828. /**
  24829. * True if the mesh intersects another mesh or a SolidParticle object
  24830. * @param mesh defines a target mesh or SolidParticle to test
  24831. * @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)
  24832. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24833. * @returns true if there is an intersection
  24834. */
  24835. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24836. /**
  24837. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24838. * @param point defines the point to test
  24839. * @returns true if there is an intersection
  24840. */
  24841. intersectsPoint(point: Vector3): boolean;
  24842. /**
  24843. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24845. */
  24846. checkCollisions: boolean;
  24847. /**
  24848. * Gets Collider object used to compute collisions (not physics)
  24849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24850. */
  24851. readonly collider: Collider;
  24852. /**
  24853. * Move the mesh using collision engine
  24854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24855. * @param displacement defines the requested displacement vector
  24856. * @returns the current mesh
  24857. */
  24858. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24859. private _onCollisionPositionChange;
  24860. /** @hidden */
  24861. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24862. /** @hidden */
  24863. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24864. /** @hidden */
  24865. _checkCollision(collider: Collider): AbstractMesh;
  24866. /** @hidden */
  24867. _generatePointsArray(): boolean;
  24868. /**
  24869. * Checks if the passed Ray intersects with the mesh
  24870. * @param ray defines the ray to use
  24871. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24872. * @returns the picking info
  24873. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24874. */
  24875. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24876. /**
  24877. * Clones the current mesh
  24878. * @param name defines the mesh name
  24879. * @param newParent defines the new mesh parent
  24880. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24881. * @returns the new mesh
  24882. */
  24883. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24884. /**
  24885. * Disposes all the submeshes of the current meshnp
  24886. * @returns the current mesh
  24887. */
  24888. releaseSubMeshes(): AbstractMesh;
  24889. /**
  24890. * Releases resources associated with this abstract mesh.
  24891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24893. */
  24894. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24895. /**
  24896. * Adds the passed mesh as a child to the current mesh
  24897. * @param mesh defines the child mesh
  24898. * @returns the current mesh
  24899. */
  24900. addChild(mesh: AbstractMesh): AbstractMesh;
  24901. /**
  24902. * Removes the passed mesh from the current mesh children list
  24903. * @param mesh defines the child mesh
  24904. * @returns the current mesh
  24905. */
  24906. removeChild(mesh: AbstractMesh): AbstractMesh;
  24907. /** @hidden */
  24908. private _initFacetData;
  24909. /**
  24910. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24911. * This method can be called within the render loop.
  24912. * 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
  24913. * @returns the current mesh
  24914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24915. */
  24916. updateFacetData(): AbstractMesh;
  24917. /**
  24918. * Returns the facetLocalNormals array.
  24919. * The normals are expressed in the mesh local spac
  24920. * @returns an array of Vector3
  24921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24922. */
  24923. getFacetLocalNormals(): Vector3[];
  24924. /**
  24925. * Returns the facetLocalPositions array.
  24926. * The facet positions are expressed in the mesh local space
  24927. * @returns an array of Vector3
  24928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24929. */
  24930. getFacetLocalPositions(): Vector3[];
  24931. /**
  24932. * Returns the facetLocalPartioning array
  24933. * @returns an array of array of numbers
  24934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24935. */
  24936. getFacetLocalPartitioning(): number[][];
  24937. /**
  24938. * Returns the i-th facet position in the world system.
  24939. * This method allocates a new Vector3 per call
  24940. * @param i defines the facet index
  24941. * @returns a new Vector3
  24942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24943. */
  24944. getFacetPosition(i: number): Vector3;
  24945. /**
  24946. * Sets the reference Vector3 with the i-th facet position in the world system
  24947. * @param i defines the facet index
  24948. * @param ref defines the target vector
  24949. * @returns the current mesh
  24950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24951. */
  24952. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24953. /**
  24954. * Returns the i-th facet normal in the world system.
  24955. * This method allocates a new Vector3 per call
  24956. * @param i defines the facet index
  24957. * @returns a new Vector3
  24958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24959. */
  24960. getFacetNormal(i: number): Vector3;
  24961. /**
  24962. * Sets the reference Vector3 with the i-th facet normal in the world system
  24963. * @param i defines the facet index
  24964. * @param ref defines the target vector
  24965. * @returns the current mesh
  24966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24967. */
  24968. getFacetNormalToRef(i: number, ref: Vector3): this;
  24969. /**
  24970. * 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)
  24971. * @param x defines x coordinate
  24972. * @param y defines y coordinate
  24973. * @param z defines z coordinate
  24974. * @returns the array of facet indexes
  24975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24976. */
  24977. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24978. /**
  24979. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24980. * @param projected sets as the (x,y,z) world projection on the facet
  24981. * @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
  24982. * @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
  24983. * @param x defines x coordinate
  24984. * @param y defines y coordinate
  24985. * @param z defines z coordinate
  24986. * @returns the face index if found (or null instead)
  24987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24988. */
  24989. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24990. /**
  24991. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24992. * @param projected sets as the (x,y,z) local projection on the facet
  24993. * @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
  24994. * @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
  24995. * @param x defines x coordinate
  24996. * @param y defines y coordinate
  24997. * @param z defines z coordinate
  24998. * @returns the face index if found (or null instead)
  24999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25000. */
  25001. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25002. /**
  25003. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25004. * @returns the parameters
  25005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25006. */
  25007. getFacetDataParameters(): any;
  25008. /**
  25009. * Disables the feature FacetData and frees the related memory
  25010. * @returns the current mesh
  25011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25012. */
  25013. disableFacetData(): AbstractMesh;
  25014. /**
  25015. * Updates the AbstractMesh indices array
  25016. * @param indices defines the data source
  25017. * @returns the current mesh
  25018. */
  25019. updateIndices(indices: IndicesArray): AbstractMesh;
  25020. /**
  25021. * Creates new normals data for the mesh
  25022. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25023. * @returns the current mesh
  25024. */
  25025. createNormals(updatable: boolean): AbstractMesh;
  25026. /**
  25027. * Align the mesh with a normal
  25028. * @param normal defines the normal to use
  25029. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25030. * @returns the current mesh
  25031. */
  25032. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25033. /** @hidden */
  25034. _checkOcclusionQuery(): boolean;
  25035. }
  25036. }
  25037. declare module BABYLON {
  25038. /**
  25039. * Defines how a node can be built from a string name.
  25040. */
  25041. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25042. /**
  25043. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25044. */
  25045. export class Node implements IBehaviorAware<Node> {
  25046. /** @hidden */
  25047. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25048. private static _NodeConstructors;
  25049. /**
  25050. * Add a new node constructor
  25051. * @param type defines the type name of the node to construct
  25052. * @param constructorFunc defines the constructor function
  25053. */
  25054. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25055. /**
  25056. * Returns a node constructor based on type name
  25057. * @param type defines the type name
  25058. * @param name defines the new node name
  25059. * @param scene defines the hosting scene
  25060. * @param options defines optional options to transmit to constructors
  25061. * @returns the new constructor or null
  25062. */
  25063. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25064. /**
  25065. * Gets or sets the name of the node
  25066. */
  25067. name: string;
  25068. /**
  25069. * Gets or sets the id of the node
  25070. */
  25071. id: string;
  25072. /**
  25073. * Gets or sets the unique id of the node
  25074. */
  25075. uniqueId: number;
  25076. /**
  25077. * Gets or sets a string used to store user defined state for the node
  25078. */
  25079. state: string;
  25080. /**
  25081. * Gets or sets an object used to store user defined information for the node
  25082. */
  25083. metadata: any;
  25084. /**
  25085. * For internal use only. Please do not use.
  25086. */
  25087. reservedDataStore: any;
  25088. /**
  25089. * Gets or sets a boolean used to define if the node must be serialized
  25090. */
  25091. doNotSerialize: boolean;
  25092. /** @hidden */
  25093. _isDisposed: boolean;
  25094. /**
  25095. * Gets a list of Animations associated with the node
  25096. */
  25097. animations: Animation[];
  25098. protected _ranges: {
  25099. [name: string]: Nullable<AnimationRange>;
  25100. };
  25101. /**
  25102. * Callback raised when the node is ready to be used
  25103. */
  25104. onReady: (node: Node) => void;
  25105. private _isEnabled;
  25106. private _isParentEnabled;
  25107. private _isReady;
  25108. /** @hidden */
  25109. _currentRenderId: number;
  25110. private _parentRenderId;
  25111. protected _childRenderId: number;
  25112. /** @hidden */
  25113. _waitingParentId: Nullable<string>;
  25114. /** @hidden */
  25115. _scene: Scene;
  25116. /** @hidden */
  25117. _cache: any;
  25118. private _parentNode;
  25119. private _children;
  25120. /** @hidden */
  25121. _worldMatrix: Matrix;
  25122. /** @hidden */
  25123. _worldMatrixDeterminant: number;
  25124. /** @hidden */
  25125. private _sceneRootNodesIndex;
  25126. /**
  25127. * Gets a boolean indicating if the node has been disposed
  25128. * @returns true if the node was disposed
  25129. */
  25130. isDisposed(): boolean;
  25131. /**
  25132. * Gets or sets the parent of the node
  25133. */
  25134. parent: Nullable<Node>;
  25135. private addToSceneRootNodes;
  25136. private removeFromSceneRootNodes;
  25137. private _animationPropertiesOverride;
  25138. /**
  25139. * Gets or sets the animation properties override
  25140. */
  25141. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25142. /**
  25143. * Gets a string idenfifying the name of the class
  25144. * @returns "Node" string
  25145. */
  25146. getClassName(): string;
  25147. /** @hidden */
  25148. readonly _isNode: boolean;
  25149. /**
  25150. * An event triggered when the mesh is disposed
  25151. */
  25152. onDisposeObservable: Observable<Node>;
  25153. private _onDisposeObserver;
  25154. /**
  25155. * Sets a callback that will be raised when the node will be disposed
  25156. */
  25157. onDispose: () => void;
  25158. /**
  25159. * Creates a new Node
  25160. * @param name the name and id to be given to this node
  25161. * @param scene the scene this node will be added to
  25162. * @param addToRootNodes the node will be added to scene.rootNodes
  25163. */
  25164. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25165. /**
  25166. * Gets the scene of the node
  25167. * @returns a scene
  25168. */
  25169. getScene(): Scene;
  25170. /**
  25171. * Gets the engine of the node
  25172. * @returns a Engine
  25173. */
  25174. getEngine(): Engine;
  25175. private _behaviors;
  25176. /**
  25177. * Attach a behavior to the node
  25178. * @see http://doc.babylonjs.com/features/behaviour
  25179. * @param behavior defines the behavior to attach
  25180. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25181. * @returns the current Node
  25182. */
  25183. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25184. /**
  25185. * Remove an attached behavior
  25186. * @see http://doc.babylonjs.com/features/behaviour
  25187. * @param behavior defines the behavior to attach
  25188. * @returns the current Node
  25189. */
  25190. removeBehavior(behavior: Behavior<Node>): Node;
  25191. /**
  25192. * Gets the list of attached behaviors
  25193. * @see http://doc.babylonjs.com/features/behaviour
  25194. */
  25195. readonly behaviors: Behavior<Node>[];
  25196. /**
  25197. * Gets an attached behavior by name
  25198. * @param name defines the name of the behavior to look for
  25199. * @see http://doc.babylonjs.com/features/behaviour
  25200. * @returns null if behavior was not found else the requested behavior
  25201. */
  25202. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25203. /**
  25204. * Returns the latest update of the World matrix
  25205. * @returns a Matrix
  25206. */
  25207. getWorldMatrix(): Matrix;
  25208. /** @hidden */
  25209. _getWorldMatrixDeterminant(): number;
  25210. /**
  25211. * Returns directly the latest state of the mesh World matrix.
  25212. * A Matrix is returned.
  25213. */
  25214. readonly worldMatrixFromCache: Matrix;
  25215. /** @hidden */
  25216. _initCache(): void;
  25217. /** @hidden */
  25218. updateCache(force?: boolean): void;
  25219. /** @hidden */
  25220. _updateCache(ignoreParentClass?: boolean): void;
  25221. /** @hidden */
  25222. _isSynchronized(): boolean;
  25223. /** @hidden */
  25224. _markSyncedWithParent(): void;
  25225. /** @hidden */
  25226. isSynchronizedWithParent(): boolean;
  25227. /** @hidden */
  25228. isSynchronized(): boolean;
  25229. /**
  25230. * Is this node ready to be used/rendered
  25231. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25232. * @return true if the node is ready
  25233. */
  25234. isReady(completeCheck?: boolean): boolean;
  25235. /**
  25236. * Is this node enabled?
  25237. * 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
  25238. * @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
  25239. * @return whether this node (and its parent) is enabled
  25240. */
  25241. isEnabled(checkAncestors?: boolean): boolean;
  25242. /** @hidden */
  25243. protected _syncParentEnabledState(): void;
  25244. /**
  25245. * Set the enabled state of this node
  25246. * @param value defines the new enabled state
  25247. */
  25248. setEnabled(value: boolean): void;
  25249. /**
  25250. * Is this node a descendant of the given node?
  25251. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25252. * @param ancestor defines the parent node to inspect
  25253. * @returns a boolean indicating if this node is a descendant of the given node
  25254. */
  25255. isDescendantOf(ancestor: Node): boolean;
  25256. /** @hidden */
  25257. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25258. /**
  25259. * Will return all nodes that have this node as ascendant
  25260. * @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
  25261. * @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
  25262. * @return all children nodes of all types
  25263. */
  25264. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25265. /**
  25266. * Get all child-meshes of this node
  25267. * @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
  25268. * @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
  25269. * @returns an array of AbstractMesh
  25270. */
  25271. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25272. /**
  25273. * Get all direct children of this node
  25274. * @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
  25275. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  25276. * @returns an array of Node
  25277. */
  25278. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25279. /** @hidden */
  25280. _setReady(state: boolean): void;
  25281. /**
  25282. * Get an animation by name
  25283. * @param name defines the name of the animation to look for
  25284. * @returns null if not found else the requested animation
  25285. */
  25286. getAnimationByName(name: string): Nullable<Animation>;
  25287. /**
  25288. * Creates an animation range for this node
  25289. * @param name defines the name of the range
  25290. * @param from defines the starting key
  25291. * @param to defines the end key
  25292. */
  25293. createAnimationRange(name: string, from: number, to: number): void;
  25294. /**
  25295. * Delete a specific animation range
  25296. * @param name defines the name of the range to delete
  25297. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25298. */
  25299. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25300. /**
  25301. * Get an animation range by name
  25302. * @param name defines the name of the animation range to look for
  25303. * @returns null if not found else the requested animation range
  25304. */
  25305. getAnimationRange(name: string): Nullable<AnimationRange>;
  25306. /**
  25307. * Will start the animation sequence
  25308. * @param name defines the range frames for animation sequence
  25309. * @param loop defines if the animation should loop (false by default)
  25310. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25311. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25312. * @returns the object created for this animation. If range does not exist, it will return null
  25313. */
  25314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25315. /**
  25316. * Serialize animation ranges into a JSON compatible object
  25317. * @returns serialization object
  25318. */
  25319. serializeAnimationRanges(): any;
  25320. /**
  25321. * Computes the world matrix of the node
  25322. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25323. * @returns the world matrix
  25324. */
  25325. computeWorldMatrix(force?: boolean): Matrix;
  25326. /**
  25327. * Releases resources associated with this node.
  25328. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25329. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25330. */
  25331. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25332. /**
  25333. * Parse animation range data from a serialization object and store them into a given node
  25334. * @param node defines where to store the animation ranges
  25335. * @param parsedNode defines the serialization object to read data from
  25336. * @param scene defines the hosting scene
  25337. */
  25338. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25339. }
  25340. }
  25341. declare module BABYLON {
  25342. /**
  25343. * Represents the range of an animation
  25344. */
  25345. export class AnimationRange {
  25346. /**The name of the animation range**/
  25347. name: string;
  25348. /**The starting frame of the animation */
  25349. from: number;
  25350. /**The ending frame of the animation*/
  25351. to: number;
  25352. /**
  25353. * Initializes the range of an animation
  25354. * @param name The name of the animation range
  25355. * @param from The starting frame of the animation
  25356. * @param to The ending frame of the animation
  25357. */
  25358. constructor(
  25359. /**The name of the animation range**/
  25360. name: string,
  25361. /**The starting frame of the animation */
  25362. from: number,
  25363. /**The ending frame of the animation*/
  25364. to: number);
  25365. /**
  25366. * Makes a copy of the animation range
  25367. * @returns A copy of the animation range
  25368. */
  25369. clone(): AnimationRange;
  25370. }
  25371. /**
  25372. * Composed of a frame, and an action function
  25373. */
  25374. export class AnimationEvent {
  25375. /** The frame for which the event is triggered **/
  25376. frame: number;
  25377. /** The event to perform when triggered **/
  25378. action: (currentFrame: number) => void;
  25379. /** Specifies if the event should be triggered only once**/
  25380. onlyOnce?: boolean | undefined;
  25381. /**
  25382. * Specifies if the animation event is done
  25383. */
  25384. isDone: boolean;
  25385. /**
  25386. * Initializes the animation event
  25387. * @param frame The frame for which the event is triggered
  25388. * @param action The event to perform when triggered
  25389. * @param onlyOnce Specifies if the event should be triggered only once
  25390. */
  25391. constructor(
  25392. /** The frame for which the event is triggered **/
  25393. frame: number,
  25394. /** The event to perform when triggered **/
  25395. action: (currentFrame: number) => void,
  25396. /** Specifies if the event should be triggered only once**/
  25397. onlyOnce?: boolean | undefined);
  25398. /** @hidden */
  25399. _clone(): AnimationEvent;
  25400. }
  25401. /**
  25402. * A cursor which tracks a point on a path
  25403. */
  25404. export class PathCursor {
  25405. private path;
  25406. /**
  25407. * Stores path cursor callbacks for when an onchange event is triggered
  25408. */
  25409. private _onchange;
  25410. /**
  25411. * The value of the path cursor
  25412. */
  25413. value: number;
  25414. /**
  25415. * The animation array of the path cursor
  25416. */
  25417. animations: Animation[];
  25418. /**
  25419. * Initializes the path cursor
  25420. * @param path The path to track
  25421. */
  25422. constructor(path: Path2);
  25423. /**
  25424. * Gets the cursor point on the path
  25425. * @returns A point on the path cursor at the cursor location
  25426. */
  25427. getPoint(): Vector3;
  25428. /**
  25429. * Moves the cursor ahead by the step amount
  25430. * @param step The amount to move the cursor forward
  25431. * @returns This path cursor
  25432. */
  25433. moveAhead(step?: number): PathCursor;
  25434. /**
  25435. * Moves the cursor behind by the step amount
  25436. * @param step The amount to move the cursor back
  25437. * @returns This path cursor
  25438. */
  25439. moveBack(step?: number): PathCursor;
  25440. /**
  25441. * Moves the cursor by the step amount
  25442. * If the step amount is greater than one, an exception is thrown
  25443. * @param step The amount to move the cursor
  25444. * @returns This path cursor
  25445. */
  25446. move(step: number): PathCursor;
  25447. /**
  25448. * Ensures that the value is limited between zero and one
  25449. * @returns This path cursor
  25450. */
  25451. private ensureLimits;
  25452. /**
  25453. * Runs onchange callbacks on change (used by the animation engine)
  25454. * @returns This path cursor
  25455. */
  25456. private raiseOnChange;
  25457. /**
  25458. * Executes a function on change
  25459. * @param f A path cursor onchange callback
  25460. * @returns This path cursor
  25461. */
  25462. onchange(f: (cursor: PathCursor) => void): PathCursor;
  25463. }
  25464. /**
  25465. * Defines an interface which represents an animation key frame
  25466. */
  25467. export interface IAnimationKey {
  25468. /**
  25469. * Frame of the key frame
  25470. */
  25471. frame: number;
  25472. /**
  25473. * Value at the specifies key frame
  25474. */
  25475. value: any;
  25476. /**
  25477. * The input tangent for the cubic hermite spline
  25478. */
  25479. inTangent?: any;
  25480. /**
  25481. * The output tangent for the cubic hermite spline
  25482. */
  25483. outTangent?: any;
  25484. /**
  25485. * The animation interpolation type
  25486. */
  25487. interpolation?: AnimationKeyInterpolation;
  25488. }
  25489. /**
  25490. * Enum for the animation key frame interpolation type
  25491. */
  25492. export enum AnimationKeyInterpolation {
  25493. /**
  25494. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  25495. */
  25496. STEP = 1
  25497. }
  25498. /**
  25499. * Class used to store any kind of animation
  25500. */
  25501. export class Animation {
  25502. /**Name of the animation */
  25503. name: string;
  25504. /**Property to animate */
  25505. targetProperty: string;
  25506. /**The frames per second of the animation */
  25507. framePerSecond: number;
  25508. /**The data type of the animation */
  25509. dataType: number;
  25510. /**The loop mode of the animation */
  25511. loopMode?: number | undefined;
  25512. /**Specifies if blending should be enabled */
  25513. enableBlending?: boolean | undefined;
  25514. /**
  25515. * Use matrix interpolation instead of using direct key value when animating matrices
  25516. */
  25517. static AllowMatricesInterpolation: boolean;
  25518. /**
  25519. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25520. */
  25521. static AllowMatrixDecomposeForInterpolation: boolean;
  25522. /**
  25523. * Stores the key frames of the animation
  25524. */
  25525. private _keys;
  25526. /**
  25527. * Stores the easing function of the animation
  25528. */
  25529. private _easingFunction;
  25530. /**
  25531. * @hidden Internal use only
  25532. */
  25533. _runtimeAnimations: RuntimeAnimation[];
  25534. /**
  25535. * The set of event that will be linked to this animation
  25536. */
  25537. private _events;
  25538. /**
  25539. * Stores an array of target property paths
  25540. */
  25541. targetPropertyPath: string[];
  25542. /**
  25543. * Stores the blending speed of the animation
  25544. */
  25545. blendingSpeed: number;
  25546. /**
  25547. * Stores the animation ranges for the animation
  25548. */
  25549. private _ranges;
  25550. /**
  25551. * @hidden Internal use
  25552. */
  25553. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25554. /**
  25555. * Sets up an animation
  25556. * @param property The property to animate
  25557. * @param animationType The animation type to apply
  25558. * @param framePerSecond The frames per second of the animation
  25559. * @param easingFunction The easing function used in the animation
  25560. * @returns The created animation
  25561. */
  25562. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25563. /**
  25564. * Create and start an animation on a node
  25565. * @param name defines the name of the global animation that will be run on all nodes
  25566. * @param node defines the root node where the animation will take place
  25567. * @param targetProperty defines property to animate
  25568. * @param framePerSecond defines the number of frame per second yo use
  25569. * @param totalFrame defines the number of frames in total
  25570. * @param from defines the initial value
  25571. * @param to defines the final value
  25572. * @param loopMode defines which loop mode you want to use (off by default)
  25573. * @param easingFunction defines the easing function to use (linear by default)
  25574. * @param onAnimationEnd defines the callback to call when animation end
  25575. * @returns the animatable created for this animation
  25576. */
  25577. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25578. /**
  25579. * Create and start an animation on a node and its descendants
  25580. * @param name defines the name of the global animation that will be run on all nodes
  25581. * @param node defines the root node where the animation will take place
  25582. * @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
  25583. * @param targetProperty defines property to animate
  25584. * @param framePerSecond defines the number of frame per second to use
  25585. * @param totalFrame defines the number of frames in total
  25586. * @param from defines the initial value
  25587. * @param to defines the final value
  25588. * @param loopMode defines which loop mode you want to use (off by default)
  25589. * @param easingFunction defines the easing function to use (linear by default)
  25590. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25591. * @returns the list of animatables created for all nodes
  25592. * @example https://www.babylonjs-playground.com/#MH0VLI
  25593. */
  25594. 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[]>;
  25595. /**
  25596. * Creates a new animation, merges it with the existing animations and starts it
  25597. * @param name Name of the animation
  25598. * @param node Node which contains the scene that begins the animations
  25599. * @param targetProperty Specifies which property to animate
  25600. * @param framePerSecond The frames per second of the animation
  25601. * @param totalFrame The total number of frames
  25602. * @param from The frame at the beginning of the animation
  25603. * @param to The frame at the end of the animation
  25604. * @param loopMode Specifies the loop mode of the animation
  25605. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25606. * @param onAnimationEnd Callback to run once the animation is complete
  25607. * @returns Nullable animation
  25608. */
  25609. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25610. /**
  25611. * Transition property of an host to the target Value
  25612. * @param property The property to transition
  25613. * @param targetValue The target Value of the property
  25614. * @param host The object where the property to animate belongs
  25615. * @param scene Scene used to run the animation
  25616. * @param frameRate Framerate (in frame/s) to use
  25617. * @param transition The transition type we want to use
  25618. * @param duration The duration of the animation, in milliseconds
  25619. * @param onAnimationEnd Callback trigger at the end of the animation
  25620. * @returns Nullable animation
  25621. */
  25622. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25623. /**
  25624. * Return the array of runtime animations currently using this animation
  25625. */
  25626. readonly runtimeAnimations: RuntimeAnimation[];
  25627. /**
  25628. * Specifies if any of the runtime animations are currently running
  25629. */
  25630. readonly hasRunningRuntimeAnimations: boolean;
  25631. /**
  25632. * Initializes the animation
  25633. * @param name Name of the animation
  25634. * @param targetProperty Property to animate
  25635. * @param framePerSecond The frames per second of the animation
  25636. * @param dataType The data type of the animation
  25637. * @param loopMode The loop mode of the animation
  25638. * @param enableBlendings Specifies if blending should be enabled
  25639. */
  25640. constructor(
  25641. /**Name of the animation */
  25642. name: string,
  25643. /**Property to animate */
  25644. targetProperty: string,
  25645. /**The frames per second of the animation */
  25646. framePerSecond: number,
  25647. /**The data type of the animation */
  25648. dataType: number,
  25649. /**The loop mode of the animation */
  25650. loopMode?: number | undefined,
  25651. /**Specifies if blending should be enabled */
  25652. enableBlending?: boolean | undefined);
  25653. /**
  25654. * Converts the animation to a string
  25655. * @param fullDetails support for multiple levels of logging within scene loading
  25656. * @returns String form of the animation
  25657. */
  25658. toString(fullDetails?: boolean): string;
  25659. /**
  25660. * Add an event to this animation
  25661. * @param event Event to add
  25662. */
  25663. addEvent(event: AnimationEvent): void;
  25664. /**
  25665. * Remove all events found at the given frame
  25666. * @param frame The frame to remove events from
  25667. */
  25668. removeEvents(frame: number): void;
  25669. /**
  25670. * Retrieves all the events from the animation
  25671. * @returns Events from the animation
  25672. */
  25673. getEvents(): AnimationEvent[];
  25674. /**
  25675. * Creates an animation range
  25676. * @param name Name of the animation range
  25677. * @param from Starting frame of the animation range
  25678. * @param to Ending frame of the animation
  25679. */
  25680. createRange(name: string, from: number, to: number): void;
  25681. /**
  25682. * Deletes an animation range by name
  25683. * @param name Name of the animation range to delete
  25684. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25685. */
  25686. deleteRange(name: string, deleteFrames?: boolean): void;
  25687. /**
  25688. * Gets the animation range by name, or null if not defined
  25689. * @param name Name of the animation range
  25690. * @returns Nullable animation range
  25691. */
  25692. getRange(name: string): Nullable<AnimationRange>;
  25693. /**
  25694. * Gets the key frames from the animation
  25695. * @returns The key frames of the animation
  25696. */
  25697. getKeys(): Array<IAnimationKey>;
  25698. /**
  25699. * Gets the highest frame rate of the animation
  25700. * @returns Highest frame rate of the animation
  25701. */
  25702. getHighestFrame(): number;
  25703. /**
  25704. * Gets the easing function of the animation
  25705. * @returns Easing function of the animation
  25706. */
  25707. getEasingFunction(): IEasingFunction;
  25708. /**
  25709. * Sets the easing function of the animation
  25710. * @param easingFunction A custom mathematical formula for animation
  25711. */
  25712. setEasingFunction(easingFunction: EasingFunction): void;
  25713. /**
  25714. * Interpolates a scalar linearly
  25715. * @param startValue Start value of the animation curve
  25716. * @param endValue End value of the animation curve
  25717. * @param gradient Scalar amount to interpolate
  25718. * @returns Interpolated scalar value
  25719. */
  25720. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25721. /**
  25722. * Interpolates a scalar cubically
  25723. * @param startValue Start value of the animation curve
  25724. * @param outTangent End tangent of the animation
  25725. * @param endValue End value of the animation curve
  25726. * @param inTangent Start tangent of the animation curve
  25727. * @param gradient Scalar amount to interpolate
  25728. * @returns Interpolated scalar value
  25729. */
  25730. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25731. /**
  25732. * Interpolates a quaternion using a spherical linear interpolation
  25733. * @param startValue Start value of the animation curve
  25734. * @param endValue End value of the animation curve
  25735. * @param gradient Scalar amount to interpolate
  25736. * @returns Interpolated quaternion value
  25737. */
  25738. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25739. /**
  25740. * Interpolates a quaternion cubically
  25741. * @param startValue Start value of the animation curve
  25742. * @param outTangent End tangent of the animation curve
  25743. * @param endValue End value of the animation curve
  25744. * @param inTangent Start tangent of the animation curve
  25745. * @param gradient Scalar amount to interpolate
  25746. * @returns Interpolated quaternion value
  25747. */
  25748. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25749. /**
  25750. * Interpolates a Vector3 linearl
  25751. * @param startValue Start value of the animation curve
  25752. * @param endValue End value of the animation curve
  25753. * @param gradient Scalar amount to interpolate
  25754. * @returns Interpolated scalar value
  25755. */
  25756. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25757. /**
  25758. * Interpolates a Vector3 cubically
  25759. * @param startValue Start value of the animation curve
  25760. * @param outTangent End tangent of the animation
  25761. * @param endValue End value of the animation curve
  25762. * @param inTangent Start tangent of the animation curve
  25763. * @param gradient Scalar amount to interpolate
  25764. * @returns InterpolatedVector3 value
  25765. */
  25766. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25767. /**
  25768. * Interpolates a Vector2 linearly
  25769. * @param startValue Start value of the animation curve
  25770. * @param endValue End value of the animation curve
  25771. * @param gradient Scalar amount to interpolate
  25772. * @returns Interpolated Vector2 value
  25773. */
  25774. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25775. /**
  25776. * Interpolates a Vector2 cubically
  25777. * @param startValue Start value of the animation curve
  25778. * @param outTangent End tangent of the animation
  25779. * @param endValue End value of the animation curve
  25780. * @param inTangent Start tangent of the animation curve
  25781. * @param gradient Scalar amount to interpolate
  25782. * @returns Interpolated Vector2 value
  25783. */
  25784. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25785. /**
  25786. * Interpolates a size linearly
  25787. * @param startValue Start value of the animation curve
  25788. * @param endValue End value of the animation curve
  25789. * @param gradient Scalar amount to interpolate
  25790. * @returns Interpolated Size value
  25791. */
  25792. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25793. /**
  25794. * Interpolates a Color3 linearly
  25795. * @param startValue Start value of the animation curve
  25796. * @param endValue End value of the animation curve
  25797. * @param gradient Scalar amount to interpolate
  25798. * @returns Interpolated Color3 value
  25799. */
  25800. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25801. /**
  25802. * @hidden Internal use only
  25803. */
  25804. _getKeyValue(value: any): any;
  25805. /**
  25806. * @hidden Internal use only
  25807. */
  25808. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25809. /**
  25810. * Defines the function to use to interpolate matrices
  25811. * @param startValue defines the start matrix
  25812. * @param endValue defines the end matrix
  25813. * @param gradient defines the gradient between both matrices
  25814. * @param result defines an optional target matrix where to store the interpolation
  25815. * @returns the interpolated matrix
  25816. */
  25817. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25818. /**
  25819. * Makes a copy of the animation
  25820. * @returns Cloned animation
  25821. */
  25822. clone(): Animation;
  25823. /**
  25824. * Sets the key frames of the animation
  25825. * @param values The animation key frames to set
  25826. */
  25827. setKeys(values: Array<IAnimationKey>): void;
  25828. /**
  25829. * Serializes the animation to an object
  25830. * @returns Serialized object
  25831. */
  25832. serialize(): any;
  25833. /**
  25834. * Float animation type
  25835. */
  25836. private static _ANIMATIONTYPE_FLOAT;
  25837. /**
  25838. * Vector3 animation type
  25839. */
  25840. private static _ANIMATIONTYPE_VECTOR3;
  25841. /**
  25842. * Quaternion animation type
  25843. */
  25844. private static _ANIMATIONTYPE_QUATERNION;
  25845. /**
  25846. * Matrix animation type
  25847. */
  25848. private static _ANIMATIONTYPE_MATRIX;
  25849. /**
  25850. * Color3 animation type
  25851. */
  25852. private static _ANIMATIONTYPE_COLOR3;
  25853. /**
  25854. * Vector2 animation type
  25855. */
  25856. private static _ANIMATIONTYPE_VECTOR2;
  25857. /**
  25858. * Size animation type
  25859. */
  25860. private static _ANIMATIONTYPE_SIZE;
  25861. /**
  25862. * Relative Loop Mode
  25863. */
  25864. private static _ANIMATIONLOOPMODE_RELATIVE;
  25865. /**
  25866. * Cycle Loop Mode
  25867. */
  25868. private static _ANIMATIONLOOPMODE_CYCLE;
  25869. /**
  25870. * Constant Loop Mode
  25871. */
  25872. private static _ANIMATIONLOOPMODE_CONSTANT;
  25873. /**
  25874. * Get the float animation type
  25875. */
  25876. static readonly ANIMATIONTYPE_FLOAT: number;
  25877. /**
  25878. * Get the Vector3 animation type
  25879. */
  25880. static readonly ANIMATIONTYPE_VECTOR3: number;
  25881. /**
  25882. * Get the Vector2 animation type
  25883. */
  25884. static readonly ANIMATIONTYPE_VECTOR2: number;
  25885. /**
  25886. * Get the Size animation type
  25887. */
  25888. static readonly ANIMATIONTYPE_SIZE: number;
  25889. /**
  25890. * Get the Quaternion animation type
  25891. */
  25892. static readonly ANIMATIONTYPE_QUATERNION: number;
  25893. /**
  25894. * Get the Matrix animation type
  25895. */
  25896. static readonly ANIMATIONTYPE_MATRIX: number;
  25897. /**
  25898. * Get the Color3 animation type
  25899. */
  25900. static readonly ANIMATIONTYPE_COLOR3: number;
  25901. /**
  25902. * Get the Relative Loop Mode
  25903. */
  25904. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25905. /**
  25906. * Get the Cycle Loop Mode
  25907. */
  25908. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25909. /**
  25910. * Get the Constant Loop Mode
  25911. */
  25912. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25913. /** @hidden */
  25914. static _UniversalLerp(left: any, right: any, amount: number): any;
  25915. /**
  25916. * Parses an animation object and creates an animation
  25917. * @param parsedAnimation Parsed animation object
  25918. * @returns Animation object
  25919. */
  25920. static Parse(parsedAnimation: any): Animation;
  25921. /**
  25922. * Appends the serialized animations from the source animations
  25923. * @param source Source containing the animations
  25924. * @param destination Target to store the animations
  25925. */
  25926. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25927. }
  25928. }
  25929. declare module BABYLON {
  25930. /**
  25931. * Base class of all the textures in babylon.
  25932. * It groups all the common properties the materials, post process, lights... might need
  25933. * in order to make a correct use of the texture.
  25934. */
  25935. export class BaseTexture implements IAnimatable {
  25936. /**
  25937. * Default anisotropic filtering level for the application.
  25938. * It is set to 4 as a good tradeoff between perf and quality.
  25939. */
  25940. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25941. /**
  25942. * Gets or sets the unique id of the texture
  25943. */
  25944. uniqueId: number;
  25945. /**
  25946. * Define the name of the texture.
  25947. */
  25948. name: string;
  25949. /**
  25950. * Gets or sets an object used to store user defined information.
  25951. */
  25952. metadata: any;
  25953. /**
  25954. * For internal use only. Please do not use.
  25955. */
  25956. reservedDataStore: any;
  25957. private _hasAlpha;
  25958. /**
  25959. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25960. */
  25961. hasAlpha: boolean;
  25962. /**
  25963. * Defines if the alpha value should be determined via the rgb values.
  25964. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25965. */
  25966. getAlphaFromRGB: boolean;
  25967. /**
  25968. * Intensity or strength of the texture.
  25969. * It is commonly used by materials to fine tune the intensity of the texture
  25970. */
  25971. level: number;
  25972. /**
  25973. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25974. * This is part of the texture as textures usually maps to one uv set.
  25975. */
  25976. coordinatesIndex: number;
  25977. private _coordinatesMode;
  25978. /**
  25979. * How a texture is mapped.
  25980. *
  25981. * | Value | Type | Description |
  25982. * | ----- | ----------------------------------- | ----------- |
  25983. * | 0 | EXPLICIT_MODE | |
  25984. * | 1 | SPHERICAL_MODE | |
  25985. * | 2 | PLANAR_MODE | |
  25986. * | 3 | CUBIC_MODE | |
  25987. * | 4 | PROJECTION_MODE | |
  25988. * | 5 | SKYBOX_MODE | |
  25989. * | 6 | INVCUBIC_MODE | |
  25990. * | 7 | EQUIRECTANGULAR_MODE | |
  25991. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25992. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25993. */
  25994. coordinatesMode: number;
  25995. /**
  25996. * | Value | Type | Description |
  25997. * | ----- | ------------------ | ----------- |
  25998. * | 0 | CLAMP_ADDRESSMODE | |
  25999. * | 1 | WRAP_ADDRESSMODE | |
  26000. * | 2 | MIRROR_ADDRESSMODE | |
  26001. */
  26002. wrapU: number;
  26003. /**
  26004. * | Value | Type | Description |
  26005. * | ----- | ------------------ | ----------- |
  26006. * | 0 | CLAMP_ADDRESSMODE | |
  26007. * | 1 | WRAP_ADDRESSMODE | |
  26008. * | 2 | MIRROR_ADDRESSMODE | |
  26009. */
  26010. wrapV: number;
  26011. /**
  26012. * | Value | Type | Description |
  26013. * | ----- | ------------------ | ----------- |
  26014. * | 0 | CLAMP_ADDRESSMODE | |
  26015. * | 1 | WRAP_ADDRESSMODE | |
  26016. * | 2 | MIRROR_ADDRESSMODE | |
  26017. */
  26018. wrapR: number;
  26019. /**
  26020. * With compliant hardware and browser (supporting anisotropic filtering)
  26021. * this defines the level of anisotropic filtering in the texture.
  26022. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26023. */
  26024. anisotropicFilteringLevel: number;
  26025. /**
  26026. * Define if the texture is a cube texture or if false a 2d texture.
  26027. */
  26028. isCube: boolean;
  26029. /**
  26030. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26031. */
  26032. is3D: boolean;
  26033. /**
  26034. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26035. * HDR texture are usually stored in linear space.
  26036. * This only impacts the PBR and Background materials
  26037. */
  26038. gammaSpace: boolean;
  26039. /**
  26040. * Gets whether or not the texture contains RGBD data.
  26041. */
  26042. readonly isRGBD: boolean;
  26043. /**
  26044. * Is Z inverted in the texture (useful in a cube texture).
  26045. */
  26046. invertZ: boolean;
  26047. /**
  26048. * Are mip maps generated for this texture or not.
  26049. */
  26050. readonly noMipmap: boolean;
  26051. /**
  26052. * @hidden
  26053. */
  26054. lodLevelInAlpha: boolean;
  26055. /**
  26056. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26057. */
  26058. lodGenerationOffset: number;
  26059. /**
  26060. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26061. */
  26062. lodGenerationScale: number;
  26063. /**
  26064. * Define if the texture is a render target.
  26065. */
  26066. isRenderTarget: boolean;
  26067. /**
  26068. * Define the unique id of the texture in the scene.
  26069. */
  26070. readonly uid: string;
  26071. /**
  26072. * Return a string representation of the texture.
  26073. * @returns the texture as a string
  26074. */
  26075. toString(): string;
  26076. /**
  26077. * Get the class name of the texture.
  26078. * @returns "BaseTexture"
  26079. */
  26080. getClassName(): string;
  26081. /**
  26082. * Define the list of animation attached to the texture.
  26083. */
  26084. animations: Animation[];
  26085. /**
  26086. * An event triggered when the texture is disposed.
  26087. */
  26088. onDisposeObservable: Observable<BaseTexture>;
  26089. private _onDisposeObserver;
  26090. /**
  26091. * Callback triggered when the texture has been disposed.
  26092. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26093. */
  26094. onDispose: () => void;
  26095. /**
  26096. * Define the current state of the loading sequence when in delayed load mode.
  26097. */
  26098. delayLoadState: number;
  26099. private _scene;
  26100. /** @hidden */
  26101. _texture: Nullable<InternalTexture>;
  26102. private _uid;
  26103. /**
  26104. * Define if the texture is preventinga material to render or not.
  26105. * If not and the texture is not ready, the engine will use a default black texture instead.
  26106. */
  26107. readonly isBlocking: boolean;
  26108. /**
  26109. * Instantiates a new BaseTexture.
  26110. * Base class of all the textures in babylon.
  26111. * It groups all the common properties the materials, post process, lights... might need
  26112. * in order to make a correct use of the texture.
  26113. * @param scene Define the scene the texture blongs to
  26114. */
  26115. constructor(scene: Nullable<Scene>);
  26116. /**
  26117. * Get the scene the texture belongs to.
  26118. * @returns the scene or null if undefined
  26119. */
  26120. getScene(): Nullable<Scene>;
  26121. /**
  26122. * Get the texture transform matrix used to offset tile the texture for istance.
  26123. * @returns the transformation matrix
  26124. */
  26125. getTextureMatrix(): Matrix;
  26126. /**
  26127. * Get the texture reflection matrix used to rotate/transform the reflection.
  26128. * @returns the reflection matrix
  26129. */
  26130. getReflectionTextureMatrix(): Matrix;
  26131. /**
  26132. * Get the underlying lower level texture from Babylon.
  26133. * @returns the insternal texture
  26134. */
  26135. getInternalTexture(): Nullable<InternalTexture>;
  26136. /**
  26137. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26138. * @returns true if ready or not blocking
  26139. */
  26140. isReadyOrNotBlocking(): boolean;
  26141. /**
  26142. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26143. * @returns true if fully ready
  26144. */
  26145. isReady(): boolean;
  26146. private _cachedSize;
  26147. /**
  26148. * Get the size of the texture.
  26149. * @returns the texture size.
  26150. */
  26151. getSize(): ISize;
  26152. /**
  26153. * Get the base size of the texture.
  26154. * It can be different from the size if the texture has been resized for POT for instance
  26155. * @returns the base size
  26156. */
  26157. getBaseSize(): ISize;
  26158. /**
  26159. * Update the sampling mode of the texture.
  26160. * Default is Trilinear mode.
  26161. *
  26162. * | Value | Type | Description |
  26163. * | ----- | ------------------ | ----------- |
  26164. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26165. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26166. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26167. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26168. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26169. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26170. * | 7 | NEAREST_LINEAR | |
  26171. * | 8 | NEAREST_NEAREST | |
  26172. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26173. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26174. * | 11 | LINEAR_LINEAR | |
  26175. * | 12 | LINEAR_NEAREST | |
  26176. *
  26177. * > _mag_: magnification filter (close to the viewer)
  26178. * > _min_: minification filter (far from the viewer)
  26179. * > _mip_: filter used between mip map levels
  26180. *@param samplingMode Define the new sampling mode of the texture
  26181. */
  26182. updateSamplingMode(samplingMode: number): void;
  26183. /**
  26184. * Scales the texture if is `canRescale()`
  26185. * @param ratio the resize factor we want to use to rescale
  26186. */
  26187. scale(ratio: number): void;
  26188. /**
  26189. * Get if the texture can rescale.
  26190. */
  26191. readonly canRescale: boolean;
  26192. /** @hidden */
  26193. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26194. /** @hidden */
  26195. _rebuild(): void;
  26196. /**
  26197. * Triggers the load sequence in delayed load mode.
  26198. */
  26199. delayLoad(): void;
  26200. /**
  26201. * Clones the texture.
  26202. * @returns the cloned texture
  26203. */
  26204. clone(): Nullable<BaseTexture>;
  26205. /**
  26206. * Get the texture underlying type (INT, FLOAT...)
  26207. */
  26208. readonly textureType: number;
  26209. /**
  26210. * Get the texture underlying format (RGB, RGBA...)
  26211. */
  26212. readonly textureFormat: number;
  26213. /**
  26214. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26215. * This will returns an RGBA array buffer containing either in values (0-255) or
  26216. * float values (0-1) depending of the underlying buffer type.
  26217. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26218. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26219. * @param buffer defines a user defined buffer to fill with data (can be null)
  26220. * @returns The Array buffer containing the pixels data.
  26221. */
  26222. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26223. /**
  26224. * Release and destroy the underlying lower level texture aka internalTexture.
  26225. */
  26226. releaseInternalTexture(): void;
  26227. /**
  26228. * Get the polynomial representation of the texture data.
  26229. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26230. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26231. */
  26232. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26233. /** @hidden */
  26234. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26235. /** @hidden */
  26236. readonly _lodTextureMid: Nullable<BaseTexture>;
  26237. /** @hidden */
  26238. readonly _lodTextureLow: Nullable<BaseTexture>;
  26239. /**
  26240. * Dispose the texture and release its associated resources.
  26241. */
  26242. dispose(): void;
  26243. /**
  26244. * Serialize the texture into a JSON representation that can be parsed later on.
  26245. * @returns the JSON representation of the texture
  26246. */
  26247. serialize(): any;
  26248. /**
  26249. * Helper function to be called back once a list of texture contains only ready textures.
  26250. * @param textures Define the list of textures to wait for
  26251. * @param callback Define the callback triggered once the entire list will be ready
  26252. */
  26253. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26254. }
  26255. }
  26256. declare module BABYLON {
  26257. /**
  26258. * Uniform buffer objects.
  26259. *
  26260. * Handles blocks of uniform on the GPU.
  26261. *
  26262. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26263. *
  26264. * For more information, please refer to :
  26265. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26266. */
  26267. export class UniformBuffer {
  26268. private _engine;
  26269. private _buffer;
  26270. private _data;
  26271. private _bufferData;
  26272. private _dynamic?;
  26273. private _uniformLocations;
  26274. private _uniformSizes;
  26275. private _uniformLocationPointer;
  26276. private _needSync;
  26277. private _noUBO;
  26278. private _currentEffect;
  26279. private static _MAX_UNIFORM_SIZE;
  26280. private static _tempBuffer;
  26281. /**
  26282. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26283. * This is dynamic to allow compat with webgl 1 and 2.
  26284. * You will need to pass the name of the uniform as well as the value.
  26285. */
  26286. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26287. /**
  26288. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26289. * This is dynamic to allow compat with webgl 1 and 2.
  26290. * You will need to pass the name of the uniform as well as the value.
  26291. */
  26292. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26293. /**
  26294. * Lambda to Update a single float in a uniform buffer.
  26295. * This is dynamic to allow compat with webgl 1 and 2.
  26296. * You will need to pass the name of the uniform as well as the value.
  26297. */
  26298. updateFloat: (name: string, x: number) => void;
  26299. /**
  26300. * Lambda to Update a vec2 of float in a uniform buffer.
  26301. * This is dynamic to allow compat with webgl 1 and 2.
  26302. * You will need to pass the name of the uniform as well as the value.
  26303. */
  26304. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26305. /**
  26306. * Lambda to Update a vec3 of float in a uniform buffer.
  26307. * This is dynamic to allow compat with webgl 1 and 2.
  26308. * You will need to pass the name of the uniform as well as the value.
  26309. */
  26310. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26311. /**
  26312. * Lambda to Update a vec4 of float in a uniform buffer.
  26313. * This is dynamic to allow compat with webgl 1 and 2.
  26314. * You will need to pass the name of the uniform as well as the value.
  26315. */
  26316. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26317. /**
  26318. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26319. * This is dynamic to allow compat with webgl 1 and 2.
  26320. * You will need to pass the name of the uniform as well as the value.
  26321. */
  26322. updateMatrix: (name: string, mat: Matrix) => void;
  26323. /**
  26324. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26325. * This is dynamic to allow compat with webgl 1 and 2.
  26326. * You will need to pass the name of the uniform as well as the value.
  26327. */
  26328. updateVector3: (name: string, vector: Vector3) => void;
  26329. /**
  26330. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26331. * This is dynamic to allow compat with webgl 1 and 2.
  26332. * You will need to pass the name of the uniform as well as the value.
  26333. */
  26334. updateVector4: (name: string, vector: Vector4) => void;
  26335. /**
  26336. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26337. * This is dynamic to allow compat with webgl 1 and 2.
  26338. * You will need to pass the name of the uniform as well as the value.
  26339. */
  26340. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26341. /**
  26342. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26343. * This is dynamic to allow compat with webgl 1 and 2.
  26344. * You will need to pass the name of the uniform as well as the value.
  26345. */
  26346. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26347. /**
  26348. * Instantiates a new Uniform buffer objects.
  26349. *
  26350. * Handles blocks of uniform on the GPU.
  26351. *
  26352. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26353. *
  26354. * For more information, please refer to :
  26355. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26356. * @param engine Define the engine the buffer is associated with
  26357. * @param data Define the data contained in the buffer
  26358. * @param dynamic Define if the buffer is updatable
  26359. */
  26360. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26361. /**
  26362. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26363. * or just falling back on setUniformXXX calls.
  26364. */
  26365. readonly useUbo: boolean;
  26366. /**
  26367. * Indicates if the WebGL underlying uniform buffer is in sync
  26368. * with the javascript cache data.
  26369. */
  26370. readonly isSync: boolean;
  26371. /**
  26372. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26373. * Also, a dynamic UniformBuffer will disable cache verification and always
  26374. * update the underlying WebGL uniform buffer to the GPU.
  26375. * @returns if Dynamic, otherwise false
  26376. */
  26377. isDynamic(): boolean;
  26378. /**
  26379. * The data cache on JS side.
  26380. * @returns the underlying data as a float array
  26381. */
  26382. getData(): Float32Array;
  26383. /**
  26384. * The underlying WebGL Uniform buffer.
  26385. * @returns the webgl buffer
  26386. */
  26387. getBuffer(): Nullable<WebGLBuffer>;
  26388. /**
  26389. * std140 layout specifies how to align data within an UBO structure.
  26390. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26391. * for specs.
  26392. */
  26393. private _fillAlignment;
  26394. /**
  26395. * Adds an uniform in the buffer.
  26396. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26397. * for the layout to be correct !
  26398. * @param name Name of the uniform, as used in the uniform block in the shader.
  26399. * @param size Data size, or data directly.
  26400. */
  26401. addUniform(name: string, size: number | number[]): void;
  26402. /**
  26403. * Adds a Matrix 4x4 to the uniform buffer.
  26404. * @param name Name of the uniform, as used in the uniform block in the shader.
  26405. * @param mat A 4x4 matrix.
  26406. */
  26407. addMatrix(name: string, mat: Matrix): void;
  26408. /**
  26409. * Adds a vec2 to the uniform buffer.
  26410. * @param name Name of the uniform, as used in the uniform block in the shader.
  26411. * @param x Define the x component value of the vec2
  26412. * @param y Define the y component value of the vec2
  26413. */
  26414. addFloat2(name: string, x: number, y: number): void;
  26415. /**
  26416. * Adds a vec3 to the uniform buffer.
  26417. * @param name Name of the uniform, as used in the uniform block in the shader.
  26418. * @param x Define the x component value of the vec3
  26419. * @param y Define the y component value of the vec3
  26420. * @param z Define the z component value of the vec3
  26421. */
  26422. addFloat3(name: string, x: number, y: number, z: number): void;
  26423. /**
  26424. * Adds a vec3 to the uniform buffer.
  26425. * @param name Name of the uniform, as used in the uniform block in the shader.
  26426. * @param color Define the vec3 from a Color
  26427. */
  26428. addColor3(name: string, color: Color3): void;
  26429. /**
  26430. * Adds a vec4 to the uniform buffer.
  26431. * @param name Name of the uniform, as used in the uniform block in the shader.
  26432. * @param color Define the rgb components from a Color
  26433. * @param alpha Define the a component of the vec4
  26434. */
  26435. addColor4(name: string, color: Color3, alpha: number): void;
  26436. /**
  26437. * Adds a vec3 to the uniform buffer.
  26438. * @param name Name of the uniform, as used in the uniform block in the shader.
  26439. * @param vector Define the vec3 components from a Vector
  26440. */
  26441. addVector3(name: string, vector: Vector3): void;
  26442. /**
  26443. * Adds a Matrix 3x3 to the uniform buffer.
  26444. * @param name Name of the uniform, as used in the uniform block in the shader.
  26445. */
  26446. addMatrix3x3(name: string): void;
  26447. /**
  26448. * Adds a Matrix 2x2 to the uniform buffer.
  26449. * @param name Name of the uniform, as used in the uniform block in the shader.
  26450. */
  26451. addMatrix2x2(name: string): void;
  26452. /**
  26453. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26454. */
  26455. create(): void;
  26456. /** @hidden */
  26457. _rebuild(): void;
  26458. /**
  26459. * Updates the WebGL Uniform Buffer on the GPU.
  26460. * If the `dynamic` flag is set to true, no cache comparison is done.
  26461. * Otherwise, the buffer will be updated only if the cache differs.
  26462. */
  26463. update(): void;
  26464. /**
  26465. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26466. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26467. * @param data Define the flattened data
  26468. * @param size Define the size of the data.
  26469. */
  26470. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26471. private _updateMatrix3x3ForUniform;
  26472. private _updateMatrix3x3ForEffect;
  26473. private _updateMatrix2x2ForEffect;
  26474. private _updateMatrix2x2ForUniform;
  26475. private _updateFloatForEffect;
  26476. private _updateFloatForUniform;
  26477. private _updateFloat2ForEffect;
  26478. private _updateFloat2ForUniform;
  26479. private _updateFloat3ForEffect;
  26480. private _updateFloat3ForUniform;
  26481. private _updateFloat4ForEffect;
  26482. private _updateFloat4ForUniform;
  26483. private _updateMatrixForEffect;
  26484. private _updateMatrixForUniform;
  26485. private _updateVector3ForEffect;
  26486. private _updateVector3ForUniform;
  26487. private _updateVector4ForEffect;
  26488. private _updateVector4ForUniform;
  26489. private _updateColor3ForEffect;
  26490. private _updateColor3ForUniform;
  26491. private _updateColor4ForEffect;
  26492. private _updateColor4ForUniform;
  26493. /**
  26494. * Sets a sampler uniform on the effect.
  26495. * @param name Define the name of the sampler.
  26496. * @param texture Define the texture to set in the sampler
  26497. */
  26498. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26499. /**
  26500. * Directly updates the value of the uniform in the cache AND on the GPU.
  26501. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26502. * @param data Define the flattened data
  26503. */
  26504. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26505. /**
  26506. * Binds this uniform buffer to an effect.
  26507. * @param effect Define the effect to bind the buffer to
  26508. * @param name Name of the uniform block in the shader.
  26509. */
  26510. bindToEffect(effect: Effect, name: string): void;
  26511. /**
  26512. * Disposes the uniform buffer.
  26513. */
  26514. dispose(): void;
  26515. }
  26516. }
  26517. declare module BABYLON {
  26518. /**
  26519. * This represents the required contract to create a new type of texture loader.
  26520. */
  26521. export interface IInternalTextureLoader {
  26522. /**
  26523. * Defines wether the loader supports cascade loading the different faces.
  26524. */
  26525. supportCascades: boolean;
  26526. /**
  26527. * This returns if the loader support the current file information.
  26528. * @param extension defines the file extension of the file being loaded
  26529. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26530. * @param fallback defines the fallback internal texture if any
  26531. * @param isBase64 defines whether the texture is encoded as a base64
  26532. * @param isBuffer defines whether the texture data are stored as a buffer
  26533. * @returns true if the loader can load the specified file
  26534. */
  26535. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26536. /**
  26537. * Transform the url before loading if required.
  26538. * @param rootUrl the url of the texture
  26539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26540. * @returns the transformed texture
  26541. */
  26542. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26543. /**
  26544. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26545. * @param rootUrl the url of the texture
  26546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26547. * @returns the fallback texture
  26548. */
  26549. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26550. /**
  26551. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26552. * @param data contains the texture data
  26553. * @param texture defines the BabylonJS internal texture
  26554. * @param createPolynomials will be true if polynomials have been requested
  26555. * @param onLoad defines the callback to trigger once the texture is ready
  26556. * @param onError defines the callback to trigger in case of error
  26557. */
  26558. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26559. /**
  26560. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26561. * @param data contains the texture data
  26562. * @param texture defines the BabylonJS internal texture
  26563. * @param callback defines the method to call once ready to upload
  26564. */
  26565. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26566. }
  26567. }
  26568. declare module BABYLON {
  26569. /**
  26570. * Creation options of the multi render target texture.
  26571. */
  26572. export interface IMultiRenderTargetOptions {
  26573. /**
  26574. * Define if the texture needs to create mip maps after render.
  26575. */
  26576. generateMipMaps?: boolean;
  26577. /**
  26578. * Define the types of all the draw buffers we want to create
  26579. */
  26580. types?: number[];
  26581. /**
  26582. * Define the sampling modes of all the draw buffers we want to create
  26583. */
  26584. samplingModes?: number[];
  26585. /**
  26586. * Define if a depth buffer is required
  26587. */
  26588. generateDepthBuffer?: boolean;
  26589. /**
  26590. * Define if a stencil buffer is required
  26591. */
  26592. generateStencilBuffer?: boolean;
  26593. /**
  26594. * Define if a depth texture is required instead of a depth buffer
  26595. */
  26596. generateDepthTexture?: boolean;
  26597. /**
  26598. * Define the number of desired draw buffers
  26599. */
  26600. textureCount?: number;
  26601. /**
  26602. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26603. */
  26604. doNotChangeAspectRatio?: boolean;
  26605. /**
  26606. * Define the default type of the buffers we are creating
  26607. */
  26608. defaultType?: number;
  26609. }
  26610. /**
  26611. * A multi render target, like a render target provides the ability to render to a texture.
  26612. * Unlike the render target, it can render to several draw buffers in one draw.
  26613. * This is specially interesting in deferred rendering or for any effects requiring more than
  26614. * just one color from a single pass.
  26615. */
  26616. export class MultiRenderTarget extends RenderTargetTexture {
  26617. private _internalTextures;
  26618. private _textures;
  26619. private _multiRenderTargetOptions;
  26620. /**
  26621. * Get if draw buffers are currently supported by the used hardware and browser.
  26622. */
  26623. readonly isSupported: boolean;
  26624. /**
  26625. * Get the list of textures generated by the multi render target.
  26626. */
  26627. readonly textures: Texture[];
  26628. /**
  26629. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26630. */
  26631. readonly depthTexture: Texture;
  26632. /**
  26633. * Set the wrapping mode on U of all the textures we are rendering to.
  26634. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26635. */
  26636. wrapU: number;
  26637. /**
  26638. * Set the wrapping mode on V of all the textures we are rendering to.
  26639. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26640. */
  26641. wrapV: number;
  26642. /**
  26643. * Instantiate a new multi render target texture.
  26644. * A multi render target, like a render target provides the ability to render to a texture.
  26645. * Unlike the render target, it can render to several draw buffers in one draw.
  26646. * This is specially interesting in deferred rendering or for any effects requiring more than
  26647. * just one color from a single pass.
  26648. * @param name Define the name of the texture
  26649. * @param size Define the size of the buffers to render to
  26650. * @param count Define the number of target we are rendering into
  26651. * @param scene Define the scene the texture belongs to
  26652. * @param options Define the options used to create the multi render target
  26653. */
  26654. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26655. /** @hidden */
  26656. _rebuild(): void;
  26657. private _createInternalTextures;
  26658. private _createTextures;
  26659. /**
  26660. * Define the number of samples used if MSAA is enabled.
  26661. */
  26662. samples: number;
  26663. /**
  26664. * Resize all the textures in the multi render target.
  26665. * Be carrefull as it will recreate all the data in the new texture.
  26666. * @param size Define the new size
  26667. */
  26668. resize(size: any): void;
  26669. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26670. /**
  26671. * Dispose the render targets and their associated resources
  26672. */
  26673. dispose(): void;
  26674. /**
  26675. * Release all the underlying texture used as draw buffers.
  26676. */
  26677. releaseInternalTextures(): void;
  26678. }
  26679. }
  26680. declare module BABYLON {
  26681. /**
  26682. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26684. */
  26685. export class Analyser {
  26686. /**
  26687. * Gets or sets the smoothing
  26688. * @ignorenaming
  26689. */
  26690. SMOOTHING: number;
  26691. /**
  26692. * Gets or sets the FFT table size
  26693. * @ignorenaming
  26694. */
  26695. FFT_SIZE: number;
  26696. /**
  26697. * Gets or sets the bar graph amplitude
  26698. * @ignorenaming
  26699. */
  26700. BARGRAPHAMPLITUDE: number;
  26701. /**
  26702. * Gets or sets the position of the debug canvas
  26703. * @ignorenaming
  26704. */
  26705. DEBUGCANVASPOS: {
  26706. x: number;
  26707. y: number;
  26708. };
  26709. /**
  26710. * Gets or sets the debug canvas size
  26711. * @ignorenaming
  26712. */
  26713. DEBUGCANVASSIZE: {
  26714. width: number;
  26715. height: number;
  26716. };
  26717. private _byteFreqs;
  26718. private _byteTime;
  26719. private _floatFreqs;
  26720. private _webAudioAnalyser;
  26721. private _debugCanvas;
  26722. private _debugCanvasContext;
  26723. private _scene;
  26724. private _registerFunc;
  26725. private _audioEngine;
  26726. /**
  26727. * Creates a new analyser
  26728. * @param scene defines hosting scene
  26729. */
  26730. constructor(scene: Scene);
  26731. /**
  26732. * Get the number of data values you will have to play with for the visualization
  26733. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26734. * @returns a number
  26735. */
  26736. getFrequencyBinCount(): number;
  26737. /**
  26738. * Gets the current frequency data as a byte array
  26739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26740. * @returns a Uint8Array
  26741. */
  26742. getByteFrequencyData(): Uint8Array;
  26743. /**
  26744. * Gets the current waveform as a byte array
  26745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26746. * @returns a Uint8Array
  26747. */
  26748. getByteTimeDomainData(): Uint8Array;
  26749. /**
  26750. * Gets the current frequency data as a float array
  26751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26752. * @returns a Float32Array
  26753. */
  26754. getFloatFrequencyData(): Float32Array;
  26755. /**
  26756. * Renders the debug canvas
  26757. */
  26758. drawDebugCanvas(): void;
  26759. /**
  26760. * Stops rendering the debug canvas and removes it
  26761. */
  26762. stopDebugCanvas(): void;
  26763. /**
  26764. * Connects two audio nodes
  26765. * @param inputAudioNode defines first node to connect
  26766. * @param outputAudioNode defines second node to connect
  26767. */
  26768. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26769. /**
  26770. * Releases all associated resources
  26771. */
  26772. dispose(): void;
  26773. }
  26774. }
  26775. declare module BABYLON {
  26776. /**
  26777. * This represents an audio engine and it is responsible
  26778. * to play, synchronize and analyse sounds throughout the application.
  26779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26780. */
  26781. export interface IAudioEngine extends IDisposable {
  26782. /**
  26783. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26784. */
  26785. readonly canUseWebAudio: boolean;
  26786. /**
  26787. * Gets the current AudioContext if available.
  26788. */
  26789. readonly audioContext: Nullable<AudioContext>;
  26790. /**
  26791. * The master gain node defines the global audio volume of your audio engine.
  26792. */
  26793. readonly masterGain: GainNode;
  26794. /**
  26795. * Gets whether or not mp3 are supported by your browser.
  26796. */
  26797. readonly isMP3supported: boolean;
  26798. /**
  26799. * Gets whether or not ogg are supported by your browser.
  26800. */
  26801. readonly isOGGsupported: boolean;
  26802. /**
  26803. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26804. * @ignoreNaming
  26805. */
  26806. WarnedWebAudioUnsupported: boolean;
  26807. /**
  26808. * Defines if the audio engine relies on a custom unlocked button.
  26809. * In this case, the embedded button will not be displayed.
  26810. */
  26811. useCustomUnlockedButton: boolean;
  26812. /**
  26813. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26814. */
  26815. readonly unlocked: boolean;
  26816. /**
  26817. * Event raised when audio has been unlocked on the browser.
  26818. */
  26819. onAudioUnlockedObservable: Observable<AudioEngine>;
  26820. /**
  26821. * Event raised when audio has been locked on the browser.
  26822. */
  26823. onAudioLockedObservable: Observable<AudioEngine>;
  26824. /**
  26825. * Flags the audio engine in Locked state.
  26826. * This happens due to new browser policies preventing audio to autoplay.
  26827. */
  26828. lock(): void;
  26829. /**
  26830. * Unlocks the audio engine once a user action has been done on the dom.
  26831. * This is helpful to resume play once browser policies have been satisfied.
  26832. */
  26833. unlock(): void;
  26834. }
  26835. /**
  26836. * This represents the default audio engine used in babylon.
  26837. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26839. */
  26840. export class AudioEngine implements IAudioEngine {
  26841. private _audioContext;
  26842. private _audioContextInitialized;
  26843. private _muteButton;
  26844. private _hostElement;
  26845. /**
  26846. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26847. */
  26848. canUseWebAudio: boolean;
  26849. /**
  26850. * The master gain node defines the global audio volume of your audio engine.
  26851. */
  26852. masterGain: GainNode;
  26853. /**
  26854. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26855. * @ignoreNaming
  26856. */
  26857. WarnedWebAudioUnsupported: boolean;
  26858. /**
  26859. * Gets whether or not mp3 are supported by your browser.
  26860. */
  26861. isMP3supported: boolean;
  26862. /**
  26863. * Gets whether or not ogg are supported by your browser.
  26864. */
  26865. isOGGsupported: boolean;
  26866. /**
  26867. * Gets whether audio has been unlocked on the device.
  26868. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26869. * a user interaction has happened.
  26870. */
  26871. unlocked: boolean;
  26872. /**
  26873. * Defines if the audio engine relies on a custom unlocked button.
  26874. * In this case, the embedded button will not be displayed.
  26875. */
  26876. useCustomUnlockedButton: boolean;
  26877. /**
  26878. * Event raised when audio has been unlocked on the browser.
  26879. */
  26880. onAudioUnlockedObservable: Observable<AudioEngine>;
  26881. /**
  26882. * Event raised when audio has been locked on the browser.
  26883. */
  26884. onAudioLockedObservable: Observable<AudioEngine>;
  26885. /**
  26886. * Gets the current AudioContext if available.
  26887. */
  26888. readonly audioContext: Nullable<AudioContext>;
  26889. private _connectedAnalyser;
  26890. /**
  26891. * Instantiates a new audio engine.
  26892. *
  26893. * There should be only one per page as some browsers restrict the number
  26894. * of audio contexts you can create.
  26895. * @param hostElement defines the host element where to display the mute icon if necessary
  26896. */
  26897. constructor(hostElement?: Nullable<HTMLElement>);
  26898. /**
  26899. * Flags the audio engine in Locked state.
  26900. * This happens due to new browser policies preventing audio to autoplay.
  26901. */
  26902. lock(): void;
  26903. /**
  26904. * Unlocks the audio engine once a user action has been done on the dom.
  26905. * This is helpful to resume play once browser policies have been satisfied.
  26906. */
  26907. unlock(): void;
  26908. private _resumeAudioContext;
  26909. private _initializeAudioContext;
  26910. private _tryToRun;
  26911. private _triggerRunningState;
  26912. private _triggerSuspendedState;
  26913. private _displayMuteButton;
  26914. private _moveButtonToTopLeft;
  26915. private _onResize;
  26916. private _hideMuteButton;
  26917. /**
  26918. * Destroy and release the resources associated with the audio ccontext.
  26919. */
  26920. dispose(): void;
  26921. /**
  26922. * Gets the global volume sets on the master gain.
  26923. * @returns the global volume if set or -1 otherwise
  26924. */
  26925. getGlobalVolume(): number;
  26926. /**
  26927. * Sets the global volume of your experience (sets on the master gain).
  26928. * @param newVolume Defines the new global volume of the application
  26929. */
  26930. setGlobalVolume(newVolume: number): void;
  26931. /**
  26932. * Connect the audio engine to an audio analyser allowing some amazing
  26933. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26935. * @param analyser The analyser to connect to the engine
  26936. */
  26937. connectToAnalyser(analyser: Analyser): void;
  26938. }
  26939. }
  26940. declare module BABYLON {
  26941. /**
  26942. * Interface used to present a loading screen while loading a scene
  26943. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26944. */
  26945. export interface ILoadingScreen {
  26946. /**
  26947. * Function called to display the loading screen
  26948. */
  26949. displayLoadingUI: () => void;
  26950. /**
  26951. * Function called to hide the loading screen
  26952. */
  26953. hideLoadingUI: () => void;
  26954. /**
  26955. * Gets or sets the color to use for the background
  26956. */
  26957. loadingUIBackgroundColor: string;
  26958. /**
  26959. * Gets or sets the text to display while loading
  26960. */
  26961. loadingUIText: string;
  26962. }
  26963. /**
  26964. * Class used for the default loading screen
  26965. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26966. */
  26967. export class DefaultLoadingScreen implements ILoadingScreen {
  26968. private _renderingCanvas;
  26969. private _loadingText;
  26970. private _loadingDivBackgroundColor;
  26971. private _loadingDiv;
  26972. private _loadingTextDiv;
  26973. /**
  26974. * Creates a new default loading screen
  26975. * @param _renderingCanvas defines the canvas used to render the scene
  26976. * @param _loadingText defines the default text to display
  26977. * @param _loadingDivBackgroundColor defines the default background color
  26978. */
  26979. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26980. /**
  26981. * Function called to display the loading screen
  26982. */
  26983. displayLoadingUI(): void;
  26984. /**
  26985. * Function called to hide the loading screen
  26986. */
  26987. hideLoadingUI(): void;
  26988. /**
  26989. * Gets or sets the text to display while loading
  26990. */
  26991. loadingUIText: string;
  26992. /**
  26993. * Gets or sets the color to use for the background
  26994. */
  26995. loadingUIBackgroundColor: string;
  26996. private _resizeLoadingUI;
  26997. }
  26998. }
  26999. declare module BABYLON {
  27000. /**
  27001. * Settings for finer control over video usage
  27002. */
  27003. export interface VideoTextureSettings {
  27004. /**
  27005. * Applies `autoplay` to video, if specified
  27006. */
  27007. autoPlay?: boolean;
  27008. /**
  27009. * Applies `loop` to video, if specified
  27010. */
  27011. loop?: boolean;
  27012. /**
  27013. * Automatically updates internal texture from video at every frame in the render loop
  27014. */
  27015. autoUpdateTexture: boolean;
  27016. /**
  27017. * Image src displayed during the video loading or until the user interacts with the video.
  27018. */
  27019. poster?: string;
  27020. }
  27021. /**
  27022. * If you want to display a video in your scene, this is the special texture for that.
  27023. * This special texture works similar to other textures, with the exception of a few parameters.
  27024. * @see https://doc.babylonjs.com/how_to/video_texture
  27025. */
  27026. export class VideoTexture extends Texture {
  27027. /**
  27028. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27029. */
  27030. readonly autoUpdateTexture: boolean;
  27031. /**
  27032. * The video instance used by the texture internally
  27033. */
  27034. readonly video: HTMLVideoElement;
  27035. private _onUserActionRequestedObservable;
  27036. /**
  27037. * Event triggerd when a dom action is required by the user to play the video.
  27038. * This happens due to recent changes in browser policies preventing video to auto start.
  27039. */
  27040. readonly onUserActionRequestedObservable: Observable<Texture>;
  27041. private _generateMipMaps;
  27042. private _engine;
  27043. private _stillImageCaptured;
  27044. private _displayingPosterTexture;
  27045. private _settings;
  27046. private _createInternalTextureOnEvent;
  27047. /**
  27048. * Creates a video texture.
  27049. * If you want to display a video in your scene, this is the special texture for that.
  27050. * This special texture works similar to other textures, with the exception of a few parameters.
  27051. * @see https://doc.babylonjs.com/how_to/video_texture
  27052. * @param name optional name, will detect from video source, if not defined
  27053. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27054. * @param scene is obviously the current scene.
  27055. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27056. * @param invertY is false by default but can be used to invert video on Y axis
  27057. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27058. * @param settings allows finer control over video usage
  27059. */
  27060. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27061. private _getName;
  27062. private _getVideo;
  27063. private _createInternalTexture;
  27064. private reset;
  27065. /**
  27066. * @hidden Internal method to initiate `update`.
  27067. */
  27068. _rebuild(): void;
  27069. /**
  27070. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27071. */
  27072. update(): void;
  27073. /**
  27074. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27075. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27076. */
  27077. updateTexture(isVisible: boolean): void;
  27078. protected _updateInternalTexture: () => void;
  27079. /**
  27080. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27081. * @param url New url.
  27082. */
  27083. updateURL(url: string): void;
  27084. /**
  27085. * Dispose the texture and release its associated resources.
  27086. */
  27087. dispose(): void;
  27088. /**
  27089. * Creates a video texture straight from your WebCam video feed.
  27090. * @param scene Define the scene the texture should be created in
  27091. * @param onReady Define a callback to triggered once the texture will be ready
  27092. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27093. */
  27094. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27095. minWidth: number;
  27096. maxWidth: number;
  27097. minHeight: number;
  27098. maxHeight: number;
  27099. deviceId: string;
  27100. }): void;
  27101. }
  27102. }
  27103. declare module BABYLON {
  27104. /**
  27105. * Interface for attribute information associated with buffer instanciation
  27106. */
  27107. export class InstancingAttributeInfo {
  27108. /**
  27109. * Index/offset of the attribute in the vertex shader
  27110. */
  27111. index: number;
  27112. /**
  27113. * size of the attribute, 1, 2, 3 or 4
  27114. */
  27115. attributeSize: number;
  27116. /**
  27117. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27118. * default is FLOAT
  27119. */
  27120. attribyteType: number;
  27121. /**
  27122. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27123. */
  27124. normalized: boolean;
  27125. /**
  27126. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27127. */
  27128. offset: number;
  27129. /**
  27130. * Name of the GLSL attribute, for debugging purpose only
  27131. */
  27132. attributeName: string;
  27133. }
  27134. /**
  27135. * Define options used to create a depth texture
  27136. */
  27137. export class DepthTextureCreationOptions {
  27138. /** Specifies whether or not a stencil should be allocated in the texture */
  27139. generateStencil?: boolean;
  27140. /** Specifies whether or not bilinear filtering is enable on the texture */
  27141. bilinearFiltering?: boolean;
  27142. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27143. comparisonFunction?: number;
  27144. /** Specifies if the created texture is a cube texture */
  27145. isCube?: boolean;
  27146. }
  27147. /**
  27148. * Class used to describe the capabilities of the engine relatively to the current browser
  27149. */
  27150. export class EngineCapabilities {
  27151. /** Maximum textures units per fragment shader */
  27152. maxTexturesImageUnits: number;
  27153. /** Maximum texture units per vertex shader */
  27154. maxVertexTextureImageUnits: number;
  27155. /** Maximum textures units in the entire pipeline */
  27156. maxCombinedTexturesImageUnits: number;
  27157. /** Maximum texture size */
  27158. maxTextureSize: number;
  27159. /** Maximum cube texture size */
  27160. maxCubemapTextureSize: number;
  27161. /** Maximum render texture size */
  27162. maxRenderTextureSize: number;
  27163. /** Maximum number of vertex attributes */
  27164. maxVertexAttribs: number;
  27165. /** Maximum number of varyings */
  27166. maxVaryingVectors: number;
  27167. /** Maximum number of uniforms per vertex shader */
  27168. maxVertexUniformVectors: number;
  27169. /** Maximum number of uniforms per fragment shader */
  27170. maxFragmentUniformVectors: number;
  27171. /** Defines if standard derivates (dx/dy) are supported */
  27172. standardDerivatives: boolean;
  27173. /** Defines if s3tc texture compression is supported */
  27174. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27175. /** Defines if pvrtc texture compression is supported */
  27176. pvrtc: any;
  27177. /** Defines if etc1 texture compression is supported */
  27178. etc1: any;
  27179. /** Defines if etc2 texture compression is supported */
  27180. etc2: any;
  27181. /** Defines if astc texture compression is supported */
  27182. astc: any;
  27183. /** Defines if float textures are supported */
  27184. textureFloat: boolean;
  27185. /** Defines if vertex array objects are supported */
  27186. vertexArrayObject: boolean;
  27187. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27188. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27189. /** Gets the maximum level of anisotropy supported */
  27190. maxAnisotropy: number;
  27191. /** Defines if instancing is supported */
  27192. instancedArrays: boolean;
  27193. /** Defines if 32 bits indices are supported */
  27194. uintIndices: boolean;
  27195. /** Defines if high precision shaders are supported */
  27196. highPrecisionShaderSupported: boolean;
  27197. /** Defines if depth reading in the fragment shader is supported */
  27198. fragmentDepthSupported: boolean;
  27199. /** Defines if float texture linear filtering is supported*/
  27200. textureFloatLinearFiltering: boolean;
  27201. /** Defines if rendering to float textures is supported */
  27202. textureFloatRender: boolean;
  27203. /** Defines if half float textures are supported*/
  27204. textureHalfFloat: boolean;
  27205. /** Defines if half float texture linear filtering is supported*/
  27206. textureHalfFloatLinearFiltering: boolean;
  27207. /** Defines if rendering to half float textures is supported */
  27208. textureHalfFloatRender: boolean;
  27209. /** Defines if textureLOD shader command is supported */
  27210. textureLOD: boolean;
  27211. /** Defines if draw buffers extension is supported */
  27212. drawBuffersExtension: boolean;
  27213. /** Defines if depth textures are supported */
  27214. depthTextureExtension: boolean;
  27215. /** Defines if float color buffer are supported */
  27216. colorBufferFloat: boolean;
  27217. /** Gets disjoint timer query extension (null if not supported) */
  27218. timerQuery: EXT_disjoint_timer_query;
  27219. /** Defines if timestamp can be used with timer query */
  27220. canUseTimestampForTimerQuery: boolean;
  27221. /** Function used to let the system compiles shaders in background */
  27222. parallelShaderCompile: {
  27223. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27224. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27225. COMPLETION_STATUS_KHR: number;
  27226. };
  27227. }
  27228. /** Interface defining initialization parameters for Engine class */
  27229. export interface EngineOptions extends WebGLContextAttributes {
  27230. /**
  27231. * Defines if the engine should no exceed a specified device ratio
  27232. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27233. */
  27234. limitDeviceRatio?: number;
  27235. /**
  27236. * Defines if webvr should be enabled automatically
  27237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27238. */
  27239. autoEnableWebVR?: boolean;
  27240. /**
  27241. * Defines if webgl2 should be turned off even if supported
  27242. * @see http://doc.babylonjs.com/features/webgl2
  27243. */
  27244. disableWebGL2Support?: boolean;
  27245. /**
  27246. * Defines if webaudio should be initialized as well
  27247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27248. */
  27249. audioEngine?: boolean;
  27250. /**
  27251. * Defines if animations should run using a deterministic lock step
  27252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27253. */
  27254. deterministicLockstep?: boolean;
  27255. /** Defines the maximum steps to use with deterministic lock step mode */
  27256. lockstepMaxSteps?: number;
  27257. /**
  27258. * Defines that engine should ignore context lost events
  27259. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27260. */
  27261. doNotHandleContextLost?: boolean;
  27262. /**
  27263. * Defines that engine should ignore modifying touch action attribute and style
  27264. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27265. */
  27266. doNotHandleTouchAction?: boolean;
  27267. }
  27268. /**
  27269. * Defines the interface used by display changed events
  27270. */
  27271. export interface IDisplayChangedEventArgs {
  27272. /** Gets the vrDisplay object (if any) */
  27273. vrDisplay: Nullable<any>;
  27274. /** Gets a boolean indicating if webVR is supported */
  27275. vrSupported: boolean;
  27276. }
  27277. /**
  27278. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27279. */
  27280. export class Engine {
  27281. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27282. static ExceptionList: ({
  27283. key: string;
  27284. capture: string;
  27285. captureConstraint: number;
  27286. targets: string[];
  27287. } | {
  27288. key: string;
  27289. capture: null;
  27290. captureConstraint: null;
  27291. targets: string[];
  27292. })[];
  27293. /** Gets the list of created engines */
  27294. static readonly Instances: Engine[];
  27295. /**
  27296. * Gets the latest created engine
  27297. */
  27298. static readonly LastCreatedEngine: Nullable<Engine>;
  27299. /**
  27300. * Gets the latest created scene
  27301. */
  27302. static readonly LastCreatedScene: Nullable<Scene>;
  27303. /**
  27304. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27305. * @param flag defines which part of the materials must be marked as dirty
  27306. * @param predicate defines a predicate used to filter which materials should be affected
  27307. */
  27308. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27309. /**
  27310. * Hidden
  27311. */
  27312. static _TextureLoaders: IInternalTextureLoader[];
  27313. /** Defines that alpha blending is disabled */
  27314. static readonly ALPHA_DISABLE: number;
  27315. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27316. static readonly ALPHA_ADD: number;
  27317. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27318. static readonly ALPHA_COMBINE: number;
  27319. /** Defines that alpha blending to DEST - SRC * DEST */
  27320. static readonly ALPHA_SUBTRACT: number;
  27321. /** Defines that alpha blending to SRC * DEST */
  27322. static readonly ALPHA_MULTIPLY: number;
  27323. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27324. static readonly ALPHA_MAXIMIZED: number;
  27325. /** Defines that alpha blending to SRC + DEST */
  27326. static readonly ALPHA_ONEONE: number;
  27327. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27328. static readonly ALPHA_PREMULTIPLIED: number;
  27329. /**
  27330. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27331. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27332. */
  27333. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27334. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27335. static readonly ALPHA_INTERPOLATE: number;
  27336. /**
  27337. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27338. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27339. */
  27340. static readonly ALPHA_SCREENMODE: number;
  27341. /** Defines that the ressource is not delayed*/
  27342. static readonly DELAYLOADSTATE_NONE: number;
  27343. /** Defines that the ressource was successfully delay loaded */
  27344. static readonly DELAYLOADSTATE_LOADED: number;
  27345. /** Defines that the ressource is currently delay loading */
  27346. static readonly DELAYLOADSTATE_LOADING: number;
  27347. /** Defines that the ressource is delayed and has not started loading */
  27348. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27349. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27350. static readonly NEVER: number;
  27351. /** 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 */
  27352. static readonly ALWAYS: number;
  27353. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27354. static readonly LESS: number;
  27355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27356. static readonly EQUAL: number;
  27357. /** 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 */
  27358. static readonly LEQUAL: number;
  27359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27360. static readonly GREATER: number;
  27361. /** 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 */
  27362. static readonly GEQUAL: number;
  27363. /** 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 */
  27364. static readonly NOTEQUAL: number;
  27365. /** Passed to stencilOperation to specify that stencil value must be kept */
  27366. static readonly KEEP: number;
  27367. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27368. static readonly REPLACE: number;
  27369. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27370. static readonly INCR: number;
  27371. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27372. static readonly DECR: number;
  27373. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27374. static readonly INVERT: number;
  27375. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27376. static readonly INCR_WRAP: number;
  27377. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27378. static readonly DECR_WRAP: number;
  27379. /** Texture is not repeating outside of 0..1 UVs */
  27380. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27381. /** Texture is repeating outside of 0..1 UVs */
  27382. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27383. /** Texture is repeating and mirrored */
  27384. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27385. /** ALPHA */
  27386. static readonly TEXTUREFORMAT_ALPHA: number;
  27387. /** LUMINANCE */
  27388. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27389. /** LUMINANCE_ALPHA */
  27390. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27391. /** RGB */
  27392. static readonly TEXTUREFORMAT_RGB: number;
  27393. /** RGBA */
  27394. static readonly TEXTUREFORMAT_RGBA: number;
  27395. /** RED */
  27396. static readonly TEXTUREFORMAT_RED: number;
  27397. /** RED (2nd reference) */
  27398. static readonly TEXTUREFORMAT_R: number;
  27399. /** RG */
  27400. static readonly TEXTUREFORMAT_RG: number;
  27401. /** RED_INTEGER */
  27402. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27403. /** RED_INTEGER (2nd reference) */
  27404. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27405. /** RG_INTEGER */
  27406. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27407. /** RGB_INTEGER */
  27408. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27409. /** RGBA_INTEGER */
  27410. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27411. /** UNSIGNED_BYTE */
  27412. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27413. /** UNSIGNED_BYTE (2nd reference) */
  27414. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27415. /** FLOAT */
  27416. static readonly TEXTURETYPE_FLOAT: number;
  27417. /** HALF_FLOAT */
  27418. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27419. /** BYTE */
  27420. static readonly TEXTURETYPE_BYTE: number;
  27421. /** SHORT */
  27422. static readonly TEXTURETYPE_SHORT: number;
  27423. /** UNSIGNED_SHORT */
  27424. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27425. /** INT */
  27426. static readonly TEXTURETYPE_INT: number;
  27427. /** UNSIGNED_INT */
  27428. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27429. /** UNSIGNED_SHORT_4_4_4_4 */
  27430. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27431. /** UNSIGNED_SHORT_5_5_5_1 */
  27432. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27433. /** UNSIGNED_SHORT_5_6_5 */
  27434. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27435. /** UNSIGNED_INT_2_10_10_10_REV */
  27436. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27437. /** UNSIGNED_INT_24_8 */
  27438. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27439. /** UNSIGNED_INT_10F_11F_11F_REV */
  27440. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27441. /** UNSIGNED_INT_5_9_9_9_REV */
  27442. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27443. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27444. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27445. /** nearest is mag = nearest and min = nearest and mip = linear */
  27446. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27447. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27448. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27449. /** Trilinear is mag = linear and min = linear and mip = linear */
  27450. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27451. /** nearest is mag = nearest and min = nearest and mip = linear */
  27452. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27453. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27454. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27455. /** Trilinear is mag = linear and min = linear and mip = linear */
  27456. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27457. /** mag = nearest and min = nearest and mip = nearest */
  27458. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27459. /** mag = nearest and min = linear and mip = nearest */
  27460. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27461. /** mag = nearest and min = linear and mip = linear */
  27462. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27463. /** mag = nearest and min = linear and mip = none */
  27464. static readonly TEXTURE_NEAREST_LINEAR: number;
  27465. /** mag = nearest and min = nearest and mip = none */
  27466. static readonly TEXTURE_NEAREST_NEAREST: number;
  27467. /** mag = linear and min = nearest and mip = nearest */
  27468. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27469. /** mag = linear and min = nearest and mip = linear */
  27470. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27471. /** mag = linear and min = linear and mip = none */
  27472. static readonly TEXTURE_LINEAR_LINEAR: number;
  27473. /** mag = linear and min = nearest and mip = none */
  27474. static readonly TEXTURE_LINEAR_NEAREST: number;
  27475. /** Explicit coordinates mode */
  27476. static readonly TEXTURE_EXPLICIT_MODE: number;
  27477. /** Spherical coordinates mode */
  27478. static readonly TEXTURE_SPHERICAL_MODE: number;
  27479. /** Planar coordinates mode */
  27480. static readonly TEXTURE_PLANAR_MODE: number;
  27481. /** Cubic coordinates mode */
  27482. static readonly TEXTURE_CUBIC_MODE: number;
  27483. /** Projection coordinates mode */
  27484. static readonly TEXTURE_PROJECTION_MODE: number;
  27485. /** Skybox coordinates mode */
  27486. static readonly TEXTURE_SKYBOX_MODE: number;
  27487. /** Inverse Cubic coordinates mode */
  27488. static readonly TEXTURE_INVCUBIC_MODE: number;
  27489. /** Equirectangular coordinates mode */
  27490. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27491. /** Equirectangular Fixed coordinates mode */
  27492. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27493. /** Equirectangular Fixed Mirrored coordinates mode */
  27494. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27495. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27496. static readonly SCALEMODE_FLOOR: number;
  27497. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27498. static readonly SCALEMODE_NEAREST: number;
  27499. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27500. static readonly SCALEMODE_CEILING: number;
  27501. /**
  27502. * Returns the current version of the framework
  27503. */
  27504. static readonly Version: string;
  27505. /**
  27506. * Returns a string describing the current engine
  27507. */
  27508. readonly description: string;
  27509. /**
  27510. * Gets or sets the epsilon value used by collision engine
  27511. */
  27512. static CollisionsEpsilon: number;
  27513. /**
  27514. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27515. */
  27516. static ShadersRepository: string;
  27517. /**
  27518. * Method called to create the default loading screen.
  27519. * This can be overriden in your own app.
  27520. * @param canvas The rendering canvas element
  27521. * @returns The loading screen
  27522. */
  27523. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27524. /**
  27525. * Method called to create the default rescale post process on each engine.
  27526. */
  27527. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27528. /**
  27529. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27530. */
  27531. forcePOTTextures: boolean;
  27532. /**
  27533. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27534. */
  27535. isFullscreen: boolean;
  27536. /**
  27537. * Gets a boolean indicating if the pointer is currently locked
  27538. */
  27539. isPointerLock: boolean;
  27540. /**
  27541. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27542. */
  27543. cullBackFaces: boolean;
  27544. /**
  27545. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27546. */
  27547. renderEvenInBackground: boolean;
  27548. /**
  27549. * Gets or sets a boolean indicating that cache can be kept between frames
  27550. */
  27551. preventCacheWipeBetweenFrames: boolean;
  27552. /**
  27553. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27554. **/
  27555. enableOfflineSupport: boolean;
  27556. /**
  27557. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  27558. **/
  27559. disableManifestCheck: boolean;
  27560. /**
  27561. * Gets the list of created scenes
  27562. */
  27563. scenes: Scene[];
  27564. /**
  27565. * Event raised when a new scene is created
  27566. */
  27567. onNewSceneAddedObservable: Observable<Scene>;
  27568. /**
  27569. * Gets the list of created postprocesses
  27570. */
  27571. postProcesses: PostProcess[];
  27572. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27573. validateShaderPrograms: boolean;
  27574. /**
  27575. * Observable event triggered each time the rendering canvas is resized
  27576. */
  27577. onResizeObservable: Observable<Engine>;
  27578. /**
  27579. * Observable event triggered each time the canvas loses focus
  27580. */
  27581. onCanvasBlurObservable: Observable<Engine>;
  27582. /**
  27583. * Observable event triggered each time the canvas gains focus
  27584. */
  27585. onCanvasFocusObservable: Observable<Engine>;
  27586. /**
  27587. * Observable event triggered each time the canvas receives pointerout event
  27588. */
  27589. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27590. /**
  27591. * Observable event triggered before each texture is initialized
  27592. */
  27593. onBeforeTextureInitObservable: Observable<Texture>;
  27594. private _vrDisplay;
  27595. private _vrSupported;
  27596. private _oldSize;
  27597. private _oldHardwareScaleFactor;
  27598. private _vrExclusivePointerMode;
  27599. private _webVRInitPromise;
  27600. /**
  27601. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27602. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27603. */
  27604. readonly isInVRExclusivePointerMode: boolean;
  27605. /**
  27606. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27607. */
  27608. disableUniformBuffers: boolean;
  27609. /** @hidden */
  27610. _uniformBuffers: UniformBuffer[];
  27611. /**
  27612. * Gets a boolean indicating that the engine supports uniform buffers
  27613. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27614. */
  27615. readonly supportsUniformBuffers: boolean;
  27616. /**
  27617. * Observable raised when the engine begins a new frame
  27618. */
  27619. onBeginFrameObservable: Observable<Engine>;
  27620. /**
  27621. * If set, will be used to request the next animation frame for the render loop
  27622. */
  27623. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27624. /**
  27625. * Observable raised when the engine ends the current frame
  27626. */
  27627. onEndFrameObservable: Observable<Engine>;
  27628. /**
  27629. * Observable raised when the engine is about to compile a shader
  27630. */
  27631. onBeforeShaderCompilationObservable: Observable<Engine>;
  27632. /**
  27633. * Observable raised when the engine has jsut compiled a shader
  27634. */
  27635. onAfterShaderCompilationObservable: Observable<Engine>;
  27636. /** @hidden */
  27637. _gl: WebGLRenderingContext;
  27638. private _renderingCanvas;
  27639. private _windowIsBackground;
  27640. private _webGLVersion;
  27641. /**
  27642. * Gets a boolean indicating that only power of 2 textures are supported
  27643. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27644. */
  27645. readonly needPOTTextures: boolean;
  27646. /** @hidden */
  27647. _badOS: boolean;
  27648. /** @hidden */
  27649. _badDesktopOS: boolean;
  27650. /**
  27651. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27652. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27653. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27654. */
  27655. disableTextureBindingOptimization: boolean;
  27656. /**
  27657. * Gets the audio engine
  27658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27659. * @ignorenaming
  27660. */
  27661. static audioEngine: IAudioEngine;
  27662. /**
  27663. * Default AudioEngine factory responsible of creating the Audio Engine.
  27664. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27665. */
  27666. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27667. /**
  27668. * Default offline support factory responsible of creating a tool used to store data locally.
  27669. * By default, this will create a Database object if the workload has been embedded.
  27670. */
  27671. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27672. private _onFocus;
  27673. private _onBlur;
  27674. private _onCanvasPointerOut;
  27675. private _onCanvasBlur;
  27676. private _onCanvasFocus;
  27677. private _onFullscreenChange;
  27678. private _onPointerLockChange;
  27679. private _onVRDisplayPointerRestricted;
  27680. private _onVRDisplayPointerUnrestricted;
  27681. private _onVrDisplayConnect;
  27682. private _onVrDisplayDisconnect;
  27683. private _onVrDisplayPresentChange;
  27684. /**
  27685. * Observable signaled when VR display mode changes
  27686. */
  27687. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27688. /**
  27689. * Observable signaled when VR request present is complete
  27690. */
  27691. onVRRequestPresentComplete: Observable<boolean>;
  27692. /**
  27693. * Observable signaled when VR request present starts
  27694. */
  27695. onVRRequestPresentStart: Observable<Engine>;
  27696. private _hardwareScalingLevel;
  27697. /** @hidden */
  27698. protected _caps: EngineCapabilities;
  27699. private _pointerLockRequested;
  27700. private _isStencilEnable;
  27701. private _colorWrite;
  27702. private _loadingScreen;
  27703. /** @hidden */
  27704. _drawCalls: PerfCounter;
  27705. /** @hidden */
  27706. _textureCollisions: PerfCounter;
  27707. private _glVersion;
  27708. private _glRenderer;
  27709. private _glVendor;
  27710. private _videoTextureSupported;
  27711. private _renderingQueueLaunched;
  27712. private _activeRenderLoops;
  27713. private _deterministicLockstep;
  27714. private _lockstepMaxSteps;
  27715. /**
  27716. * Observable signaled when a context lost event is raised
  27717. */
  27718. onContextLostObservable: Observable<Engine>;
  27719. /**
  27720. * Observable signaled when a context restored event is raised
  27721. */
  27722. onContextRestoredObservable: Observable<Engine>;
  27723. private _onContextLost;
  27724. private _onContextRestored;
  27725. private _contextWasLost;
  27726. private _doNotHandleContextLost;
  27727. /**
  27728. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27730. */
  27731. doNotHandleContextLost: boolean;
  27732. private _performanceMonitor;
  27733. private _fps;
  27734. private _deltaTime;
  27735. /**
  27736. * Turn this value on if you want to pause FPS computation when in background
  27737. */
  27738. disablePerformanceMonitorInBackground: boolean;
  27739. /**
  27740. * Gets the performance monitor attached to this engine
  27741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27742. */
  27743. readonly performanceMonitor: PerformanceMonitor;
  27744. /** @hidden */
  27745. protected _depthCullingState: _DepthCullingState;
  27746. /** @hidden */
  27747. protected _stencilState: _StencilState;
  27748. /** @hidden */
  27749. protected _alphaState: _AlphaState;
  27750. /** @hidden */
  27751. protected _alphaMode: number;
  27752. protected _internalTexturesCache: InternalTexture[];
  27753. /** @hidden */
  27754. protected _activeChannel: number;
  27755. private _currentTextureChannel;
  27756. /** @hidden */
  27757. protected _boundTexturesCache: {
  27758. [key: string]: Nullable<InternalTexture>;
  27759. };
  27760. /** @hidden */
  27761. protected _currentEffect: Nullable<Effect>;
  27762. /** @hidden */
  27763. protected _currentProgram: Nullable<WebGLProgram>;
  27764. private _compiledEffects;
  27765. private _vertexAttribArraysEnabled;
  27766. /** @hidden */
  27767. protected _cachedViewport: Nullable<Viewport>;
  27768. private _cachedVertexArrayObject;
  27769. /** @hidden */
  27770. protected _cachedVertexBuffers: any;
  27771. /** @hidden */
  27772. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27773. /** @hidden */
  27774. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27775. /** @hidden */
  27776. protected _currentRenderTarget: Nullable<InternalTexture>;
  27777. private _uintIndicesCurrentlySet;
  27778. private _currentBoundBuffer;
  27779. /** @hidden */
  27780. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27781. private _currentBufferPointers;
  27782. private _currentInstanceLocations;
  27783. private _currentInstanceBuffers;
  27784. private _textureUnits;
  27785. private _firstBoundInternalTextureTracker;
  27786. private _lastBoundInternalTextureTracker;
  27787. private _workingCanvas;
  27788. private _workingContext;
  27789. private _rescalePostProcess;
  27790. private _dummyFramebuffer;
  27791. private _externalData;
  27792. private _bindedRenderFunction;
  27793. private _vaoRecordInProgress;
  27794. private _mustWipeVertexAttributes;
  27795. private _emptyTexture;
  27796. private _emptyCubeTexture;
  27797. private _emptyTexture3D;
  27798. /** @hidden */
  27799. _frameHandler: number;
  27800. private _nextFreeTextureSlots;
  27801. private _maxSimultaneousTextures;
  27802. private _activeRequests;
  27803. private _texturesSupported;
  27804. private _textureFormatInUse;
  27805. /**
  27806. * Gets the list of texture formats supported
  27807. */
  27808. readonly texturesSupported: Array<string>;
  27809. /**
  27810. * Gets the list of texture formats in use
  27811. */
  27812. readonly textureFormatInUse: Nullable<string>;
  27813. /**
  27814. * Gets the current viewport
  27815. */
  27816. readonly currentViewport: Nullable<Viewport>;
  27817. /**
  27818. * Gets the default empty texture
  27819. */
  27820. readonly emptyTexture: InternalTexture;
  27821. /**
  27822. * Gets the default empty 3D texture
  27823. */
  27824. readonly emptyTexture3D: InternalTexture;
  27825. /**
  27826. * Gets the default empty cube texture
  27827. */
  27828. readonly emptyCubeTexture: InternalTexture;
  27829. /**
  27830. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27831. */
  27832. readonly premultipliedAlpha: boolean;
  27833. /**
  27834. * Creates a new engine
  27835. * @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
  27836. * @param antialias defines enable antialiasing (default: false)
  27837. * @param options defines further options to be sent to the getContext() function
  27838. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27839. */
  27840. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27841. private _disableTouchAction;
  27842. private _rebuildInternalTextures;
  27843. private _rebuildEffects;
  27844. /**
  27845. * Gets a boolean indicating if all created effects are ready
  27846. * @returns true if all effects are ready
  27847. */
  27848. areAllEffectsReady(): boolean;
  27849. private _rebuildBuffers;
  27850. private _initGLContext;
  27851. /**
  27852. * Gets version of the current webGL context
  27853. */
  27854. readonly webGLVersion: number;
  27855. /**
  27856. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27857. */
  27858. readonly isStencilEnable: boolean;
  27859. private _prepareWorkingCanvas;
  27860. /**
  27861. * Reset the texture cache to empty state
  27862. */
  27863. resetTextureCache(): void;
  27864. /**
  27865. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27866. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27867. * @returns true if engine is in deterministic lock step mode
  27868. */
  27869. isDeterministicLockStep(): boolean;
  27870. /**
  27871. * Gets the max steps when engine is running in deterministic lock step
  27872. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27873. * @returns the max steps
  27874. */
  27875. getLockstepMaxSteps(): number;
  27876. /**
  27877. * Gets an object containing information about the current webGL context
  27878. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27879. */
  27880. getGlInfo(): {
  27881. vendor: string;
  27882. renderer: string;
  27883. version: string;
  27884. };
  27885. /**
  27886. * Gets current aspect ratio
  27887. * @param camera defines the camera to use to get the aspect ratio
  27888. * @param useScreen defines if screen size must be used (or the current render target if any)
  27889. * @returns a number defining the aspect ratio
  27890. */
  27891. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27892. /**
  27893. * Gets current screen aspect ratio
  27894. * @returns a number defining the aspect ratio
  27895. */
  27896. getScreenAspectRatio(): number;
  27897. /**
  27898. * Gets the current render width
  27899. * @param useScreen defines if screen size must be used (or the current render target if any)
  27900. * @returns a number defining the current render width
  27901. */
  27902. getRenderWidth(useScreen?: boolean): number;
  27903. /**
  27904. * Gets the current render height
  27905. * @param useScreen defines if screen size must be used (or the current render target if any)
  27906. * @returns a number defining the current render height
  27907. */
  27908. getRenderHeight(useScreen?: boolean): number;
  27909. /**
  27910. * Gets the HTML canvas attached with the current webGL context
  27911. * @returns a HTML canvas
  27912. */
  27913. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27914. /**
  27915. * Gets the client rect of the HTML canvas attached with the current webGL context
  27916. * @returns a client rectanglee
  27917. */
  27918. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27919. /**
  27920. * Defines the hardware scaling level.
  27921. * By default the hardware scaling level is computed from the window device ratio.
  27922. * 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.
  27923. * @param level defines the level to use
  27924. */
  27925. setHardwareScalingLevel(level: number): void;
  27926. /**
  27927. * Gets the current hardware scaling level.
  27928. * By default the hardware scaling level is computed from the window device ratio.
  27929. * 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.
  27930. * @returns a number indicating the current hardware scaling level
  27931. */
  27932. getHardwareScalingLevel(): number;
  27933. /**
  27934. * Gets the list of loaded textures
  27935. * @returns an array containing all loaded textures
  27936. */
  27937. getLoadedTexturesCache(): InternalTexture[];
  27938. /**
  27939. * Gets the object containing all engine capabilities
  27940. * @returns the EngineCapabilities object
  27941. */
  27942. getCaps(): EngineCapabilities;
  27943. /**
  27944. * Gets the current depth function
  27945. * @returns a number defining the depth function
  27946. */
  27947. getDepthFunction(): Nullable<number>;
  27948. /**
  27949. * Sets the current depth function
  27950. * @param depthFunc defines the function to use
  27951. */
  27952. setDepthFunction(depthFunc: number): void;
  27953. /**
  27954. * Sets the current depth function to GREATER
  27955. */
  27956. setDepthFunctionToGreater(): void;
  27957. /**
  27958. * Sets the current depth function to GEQUAL
  27959. */
  27960. setDepthFunctionToGreaterOrEqual(): void;
  27961. /**
  27962. * Sets the current depth function to LESS
  27963. */
  27964. setDepthFunctionToLess(): void;
  27965. /**
  27966. * Sets the current depth function to LEQUAL
  27967. */
  27968. setDepthFunctionToLessOrEqual(): void;
  27969. /**
  27970. * Gets a boolean indicating if stencil buffer is enabled
  27971. * @returns the current stencil buffer state
  27972. */
  27973. getStencilBuffer(): boolean;
  27974. /**
  27975. * Enable or disable the stencil buffer
  27976. * @param enable defines if the stencil buffer must be enabled or disabled
  27977. */
  27978. setStencilBuffer(enable: boolean): void;
  27979. /**
  27980. * Gets the current stencil mask
  27981. * @returns a number defining the new stencil mask to use
  27982. */
  27983. getStencilMask(): number;
  27984. /**
  27985. * Sets the current stencil mask
  27986. * @param mask defines the new stencil mask to use
  27987. */
  27988. setStencilMask(mask: number): void;
  27989. /**
  27990. * Gets the current stencil function
  27991. * @returns a number defining the stencil function to use
  27992. */
  27993. getStencilFunction(): number;
  27994. /**
  27995. * Gets the current stencil reference value
  27996. * @returns a number defining the stencil reference value to use
  27997. */
  27998. getStencilFunctionReference(): number;
  27999. /**
  28000. * Gets the current stencil mask
  28001. * @returns a number defining the stencil mask to use
  28002. */
  28003. getStencilFunctionMask(): number;
  28004. /**
  28005. * Sets the current stencil function
  28006. * @param stencilFunc defines the new stencil function to use
  28007. */
  28008. setStencilFunction(stencilFunc: number): void;
  28009. /**
  28010. * Sets the current stencil reference
  28011. * @param reference defines the new stencil reference to use
  28012. */
  28013. setStencilFunctionReference(reference: number): void;
  28014. /**
  28015. * Sets the current stencil mask
  28016. * @param mask defines the new stencil mask to use
  28017. */
  28018. setStencilFunctionMask(mask: number): void;
  28019. /**
  28020. * Gets the current stencil operation when stencil fails
  28021. * @returns a number defining stencil operation to use when stencil fails
  28022. */
  28023. getStencilOperationFail(): number;
  28024. /**
  28025. * Gets the current stencil operation when depth fails
  28026. * @returns a number defining stencil operation to use when depth fails
  28027. */
  28028. getStencilOperationDepthFail(): number;
  28029. /**
  28030. * Gets the current stencil operation when stencil passes
  28031. * @returns a number defining stencil operation to use when stencil passes
  28032. */
  28033. getStencilOperationPass(): number;
  28034. /**
  28035. * Sets the stencil operation to use when stencil fails
  28036. * @param operation defines the stencil operation to use when stencil fails
  28037. */
  28038. setStencilOperationFail(operation: number): void;
  28039. /**
  28040. * Sets the stencil operation to use when depth fails
  28041. * @param operation defines the stencil operation to use when depth fails
  28042. */
  28043. setStencilOperationDepthFail(operation: number): void;
  28044. /**
  28045. * Sets the stencil operation to use when stencil passes
  28046. * @param operation defines the stencil operation to use when stencil passes
  28047. */
  28048. setStencilOperationPass(operation: number): void;
  28049. /**
  28050. * Sets a boolean indicating if the dithering state is enabled or disabled
  28051. * @param value defines the dithering state
  28052. */
  28053. setDitheringState(value: boolean): void;
  28054. /**
  28055. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28056. * @param value defines the rasterizer state
  28057. */
  28058. setRasterizerState(value: boolean): void;
  28059. /**
  28060. * stop executing a render loop function and remove it from the execution array
  28061. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28062. */
  28063. stopRenderLoop(renderFunction?: () => void): void;
  28064. /** @hidden */
  28065. _renderLoop(): void;
  28066. /**
  28067. * Register and execute a render loop. The engine can have more than one render function
  28068. * @param renderFunction defines the function to continuously execute
  28069. */
  28070. runRenderLoop(renderFunction: () => void): void;
  28071. /**
  28072. * Toggle full screen mode
  28073. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28074. */
  28075. switchFullscreen(requestPointerLock: boolean): void;
  28076. /**
  28077. * Clear the current render buffer or the current render target (if any is set up)
  28078. * @param color defines the color to use
  28079. * @param backBuffer defines if the back buffer must be cleared
  28080. * @param depth defines if the depth buffer must be cleared
  28081. * @param stencil defines if the stencil buffer must be cleared
  28082. */
  28083. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28084. /**
  28085. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28086. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28087. * @param y defines the y-coordinate of the corner of the clear rectangle
  28088. * @param width defines the width of the clear rectangle
  28089. * @param height defines the height of the clear rectangle
  28090. * @param clearColor defines the clear color
  28091. */
  28092. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28093. /**
  28094. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28095. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28096. * @param y defines the y-coordinate of the corner of the clear rectangle
  28097. * @param width defines the width of the clear rectangle
  28098. * @param height defines the height of the clear rectangle
  28099. */
  28100. enableScissor(x: number, y: number, width: number, height: number): void;
  28101. /**
  28102. * Disable previously set scissor test rectangle
  28103. */
  28104. disableScissor(): void;
  28105. private _viewportCached;
  28106. /** @hidden */
  28107. _viewport(x: number, y: number, width: number, height: number): void;
  28108. /**
  28109. * Set the WebGL's viewport
  28110. * @param viewport defines the viewport element to be used
  28111. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28112. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28113. */
  28114. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28115. /**
  28116. * Directly set the WebGL Viewport
  28117. * @param x defines the x coordinate of the viewport (in screen space)
  28118. * @param y defines the y coordinate of the viewport (in screen space)
  28119. * @param width defines the width of the viewport (in screen space)
  28120. * @param height defines the height of the viewport (in screen space)
  28121. * @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
  28122. */
  28123. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28124. /**
  28125. * Begin a new frame
  28126. */
  28127. beginFrame(): void;
  28128. /**
  28129. * Enf the current frame
  28130. */
  28131. endFrame(): void;
  28132. /**
  28133. * Resize the view according to the canvas' size
  28134. */
  28135. resize(): void;
  28136. /**
  28137. * Force a specific size of the canvas
  28138. * @param width defines the new canvas' width
  28139. * @param height defines the new canvas' height
  28140. */
  28141. setSize(width: number, height: number): void;
  28142. /**
  28143. * Gets a boolean indicating if a webVR device was detected
  28144. * @returns true if a webVR device was detected
  28145. */
  28146. isVRDevicePresent(): boolean;
  28147. /**
  28148. * Gets the current webVR device
  28149. * @returns the current webVR device (or null)
  28150. */
  28151. getVRDevice(): any;
  28152. /**
  28153. * Initializes a webVR display and starts listening to display change events
  28154. * The onVRDisplayChangedObservable will be notified upon these changes
  28155. * @returns The onVRDisplayChangedObservable
  28156. */
  28157. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28158. /**
  28159. * Initializes a webVR display and starts listening to display change events
  28160. * The onVRDisplayChangedObservable will be notified upon these changes
  28161. * @returns A promise containing a VRDisplay and if vr is supported
  28162. */
  28163. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28164. /**
  28165. * Call this function to switch to webVR mode
  28166. * Will do nothing if webVR is not supported or if there is no webVR device
  28167. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28168. */
  28169. enableVR(): void;
  28170. /**
  28171. * Call this function to leave webVR mode
  28172. * Will do nothing if webVR is not supported or if there is no webVR device
  28173. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28174. */
  28175. disableVR(): void;
  28176. private _onVRFullScreenTriggered;
  28177. private _getVRDisplaysAsync;
  28178. /**
  28179. * Binds the frame buffer to the specified texture.
  28180. * @param texture The texture to render to or null for the default canvas
  28181. * @param faceIndex The face of the texture to render to in case of cube texture
  28182. * @param requiredWidth The width of the target to render to
  28183. * @param requiredHeight The height of the target to render to
  28184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28185. * @param depthStencilTexture The depth stencil texture to use to render
  28186. * @param lodLevel defines le lod level to bind to the frame buffer
  28187. */
  28188. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28189. private bindUnboundFramebuffer;
  28190. /**
  28191. * Unbind the current render target texture from the webGL context
  28192. * @param texture defines the render target texture to unbind
  28193. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28194. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28195. */
  28196. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28197. /**
  28198. * Unbind a list of render target textures from the webGL context
  28199. * This is used only when drawBuffer extension or webGL2 are active
  28200. * @param textures defines the render target textures to unbind
  28201. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28202. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28203. */
  28204. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28205. /**
  28206. * Force the mipmap generation for the given render target texture
  28207. * @param texture defines the render target texture to use
  28208. */
  28209. generateMipMapsForCubemap(texture: InternalTexture): void;
  28210. /**
  28211. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28212. */
  28213. flushFramebuffer(): void;
  28214. /**
  28215. * Unbind the current render target and bind the default framebuffer
  28216. */
  28217. restoreDefaultFramebuffer(): void;
  28218. /**
  28219. * Create an uniform buffer
  28220. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28221. * @param elements defines the content of the uniform buffer
  28222. * @returns the webGL uniform buffer
  28223. */
  28224. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28225. /**
  28226. * Create a dynamic uniform buffer
  28227. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28228. * @param elements defines the content of the uniform buffer
  28229. * @returns the webGL uniform buffer
  28230. */
  28231. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28232. /**
  28233. * Update an existing uniform buffer
  28234. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28235. * @param uniformBuffer defines the target uniform buffer
  28236. * @param elements defines the content to update
  28237. * @param offset defines the offset in the uniform buffer where update should start
  28238. * @param count defines the size of the data to update
  28239. */
  28240. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28241. private _resetVertexBufferBinding;
  28242. /**
  28243. * Creates a vertex buffer
  28244. * @param data the data for the vertex buffer
  28245. * @returns the new WebGL static buffer
  28246. */
  28247. createVertexBuffer(data: DataArray): WebGLBuffer;
  28248. /**
  28249. * Creates a dynamic vertex buffer
  28250. * @param data the data for the dynamic vertex buffer
  28251. * @returns the new WebGL dynamic buffer
  28252. */
  28253. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28254. /**
  28255. * Update a dynamic index buffer
  28256. * @param indexBuffer defines the target index buffer
  28257. * @param indices defines the data to update
  28258. * @param offset defines the offset in the target index buffer where update should start
  28259. */
  28260. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28261. /**
  28262. * Updates a dynamic vertex buffer.
  28263. * @param vertexBuffer the vertex buffer to update
  28264. * @param data the data used to update the vertex buffer
  28265. * @param byteOffset the byte offset of the data
  28266. * @param byteLength the byte length of the data
  28267. */
  28268. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28269. private _resetIndexBufferBinding;
  28270. /**
  28271. * Creates a new index buffer
  28272. * @param indices defines the content of the index buffer
  28273. * @param updatable defines if the index buffer must be updatable
  28274. * @returns a new webGL buffer
  28275. */
  28276. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28277. /**
  28278. * Bind a webGL buffer to the webGL context
  28279. * @param buffer defines the buffer to bind
  28280. */
  28281. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28282. /**
  28283. * Bind an uniform buffer to the current webGL context
  28284. * @param buffer defines the buffer to bind
  28285. */
  28286. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28287. /**
  28288. * Bind a buffer to the current webGL context at a given location
  28289. * @param buffer defines the buffer to bind
  28290. * @param location defines the index where to bind the buffer
  28291. */
  28292. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28293. /**
  28294. * Bind a specific block at a given index in a specific shader program
  28295. * @param shaderProgram defines the shader program
  28296. * @param blockName defines the block name
  28297. * @param index defines the index where to bind the block
  28298. */
  28299. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28300. private bindIndexBuffer;
  28301. private bindBuffer;
  28302. /**
  28303. * update the bound buffer with the given data
  28304. * @param data defines the data to update
  28305. */
  28306. updateArrayBuffer(data: Float32Array): void;
  28307. private _vertexAttribPointer;
  28308. private _bindIndexBufferWithCache;
  28309. private _bindVertexBuffersAttributes;
  28310. /**
  28311. * Records a vertex array object
  28312. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28313. * @param vertexBuffers defines the list of vertex buffers to store
  28314. * @param indexBuffer defines the index buffer to store
  28315. * @param effect defines the effect to store
  28316. * @returns the new vertex array object
  28317. */
  28318. recordVertexArrayObject(vertexBuffers: {
  28319. [key: string]: VertexBuffer;
  28320. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28321. /**
  28322. * Bind a specific vertex array object
  28323. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28324. * @param vertexArrayObject defines the vertex array object to bind
  28325. * @param indexBuffer defines the index buffer to bind
  28326. */
  28327. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28328. /**
  28329. * Bind webGl buffers directly to the webGL context
  28330. * @param vertexBuffer defines the vertex buffer to bind
  28331. * @param indexBuffer defines the index buffer to bind
  28332. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28333. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28334. * @param effect defines the effect associated with the vertex buffer
  28335. */
  28336. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28337. private _unbindVertexArrayObject;
  28338. /**
  28339. * Bind a list of vertex buffers to the webGL context
  28340. * @param vertexBuffers defines the list of vertex buffers to bind
  28341. * @param indexBuffer defines the index buffer to bind
  28342. * @param effect defines the effect associated with the vertex buffers
  28343. */
  28344. bindBuffers(vertexBuffers: {
  28345. [key: string]: Nullable<VertexBuffer>;
  28346. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28347. /**
  28348. * Unbind all instance attributes
  28349. */
  28350. unbindInstanceAttributes(): void;
  28351. /**
  28352. * Release and free the memory of a vertex array object
  28353. * @param vao defines the vertex array object to delete
  28354. */
  28355. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28356. /** @hidden */
  28357. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28358. /**
  28359. * Creates a webGL buffer to use with instanciation
  28360. * @param capacity defines the size of the buffer
  28361. * @returns the webGL buffer
  28362. */
  28363. createInstancesBuffer(capacity: number): WebGLBuffer;
  28364. /**
  28365. * Delete a webGL buffer used with instanciation
  28366. * @param buffer defines the webGL buffer to delete
  28367. */
  28368. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28369. /**
  28370. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28371. * @param instancesBuffer defines the webGL buffer to update and bind
  28372. * @param data defines the data to store in the buffer
  28373. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28374. */
  28375. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28376. /**
  28377. * Apply all cached states (depth, culling, stencil and alpha)
  28378. */
  28379. applyStates(): void;
  28380. /**
  28381. * Send a draw order
  28382. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28383. * @param indexStart defines the starting index
  28384. * @param indexCount defines the number of index to draw
  28385. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28386. */
  28387. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28388. /**
  28389. * Draw a list of points
  28390. * @param verticesStart defines the index of first vertex to draw
  28391. * @param verticesCount defines the count of vertices to draw
  28392. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28393. */
  28394. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28395. /**
  28396. * Draw a list of unindexed primitives
  28397. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28398. * @param verticesStart defines the index of first vertex to draw
  28399. * @param verticesCount defines the count of vertices to draw
  28400. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28401. */
  28402. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28403. /**
  28404. * Draw a list of indexed primitives
  28405. * @param fillMode defines the primitive to use
  28406. * @param indexStart defines the starting index
  28407. * @param indexCount defines the number of index to draw
  28408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28409. */
  28410. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28411. /**
  28412. * Draw a list of unindexed primitives
  28413. * @param fillMode defines the primitive to use
  28414. * @param verticesStart defines the index of first vertex to draw
  28415. * @param verticesCount defines the count of vertices to draw
  28416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28417. */
  28418. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28419. private _drawMode;
  28420. /** @hidden */
  28421. _releaseEffect(effect: Effect): void;
  28422. /** @hidden */
  28423. _deleteProgram(program: WebGLProgram): void;
  28424. /**
  28425. * Create a new effect (used to store vertex/fragment shaders)
  28426. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28427. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28428. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28429. * @param samplers defines an array of string used to represent textures
  28430. * @param defines defines the string containing the defines to use to compile the shaders
  28431. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28432. * @param onCompiled defines a function to call when the effect creation is successful
  28433. * @param onError defines a function to call when the effect creation has failed
  28434. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28435. * @returns the new Effect
  28436. */
  28437. 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;
  28438. private _compileShader;
  28439. private _compileRawShader;
  28440. /**
  28441. * Directly creates a webGL program
  28442. * @param vertexCode defines the vertex shader code to use
  28443. * @param fragmentCode defines the fragment shader code to use
  28444. * @param context defines the webGL context to use (if not set, the current one will be used)
  28445. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28446. * @returns the new webGL program
  28447. */
  28448. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28449. /**
  28450. * Creates a webGL program
  28451. * @param vertexCode defines the vertex shader code to use
  28452. * @param fragmentCode defines the fragment shader code to use
  28453. * @param defines defines the string containing the defines to use to compile the shaders
  28454. * @param context defines the webGL context to use (if not set, the current one will be used)
  28455. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28456. * @returns the new webGL program
  28457. */
  28458. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28459. private _createShaderProgram;
  28460. private _finalizeProgram;
  28461. /** @hidden */
  28462. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28463. /** @hidden */
  28464. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28465. /**
  28466. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28467. * @param shaderProgram defines the webGL program to use
  28468. * @param uniformsNames defines the list of uniform names
  28469. * @returns an array of webGL uniform locations
  28470. */
  28471. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28472. /**
  28473. * Gets the lsit of active attributes for a given webGL program
  28474. * @param shaderProgram defines the webGL program to use
  28475. * @param attributesNames defines the list of attribute names to get
  28476. * @returns an array of indices indicating the offset of each attribute
  28477. */
  28478. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28479. /**
  28480. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28481. * @param effect defines the effect to activate
  28482. */
  28483. enableEffect(effect: Nullable<Effect>): void;
  28484. /**
  28485. * Set the value of an uniform to an array of int32
  28486. * @param uniform defines the webGL uniform location where to store the value
  28487. * @param array defines the array of int32 to store
  28488. */
  28489. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28490. /**
  28491. * Set the value of an uniform to an array of int32 (stored as vec2)
  28492. * @param uniform defines the webGL uniform location where to store the value
  28493. * @param array defines the array of int32 to store
  28494. */
  28495. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28496. /**
  28497. * Set the value of an uniform to an array of int32 (stored as vec3)
  28498. * @param uniform defines the webGL uniform location where to store the value
  28499. * @param array defines the array of int32 to store
  28500. */
  28501. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28502. /**
  28503. * Set the value of an uniform to an array of int32 (stored as vec4)
  28504. * @param uniform defines the webGL uniform location where to store the value
  28505. * @param array defines the array of int32 to store
  28506. */
  28507. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28508. /**
  28509. * Set the value of an uniform to an array of float32
  28510. * @param uniform defines the webGL uniform location where to store the value
  28511. * @param array defines the array of float32 to store
  28512. */
  28513. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28514. /**
  28515. * Set the value of an uniform to an array of float32 (stored as vec2)
  28516. * @param uniform defines the webGL uniform location where to store the value
  28517. * @param array defines the array of float32 to store
  28518. */
  28519. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28520. /**
  28521. * Set the value of an uniform to an array of float32 (stored as vec3)
  28522. * @param uniform defines the webGL uniform location where to store the value
  28523. * @param array defines the array of float32 to store
  28524. */
  28525. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28526. /**
  28527. * Set the value of an uniform to an array of float32 (stored as vec4)
  28528. * @param uniform defines the webGL uniform location where to store the value
  28529. * @param array defines the array of float32 to store
  28530. */
  28531. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28532. /**
  28533. * Set the value of an uniform to an array of number
  28534. * @param uniform defines the webGL uniform location where to store the value
  28535. * @param array defines the array of number to store
  28536. */
  28537. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28538. /**
  28539. * Set the value of an uniform to an array of number (stored as vec2)
  28540. * @param uniform defines the webGL uniform location where to store the value
  28541. * @param array defines the array of number to store
  28542. */
  28543. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28544. /**
  28545. * Set the value of an uniform to an array of number (stored as vec3)
  28546. * @param uniform defines the webGL uniform location where to store the value
  28547. * @param array defines the array of number to store
  28548. */
  28549. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28550. /**
  28551. * Set the value of an uniform to an array of number (stored as vec4)
  28552. * @param uniform defines the webGL uniform location where to store the value
  28553. * @param array defines the array of number to store
  28554. */
  28555. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28556. /**
  28557. * Set the value of an uniform to an array of float32 (stored as matrices)
  28558. * @param uniform defines the webGL uniform location where to store the value
  28559. * @param matrices defines the array of float32 to store
  28560. */
  28561. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28562. /**
  28563. * Set the value of an uniform to a matrix
  28564. * @param uniform defines the webGL uniform location where to store the value
  28565. * @param matrix defines the matrix to store
  28566. */
  28567. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28568. /**
  28569. * Set the value of an uniform to a matrix (3x3)
  28570. * @param uniform defines the webGL uniform location where to store the value
  28571. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28572. */
  28573. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28574. /**
  28575. * Set the value of an uniform to a matrix (2x2)
  28576. * @param uniform defines the webGL uniform location where to store the value
  28577. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28578. */
  28579. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28580. /**
  28581. * Set the value of an uniform to a number (int)
  28582. * @param uniform defines the webGL uniform location where to store the value
  28583. * @param value defines the int number to store
  28584. */
  28585. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28586. /**
  28587. * Set the value of an uniform to a number (float)
  28588. * @param uniform defines the webGL uniform location where to store the value
  28589. * @param value defines the float number to store
  28590. */
  28591. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28592. /**
  28593. * Set the value of an uniform to a vec2
  28594. * @param uniform defines the webGL uniform location where to store the value
  28595. * @param x defines the 1st component of the value
  28596. * @param y defines the 2nd component of the value
  28597. */
  28598. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28599. /**
  28600. * Set the value of an uniform to a vec3
  28601. * @param uniform defines the webGL uniform location where to store the value
  28602. * @param x defines the 1st component of the value
  28603. * @param y defines the 2nd component of the value
  28604. * @param z defines the 3rd component of the value
  28605. */
  28606. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28607. /**
  28608. * Set the value of an uniform to a boolean
  28609. * @param uniform defines the webGL uniform location where to store the value
  28610. * @param bool defines the boolean to store
  28611. */
  28612. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28613. /**
  28614. * Set the value of an uniform to a vec4
  28615. * @param uniform defines the webGL uniform location where to store the value
  28616. * @param x defines the 1st component of the value
  28617. * @param y defines the 2nd component of the value
  28618. * @param z defines the 3rd component of the value
  28619. * @param w defines the 4th component of the value
  28620. */
  28621. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28622. /**
  28623. * Set the value of an uniform to a Color3
  28624. * @param uniform defines the webGL uniform location where to store the value
  28625. * @param color3 defines the color to store
  28626. */
  28627. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28628. /**
  28629. * Set the value of an uniform to a Color3 and an alpha value
  28630. * @param uniform defines the webGL uniform location where to store the value
  28631. * @param color3 defines the color to store
  28632. * @param alpha defines the alpha component to store
  28633. */
  28634. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28635. /**
  28636. * Sets a Color4 on a uniform variable
  28637. * @param uniform defines the uniform location
  28638. * @param color4 defines the value to be set
  28639. */
  28640. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28641. /**
  28642. * Set various states to the webGL context
  28643. * @param culling defines backface culling state
  28644. * @param zOffset defines the value to apply to zOffset (0 by default)
  28645. * @param force defines if states must be applied even if cache is up to date
  28646. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28647. */
  28648. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28649. /**
  28650. * Set the z offset to apply to current rendering
  28651. * @param value defines the offset to apply
  28652. */
  28653. setZOffset(value: number): void;
  28654. /**
  28655. * Gets the current value of the zOffset
  28656. * @returns the current zOffset state
  28657. */
  28658. getZOffset(): number;
  28659. /**
  28660. * Enable or disable depth buffering
  28661. * @param enable defines the state to set
  28662. */
  28663. setDepthBuffer(enable: boolean): void;
  28664. /**
  28665. * Gets a boolean indicating if depth writing is enabled
  28666. * @returns the current depth writing state
  28667. */
  28668. getDepthWrite(): boolean;
  28669. /**
  28670. * Enable or disable depth writing
  28671. * @param enable defines the state to set
  28672. */
  28673. setDepthWrite(enable: boolean): void;
  28674. /**
  28675. * Enable or disable color writing
  28676. * @param enable defines the state to set
  28677. */
  28678. setColorWrite(enable: boolean): void;
  28679. /**
  28680. * Gets a boolean indicating if color writing is enabled
  28681. * @returns the current color writing state
  28682. */
  28683. getColorWrite(): boolean;
  28684. /**
  28685. * Sets alpha constants used by some alpha blending modes
  28686. * @param r defines the red component
  28687. * @param g defines the green component
  28688. * @param b defines the blue component
  28689. * @param a defines the alpha component
  28690. */
  28691. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28692. /**
  28693. * Sets the current alpha mode
  28694. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28695. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28696. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28697. */
  28698. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28699. /**
  28700. * Gets the current alpha mode
  28701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28702. * @returns the current alpha mode
  28703. */
  28704. getAlphaMode(): number;
  28705. /**
  28706. * Clears the list of texture accessible through engine.
  28707. * This can help preventing texture load conflict due to name collision.
  28708. */
  28709. clearInternalTexturesCache(): void;
  28710. /**
  28711. * Force the entire cache to be cleared
  28712. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28713. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28714. */
  28715. wipeCaches(bruteForce?: boolean): void;
  28716. /**
  28717. * Set the compressed texture format to use, based on the formats you have, and the formats
  28718. * supported by the hardware / browser.
  28719. *
  28720. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28721. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28722. * to API arguments needed to compressed textures. This puts the burden on the container
  28723. * generator to house the arcane code for determining these for current & future formats.
  28724. *
  28725. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28726. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28727. *
  28728. * Note: The result of this call is not taken into account when a texture is base64.
  28729. *
  28730. * @param formatsAvailable defines the list of those format families you have created
  28731. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28732. *
  28733. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28734. * @returns The extension selected.
  28735. */
  28736. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28737. private _getSamplingParameters;
  28738. private _partialLoadImg;
  28739. private _cascadeLoadImgs;
  28740. /** @hidden */
  28741. _createTexture(): WebGLTexture;
  28742. /**
  28743. * Usually called from Texture.ts.
  28744. * Passed information to create a WebGLTexture
  28745. * @param urlArg defines a value which contains one of the following:
  28746. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28747. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28748. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28750. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  28751. * @param scene needed for loading to the correct scene
  28752. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28753. * @param onLoad optional callback to be called upon successful completion
  28754. * @param onError optional callback to be called upon failure
  28755. * @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
  28756. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28757. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28758. * @param forcedExtension defines the extension to use to pick the right loader
  28759. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28760. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28761. */
  28762. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28763. private _rescaleTexture;
  28764. /**
  28765. * Update a raw texture
  28766. * @param texture defines the texture to update
  28767. * @param data defines the data to store in the texture
  28768. * @param format defines the format of the data
  28769. * @param invertY defines if data must be stored with Y axis inverted
  28770. * @param compression defines the compression used (null by default)
  28771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28772. */
  28773. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28774. /**
  28775. * Creates a raw texture
  28776. * @param data defines the data to store in the texture
  28777. * @param width defines the width of the texture
  28778. * @param height defines the height of the texture
  28779. * @param format defines the format of the data
  28780. * @param generateMipMaps defines if the engine should generate the mip levels
  28781. * @param invertY defines if data must be stored with Y axis inverted
  28782. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28783. * @param compression defines the compression used (null by default)
  28784. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28785. * @returns the raw texture inside an InternalTexture
  28786. */
  28787. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28788. private _unpackFlipYCached;
  28789. /**
  28790. * In case you are sharing the context with other applications, it might
  28791. * be interested to not cache the unpack flip y state to ensure a consistent
  28792. * value would be set.
  28793. */
  28794. enableUnpackFlipYCached: boolean;
  28795. /** @hidden */
  28796. _unpackFlipY(value: boolean): void;
  28797. /** @hidden */
  28798. _getUnpackAlignement(): number;
  28799. /**
  28800. * Creates a dynamic texture
  28801. * @param width defines the width of the texture
  28802. * @param height defines the height of the texture
  28803. * @param generateMipMaps defines if the engine should generate the mip levels
  28804. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28805. * @returns the dynamic texture inside an InternalTexture
  28806. */
  28807. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28808. /**
  28809. * Update the sampling mode of a given texture
  28810. * @param samplingMode defines the required sampling mode
  28811. * @param texture defines the texture to update
  28812. */
  28813. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28814. /**
  28815. * Update the content of a dynamic texture
  28816. * @param texture defines the texture to update
  28817. * @param canvas defines the canvas containing the source
  28818. * @param invertY defines if data must be stored with Y axis inverted
  28819. * @param premulAlpha defines if alpha is stored as premultiplied
  28820. * @param format defines the format of the data
  28821. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28822. */
  28823. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28824. /**
  28825. * Update a video texture
  28826. * @param texture defines the texture to update
  28827. * @param video defines the video element to use
  28828. * @param invertY defines if data must be stored with Y axis inverted
  28829. */
  28830. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28831. /**
  28832. * Updates a depth texture Comparison Mode and Function.
  28833. * If the comparison Function is equal to 0, the mode will be set to none.
  28834. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28835. * @param texture The texture to set the comparison function for
  28836. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28837. */
  28838. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28839. private _setupDepthStencilTexture;
  28840. /**
  28841. * Creates a depth stencil texture.
  28842. * This is only available in WebGL 2 or with the depth texture extension available.
  28843. * @param size The size of face edge in the texture.
  28844. * @param options The options defining the texture.
  28845. * @returns The texture
  28846. */
  28847. createDepthStencilTexture(size: number | {
  28848. width: number;
  28849. height: number;
  28850. }, options: DepthTextureCreationOptions): InternalTexture;
  28851. /**
  28852. * Creates a depth stencil texture.
  28853. * This is only available in WebGL 2 or with the depth texture extension available.
  28854. * @param size The size of face edge in the texture.
  28855. * @param options The options defining the texture.
  28856. * @returns The texture
  28857. */
  28858. private _createDepthStencilTexture;
  28859. /**
  28860. * Creates a depth stencil cube texture.
  28861. * This is only available in WebGL 2.
  28862. * @param size The size of face edge in the cube texture.
  28863. * @param options The options defining the cube texture.
  28864. * @returns The cube texture
  28865. */
  28866. private _createDepthStencilCubeTexture;
  28867. /**
  28868. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28869. * @param renderTarget The render target to set the frame buffer for
  28870. */
  28871. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28872. /**
  28873. * Creates a new render target texture
  28874. * @param size defines the size of the texture
  28875. * @param options defines the options used to create the texture
  28876. * @returns a new render target texture stored in an InternalTexture
  28877. */
  28878. createRenderTargetTexture(size: number | {
  28879. width: number;
  28880. height: number;
  28881. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28882. /**
  28883. * Create a multi render target texture
  28884. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28885. * @param size defines the size of the texture
  28886. * @param options defines the creation options
  28887. * @returns the cube texture as an InternalTexture
  28888. */
  28889. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28890. private _setupFramebufferDepthAttachments;
  28891. /**
  28892. * Updates the sample count of a render target texture
  28893. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28894. * @param texture defines the texture to update
  28895. * @param samples defines the sample count to set
  28896. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28897. */
  28898. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28899. /**
  28900. * Update the sample count for a given multiple render target texture
  28901. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28902. * @param textures defines the textures to update
  28903. * @param samples defines the sample count to set
  28904. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28905. */
  28906. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28907. /** @hidden */
  28908. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28909. /** @hidden */
  28910. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28911. /** @hidden */
  28912. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28913. /** @hidden */
  28914. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28915. /**
  28916. * Creates a new render target cube texture
  28917. * @param size defines the size of the texture
  28918. * @param options defines the options used to create the texture
  28919. * @returns a new render target cube texture stored in an InternalTexture
  28920. */
  28921. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28922. /**
  28923. * Creates a cube texture
  28924. * @param rootUrl defines the url where the files to load is located
  28925. * @param scene defines the current scene
  28926. * @param files defines the list of files to load (1 per face)
  28927. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28928. * @param onLoad defines an optional callback raised when the texture is loaded
  28929. * @param onError defines an optional callback raised if there is an issue to load the texture
  28930. * @param format defines the format of the data
  28931. * @param forcedExtension defines the extension to use to pick the right loader
  28932. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28933. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28934. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28935. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28936. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28937. * @returns the cube texture as an InternalTexture
  28938. */
  28939. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28940. /**
  28941. * @hidden
  28942. */
  28943. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28944. /**
  28945. * Update a raw cube texture
  28946. * @param texture defines the texture to udpdate
  28947. * @param data defines the data to store
  28948. * @param format defines the data format
  28949. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28950. * @param invertY defines if data must be stored with Y axis inverted
  28951. * @param compression defines the compression used (null by default)
  28952. * @param level defines which level of the texture to update
  28953. */
  28954. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28955. /**
  28956. * Creates a new raw cube texture
  28957. * @param data defines the array of data to use to create each face
  28958. * @param size defines the size of the textures
  28959. * @param format defines the format of the data
  28960. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28961. * @param generateMipMaps defines if the engine should generate the mip levels
  28962. * @param invertY defines if data must be stored with Y axis inverted
  28963. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28964. * @param compression defines the compression used (null by default)
  28965. * @returns the cube texture as an InternalTexture
  28966. */
  28967. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28968. /**
  28969. * Creates a new raw cube texture from a specified url
  28970. * @param url defines the url where the data is located
  28971. * @param scene defines the current scene
  28972. * @param size defines the size of the textures
  28973. * @param format defines the format of the data
  28974. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28975. * @param noMipmap defines if the engine should avoid generating the mip levels
  28976. * @param callback defines a callback used to extract texture data from loaded data
  28977. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28978. * @param onLoad defines a callback called when texture is loaded
  28979. * @param onError defines a callback called if there is an error
  28980. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28981. * @param invertY defines if data must be stored with Y axis inverted
  28982. * @returns the cube texture as an InternalTexture
  28983. */
  28984. 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;
  28985. /**
  28986. * Update a raw 3D texture
  28987. * @param texture defines the texture to update
  28988. * @param data defines the data to store
  28989. * @param format defines the data format
  28990. * @param invertY defines if data must be stored with Y axis inverted
  28991. * @param compression defines the used compression (can be null)
  28992. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28993. */
  28994. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28995. /**
  28996. * Creates a new raw 3D texture
  28997. * @param data defines the data used to create the texture
  28998. * @param width defines the width of the texture
  28999. * @param height defines the height of the texture
  29000. * @param depth defines the depth of the texture
  29001. * @param format defines the format of the texture
  29002. * @param generateMipMaps defines if the engine must generate mip levels
  29003. * @param invertY defines if data must be stored with Y axis inverted
  29004. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29005. * @param compression defines the compressed used (can be null)
  29006. * @param textureType defines the compressed used (can be null)
  29007. * @returns a new raw 3D texture (stored in an InternalTexture)
  29008. */
  29009. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29010. private _prepareWebGLTextureContinuation;
  29011. private _prepareWebGLTexture;
  29012. private _convertRGBtoRGBATextureData;
  29013. /** @hidden */
  29014. _releaseFramebufferObjects(texture: InternalTexture): void;
  29015. /** @hidden */
  29016. _releaseTexture(texture: InternalTexture): void;
  29017. private setProgram;
  29018. private _boundUniforms;
  29019. /**
  29020. * Binds an effect to the webGL context
  29021. * @param effect defines the effect to bind
  29022. */
  29023. bindSamplers(effect: Effect): void;
  29024. private _moveBoundTextureOnTop;
  29025. private _getCorrectTextureChannel;
  29026. private _linkTrackers;
  29027. private _removeDesignatedSlot;
  29028. private _activateCurrentTexture;
  29029. /** @hidden */
  29030. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29031. /** @hidden */
  29032. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29033. /**
  29034. * Sets a texture to the webGL context from a postprocess
  29035. * @param channel defines the channel to use
  29036. * @param postProcess defines the source postprocess
  29037. */
  29038. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29039. /**
  29040. * Binds the output of the passed in post process to the texture channel specified
  29041. * @param channel The channel the texture should be bound to
  29042. * @param postProcess The post process which's output should be bound
  29043. */
  29044. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29045. /**
  29046. * Unbind all textures from the webGL context
  29047. */
  29048. unbindAllTextures(): void;
  29049. /**
  29050. * Sets a texture to the according uniform.
  29051. * @param channel The texture channel
  29052. * @param uniform The uniform to set
  29053. * @param texture The texture to apply
  29054. */
  29055. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29056. /**
  29057. * Sets a depth stencil texture from a render target to the according uniform.
  29058. * @param channel The texture channel
  29059. * @param uniform The uniform to set
  29060. * @param texture The render target texture containing the depth stencil texture to apply
  29061. */
  29062. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29063. private _bindSamplerUniformToChannel;
  29064. private _getTextureWrapMode;
  29065. private _setTexture;
  29066. /**
  29067. * Sets an array of texture to the webGL context
  29068. * @param channel defines the channel where the texture array must be set
  29069. * @param uniform defines the associated uniform location
  29070. * @param textures defines the array of textures to bind
  29071. */
  29072. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29073. /** @hidden */
  29074. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29075. private _setTextureParameterFloat;
  29076. private _setTextureParameterInteger;
  29077. /**
  29078. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29079. * @param x defines the x coordinate of the rectangle where pixels must be read
  29080. * @param y defines the y coordinate of the rectangle where pixels must be read
  29081. * @param width defines the width of the rectangle where pixels must be read
  29082. * @param height defines the height of the rectangle where pixels must be read
  29083. * @returns a Uint8Array containing RGBA colors
  29084. */
  29085. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29086. /**
  29087. * Add an externaly attached data from its key.
  29088. * This method call will fail and return false, if such key already exists.
  29089. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29090. * @param key the unique key that identifies the data
  29091. * @param data the data object to associate to the key for this Engine instance
  29092. * @return true if no such key were already present and the data was added successfully, false otherwise
  29093. */
  29094. addExternalData<T>(key: string, data: T): boolean;
  29095. /**
  29096. * Get an externaly attached data from its key
  29097. * @param key the unique key that identifies the data
  29098. * @return the associated data, if present (can be null), or undefined if not present
  29099. */
  29100. getExternalData<T>(key: string): T;
  29101. /**
  29102. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29103. * @param key the unique key that identifies the data
  29104. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29105. * @return the associated data, can be null if the factory returned null.
  29106. */
  29107. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29108. /**
  29109. * Remove an externaly attached data from the Engine instance
  29110. * @param key the unique key that identifies the data
  29111. * @return true if the data was successfully removed, false if it doesn't exist
  29112. */
  29113. removeExternalData(key: string): boolean;
  29114. /**
  29115. * Unbind all vertex attributes from the webGL context
  29116. */
  29117. unbindAllAttributes(): void;
  29118. /**
  29119. * 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
  29120. */
  29121. releaseEffects(): void;
  29122. /**
  29123. * Dispose and release all associated resources
  29124. */
  29125. dispose(): void;
  29126. /**
  29127. * Display the loading screen
  29128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29129. */
  29130. displayLoadingUI(): void;
  29131. /**
  29132. * Hide the loading screen
  29133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29134. */
  29135. hideLoadingUI(): void;
  29136. /**
  29137. * Gets the current loading screen object
  29138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29139. */
  29140. /**
  29141. * Sets the current loading screen object
  29142. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29143. */
  29144. loadingScreen: ILoadingScreen;
  29145. /**
  29146. * Sets the current loading screen text
  29147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29148. */
  29149. loadingUIText: string;
  29150. /**
  29151. * Sets the current loading screen background color
  29152. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29153. */
  29154. loadingUIBackgroundColor: string;
  29155. /**
  29156. * Attach a new callback raised when context lost event is fired
  29157. * @param callback defines the callback to call
  29158. */
  29159. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29160. /**
  29161. * Attach a new callback raised when context restored event is fired
  29162. * @param callback defines the callback to call
  29163. */
  29164. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29165. /**
  29166. * Gets the source code of the vertex shader associated with a specific webGL program
  29167. * @param program defines the program to use
  29168. * @returns a string containing the source code of the vertex shader associated with the program
  29169. */
  29170. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29171. /**
  29172. * Gets the source code of the fragment shader associated with a specific webGL program
  29173. * @param program defines the program to use
  29174. * @returns a string containing the source code of the fragment shader associated with the program
  29175. */
  29176. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29177. /**
  29178. * Get the current error code of the webGL context
  29179. * @returns the error code
  29180. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29181. */
  29182. getError(): number;
  29183. /**
  29184. * Gets the current framerate
  29185. * @returns a number representing the framerate
  29186. */
  29187. getFps(): number;
  29188. /**
  29189. * Gets the time spent between current and previous frame
  29190. * @returns a number representing the delta time in ms
  29191. */
  29192. getDeltaTime(): number;
  29193. private _measureFps;
  29194. /** @hidden */
  29195. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29196. private _canRenderToFloatFramebuffer;
  29197. private _canRenderToHalfFloatFramebuffer;
  29198. private _canRenderToFramebuffer;
  29199. /** @hidden */
  29200. _getWebGLTextureType(type: number): number;
  29201. private _getInternalFormat;
  29202. /** @hidden */
  29203. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29204. /** @hidden */
  29205. _getRGBAMultiSampleBufferFormat(type: number): number;
  29206. /** @hidden */
  29207. _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;
  29208. /** @hidden */
  29209. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29210. private _partialLoadFile;
  29211. private _cascadeLoadFiles;
  29212. /**
  29213. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29214. * @returns true if the engine can be created
  29215. * @ignorenaming
  29216. */
  29217. static isSupported(): boolean;
  29218. }
  29219. }
  29220. declare module BABYLON {
  29221. /**
  29222. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29223. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29224. */
  29225. export class EffectFallbacks {
  29226. private _defines;
  29227. private _currentRank;
  29228. private _maxRank;
  29229. private _mesh;
  29230. /**
  29231. * Removes the fallback from the bound mesh.
  29232. */
  29233. unBindMesh(): void;
  29234. /**
  29235. * Adds a fallback on the specified property.
  29236. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29237. * @param define The name of the define in the shader
  29238. */
  29239. addFallback(rank: number, define: string): void;
  29240. /**
  29241. * Sets the mesh to use CPU skinning when needing to fallback.
  29242. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29243. * @param mesh The mesh to use the fallbacks.
  29244. */
  29245. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29246. /**
  29247. * Checks to see if more fallbacks are still availible.
  29248. */
  29249. readonly isMoreFallbacks: boolean;
  29250. /**
  29251. * Removes the defines that shoould be removed when falling back.
  29252. * @param currentDefines defines the current define statements for the shader.
  29253. * @param effect defines the current effect we try to compile
  29254. * @returns The resulting defines with defines of the current rank removed.
  29255. */
  29256. reduce(currentDefines: string, effect: Effect): string;
  29257. }
  29258. /**
  29259. * Options to be used when creating an effect.
  29260. */
  29261. export class EffectCreationOptions {
  29262. /**
  29263. * Atrributes that will be used in the shader.
  29264. */
  29265. attributes: string[];
  29266. /**
  29267. * Uniform varible names that will be set in the shader.
  29268. */
  29269. uniformsNames: string[];
  29270. /**
  29271. * Uniform buffer varible names that will be set in the shader.
  29272. */
  29273. uniformBuffersNames: string[];
  29274. /**
  29275. * Sampler texture variable names that will be set in the shader.
  29276. */
  29277. samplers: string[];
  29278. /**
  29279. * Define statements that will be set in the shader.
  29280. */
  29281. defines: any;
  29282. /**
  29283. * Possible fallbacks for this effect to improve performance when needed.
  29284. */
  29285. fallbacks: Nullable<EffectFallbacks>;
  29286. /**
  29287. * Callback that will be called when the shader is compiled.
  29288. */
  29289. onCompiled: Nullable<(effect: Effect) => void>;
  29290. /**
  29291. * Callback that will be called if an error occurs during shader compilation.
  29292. */
  29293. onError: Nullable<(effect: Effect, errors: string) => void>;
  29294. /**
  29295. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29296. */
  29297. indexParameters: any;
  29298. /**
  29299. * Max number of lights that can be used in the shader.
  29300. */
  29301. maxSimultaneousLights: number;
  29302. /**
  29303. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29304. */
  29305. transformFeedbackVaryings: Nullable<string[]>;
  29306. }
  29307. /**
  29308. * Effect containing vertex and fragment shader that can be executed on an object.
  29309. */
  29310. export class Effect {
  29311. /**
  29312. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29313. */
  29314. static ShadersRepository: string;
  29315. /**
  29316. * Name of the effect.
  29317. */
  29318. name: any;
  29319. /**
  29320. * String container all the define statements that should be set on the shader.
  29321. */
  29322. defines: string;
  29323. /**
  29324. * Callback that will be called when the shader is compiled.
  29325. */
  29326. onCompiled: Nullable<(effect: Effect) => void>;
  29327. /**
  29328. * Callback that will be called if an error occurs during shader compilation.
  29329. */
  29330. onError: Nullable<(effect: Effect, errors: string) => void>;
  29331. /**
  29332. * Callback that will be called when effect is bound.
  29333. */
  29334. onBind: Nullable<(effect: Effect) => void>;
  29335. /**
  29336. * Unique ID of the effect.
  29337. */
  29338. uniqueId: number;
  29339. /**
  29340. * Observable that will be called when the shader is compiled.
  29341. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29342. */
  29343. onCompileObservable: Observable<Effect>;
  29344. /**
  29345. * Observable that will be called if an error occurs during shader compilation.
  29346. */
  29347. onErrorObservable: Observable<Effect>;
  29348. /** @hidden */
  29349. _onBindObservable: Nullable<Observable<Effect>>;
  29350. /**
  29351. * Observable that will be called when effect is bound.
  29352. */
  29353. readonly onBindObservable: Observable<Effect>;
  29354. /** @hidden */
  29355. _bonesComputationForcedToCPU: boolean;
  29356. private static _uniqueIdSeed;
  29357. private _engine;
  29358. private _uniformBuffersNames;
  29359. private _uniformsNames;
  29360. private _samplers;
  29361. private _isReady;
  29362. private _compilationError;
  29363. private _attributesNames;
  29364. private _attributes;
  29365. private _uniforms;
  29366. /**
  29367. * Key for the effect.
  29368. * @hidden
  29369. */
  29370. _key: string;
  29371. private _indexParameters;
  29372. private _fallbacks;
  29373. private _vertexSourceCode;
  29374. private _fragmentSourceCode;
  29375. private _vertexSourceCodeOverride;
  29376. private _fragmentSourceCodeOverride;
  29377. private _transformFeedbackVaryings;
  29378. /**
  29379. * Compiled shader to webGL program.
  29380. * @hidden
  29381. */
  29382. _program: WebGLProgram;
  29383. private _valueCache;
  29384. private static _baseCache;
  29385. /**
  29386. * Instantiates an effect.
  29387. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29388. * @param baseName Name of the effect.
  29389. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29390. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29391. * @param samplers List of sampler variables that will be passed to the shader.
  29392. * @param engine Engine to be used to render the effect
  29393. * @param defines Define statements to be added to the shader.
  29394. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29395. * @param onCompiled Callback that will be called when the shader is compiled.
  29396. * @param onError Callback that will be called if an error occurs during shader compilation.
  29397. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29398. */
  29399. 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);
  29400. /**
  29401. * Unique key for this effect
  29402. */
  29403. readonly key: string;
  29404. /**
  29405. * If the effect has been compiled and prepared.
  29406. * @returns if the effect is compiled and prepared.
  29407. */
  29408. isReady(): boolean;
  29409. /**
  29410. * The engine the effect was initialized with.
  29411. * @returns the engine.
  29412. */
  29413. getEngine(): Engine;
  29414. /**
  29415. * The compiled webGL program for the effect
  29416. * @returns the webGL program.
  29417. */
  29418. getProgram(): WebGLProgram;
  29419. /**
  29420. * The set of names of attribute variables for the shader.
  29421. * @returns An array of attribute names.
  29422. */
  29423. getAttributesNames(): string[];
  29424. /**
  29425. * Returns the attribute at the given index.
  29426. * @param index The index of the attribute.
  29427. * @returns The location of the attribute.
  29428. */
  29429. getAttributeLocation(index: number): number;
  29430. /**
  29431. * Returns the attribute based on the name of the variable.
  29432. * @param name of the attribute to look up.
  29433. * @returns the attribute location.
  29434. */
  29435. getAttributeLocationByName(name: string): number;
  29436. /**
  29437. * The number of attributes.
  29438. * @returns the numnber of attributes.
  29439. */
  29440. getAttributesCount(): number;
  29441. /**
  29442. * Gets the index of a uniform variable.
  29443. * @param uniformName of the uniform to look up.
  29444. * @returns the index.
  29445. */
  29446. getUniformIndex(uniformName: string): number;
  29447. /**
  29448. * Returns the attribute based on the name of the variable.
  29449. * @param uniformName of the uniform to look up.
  29450. * @returns the location of the uniform.
  29451. */
  29452. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29453. /**
  29454. * Returns an array of sampler variable names
  29455. * @returns The array of sampler variable neames.
  29456. */
  29457. getSamplers(): string[];
  29458. /**
  29459. * The error from the last compilation.
  29460. * @returns the error string.
  29461. */
  29462. getCompilationError(): string;
  29463. /**
  29464. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29465. * @param func The callback to be used.
  29466. */
  29467. executeWhenCompiled(func: (effect: Effect) => void): void;
  29468. private _checkIsReady;
  29469. /** @hidden */
  29470. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29471. /** @hidden */
  29472. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29473. /** @hidden */
  29474. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29475. private _processShaderConversion;
  29476. private _processIncludes;
  29477. private _processPrecision;
  29478. /**
  29479. * Recompiles the webGL program
  29480. * @param vertexSourceCode The source code for the vertex shader.
  29481. * @param fragmentSourceCode The source code for the fragment shader.
  29482. * @param onCompiled Callback called when completed.
  29483. * @param onError Callback called on error.
  29484. * @hidden
  29485. */
  29486. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29487. /**
  29488. * Gets the uniform locations of the the specified variable names
  29489. * @param names THe names of the variables to lookup.
  29490. * @returns Array of locations in the same order as variable names.
  29491. */
  29492. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29493. /**
  29494. * Prepares the effect
  29495. * @hidden
  29496. */
  29497. _prepareEffect(): void;
  29498. /**
  29499. * Checks if the effect is supported. (Must be called after compilation)
  29500. */
  29501. readonly isSupported: boolean;
  29502. /**
  29503. * Binds a texture to the engine to be used as output of the shader.
  29504. * @param channel Name of the output variable.
  29505. * @param texture Texture to bind.
  29506. * @hidden
  29507. */
  29508. _bindTexture(channel: string, texture: InternalTexture): void;
  29509. /**
  29510. * Sets a texture on the engine to be used in the shader.
  29511. * @param channel Name of the sampler variable.
  29512. * @param texture Texture to set.
  29513. */
  29514. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29515. /**
  29516. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29517. * @param channel Name of the sampler variable.
  29518. * @param texture Texture to set.
  29519. */
  29520. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29521. /**
  29522. * Sets an array of textures on the engine to be used in the shader.
  29523. * @param channel Name of the variable.
  29524. * @param textures Textures to set.
  29525. */
  29526. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29527. /**
  29528. * 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)
  29529. * @param channel Name of the sampler variable.
  29530. * @param postProcess Post process to get the input texture from.
  29531. */
  29532. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29533. /**
  29534. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29535. * 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)
  29536. * @param channel Name of the sampler variable.
  29537. * @param postProcess Post process to get the output texture from.
  29538. */
  29539. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29540. /** @hidden */
  29541. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29542. /** @hidden */
  29543. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29544. /** @hidden */
  29545. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29546. /** @hidden */
  29547. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29548. /**
  29549. * Binds a buffer to a uniform.
  29550. * @param buffer Buffer to bind.
  29551. * @param name Name of the uniform variable to bind to.
  29552. */
  29553. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29554. /**
  29555. * Binds block to a uniform.
  29556. * @param blockName Name of the block to bind.
  29557. * @param index Index to bind.
  29558. */
  29559. bindUniformBlock(blockName: string, index: number): void;
  29560. /**
  29561. * Sets an interger value on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param value Value to be set.
  29564. * @returns this effect.
  29565. */
  29566. setInt(uniformName: string, value: number): Effect;
  29567. /**
  29568. * Sets an int array on a uniform variable.
  29569. * @param uniformName Name of the variable.
  29570. * @param array array to be set.
  29571. * @returns this effect.
  29572. */
  29573. setIntArray(uniformName: string, array: Int32Array): Effect;
  29574. /**
  29575. * 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)
  29576. * @param uniformName Name of the variable.
  29577. * @param array array to be set.
  29578. * @returns this effect.
  29579. */
  29580. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29581. /**
  29582. * 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)
  29583. * @param uniformName Name of the variable.
  29584. * @param array array to be set.
  29585. * @returns this effect.
  29586. */
  29587. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29588. /**
  29589. * 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)
  29590. * @param uniformName Name of the variable.
  29591. * @param array array to be set.
  29592. * @returns this effect.
  29593. */
  29594. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29595. /**
  29596. * Sets an float array on a uniform variable.
  29597. * @param uniformName Name of the variable.
  29598. * @param array array to be set.
  29599. * @returns this effect.
  29600. */
  29601. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29602. /**
  29603. * 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)
  29604. * @param uniformName Name of the variable.
  29605. * @param array array to be set.
  29606. * @returns this effect.
  29607. */
  29608. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29609. /**
  29610. * 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)
  29611. * @param uniformName Name of the variable.
  29612. * @param array array to be set.
  29613. * @returns this effect.
  29614. */
  29615. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29616. /**
  29617. * 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)
  29618. * @param uniformName Name of the variable.
  29619. * @param array array to be set.
  29620. * @returns this effect.
  29621. */
  29622. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29623. /**
  29624. * Sets an array on a uniform variable.
  29625. * @param uniformName Name of the variable.
  29626. * @param array array to be set.
  29627. * @returns this effect.
  29628. */
  29629. setArray(uniformName: string, array: number[]): Effect;
  29630. /**
  29631. * 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)
  29632. * @param uniformName Name of the variable.
  29633. * @param array array to be set.
  29634. * @returns this effect.
  29635. */
  29636. setArray2(uniformName: string, array: number[]): Effect;
  29637. /**
  29638. * 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)
  29639. * @param uniformName Name of the variable.
  29640. * @param array array to be set.
  29641. * @returns this effect.
  29642. */
  29643. setArray3(uniformName: string, array: number[]): Effect;
  29644. /**
  29645. * 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)
  29646. * @param uniformName Name of the variable.
  29647. * @param array array to be set.
  29648. * @returns this effect.
  29649. */
  29650. setArray4(uniformName: string, array: number[]): Effect;
  29651. /**
  29652. * Sets matrices on a uniform variable.
  29653. * @param uniformName Name of the variable.
  29654. * @param matrices matrices to be set.
  29655. * @returns this effect.
  29656. */
  29657. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29658. /**
  29659. * Sets matrix on a uniform variable.
  29660. * @param uniformName Name of the variable.
  29661. * @param matrix matrix to be set.
  29662. * @returns this effect.
  29663. */
  29664. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29665. /**
  29666. * 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)
  29667. * @param uniformName Name of the variable.
  29668. * @param matrix matrix to be set.
  29669. * @returns this effect.
  29670. */
  29671. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29672. /**
  29673. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29674. * @param uniformName Name of the variable.
  29675. * @param matrix matrix to be set.
  29676. * @returns this effect.
  29677. */
  29678. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29679. /**
  29680. * Sets a float on a uniform variable.
  29681. * @param uniformName Name of the variable.
  29682. * @param value value to be set.
  29683. * @returns this effect.
  29684. */
  29685. setFloat(uniformName: string, value: number): Effect;
  29686. /**
  29687. * Sets a boolean on a uniform variable.
  29688. * @param uniformName Name of the variable.
  29689. * @param bool value to be set.
  29690. * @returns this effect.
  29691. */
  29692. setBool(uniformName: string, bool: boolean): Effect;
  29693. /**
  29694. * Sets a Vector2 on a uniform variable.
  29695. * @param uniformName Name of the variable.
  29696. * @param vector2 vector2 to be set.
  29697. * @returns this effect.
  29698. */
  29699. setVector2(uniformName: string, vector2: Vector2): Effect;
  29700. /**
  29701. * Sets a float2 on a uniform variable.
  29702. * @param uniformName Name of the variable.
  29703. * @param x First float in float2.
  29704. * @param y Second float in float2.
  29705. * @returns this effect.
  29706. */
  29707. setFloat2(uniformName: string, x: number, y: number): Effect;
  29708. /**
  29709. * Sets a Vector3 on a uniform variable.
  29710. * @param uniformName Name of the variable.
  29711. * @param vector3 Value to be set.
  29712. * @returns this effect.
  29713. */
  29714. setVector3(uniformName: string, vector3: Vector3): Effect;
  29715. /**
  29716. * Sets a float3 on a uniform variable.
  29717. * @param uniformName Name of the variable.
  29718. * @param x First float in float3.
  29719. * @param y Second float in float3.
  29720. * @param z Third float in float3.
  29721. * @returns this effect.
  29722. */
  29723. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29724. /**
  29725. * Sets a Vector4 on a uniform variable.
  29726. * @param uniformName Name of the variable.
  29727. * @param vector4 Value to be set.
  29728. * @returns this effect.
  29729. */
  29730. setVector4(uniformName: string, vector4: Vector4): Effect;
  29731. /**
  29732. * Sets a float4 on a uniform variable.
  29733. * @param uniformName Name of the variable.
  29734. * @param x First float in float4.
  29735. * @param y Second float in float4.
  29736. * @param z Third float in float4.
  29737. * @param w Fourth float in float4.
  29738. * @returns this effect.
  29739. */
  29740. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29741. /**
  29742. * Sets a Color3 on a uniform variable.
  29743. * @param uniformName Name of the variable.
  29744. * @param color3 Value to be set.
  29745. * @returns this effect.
  29746. */
  29747. setColor3(uniformName: string, color3: Color3): Effect;
  29748. /**
  29749. * Sets a Color4 on a uniform variable.
  29750. * @param uniformName Name of the variable.
  29751. * @param color3 Value to be set.
  29752. * @param alpha Alpha value to be set.
  29753. * @returns this effect.
  29754. */
  29755. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29756. /**
  29757. * Sets a Color4 on a uniform variable
  29758. * @param uniformName defines the name of the variable
  29759. * @param color4 defines the value to be set
  29760. * @returns this effect.
  29761. */
  29762. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29763. /**
  29764. * This function will add a new shader to the shader store
  29765. * @param name the name of the shader
  29766. * @param pixelShader optional pixel shader content
  29767. * @param vertexShader optional vertex shader content
  29768. */
  29769. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29770. /**
  29771. * Store of each shader (The can be looked up using effect.key)
  29772. */
  29773. static ShadersStore: {
  29774. [key: string]: string;
  29775. };
  29776. /**
  29777. * Store of each included file for a shader (The can be looked up using effect.key)
  29778. */
  29779. static IncludesShadersStore: {
  29780. [key: string]: string;
  29781. };
  29782. /**
  29783. * Resets the cache of effects.
  29784. */
  29785. static ResetCache(): void;
  29786. }
  29787. }
  29788. declare module BABYLON {
  29789. /**
  29790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29792. * 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;
  29793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29794. */
  29795. export class ColorCurves {
  29796. private _dirty;
  29797. private _tempColor;
  29798. private _globalCurve;
  29799. private _highlightsCurve;
  29800. private _midtonesCurve;
  29801. private _shadowsCurve;
  29802. private _positiveCurve;
  29803. private _negativeCurve;
  29804. private _globalHue;
  29805. private _globalDensity;
  29806. private _globalSaturation;
  29807. private _globalExposure;
  29808. /**
  29809. * Gets the global Hue value.
  29810. * 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).
  29811. */
  29812. /**
  29813. * Sets the global Hue value.
  29814. * 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).
  29815. */
  29816. globalHue: number;
  29817. /**
  29818. * Gets the global Density value.
  29819. * 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.
  29820. * Values less than zero provide a filter of opposite hue.
  29821. */
  29822. /**
  29823. * Sets the global Density value.
  29824. * 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.
  29825. * Values less than zero provide a filter of opposite hue.
  29826. */
  29827. globalDensity: number;
  29828. /**
  29829. * Gets the global Saturation value.
  29830. * 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.
  29831. */
  29832. /**
  29833. * Sets the global Saturation value.
  29834. * 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.
  29835. */
  29836. globalSaturation: number;
  29837. /**
  29838. * Gets the global Exposure value.
  29839. * 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.
  29840. */
  29841. /**
  29842. * Sets the global Exposure value.
  29843. * 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.
  29844. */
  29845. globalExposure: number;
  29846. private _highlightsHue;
  29847. private _highlightsDensity;
  29848. private _highlightsSaturation;
  29849. private _highlightsExposure;
  29850. /**
  29851. * Gets the highlights Hue value.
  29852. * 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).
  29853. */
  29854. /**
  29855. * Sets the highlights Hue value.
  29856. * 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).
  29857. */
  29858. highlightsHue: number;
  29859. /**
  29860. * Gets the highlights Density value.
  29861. * 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.
  29862. * Values less than zero provide a filter of opposite hue.
  29863. */
  29864. /**
  29865. * Sets the highlights Density value.
  29866. * 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.
  29867. * Values less than zero provide a filter of opposite hue.
  29868. */
  29869. highlightsDensity: number;
  29870. /**
  29871. * Gets the highlights Saturation value.
  29872. * 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.
  29873. */
  29874. /**
  29875. * Sets the highlights Saturation value.
  29876. * 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.
  29877. */
  29878. highlightsSaturation: number;
  29879. /**
  29880. * Gets the highlights Exposure value.
  29881. * 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.
  29882. */
  29883. /**
  29884. * Sets the highlights Exposure value.
  29885. * 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.
  29886. */
  29887. highlightsExposure: number;
  29888. private _midtonesHue;
  29889. private _midtonesDensity;
  29890. private _midtonesSaturation;
  29891. private _midtonesExposure;
  29892. /**
  29893. * Gets the midtones Hue value.
  29894. * 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).
  29895. */
  29896. /**
  29897. * Sets the midtones Hue value.
  29898. * 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).
  29899. */
  29900. midtonesHue: number;
  29901. /**
  29902. * Gets the midtones Density value.
  29903. * 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.
  29904. * Values less than zero provide a filter of opposite hue.
  29905. */
  29906. /**
  29907. * Sets the midtones Density value.
  29908. * 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.
  29909. * Values less than zero provide a filter of opposite hue.
  29910. */
  29911. midtonesDensity: number;
  29912. /**
  29913. * Gets the midtones Saturation value.
  29914. * 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.
  29915. */
  29916. /**
  29917. * Sets the midtones Saturation value.
  29918. * 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.
  29919. */
  29920. midtonesSaturation: number;
  29921. /**
  29922. * Gets the midtones Exposure value.
  29923. * 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.
  29924. */
  29925. /**
  29926. * Sets the midtones Exposure value.
  29927. * 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.
  29928. */
  29929. midtonesExposure: number;
  29930. private _shadowsHue;
  29931. private _shadowsDensity;
  29932. private _shadowsSaturation;
  29933. private _shadowsExposure;
  29934. /**
  29935. * Gets the shadows Hue value.
  29936. * 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).
  29937. */
  29938. /**
  29939. * Sets the shadows Hue value.
  29940. * 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).
  29941. */
  29942. shadowsHue: number;
  29943. /**
  29944. * Gets the shadows Density value.
  29945. * 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.
  29946. * Values less than zero provide a filter of opposite hue.
  29947. */
  29948. /**
  29949. * Sets the shadows Density value.
  29950. * 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.
  29951. * Values less than zero provide a filter of opposite hue.
  29952. */
  29953. shadowsDensity: number;
  29954. /**
  29955. * Gets the shadows Saturation value.
  29956. * 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.
  29957. */
  29958. /**
  29959. * Sets the shadows Saturation value.
  29960. * 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.
  29961. */
  29962. shadowsSaturation: number;
  29963. /**
  29964. * Gets the shadows Exposure value.
  29965. * 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.
  29966. */
  29967. /**
  29968. * Sets the shadows Exposure value.
  29969. * 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.
  29970. */
  29971. shadowsExposure: number;
  29972. /**
  29973. * Returns the class name
  29974. * @returns The class name
  29975. */
  29976. getClassName(): string;
  29977. /**
  29978. * Binds the color curves to the shader.
  29979. * @param colorCurves The color curve to bind
  29980. * @param effect The effect to bind to
  29981. * @param positiveUniform The positive uniform shader parameter
  29982. * @param neutralUniform The neutral uniform shader parameter
  29983. * @param negativeUniform The negative uniform shader parameter
  29984. */
  29985. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29986. /**
  29987. * Prepare the list of uniforms associated with the ColorCurves effects.
  29988. * @param uniformsList The list of uniforms used in the effect
  29989. */
  29990. static PrepareUniforms(uniformsList: string[]): void;
  29991. /**
  29992. * Returns color grading data based on a hue, density, saturation and exposure value.
  29993. * @param filterHue The hue of the color filter.
  29994. * @param filterDensity The density of the color filter.
  29995. * @param saturation The saturation.
  29996. * @param exposure The exposure.
  29997. * @param result The result data container.
  29998. */
  29999. private getColorGradingDataToRef;
  30000. /**
  30001. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30002. * @param value The input slider value in range [-100,100].
  30003. * @returns Adjusted value.
  30004. */
  30005. private static applyColorGradingSliderNonlinear;
  30006. /**
  30007. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30008. * @param hue The hue (H) input.
  30009. * @param saturation The saturation (S) input.
  30010. * @param brightness The brightness (B) input.
  30011. * @result An RGBA color represented as Vector4.
  30012. */
  30013. private static fromHSBToRef;
  30014. /**
  30015. * Returns a value clamped between min and max
  30016. * @param value The value to clamp
  30017. * @param min The minimum of value
  30018. * @param max The maximum of value
  30019. * @returns The clamped value.
  30020. */
  30021. private static clamp;
  30022. /**
  30023. * Clones the current color curve instance.
  30024. * @return The cloned curves
  30025. */
  30026. clone(): ColorCurves;
  30027. /**
  30028. * Serializes the current color curve instance to a json representation.
  30029. * @return a JSON representation
  30030. */
  30031. serialize(): any;
  30032. /**
  30033. * Parses the color curve from a json representation.
  30034. * @param source the JSON source to parse
  30035. * @return The parsed curves
  30036. */
  30037. static Parse(source: any): ColorCurves;
  30038. }
  30039. }
  30040. declare module BABYLON {
  30041. /**
  30042. * Interface to follow in your material defines to integrate easily the
  30043. * Image proccessing functions.
  30044. * @hidden
  30045. */
  30046. export interface IImageProcessingConfigurationDefines {
  30047. IMAGEPROCESSING: boolean;
  30048. VIGNETTE: boolean;
  30049. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30050. VIGNETTEBLENDMODEOPAQUE: boolean;
  30051. TONEMAPPING: boolean;
  30052. TONEMAPPING_ACES: boolean;
  30053. CONTRAST: boolean;
  30054. EXPOSURE: boolean;
  30055. COLORCURVES: boolean;
  30056. COLORGRADING: boolean;
  30057. COLORGRADING3D: boolean;
  30058. SAMPLER3DGREENDEPTH: boolean;
  30059. SAMPLER3DBGRMAP: boolean;
  30060. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30061. }
  30062. /**
  30063. * @hidden
  30064. */
  30065. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30066. IMAGEPROCESSING: boolean;
  30067. VIGNETTE: boolean;
  30068. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30069. VIGNETTEBLENDMODEOPAQUE: boolean;
  30070. TONEMAPPING: boolean;
  30071. TONEMAPPING_ACES: boolean;
  30072. CONTRAST: boolean;
  30073. COLORCURVES: boolean;
  30074. COLORGRADING: boolean;
  30075. COLORGRADING3D: boolean;
  30076. SAMPLER3DGREENDEPTH: boolean;
  30077. SAMPLER3DBGRMAP: boolean;
  30078. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30079. EXPOSURE: boolean;
  30080. constructor();
  30081. }
  30082. /**
  30083. * This groups together the common properties used for image processing either in direct forward pass
  30084. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30085. * or not.
  30086. */
  30087. export class ImageProcessingConfiguration {
  30088. /**
  30089. * Default tone mapping applied in BabylonJS.
  30090. */
  30091. static readonly TONEMAPPING_STANDARD: number;
  30092. /**
  30093. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30094. * to other engines rendering to increase portability.
  30095. */
  30096. static readonly TONEMAPPING_ACES: number;
  30097. /**
  30098. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30099. */
  30100. colorCurves: Nullable<ColorCurves>;
  30101. private _colorCurvesEnabled;
  30102. /**
  30103. * Gets wether the color curves effect is enabled.
  30104. */
  30105. /**
  30106. * Sets wether the color curves effect is enabled.
  30107. */
  30108. colorCurvesEnabled: boolean;
  30109. private _colorGradingTexture;
  30110. /**
  30111. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30112. */
  30113. /**
  30114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30115. */
  30116. colorGradingTexture: Nullable<BaseTexture>;
  30117. private _colorGradingEnabled;
  30118. /**
  30119. * Gets wether the color grading effect is enabled.
  30120. */
  30121. /**
  30122. * Sets wether the color grading effect is enabled.
  30123. */
  30124. colorGradingEnabled: boolean;
  30125. private _colorGradingWithGreenDepth;
  30126. /**
  30127. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30128. */
  30129. /**
  30130. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30131. */
  30132. colorGradingWithGreenDepth: boolean;
  30133. private _colorGradingBGR;
  30134. /**
  30135. * Gets wether the color grading texture contains BGR values.
  30136. */
  30137. /**
  30138. * Sets wether the color grading texture contains BGR values.
  30139. */
  30140. colorGradingBGR: boolean;
  30141. /** @hidden */
  30142. _exposure: number;
  30143. /**
  30144. * Gets the Exposure used in the effect.
  30145. */
  30146. /**
  30147. * Sets the Exposure used in the effect.
  30148. */
  30149. exposure: number;
  30150. private _toneMappingEnabled;
  30151. /**
  30152. * Gets wether the tone mapping effect is enabled.
  30153. */
  30154. /**
  30155. * Sets wether the tone mapping effect is enabled.
  30156. */
  30157. toneMappingEnabled: boolean;
  30158. private _toneMappingType;
  30159. /**
  30160. * Gets the type of tone mapping effect.
  30161. */
  30162. /**
  30163. * Sets the type of tone mapping effect used in BabylonJS.
  30164. */
  30165. toneMappingType: number;
  30166. protected _contrast: number;
  30167. /**
  30168. * Gets the contrast used in the effect.
  30169. */
  30170. /**
  30171. * Sets the contrast used in the effect.
  30172. */
  30173. contrast: number;
  30174. /**
  30175. * Vignette stretch size.
  30176. */
  30177. vignetteStretch: number;
  30178. /**
  30179. * Vignette centre X Offset.
  30180. */
  30181. vignetteCentreX: number;
  30182. /**
  30183. * Vignette centre Y Offset.
  30184. */
  30185. vignetteCentreY: number;
  30186. /**
  30187. * Vignette weight or intensity of the vignette effect.
  30188. */
  30189. vignetteWeight: number;
  30190. /**
  30191. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30192. * if vignetteEnabled is set to true.
  30193. */
  30194. vignetteColor: Color4;
  30195. /**
  30196. * Camera field of view used by the Vignette effect.
  30197. */
  30198. vignetteCameraFov: number;
  30199. private _vignetteBlendMode;
  30200. /**
  30201. * Gets the vignette blend mode allowing different kind of effect.
  30202. */
  30203. /**
  30204. * Sets the vignette blend mode allowing different kind of effect.
  30205. */
  30206. vignetteBlendMode: number;
  30207. private _vignetteEnabled;
  30208. /**
  30209. * Gets wether the vignette effect is enabled.
  30210. */
  30211. /**
  30212. * Sets wether the vignette effect is enabled.
  30213. */
  30214. vignetteEnabled: boolean;
  30215. private _applyByPostProcess;
  30216. /**
  30217. * Gets wether the image processing is applied through a post process or not.
  30218. */
  30219. /**
  30220. * Sets wether the image processing is applied through a post process or not.
  30221. */
  30222. applyByPostProcess: boolean;
  30223. private _isEnabled;
  30224. /**
  30225. * Gets wether the image processing is enabled or not.
  30226. */
  30227. /**
  30228. * Sets wether the image processing is enabled or not.
  30229. */
  30230. isEnabled: boolean;
  30231. /**
  30232. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30233. */
  30234. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30235. /**
  30236. * Method called each time the image processing information changes requires to recompile the effect.
  30237. */
  30238. protected _updateParameters(): void;
  30239. /**
  30240. * Gets the current class name.
  30241. * @return "ImageProcessingConfiguration"
  30242. */
  30243. getClassName(): string;
  30244. /**
  30245. * Prepare the list of uniforms associated with the Image Processing effects.
  30246. * @param uniforms The list of uniforms used in the effect
  30247. * @param defines the list of defines currently in use
  30248. */
  30249. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30250. /**
  30251. * Prepare the list of samplers associated with the Image Processing effects.
  30252. * @param samplersList The list of uniforms used in the effect
  30253. * @param defines the list of defines currently in use
  30254. */
  30255. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30256. /**
  30257. * Prepare the list of defines associated to the shader.
  30258. * @param defines the list of defines to complete
  30259. * @param forPostProcess Define if we are currently in post process mode or not
  30260. */
  30261. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30262. /**
  30263. * Returns true if all the image processing information are ready.
  30264. * @returns True if ready, otherwise, false
  30265. */
  30266. isReady(): boolean;
  30267. /**
  30268. * Binds the image processing to the shader.
  30269. * @param effect The effect to bind to
  30270. * @param aspectRatio Define the current aspect ratio of the effect
  30271. */
  30272. bind(effect: Effect, aspectRatio?: number): void;
  30273. /**
  30274. * Clones the current image processing instance.
  30275. * @return The cloned image processing
  30276. */
  30277. clone(): ImageProcessingConfiguration;
  30278. /**
  30279. * Serializes the current image processing instance to a json representation.
  30280. * @return a JSON representation
  30281. */
  30282. serialize(): any;
  30283. /**
  30284. * Parses the image processing from a json representation.
  30285. * @param source the JSON source to parse
  30286. * @return The parsed image processing
  30287. */
  30288. static Parse(source: any): ImageProcessingConfiguration;
  30289. private static _VIGNETTEMODE_MULTIPLY;
  30290. private static _VIGNETTEMODE_OPAQUE;
  30291. /**
  30292. * Used to apply the vignette as a mix with the pixel color.
  30293. */
  30294. static readonly VIGNETTEMODE_MULTIPLY: number;
  30295. /**
  30296. * Used to apply the vignette as a replacement of the pixel color.
  30297. */
  30298. static readonly VIGNETTEMODE_OPAQUE: number;
  30299. }
  30300. }
  30301. declare module BABYLON {
  30302. /**
  30303. * This represents all the required information to add a fresnel effect on a material:
  30304. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30305. */
  30306. export class FresnelParameters {
  30307. private _isEnabled;
  30308. /**
  30309. * Define if the fresnel effect is enable or not.
  30310. */
  30311. isEnabled: boolean;
  30312. /**
  30313. * Define the color used on edges (grazing angle)
  30314. */
  30315. leftColor: Color3;
  30316. /**
  30317. * Define the color used on center
  30318. */
  30319. rightColor: Color3;
  30320. /**
  30321. * Define bias applied to computed fresnel term
  30322. */
  30323. bias: number;
  30324. /**
  30325. * Defined the power exponent applied to fresnel term
  30326. */
  30327. power: number;
  30328. /**
  30329. * Clones the current fresnel and its valuues
  30330. * @returns a clone fresnel configuration
  30331. */
  30332. clone(): FresnelParameters;
  30333. /**
  30334. * Serializes the current fresnel parameters to a JSON representation.
  30335. * @return the JSON serialization
  30336. */
  30337. serialize(): any;
  30338. /**
  30339. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30340. * @param parsedFresnelParameters Define the JSON representation
  30341. * @returns the parsed parameters
  30342. */
  30343. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30344. }
  30345. }
  30346. declare module BABYLON {
  30347. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30348. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30349. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30350. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30351. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30352. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30353. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30354. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30355. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30356. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30357. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30358. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30359. /**
  30360. * Decorator used to define property that can be serialized as reference to a camera
  30361. * @param sourceName defines the name of the property to decorate
  30362. */
  30363. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30364. /**
  30365. * Class used to help serialization objects
  30366. */
  30367. export class SerializationHelper {
  30368. /** hidden */
  30369. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30370. /** hidden */
  30371. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30372. /** hidden */
  30373. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30374. /** hidden */
  30375. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30376. /**
  30377. * Appends the serialized animations from the source animations
  30378. * @param source Source containing the animations
  30379. * @param destination Target to store the animations
  30380. */
  30381. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30382. /**
  30383. * Static function used to serialized a specific entity
  30384. * @param entity defines the entity to serialize
  30385. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30386. * @returns a JSON compatible object representing the serialization of the entity
  30387. */
  30388. static Serialize<T>(entity: T, serializationObject?: any): any;
  30389. /**
  30390. * Creates a new entity from a serialization data object
  30391. * @param creationFunction defines a function used to instanciated the new entity
  30392. * @param source defines the source serialization data
  30393. * @param scene defines the hosting scene
  30394. * @param rootUrl defines the root url for resources
  30395. * @returns a new entity
  30396. */
  30397. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30398. /**
  30399. * Clones an object
  30400. * @param creationFunction defines the function used to instanciate the new object
  30401. * @param source defines the source object
  30402. * @returns the cloned object
  30403. */
  30404. static Clone<T>(creationFunction: () => T, source: T): T;
  30405. /**
  30406. * Instanciates a new object based on a source one (some data will be shared between both object)
  30407. * @param creationFunction defines the function used to instanciate the new object
  30408. * @param source defines the source object
  30409. * @returns the new object
  30410. */
  30411. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30412. }
  30413. }
  30414. declare module BABYLON {
  30415. /**
  30416. * This is the base class of all the camera used in the application.
  30417. * @see http://doc.babylonjs.com/features/cameras
  30418. */
  30419. export class Camera extends Node {
  30420. /** @hidden */
  30421. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30422. /**
  30423. * This is the default projection mode used by the cameras.
  30424. * It helps recreating a feeling of perspective and better appreciate depth.
  30425. * This is the best way to simulate real life cameras.
  30426. */
  30427. static readonly PERSPECTIVE_CAMERA: number;
  30428. /**
  30429. * This helps creating camera with an orthographic mode.
  30430. * 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.
  30431. */
  30432. static readonly ORTHOGRAPHIC_CAMERA: number;
  30433. /**
  30434. * This is the default FOV mode for perspective cameras.
  30435. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30436. */
  30437. static readonly FOVMODE_VERTICAL_FIXED: number;
  30438. /**
  30439. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30440. */
  30441. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30442. /**
  30443. * This specifies ther is no need for a camera rig.
  30444. * Basically only one eye is rendered corresponding to the camera.
  30445. */
  30446. static readonly RIG_MODE_NONE: number;
  30447. /**
  30448. * Simulates a camera Rig with one blue eye and one red eye.
  30449. * This can be use with 3d blue and red glasses.
  30450. */
  30451. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30452. /**
  30453. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30454. */
  30455. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30456. /**
  30457. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered over under each other.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30464. /**
  30465. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30466. */
  30467. static readonly RIG_MODE_VR: number;
  30468. /**
  30469. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30470. */
  30471. static readonly RIG_MODE_WEBVR: number;
  30472. /**
  30473. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30474. */
  30475. static readonly RIG_MODE_CUSTOM: number;
  30476. /**
  30477. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30478. */
  30479. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30480. /**
  30481. * @hidden
  30482. * Might be removed once multiview will be a thing
  30483. */
  30484. static UseAlternateWebVRRendering: boolean;
  30485. /**
  30486. * Define the input manager associated with the camera.
  30487. */
  30488. inputs: CameraInputsManager<Camera>;
  30489. /**
  30490. * Define the current local position of the camera in the scene
  30491. */
  30492. position: Vector3;
  30493. /**
  30494. * The vector the camera should consider as up.
  30495. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30496. */
  30497. upVector: Vector3;
  30498. /**
  30499. * Define the current limit on the left side for an orthographic camera
  30500. * In scene unit
  30501. */
  30502. orthoLeft: Nullable<number>;
  30503. /**
  30504. * Define the current limit on the right side for an orthographic camera
  30505. * In scene unit
  30506. */
  30507. orthoRight: Nullable<number>;
  30508. /**
  30509. * Define the current limit on the bottom side for an orthographic camera
  30510. * In scene unit
  30511. */
  30512. orthoBottom: Nullable<number>;
  30513. /**
  30514. * Define the current limit on the top side for an orthographic camera
  30515. * In scene unit
  30516. */
  30517. orthoTop: Nullable<number>;
  30518. /**
  30519. * Field Of View is set in Radians. (default is 0.8)
  30520. */
  30521. fov: number;
  30522. /**
  30523. * Define the minimum distance the camera can see from.
  30524. * This is important to note that the depth buffer are not infinite and the closer it starts
  30525. * the more your scene might encounter depth fighting issue.
  30526. */
  30527. minZ: number;
  30528. /**
  30529. * Define the maximum distance the camera can see to.
  30530. * This is important to note that the depth buffer are not infinite and the further it end
  30531. * the more your scene might encounter depth fighting issue.
  30532. */
  30533. maxZ: number;
  30534. /**
  30535. * Define the default inertia of the camera.
  30536. * This helps giving a smooth feeling to the camera movement.
  30537. */
  30538. inertia: number;
  30539. /**
  30540. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30541. */
  30542. mode: number;
  30543. /**
  30544. * Define wether the camera is intermediate.
  30545. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30546. */
  30547. isIntermediate: boolean;
  30548. /**
  30549. * Define the viewport of the camera.
  30550. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30551. */
  30552. viewport: Viewport;
  30553. /**
  30554. * Restricts the camera to viewing objects with the same layerMask.
  30555. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30556. */
  30557. layerMask: number;
  30558. /**
  30559. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30560. */
  30561. fovMode: number;
  30562. /**
  30563. * Rig mode of the camera.
  30564. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30565. * This is normally controlled byt the camera themselves as internal use.
  30566. */
  30567. cameraRigMode: number;
  30568. /**
  30569. * Defines the distance between both "eyes" in case of a RIG
  30570. */
  30571. interaxialDistance: number;
  30572. /**
  30573. * Defines if stereoscopic rendering is done side by side or over under.
  30574. */
  30575. isStereoscopicSideBySide: boolean;
  30576. /**
  30577. * 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
  30578. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30579. * else in the scene.
  30580. */
  30581. customRenderTargets: RenderTargetTexture[];
  30582. /**
  30583. * When set, the camera will render to this render target instead of the default canvas
  30584. */
  30585. outputRenderTarget: Nullable<RenderTargetTexture>;
  30586. /**
  30587. * Observable triggered when the camera view matrix has changed.
  30588. */
  30589. onViewMatrixChangedObservable: Observable<Camera>;
  30590. /**
  30591. * Observable triggered when the camera Projection matrix has changed.
  30592. */
  30593. onProjectionMatrixChangedObservable: Observable<Camera>;
  30594. /**
  30595. * Observable triggered when the inputs have been processed.
  30596. */
  30597. onAfterCheckInputsObservable: Observable<Camera>;
  30598. /**
  30599. * Observable triggered when reset has been called and applied to the camera.
  30600. */
  30601. onRestoreStateObservable: Observable<Camera>;
  30602. /** @hidden */
  30603. _cameraRigParams: any;
  30604. /** @hidden */
  30605. _rigCameras: Camera[];
  30606. /** @hidden */
  30607. _rigPostProcess: Nullable<PostProcess>;
  30608. protected _webvrViewMatrix: Matrix;
  30609. /** @hidden */
  30610. _skipRendering: boolean;
  30611. /** @hidden */
  30612. _alternateCamera: Camera;
  30613. /** @hidden */
  30614. _projectionMatrix: Matrix;
  30615. /** @hidden */
  30616. _postProcesses: Nullable<PostProcess>[];
  30617. /** @hidden */
  30618. _activeMeshes: SmartArray<AbstractMesh>;
  30619. protected _globalPosition: Vector3;
  30620. /** hidden */
  30621. _computedViewMatrix: Matrix;
  30622. private _doNotComputeProjectionMatrix;
  30623. private _transformMatrix;
  30624. private _frustumPlanes;
  30625. private _refreshFrustumPlanes;
  30626. private _storedFov;
  30627. private _stateStored;
  30628. /**
  30629. * Instantiates a new camera object.
  30630. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30631. * @see http://doc.babylonjs.com/features/cameras
  30632. * @param name Defines the name of the camera in the scene
  30633. * @param position Defines the position of the camera
  30634. * @param scene Defines the scene the camera belongs too
  30635. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30636. */
  30637. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30638. /**
  30639. * Store current camera state (fov, position, etc..)
  30640. * @returns the camera
  30641. */
  30642. storeState(): Camera;
  30643. /**
  30644. * Restores the camera state values if it has been stored. You must call storeState() first
  30645. */
  30646. protected _restoreStateValues(): boolean;
  30647. /**
  30648. * Restored camera state. You must call storeState() first.
  30649. * @returns true if restored and false otherwise
  30650. */
  30651. restoreState(): boolean;
  30652. /**
  30653. * Gets the class name of the camera.
  30654. * @returns the class name
  30655. */
  30656. getClassName(): string;
  30657. /** @hidden */
  30658. readonly _isCamera: boolean;
  30659. /**
  30660. * Gets a string representation of the camera useful for debug purpose.
  30661. * @param fullDetails Defines that a more verboe level of logging is required
  30662. * @returns the string representation
  30663. */
  30664. toString(fullDetails?: boolean): string;
  30665. /**
  30666. * Gets the current world space position of the camera.
  30667. */
  30668. readonly globalPosition: Vector3;
  30669. /**
  30670. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30671. * @returns the active meshe list
  30672. */
  30673. getActiveMeshes(): SmartArray<AbstractMesh>;
  30674. /**
  30675. * Check wether a mesh is part of the current active mesh list of the camera
  30676. * @param mesh Defines the mesh to check
  30677. * @returns true if active, false otherwise
  30678. */
  30679. isActiveMesh(mesh: Mesh): boolean;
  30680. /**
  30681. * Is this camera ready to be used/rendered
  30682. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30683. * @return true if the camera is ready
  30684. */
  30685. isReady(completeCheck?: boolean): boolean;
  30686. /** @hidden */
  30687. _initCache(): void;
  30688. /** @hidden */
  30689. _updateCache(ignoreParentClass?: boolean): void;
  30690. /** @hidden */
  30691. _isSynchronized(): boolean;
  30692. /** @hidden */
  30693. _isSynchronizedViewMatrix(): boolean;
  30694. /** @hidden */
  30695. _isSynchronizedProjectionMatrix(): boolean;
  30696. /**
  30697. * Attach the input controls to a specific dom element to get the input from.
  30698. * @param element Defines the element the controls should be listened from
  30699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30700. */
  30701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30702. /**
  30703. * Detach the current controls from the specified dom element.
  30704. * @param element Defines the element to stop listening the inputs from
  30705. */
  30706. detachControl(element: HTMLElement): void;
  30707. /**
  30708. * Update the camera state according to the different inputs gathered during the frame.
  30709. */
  30710. update(): void;
  30711. /** @hidden */
  30712. _checkInputs(): void;
  30713. /** @hidden */
  30714. readonly rigCameras: Camera[];
  30715. /**
  30716. * Gets the post process used by the rig cameras
  30717. */
  30718. readonly rigPostProcess: Nullable<PostProcess>;
  30719. /**
  30720. * Internal, gets the first post proces.
  30721. * @returns the first post process to be run on this camera.
  30722. */
  30723. _getFirstPostProcess(): Nullable<PostProcess>;
  30724. private _cascadePostProcessesToRigCams;
  30725. /**
  30726. * Attach a post process to the camera.
  30727. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30728. * @param postProcess The post process to attach to the camera
  30729. * @param insertAt The position of the post process in case several of them are in use in the scene
  30730. * @returns the position the post process has been inserted at
  30731. */
  30732. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30733. /**
  30734. * Detach a post process to the camera.
  30735. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30736. * @param postProcess The post process to detach from the camera
  30737. */
  30738. detachPostProcess(postProcess: PostProcess): void;
  30739. /**
  30740. * Gets the current world matrix of the camera
  30741. */
  30742. getWorldMatrix(): Matrix;
  30743. /** @hidden */
  30744. _getViewMatrix(): Matrix;
  30745. /**
  30746. * Gets the current view matrix of the camera.
  30747. * @param force forces the camera to recompute the matrix without looking at the cached state
  30748. * @returns the view matrix
  30749. */
  30750. getViewMatrix(force?: boolean): Matrix;
  30751. /**
  30752. * Freeze the projection matrix.
  30753. * It will prevent the cache check of the camera projection compute and can speed up perf
  30754. * if no parameter of the camera are meant to change
  30755. * @param projection Defines manually a projection if necessary
  30756. */
  30757. freezeProjectionMatrix(projection?: Matrix): void;
  30758. /**
  30759. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30760. */
  30761. unfreezeProjectionMatrix(): void;
  30762. /**
  30763. * Gets the current projection matrix of the camera.
  30764. * @param force forces the camera to recompute the matrix without looking at the cached state
  30765. * @returns the projection matrix
  30766. */
  30767. getProjectionMatrix(force?: boolean): Matrix;
  30768. /**
  30769. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30770. * @returns a Matrix
  30771. */
  30772. getTransformationMatrix(): Matrix;
  30773. private _updateFrustumPlanes;
  30774. /**
  30775. * Checks if a cullable object (mesh...) is in the camera frustum
  30776. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30777. * @param target The object to check
  30778. * @returns true if the object is in frustum otherwise false
  30779. */
  30780. isInFrustum(target: ICullable): boolean;
  30781. /**
  30782. * Checks if a cullable object (mesh...) is in the camera frustum
  30783. * Unlike isInFrustum this cheks the full bounding box
  30784. * @param target The object to check
  30785. * @returns true if the object is in frustum otherwise false
  30786. */
  30787. isCompletelyInFrustum(target: ICullable): boolean;
  30788. /**
  30789. * Gets a ray in the forward direction from the camera.
  30790. * @param length Defines the length of the ray to create
  30791. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30792. * @param origin Defines the start point of the ray which defaults to the camera position
  30793. * @returns the forward ray
  30794. */
  30795. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30796. /**
  30797. * Releases resources associated with this node.
  30798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30800. */
  30801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30802. /**
  30803. * Gets the left camera of a rig setup in case of Rigged Camera
  30804. */
  30805. readonly leftCamera: Nullable<FreeCamera>;
  30806. /**
  30807. * Gets the right camera of a rig setup in case of Rigged Camera
  30808. */
  30809. readonly rightCamera: Nullable<FreeCamera>;
  30810. /**
  30811. * Gets the left camera target of a rig setup in case of Rigged Camera
  30812. * @returns the target position
  30813. */
  30814. getLeftTarget(): Nullable<Vector3>;
  30815. /**
  30816. * Gets the right camera target of a rig setup in case of Rigged Camera
  30817. * @returns the target position
  30818. */
  30819. getRightTarget(): Nullable<Vector3>;
  30820. /**
  30821. * @hidden
  30822. */
  30823. setCameraRigMode(mode: number, rigParams: any): void;
  30824. /** @hidden */
  30825. static _setStereoscopicRigMode(camera: Camera): void;
  30826. /** @hidden */
  30827. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30828. /** @hidden */
  30829. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30830. /** @hidden */
  30831. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30832. /** @hidden */
  30833. _getVRProjectionMatrix(): Matrix;
  30834. protected _updateCameraRotationMatrix(): void;
  30835. protected _updateWebVRCameraRotationMatrix(): void;
  30836. /**
  30837. * This function MUST be overwritten by the different WebVR cameras available.
  30838. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30839. * @hidden
  30840. */
  30841. _getWebVRProjectionMatrix(): Matrix;
  30842. /**
  30843. * This function MUST be overwritten by the different WebVR cameras available.
  30844. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30845. * @hidden
  30846. */
  30847. _getWebVRViewMatrix(): Matrix;
  30848. /** @hidden */
  30849. setCameraRigParameter(name: string, value: any): void;
  30850. /**
  30851. * needs to be overridden by children so sub has required properties to be copied
  30852. * @hidden
  30853. */
  30854. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30855. /**
  30856. * May need to be overridden by children
  30857. * @hidden
  30858. */
  30859. _updateRigCameras(): void;
  30860. /** @hidden */
  30861. _setupInputs(): void;
  30862. /**
  30863. * Serialiaze the camera setup to a json represention
  30864. * @returns the JSON representation
  30865. */
  30866. serialize(): any;
  30867. /**
  30868. * Clones the current camera.
  30869. * @param name The cloned camera name
  30870. * @returns the cloned camera
  30871. */
  30872. clone(name: string): Camera;
  30873. /**
  30874. * Gets the direction of the camera relative to a given local axis.
  30875. * @param localAxis Defines the reference axis to provide a relative direction.
  30876. * @return the direction
  30877. */
  30878. getDirection(localAxis: Vector3): Vector3;
  30879. /**
  30880. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30881. * @param localAxis Defines the reference axis to provide a relative direction.
  30882. * @param result Defines the vector to store the result in
  30883. */
  30884. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30885. /**
  30886. * Gets a camera constructor for a given camera type
  30887. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30888. * @param name The name of the camera the result will be able to instantiate
  30889. * @param scene The scene the result will construct the camera in
  30890. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30891. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30892. * @returns a factory method to construc the camera
  30893. */
  30894. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30895. /**
  30896. * Compute the world matrix of the camera.
  30897. * @returns the camera workd matrix
  30898. */
  30899. computeWorldMatrix(): Matrix;
  30900. /**
  30901. * Parse a JSON and creates the camera from the parsed information
  30902. * @param parsedCamera The JSON to parse
  30903. * @param scene The scene to instantiate the camera in
  30904. * @returns the newly constructed camera
  30905. */
  30906. static Parse(parsedCamera: any, scene: Scene): Camera;
  30907. }
  30908. }
  30909. declare module BABYLON {
  30910. /**
  30911. * Interface for any object that can request an animation frame
  30912. */
  30913. export interface ICustomAnimationFrameRequester {
  30914. /**
  30915. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30916. */
  30917. renderFunction?: Function;
  30918. /**
  30919. * Called to request the next frame to render to
  30920. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30921. */
  30922. requestAnimationFrame: Function;
  30923. /**
  30924. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30925. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30926. */
  30927. requestID?: number;
  30928. }
  30929. /**
  30930. * Interface containing an array of animations
  30931. */
  30932. export interface IAnimatable {
  30933. /**
  30934. * Array of animations
  30935. */
  30936. animations: Array<Animation>;
  30937. }
  30938. /** Interface used by value gradients (color, factor, ...) */
  30939. export interface IValueGradient {
  30940. /**
  30941. * Gets or sets the gradient value (between 0 and 1)
  30942. */
  30943. gradient: number;
  30944. }
  30945. /** Class used to store color4 gradient */
  30946. export class ColorGradient implements IValueGradient {
  30947. /**
  30948. * Gets or sets the gradient value (between 0 and 1)
  30949. */
  30950. gradient: number;
  30951. /**
  30952. * Gets or sets first associated color
  30953. */
  30954. color1: Color4;
  30955. /**
  30956. * Gets or sets second associated color
  30957. */
  30958. color2?: Color4;
  30959. /**
  30960. * Will get a color picked randomly between color1 and color2.
  30961. * If color2 is undefined then color1 will be used
  30962. * @param result defines the target Color4 to store the result in
  30963. */
  30964. getColorToRef(result: Color4): void;
  30965. }
  30966. /** Class used to store color 3 gradient */
  30967. export class Color3Gradient implements IValueGradient {
  30968. /**
  30969. * Gets or sets the gradient value (between 0 and 1)
  30970. */
  30971. gradient: number;
  30972. /**
  30973. * Gets or sets the associated color
  30974. */
  30975. color: Color3;
  30976. }
  30977. /** Class used to store factor gradient */
  30978. export class FactorGradient implements IValueGradient {
  30979. /**
  30980. * Gets or sets the gradient value (between 0 and 1)
  30981. */
  30982. gradient: number;
  30983. /**
  30984. * Gets or sets first associated factor
  30985. */
  30986. factor1: number;
  30987. /**
  30988. * Gets or sets second associated factor
  30989. */
  30990. factor2?: number;
  30991. /**
  30992. * Will get a number picked randomly between factor1 and factor2.
  30993. * If factor2 is undefined then factor1 will be used
  30994. * @returns the picked number
  30995. */
  30996. getFactor(): number;
  30997. }
  30998. /**
  30999. * @ignore
  31000. * Application error to support additional information when loading a file
  31001. */
  31002. export class LoadFileError extends Error {
  31003. /** defines the optional XHR request */
  31004. request?: XMLHttpRequest | undefined;
  31005. private static _setPrototypeOf;
  31006. /**
  31007. * Creates a new LoadFileError
  31008. * @param message defines the message of the error
  31009. * @param request defines the optional XHR request
  31010. */
  31011. constructor(message: string,
  31012. /** defines the optional XHR request */
  31013. request?: XMLHttpRequest | undefined);
  31014. }
  31015. /**
  31016. * Class used to define a retry strategy when error happens while loading assets
  31017. */
  31018. export class RetryStrategy {
  31019. /**
  31020. * Function used to defines an exponential back off strategy
  31021. * @param maxRetries defines the maximum number of retries (3 by default)
  31022. * @param baseInterval defines the interval between retries
  31023. * @returns the strategy function to use
  31024. */
  31025. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31026. }
  31027. /**
  31028. * File request interface
  31029. */
  31030. export interface IFileRequest {
  31031. /**
  31032. * Raised when the request is complete (success or error).
  31033. */
  31034. onCompleteObservable: Observable<IFileRequest>;
  31035. /**
  31036. * Aborts the request for a file.
  31037. */
  31038. abort: () => void;
  31039. }
  31040. /**
  31041. * Class containing a set of static utilities functions
  31042. */
  31043. export class Tools {
  31044. /**
  31045. * Gets or sets the base URL to use to load assets
  31046. */
  31047. static BaseUrl: string;
  31048. /**
  31049. * Enable/Disable Custom HTTP Request Headers globally.
  31050. * default = false
  31051. * @see CustomRequestHeaders
  31052. */
  31053. static UseCustomRequestHeaders: boolean;
  31054. /**
  31055. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31056. * i.e. when loading files, where the server/service expects an Authorization header.
  31057. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  31058. */
  31059. static CustomRequestHeaders: {
  31060. [key: string]: string;
  31061. };
  31062. /**
  31063. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31064. */
  31065. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31066. /**
  31067. * Default behaviour for cors in the application.
  31068. * It can be a string if the expected behavior is identical in the entire app.
  31069. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31070. */
  31071. static CorsBehavior: string | ((url: string | string[]) => string);
  31072. /**
  31073. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31074. * @ignorenaming
  31075. */
  31076. static UseFallbackTexture: boolean;
  31077. /**
  31078. * Use this object to register external classes like custom textures or material
  31079. * to allow the laoders to instantiate them
  31080. */
  31081. static RegisteredExternalClasses: {
  31082. [key: string]: Object;
  31083. };
  31084. /**
  31085. * Texture content used if a texture cannot loaded
  31086. * @ignorenaming
  31087. */
  31088. static fallbackTexture: string;
  31089. /**
  31090. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31091. * @param u defines the coordinate on X axis
  31092. * @param v defines the coordinate on Y axis
  31093. * @param width defines the width of the source data
  31094. * @param height defines the height of the source data
  31095. * @param pixels defines the source byte array
  31096. * @param color defines the output color
  31097. */
  31098. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31099. /**
  31100. * Interpolates between a and b via alpha
  31101. * @param a The lower value (returned when alpha = 0)
  31102. * @param b The upper value (returned when alpha = 1)
  31103. * @param alpha The interpolation-factor
  31104. * @return The mixed value
  31105. */
  31106. static Mix(a: number, b: number, alpha: number): number;
  31107. /**
  31108. * Tries to instantiate a new object from a given class name
  31109. * @param className defines the class name to instantiate
  31110. * @returns the new object or null if the system was not able to do the instantiation
  31111. */
  31112. static Instantiate(className: string): any;
  31113. /**
  31114. * Provides a slice function that will work even on IE
  31115. * @param data defines the array to slice
  31116. * @param start defines the start of the data (optional)
  31117. * @param end defines the end of the data (optional)
  31118. * @returns the new sliced array
  31119. */
  31120. static Slice<T>(data: T, start?: number, end?: number): T;
  31121. /**
  31122. * Polyfill for setImmediate
  31123. * @param action defines the action to execute after the current execution block
  31124. */
  31125. static SetImmediate(action: () => void): void;
  31126. /**
  31127. * Function indicating if a number is an exponent of 2
  31128. * @param value defines the value to test
  31129. * @returns true if the value is an exponent of 2
  31130. */
  31131. static IsExponentOfTwo(value: number): boolean;
  31132. private static _tmpFloatArray;
  31133. /**
  31134. * Returns the nearest 32-bit single precision float representation of a Number
  31135. * @param value A Number. If the parameter is of a different type, it will get converted
  31136. * to a number or to NaN if it cannot be converted
  31137. * @returns number
  31138. */
  31139. static FloatRound(value: number): number;
  31140. /**
  31141. * Find the next highest power of two.
  31142. * @param x Number to start search from.
  31143. * @return Next highest power of two.
  31144. */
  31145. static CeilingPOT(x: number): number;
  31146. /**
  31147. * Find the next lowest power of two.
  31148. * @param x Number to start search from.
  31149. * @return Next lowest power of two.
  31150. */
  31151. static FloorPOT(x: number): number;
  31152. /**
  31153. * Find the nearest power of two.
  31154. * @param x Number to start search from.
  31155. * @return Next nearest power of two.
  31156. */
  31157. static NearestPOT(x: number): number;
  31158. /**
  31159. * Get the closest exponent of two
  31160. * @param value defines the value to approximate
  31161. * @param max defines the maximum value to return
  31162. * @param mode defines how to define the closest value
  31163. * @returns closest exponent of two of the given value
  31164. */
  31165. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31166. /**
  31167. * Extracts the filename from a path
  31168. * @param path defines the path to use
  31169. * @returns the filename
  31170. */
  31171. static GetFilename(path: string): string;
  31172. /**
  31173. * Extracts the "folder" part of a path (everything before the filename).
  31174. * @param uri The URI to extract the info from
  31175. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31176. * @returns The "folder" part of the path
  31177. */
  31178. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31179. /**
  31180. * Extracts text content from a DOM element hierarchy
  31181. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31182. */
  31183. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31184. /**
  31185. * Convert an angle in radians to degrees
  31186. * @param angle defines the angle to convert
  31187. * @returns the angle in degrees
  31188. */
  31189. static ToDegrees(angle: number): number;
  31190. /**
  31191. * Convert an angle in degrees to radians
  31192. * @param angle defines the angle to convert
  31193. * @returns the angle in radians
  31194. */
  31195. static ToRadians(angle: number): number;
  31196. /**
  31197. * Encode a buffer to a base64 string
  31198. * @param buffer defines the buffer to encode
  31199. * @returns the encoded string
  31200. */
  31201. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31202. /**
  31203. * Extracts minimum and maximum values from a list of indexed positions
  31204. * @param positions defines the positions to use
  31205. * @param indices defines the indices to the positions
  31206. * @param indexStart defines the start index
  31207. * @param indexCount defines the end index
  31208. * @param bias defines bias value to add to the result
  31209. * @return minimum and maximum values
  31210. */
  31211. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31212. minimum: Vector3;
  31213. maximum: Vector3;
  31214. };
  31215. /**
  31216. * Extracts minimum and maximum values from a list of positions
  31217. * @param positions defines the positions to use
  31218. * @param start defines the start index in the positions array
  31219. * @param count defines the number of positions to handle
  31220. * @param bias defines bias value to add to the result
  31221. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31222. * @return minimum and maximum values
  31223. */
  31224. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31225. minimum: Vector3;
  31226. maximum: Vector3;
  31227. };
  31228. /**
  31229. * Returns an array if obj is not an array
  31230. * @param obj defines the object to evaluate as an array
  31231. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31232. * @returns either obj directly if obj is an array or a new array containing obj
  31233. */
  31234. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31235. /**
  31236. * Gets the pointer prefix to use
  31237. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31238. */
  31239. static GetPointerPrefix(): string;
  31240. /**
  31241. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31242. * @param func - the function to be called
  31243. * @param requester - the object that will request the next frame. Falls back to window.
  31244. * @returns frame number
  31245. */
  31246. static QueueNewFrame(func: () => void, requester?: any): number;
  31247. /**
  31248. * Ask the browser to promote the current element to fullscreen rendering mode
  31249. * @param element defines the DOM element to promote
  31250. */
  31251. static RequestFullscreen(element: HTMLElement): void;
  31252. /**
  31253. * Asks the browser to exit fullscreen mode
  31254. */
  31255. static ExitFullscreen(): void;
  31256. /**
  31257. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31258. * @param url define the url we are trying
  31259. * @param element define the dom element where to configure the cors policy
  31260. */
  31261. static SetCorsBehavior(url: string | string[], element: {
  31262. crossOrigin: string | null;
  31263. }): void;
  31264. /**
  31265. * Removes unwanted characters from an url
  31266. * @param url defines the url to clean
  31267. * @returns the cleaned url
  31268. */
  31269. static CleanUrl(url: string): string;
  31270. /**
  31271. * Gets or sets a function used to pre-process url before using them to load assets
  31272. */
  31273. static PreprocessUrl: (url: string) => string;
  31274. /**
  31275. * Loads an image as an HTMLImageElement.
  31276. * @param input url string, ArrayBuffer, or Blob to load
  31277. * @param onLoad callback called when the image successfully loads
  31278. * @param onError callback called when the image fails to load
  31279. * @param offlineProvider offline provider for caching
  31280. * @returns the HTMLImageElement of the loaded image
  31281. */
  31282. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31283. /**
  31284. * Loads a file
  31285. * @param url url string, ArrayBuffer, or Blob to load
  31286. * @param onSuccess callback called when the file successfully loads
  31287. * @param onProgress callback called while file is loading (if the server supports this mode)
  31288. * @param offlineProvider defines the offline provider for caching
  31289. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31290. * @param onError callback called when the file fails to load
  31291. * @returns a file request object
  31292. */
  31293. 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;
  31294. /**
  31295. * Load a script (identified by an url). When the url returns, the
  31296. * content of this file is added into a new script element, attached to the DOM (body element)
  31297. * @param scriptUrl defines the url of the script to laod
  31298. * @param onSuccess defines the callback called when the script is loaded
  31299. * @param onError defines the callback to call if an error occurs
  31300. */
  31301. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31302. /**
  31303. * Loads a file from a blob
  31304. * @param fileToLoad defines the blob to use
  31305. * @param callback defines the callback to call when data is loaded
  31306. * @param progressCallback defines the callback to call during loading process
  31307. * @returns a file request object
  31308. */
  31309. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31310. /**
  31311. * Loads a file
  31312. * @param fileToLoad defines the file to load
  31313. * @param callback defines the callback to call when data is loaded
  31314. * @param progressCallBack defines the callback to call during loading process
  31315. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31316. * @returns a file request object
  31317. */
  31318. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31319. /**
  31320. * Creates a data url from a given string content
  31321. * @param content defines the content to convert
  31322. * @returns the new data url link
  31323. */
  31324. static FileAsURL(content: string): string;
  31325. /**
  31326. * Format the given number to a specific decimal format
  31327. * @param value defines the number to format
  31328. * @param decimals defines the number of decimals to use
  31329. * @returns the formatted string
  31330. */
  31331. static Format(value: number, decimals?: number): string;
  31332. /**
  31333. * Checks if a given vector is inside a specific range
  31334. * @param v defines the vector to test
  31335. * @param min defines the minimum range
  31336. * @param max defines the maximum range
  31337. */
  31338. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31339. /**
  31340. * Tries to copy an object by duplicating every property
  31341. * @param source defines the source object
  31342. * @param destination defines the target object
  31343. * @param doNotCopyList defines a list of properties to avoid
  31344. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31345. */
  31346. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31347. /**
  31348. * Gets a boolean indicating if the given object has no own property
  31349. * @param obj defines the object to test
  31350. * @returns true if object has no own property
  31351. */
  31352. static IsEmpty(obj: any): boolean;
  31353. /**
  31354. * Function used to register events at window level
  31355. * @param events defines the events to register
  31356. */
  31357. static RegisterTopRootEvents(events: {
  31358. name: string;
  31359. handler: Nullable<(e: FocusEvent) => any>;
  31360. }[]): void;
  31361. /**
  31362. * Function used to unregister events from window level
  31363. * @param events defines the events to unregister
  31364. */
  31365. static UnregisterTopRootEvents(events: {
  31366. name: string;
  31367. handler: Nullable<(e: FocusEvent) => any>;
  31368. }[]): void;
  31369. /**
  31370. * Dumps the current bound framebuffer
  31371. * @param width defines the rendering width
  31372. * @param height defines the rendering height
  31373. * @param engine defines the hosting engine
  31374. * @param successCallback defines the callback triggered once the data are available
  31375. * @param mimeType defines the mime type of the result
  31376. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31377. */
  31378. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31379. /**
  31380. * Converts the canvas data to blob.
  31381. * This acts as a polyfill for browsers not supporting the to blob function.
  31382. * @param canvas Defines the canvas to extract the data from
  31383. * @param successCallback Defines the callback triggered once the data are available
  31384. * @param mimeType Defines the mime type of the result
  31385. */
  31386. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31387. /**
  31388. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31389. * @param successCallback defines the callback triggered once the data are available
  31390. * @param mimeType defines the mime type of the result
  31391. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31392. */
  31393. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31394. /**
  31395. * Downloads a blob in the browser
  31396. * @param blob defines the blob to download
  31397. * @param fileName defines the name of the downloaded file
  31398. */
  31399. static Download(blob: Blob, fileName: string): void;
  31400. /**
  31401. * Captures a screenshot of the current rendering
  31402. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31403. * @param engine defines the rendering engine
  31404. * @param camera defines the source camera
  31405. * @param size This parameter can be set to a single number or to an object with the
  31406. * following (optional) properties: precision, width, height. If a single number is passed,
  31407. * it will be used for both width and height. If an object is passed, the screenshot size
  31408. * will be derived from the parameters. The precision property is a multiplier allowing
  31409. * rendering at a higher or lower resolution
  31410. * @param successCallback defines the callback receives a single parameter which contains the
  31411. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31412. * src parameter of an <img> to display it
  31413. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31414. * Check your browser for supported MIME types
  31415. */
  31416. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31417. /**
  31418. * Generates an image screenshot from the specified camera.
  31419. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31420. * @param engine The engine to use for rendering
  31421. * @param camera The camera to use for rendering
  31422. * @param size This parameter can be set to a single number or to an object with the
  31423. * following (optional) properties: precision, width, height. If a single number is passed,
  31424. * it will be used for both width and height. If an object is passed, the screenshot size
  31425. * will be derived from the parameters. The precision property is a multiplier allowing
  31426. * rendering at a higher or lower resolution
  31427. * @param successCallback The callback receives a single parameter which contains the
  31428. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31429. * src parameter of an <img> to display it
  31430. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31431. * Check your browser for supported MIME types
  31432. * @param samples Texture samples (default: 1)
  31433. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31434. * @param fileName A name for for the downloaded file.
  31435. */
  31436. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31437. /**
  31438. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31439. * Be aware Math.random() could cause collisions, but:
  31440. * "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"
  31441. * @returns a pseudo random id
  31442. */
  31443. static RandomId(): string;
  31444. /**
  31445. * Test if the given uri is a base64 string
  31446. * @param uri The uri to test
  31447. * @return True if the uri is a base64 string or false otherwise
  31448. */
  31449. static IsBase64(uri: string): boolean;
  31450. /**
  31451. * Decode the given base64 uri.
  31452. * @param uri The uri to decode
  31453. * @return The decoded base64 data.
  31454. */
  31455. static DecodeBase64(uri: string): ArrayBuffer;
  31456. /**
  31457. * No log
  31458. */
  31459. static readonly NoneLogLevel: number;
  31460. /**
  31461. * Only message logs
  31462. */
  31463. static readonly MessageLogLevel: number;
  31464. /**
  31465. * Only warning logs
  31466. */
  31467. static readonly WarningLogLevel: number;
  31468. /**
  31469. * Only error logs
  31470. */
  31471. static readonly ErrorLogLevel: number;
  31472. /**
  31473. * All logs
  31474. */
  31475. static readonly AllLogLevel: number;
  31476. /**
  31477. * Gets a value indicating the number of loading errors
  31478. * @ignorenaming
  31479. */
  31480. static readonly errorsCount: number;
  31481. /**
  31482. * Callback called when a new log is added
  31483. */
  31484. static OnNewCacheEntry: (entry: string) => void;
  31485. /**
  31486. * Log a message to the console
  31487. * @param message defines the message to log
  31488. */
  31489. static Log(message: string): void;
  31490. /**
  31491. * Write a warning message to the console
  31492. * @param message defines the message to log
  31493. */
  31494. static Warn(message: string): void;
  31495. /**
  31496. * Write an error message to the console
  31497. * @param message defines the message to log
  31498. */
  31499. static Error(message: string): void;
  31500. /**
  31501. * Gets current log cache (list of logs)
  31502. */
  31503. static readonly LogCache: string;
  31504. /**
  31505. * Clears the log cache
  31506. */
  31507. static ClearLogCache(): void;
  31508. /**
  31509. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31510. */
  31511. static LogLevels: number;
  31512. /**
  31513. * Checks if the loaded document was accessed via `file:`-Protocol.
  31514. * @returns boolean
  31515. */
  31516. static IsFileURL(): boolean;
  31517. /**
  31518. * Checks if the window object exists
  31519. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31520. */
  31521. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31522. /**
  31523. * No performance log
  31524. */
  31525. static readonly PerformanceNoneLogLevel: number;
  31526. /**
  31527. * Use user marks to log performance
  31528. */
  31529. static readonly PerformanceUserMarkLogLevel: number;
  31530. /**
  31531. * Log performance to the console
  31532. */
  31533. static readonly PerformanceConsoleLogLevel: number;
  31534. private static _performance;
  31535. /**
  31536. * Sets the current performance log level
  31537. */
  31538. static PerformanceLogLevel: number;
  31539. private static _StartPerformanceCounterDisabled;
  31540. private static _EndPerformanceCounterDisabled;
  31541. private static _StartUserMark;
  31542. private static _EndUserMark;
  31543. private static _StartPerformanceConsole;
  31544. private static _EndPerformanceConsole;
  31545. /**
  31546. * Injects the @see CustomRequestHeaders into the given request
  31547. * @param request the request that should be used for injection
  31548. */
  31549. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31550. /**
  31551. * Starts a performance counter
  31552. */
  31553. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31554. /**
  31555. * Ends a specific performance coutner
  31556. */
  31557. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31558. /**
  31559. * Gets either window.performance.now() if supported or Date.now() else
  31560. */
  31561. static readonly Now: number;
  31562. /**
  31563. * This method will return the name of the class used to create the instance of the given object.
  31564. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31565. * @param object the object to get the class name from
  31566. * @param isType defines if the object is actually a type
  31567. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31568. */
  31569. static GetClassName(object: any, isType?: boolean): string;
  31570. /**
  31571. * Gets the first element of an array satisfying a given predicate
  31572. * @param array defines the array to browse
  31573. * @param predicate defines the predicate to use
  31574. * @returns null if not found or the element
  31575. */
  31576. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31577. /**
  31578. * This method will return the name of the full name of the class, including its owning module (if any).
  31579. * 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).
  31580. * @param object the object to get the class name from
  31581. * @param isType defines if the object is actually a type
  31582. * @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.
  31583. * @ignorenaming
  31584. */
  31585. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31586. /**
  31587. * Returns a promise that resolves after the given amount of time.
  31588. * @param delay Number of milliseconds to delay
  31589. * @returns Promise that resolves after the given amount of time
  31590. */
  31591. static DelayAsync(delay: number): Promise<void>;
  31592. /**
  31593. * Gets the current gradient from an array of IValueGradient
  31594. * @param ratio defines the current ratio to get
  31595. * @param gradients defines the array of IValueGradient
  31596. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31597. */
  31598. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31599. }
  31600. /**
  31601. * This class is used to track a performance counter which is number based.
  31602. * The user has access to many properties which give statistics of different nature.
  31603. *
  31604. * The implementer can track two kinds of Performance Counter: time and count.
  31605. * 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.
  31606. * 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.
  31607. */
  31608. export class PerfCounter {
  31609. /**
  31610. * Gets or sets a global boolean to turn on and off all the counters
  31611. */
  31612. static Enabled: boolean;
  31613. /**
  31614. * Returns the smallest value ever
  31615. */
  31616. readonly min: number;
  31617. /**
  31618. * Returns the biggest value ever
  31619. */
  31620. readonly max: number;
  31621. /**
  31622. * Returns the average value since the performance counter is running
  31623. */
  31624. readonly average: number;
  31625. /**
  31626. * Returns the average value of the last second the counter was monitored
  31627. */
  31628. readonly lastSecAverage: number;
  31629. /**
  31630. * Returns the current value
  31631. */
  31632. readonly current: number;
  31633. /**
  31634. * Gets the accumulated total
  31635. */
  31636. readonly total: number;
  31637. /**
  31638. * Gets the total value count
  31639. */
  31640. readonly count: number;
  31641. /**
  31642. * Creates a new counter
  31643. */
  31644. constructor();
  31645. /**
  31646. * Call this method to start monitoring a new frame.
  31647. * 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.
  31648. */
  31649. fetchNewFrame(): void;
  31650. /**
  31651. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31652. * @param newCount the count value to add to the monitored count
  31653. * @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.
  31654. */
  31655. addCount(newCount: number, fetchResult: boolean): void;
  31656. /**
  31657. * Start monitoring this performance counter
  31658. */
  31659. beginMonitoring(): void;
  31660. /**
  31661. * Compute the time lapsed since the previous beginMonitoring() call.
  31662. * @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
  31663. */
  31664. endMonitoring(newFrame?: boolean): void;
  31665. private _fetchResult;
  31666. private _startMonitoringTime;
  31667. private _min;
  31668. private _max;
  31669. private _average;
  31670. private _current;
  31671. private _totalValueCount;
  31672. private _totalAccumulated;
  31673. private _lastSecAverage;
  31674. private _lastSecAccumulated;
  31675. private _lastSecTime;
  31676. private _lastSecValueCount;
  31677. }
  31678. /**
  31679. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31680. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31681. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31682. * @param name The name of the class, case should be preserved
  31683. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31684. */
  31685. export function className(name: string, module?: string): (target: Object) => void;
  31686. /**
  31687. * An implementation of a loop for asynchronous functions.
  31688. */
  31689. export class AsyncLoop {
  31690. /**
  31691. * Defines the number of iterations for the loop
  31692. */
  31693. iterations: number;
  31694. /**
  31695. * Defines the current index of the loop.
  31696. */
  31697. index: number;
  31698. private _done;
  31699. private _fn;
  31700. private _successCallback;
  31701. /**
  31702. * Constructor.
  31703. * @param iterations the number of iterations.
  31704. * @param func the function to run each iteration
  31705. * @param successCallback the callback that will be called upon succesful execution
  31706. * @param offset starting offset.
  31707. */
  31708. constructor(
  31709. /**
  31710. * Defines the number of iterations for the loop
  31711. */
  31712. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31713. /**
  31714. * Execute the next iteration. Must be called after the last iteration was finished.
  31715. */
  31716. executeNext(): void;
  31717. /**
  31718. * Break the loop and run the success callback.
  31719. */
  31720. breakLoop(): void;
  31721. /**
  31722. * Create and run an async loop.
  31723. * @param iterations the number of iterations.
  31724. * @param fn the function to run each iteration
  31725. * @param successCallback the callback that will be called upon succesful execution
  31726. * @param offset starting offset.
  31727. * @returns the created async loop object
  31728. */
  31729. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31730. /**
  31731. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31732. * @param iterations total number of iterations
  31733. * @param syncedIterations number of synchronous iterations in each async iteration.
  31734. * @param fn the function to call each iteration.
  31735. * @param callback a success call back that will be called when iterating stops.
  31736. * @param breakFunction a break condition (optional)
  31737. * @param timeout timeout settings for the setTimeout function. default - 0.
  31738. * @returns the created async loop object
  31739. */
  31740. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31741. }
  31742. }
  31743. declare module BABYLON {
  31744. /**
  31745. * This class defines the direct association between an animation and a target
  31746. */
  31747. export class TargetedAnimation {
  31748. /**
  31749. * Animation to perform
  31750. */
  31751. animation: Animation;
  31752. /**
  31753. * Target to animate
  31754. */
  31755. target: any;
  31756. }
  31757. /**
  31758. * Use this class to create coordinated animations on multiple targets
  31759. */
  31760. export class AnimationGroup implements IDisposable {
  31761. /** The name of the animation group */
  31762. name: string;
  31763. private _scene;
  31764. private _targetedAnimations;
  31765. private _animatables;
  31766. private _from;
  31767. private _to;
  31768. private _isStarted;
  31769. private _isPaused;
  31770. private _speedRatio;
  31771. /**
  31772. * Gets or sets the unique id of the node
  31773. */
  31774. uniqueId: number;
  31775. /**
  31776. * This observable will notify when one animation have ended
  31777. */
  31778. onAnimationEndObservable: Observable<TargetedAnimation>;
  31779. /**
  31780. * Observer raised when one animation loops
  31781. */
  31782. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31783. /**
  31784. * This observable will notify when all animations have ended.
  31785. */
  31786. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31787. /**
  31788. * This observable will notify when all animations have paused.
  31789. */
  31790. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31791. /**
  31792. * This observable will notify when all animations are playing.
  31793. */
  31794. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31795. /**
  31796. * Gets the first frame
  31797. */
  31798. readonly from: number;
  31799. /**
  31800. * Gets the last frame
  31801. */
  31802. readonly to: number;
  31803. /**
  31804. * Define if the animations are started
  31805. */
  31806. readonly isStarted: boolean;
  31807. /**
  31808. * Gets a value indicating that the current group is playing
  31809. */
  31810. readonly isPlaying: boolean;
  31811. /**
  31812. * Gets or sets the speed ratio to use for all animations
  31813. */
  31814. /**
  31815. * Gets or sets the speed ratio to use for all animations
  31816. */
  31817. speedRatio: number;
  31818. /**
  31819. * Gets the targeted animations for this animation group
  31820. */
  31821. readonly targetedAnimations: Array<TargetedAnimation>;
  31822. /**
  31823. * returning the list of animatables controlled by this animation group.
  31824. */
  31825. readonly animatables: Array<Animatable>;
  31826. /**
  31827. * Instantiates a new Animation Group.
  31828. * This helps managing several animations at once.
  31829. * @see http://doc.babylonjs.com/how_to/group
  31830. * @param name Defines the name of the group
  31831. * @param scene Defines the scene the group belongs to
  31832. */
  31833. constructor(
  31834. /** The name of the animation group */
  31835. name: string, scene?: Nullable<Scene>);
  31836. /**
  31837. * Add an animation (with its target) in the group
  31838. * @param animation defines the animation we want to add
  31839. * @param target defines the target of the animation
  31840. * @returns the TargetedAnimation object
  31841. */
  31842. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31843. /**
  31844. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31845. * It can add constant keys at begin or end
  31846. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31847. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31848. * @returns the animation group
  31849. */
  31850. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31851. /**
  31852. * Start all animations on given targets
  31853. * @param loop defines if animations must loop
  31854. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31855. * @param from defines the from key (optional)
  31856. * @param to defines the to key (optional)
  31857. * @returns the current animation group
  31858. */
  31859. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31860. /**
  31861. * Pause all animations
  31862. * @returns the animation group
  31863. */
  31864. pause(): AnimationGroup;
  31865. /**
  31866. * Play all animations to initial state
  31867. * This function will start() the animations if they were not started or will restart() them if they were paused
  31868. * @param loop defines if animations must loop
  31869. * @returns the animation group
  31870. */
  31871. play(loop?: boolean): AnimationGroup;
  31872. /**
  31873. * Reset all animations to initial state
  31874. * @returns the animation group
  31875. */
  31876. reset(): AnimationGroup;
  31877. /**
  31878. * Restart animations from key 0
  31879. * @returns the animation group
  31880. */
  31881. restart(): AnimationGroup;
  31882. /**
  31883. * Stop all animations
  31884. * @returns the animation group
  31885. */
  31886. stop(): AnimationGroup;
  31887. /**
  31888. * Set animation weight for all animatables
  31889. * @param weight defines the weight to use
  31890. * @return the animationGroup
  31891. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31892. */
  31893. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31894. /**
  31895. * Synchronize and normalize all animatables with a source animatable
  31896. * @param root defines the root animatable to synchronize with
  31897. * @return the animationGroup
  31898. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31899. */
  31900. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31901. /**
  31902. * Goes to a specific frame in this animation group
  31903. * @param frame the frame number to go to
  31904. * @return the animationGroup
  31905. */
  31906. goToFrame(frame: number): AnimationGroup;
  31907. /**
  31908. * Dispose all associated resources
  31909. */
  31910. dispose(): void;
  31911. private _checkAnimationGroupEnded;
  31912. /**
  31913. * Returns a new AnimationGroup object parsed from the source provided.
  31914. * @param parsedAnimationGroup defines the source
  31915. * @param scene defines the scene that will receive the animationGroup
  31916. * @returns a new AnimationGroup
  31917. */
  31918. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31919. /**
  31920. * Returns the string "AnimationGroup"
  31921. * @returns "AnimationGroup"
  31922. */
  31923. getClassName(): string;
  31924. /**
  31925. * Creates a detailled string about the object
  31926. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31927. * @returns a string representing the object
  31928. */
  31929. toString(fullDetails?: boolean): string;
  31930. }
  31931. }
  31932. declare module BABYLON {
  31933. /** @hidden */
  31934. export interface ICollisionCoordinator {
  31935. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31936. init(scene: Scene): void;
  31937. destroy(): void;
  31938. onMeshAdded(mesh: AbstractMesh): void;
  31939. onMeshUpdated(mesh: AbstractMesh): void;
  31940. onMeshRemoved(mesh: AbstractMesh): void;
  31941. onGeometryAdded(geometry: Geometry): void;
  31942. onGeometryUpdated(geometry: Geometry): void;
  31943. onGeometryDeleted(geometry: Geometry): void;
  31944. }
  31945. /** @hidden */
  31946. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  31947. private _scene;
  31948. private _scaledPosition;
  31949. private _scaledVelocity;
  31950. private _finalPosition;
  31951. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31952. init(scene: Scene): void;
  31953. destroy(): void;
  31954. onMeshAdded(mesh: AbstractMesh): void;
  31955. onMeshUpdated(mesh: AbstractMesh): void;
  31956. onMeshRemoved(mesh: AbstractMesh): void;
  31957. onGeometryAdded(geometry: Geometry): void;
  31958. onGeometryUpdated(geometry: Geometry): void;
  31959. onGeometryDeleted(geometry: Geometry): void;
  31960. private _collideWithWorld;
  31961. }
  31962. }
  31963. declare module BABYLON {
  31964. /**
  31965. * Define an interface for all classes that will hold resources
  31966. */
  31967. export interface IDisposable {
  31968. /**
  31969. * Releases all held resources
  31970. */
  31971. dispose(): void;
  31972. }
  31973. /** Interface defining initialization parameters for Scene class */
  31974. export interface SceneOptions {
  31975. /**
  31976. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31977. * It will improve performance when the number of geometries becomes important.
  31978. */
  31979. useGeometryUniqueIdsMap?: boolean;
  31980. /**
  31981. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31982. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31983. */
  31984. useMaterialMeshMap?: boolean;
  31985. /**
  31986. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31987. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31988. */
  31989. useClonedMeshhMap?: boolean;
  31990. }
  31991. /**
  31992. * Represents a scene to be rendered by the engine.
  31993. * @see http://doc.babylonjs.com/features/scene
  31994. */
  31995. export class Scene extends AbstractScene implements IAnimatable {
  31996. private static _uniqueIdCounter;
  31997. /** The fog is deactivated */
  31998. static readonly FOGMODE_NONE: number;
  31999. /** The fog density is following an exponential function */
  32000. static readonly FOGMODE_EXP: number;
  32001. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32002. static readonly FOGMODE_EXP2: number;
  32003. /** The fog density is following a linear function. */
  32004. static readonly FOGMODE_LINEAR: number;
  32005. /**
  32006. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32008. */
  32009. static MinDeltaTime: number;
  32010. /**
  32011. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32013. */
  32014. static MaxDeltaTime: number;
  32015. /**
  32016. * Factory used to create the default material.
  32017. * @param name The name of the material to create
  32018. * @param scene The scene to create the material for
  32019. * @returns The default material
  32020. */
  32021. static DefaultMaterialFactory(scene: Scene): Material;
  32022. /** @hidden */
  32023. readonly _isScene: boolean;
  32024. /**
  32025. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32026. */
  32027. autoClear: boolean;
  32028. /**
  32029. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32030. */
  32031. autoClearDepthAndStencil: boolean;
  32032. /**
  32033. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32034. */
  32035. clearColor: Color4;
  32036. /**
  32037. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32038. */
  32039. ambientColor: Color3;
  32040. /** @hidden */
  32041. _environmentBRDFTexture: BaseTexture;
  32042. /** @hidden */
  32043. protected _environmentTexture: Nullable<BaseTexture>;
  32044. /**
  32045. * Texture used in all pbr material as the reflection texture.
  32046. * As in the majority of the scene they are the same (exception for multi room and so on),
  32047. * this is easier to reference from here than from all the materials.
  32048. */
  32049. /**
  32050. * Texture used in all pbr material as the reflection texture.
  32051. * As in the majority of the scene they are the same (exception for multi room and so on),
  32052. * this is easier to set here than in all the materials.
  32053. */
  32054. environmentTexture: Nullable<BaseTexture>;
  32055. /** @hidden */
  32056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32057. /**
  32058. * Default image processing configuration used either in the rendering
  32059. * Forward main pass or through the imageProcessingPostProcess if present.
  32060. * As in the majority of the scene they are the same (exception for multi camera),
  32061. * this is easier to reference from here than from all the materials and post process.
  32062. *
  32063. * No setter as we it is a shared configuration, you can set the values instead.
  32064. */
  32065. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32066. private _forceWireframe;
  32067. /**
  32068. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32069. */
  32070. forceWireframe: boolean;
  32071. private _forcePointsCloud;
  32072. /**
  32073. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32074. */
  32075. forcePointsCloud: boolean;
  32076. /**
  32077. * Gets or sets the active clipplane 1
  32078. */
  32079. clipPlane: Nullable<Plane>;
  32080. /**
  32081. * Gets or sets the active clipplane 2
  32082. */
  32083. clipPlane2: Nullable<Plane>;
  32084. /**
  32085. * Gets or sets the active clipplane 3
  32086. */
  32087. clipPlane3: Nullable<Plane>;
  32088. /**
  32089. * Gets or sets the active clipplane 4
  32090. */
  32091. clipPlane4: Nullable<Plane>;
  32092. /**
  32093. * Gets or sets a boolean indicating if animations are enabled
  32094. */
  32095. animationsEnabled: boolean;
  32096. private _animationPropertiesOverride;
  32097. /**
  32098. * Gets or sets the animation properties override
  32099. */
  32100. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32101. /**
  32102. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32103. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32104. */
  32105. useConstantAnimationDeltaTime: boolean;
  32106. /**
  32107. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32108. * Please note that it requires to run a ray cast through the scene on every frame
  32109. */
  32110. constantlyUpdateMeshUnderPointer: boolean;
  32111. /**
  32112. * Defines the HTML cursor to use when hovering over interactive elements
  32113. */
  32114. hoverCursor: string;
  32115. /**
  32116. * Defines the HTML default cursor to use (empty by default)
  32117. */
  32118. defaultCursor: string;
  32119. /**
  32120. * This is used to call preventDefault() on pointer down
  32121. * in order to block unwanted artifacts like system double clicks
  32122. */
  32123. preventDefaultOnPointerDown: boolean;
  32124. /**
  32125. * This is used to call preventDefault() on pointer up
  32126. * in order to block unwanted artifacts like system double clicks
  32127. */
  32128. preventDefaultOnPointerUp: boolean;
  32129. /**
  32130. * Gets or sets user defined metadata
  32131. */
  32132. metadata: any;
  32133. /**
  32134. * For internal use only. Please do not use.
  32135. */
  32136. reservedDataStore: any;
  32137. /**
  32138. * Gets the name of the plugin used to load this scene (null by default)
  32139. */
  32140. loadingPluginName: string;
  32141. /**
  32142. * Use this array to add regular expressions used to disable offline support for specific urls
  32143. */
  32144. disableOfflineSupportExceptionRules: RegExp[];
  32145. /**
  32146. * An event triggered when the scene is disposed.
  32147. */
  32148. onDisposeObservable: Observable<Scene>;
  32149. private _onDisposeObserver;
  32150. /** Sets a function to be executed when this scene is disposed. */
  32151. onDispose: () => void;
  32152. /**
  32153. * An event triggered before rendering the scene (right after animations and physics)
  32154. */
  32155. onBeforeRenderObservable: Observable<Scene>;
  32156. private _onBeforeRenderObserver;
  32157. /** Sets a function to be executed before rendering this scene */
  32158. beforeRender: Nullable<() => void>;
  32159. /**
  32160. * An event triggered after rendering the scene
  32161. */
  32162. onAfterRenderObservable: Observable<Scene>;
  32163. private _onAfterRenderObserver;
  32164. /** Sets a function to be executed after rendering this scene */
  32165. afterRender: Nullable<() => void>;
  32166. /**
  32167. * An event triggered before animating the scene
  32168. */
  32169. onBeforeAnimationsObservable: Observable<Scene>;
  32170. /**
  32171. * An event triggered after animations processing
  32172. */
  32173. onAfterAnimationsObservable: Observable<Scene>;
  32174. /**
  32175. * An event triggered before draw calls are ready to be sent
  32176. */
  32177. onBeforeDrawPhaseObservable: Observable<Scene>;
  32178. /**
  32179. * An event triggered after draw calls have been sent
  32180. */
  32181. onAfterDrawPhaseObservable: Observable<Scene>;
  32182. /**
  32183. * An event triggered when the scene is ready
  32184. */
  32185. onReadyObservable: Observable<Scene>;
  32186. /**
  32187. * An event triggered before rendering a camera
  32188. */
  32189. onBeforeCameraRenderObservable: Observable<Camera>;
  32190. private _onBeforeCameraRenderObserver;
  32191. /** Sets a function to be executed before rendering a camera*/
  32192. beforeCameraRender: () => void;
  32193. /**
  32194. * An event triggered after rendering a camera
  32195. */
  32196. onAfterCameraRenderObservable: Observable<Camera>;
  32197. private _onAfterCameraRenderObserver;
  32198. /** Sets a function to be executed after rendering a camera*/
  32199. afterCameraRender: () => void;
  32200. /**
  32201. * An event triggered when active meshes evaluation is about to start
  32202. */
  32203. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32204. /**
  32205. * An event triggered when active meshes evaluation is done
  32206. */
  32207. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32208. /**
  32209. * An event triggered when particles rendering is about to start
  32210. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32211. */
  32212. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32213. /**
  32214. * An event triggered when particles rendering is done
  32215. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32216. */
  32217. onAfterParticlesRenderingObservable: Observable<Scene>;
  32218. /**
  32219. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32220. */
  32221. onDataLoadedObservable: Observable<Scene>;
  32222. /**
  32223. * An event triggered when a camera is created
  32224. */
  32225. onNewCameraAddedObservable: Observable<Camera>;
  32226. /**
  32227. * An event triggered when a camera is removed
  32228. */
  32229. onCameraRemovedObservable: Observable<Camera>;
  32230. /**
  32231. * An event triggered when a light is created
  32232. */
  32233. onNewLightAddedObservable: Observable<Light>;
  32234. /**
  32235. * An event triggered when a light is removed
  32236. */
  32237. onLightRemovedObservable: Observable<Light>;
  32238. /**
  32239. * An event triggered when a geometry is created
  32240. */
  32241. onNewGeometryAddedObservable: Observable<Geometry>;
  32242. /**
  32243. * An event triggered when a geometry is removed
  32244. */
  32245. onGeometryRemovedObservable: Observable<Geometry>;
  32246. /**
  32247. * An event triggered when a transform node is created
  32248. */
  32249. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32250. /**
  32251. * An event triggered when a transform node is removed
  32252. */
  32253. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32254. /**
  32255. * An event triggered when a mesh is created
  32256. */
  32257. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32258. /**
  32259. * An event triggered when a mesh is removed
  32260. */
  32261. onMeshRemovedObservable: Observable<AbstractMesh>;
  32262. /**
  32263. * An event triggered when a material is created
  32264. */
  32265. onNewMaterialAddedObservable: Observable<Material>;
  32266. /**
  32267. * An event triggered when a material is removed
  32268. */
  32269. onMaterialRemovedObservable: Observable<Material>;
  32270. /**
  32271. * An event triggered when a texture is created
  32272. */
  32273. onNewTextureAddedObservable: Observable<BaseTexture>;
  32274. /**
  32275. * An event triggered when a texture is removed
  32276. */
  32277. onTextureRemovedObservable: Observable<BaseTexture>;
  32278. /**
  32279. * An event triggered when render targets are about to be rendered
  32280. * Can happen multiple times per frame.
  32281. */
  32282. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32283. /**
  32284. * An event triggered when render targets were rendered.
  32285. * Can happen multiple times per frame.
  32286. */
  32287. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32288. /**
  32289. * An event triggered before calculating deterministic simulation step
  32290. */
  32291. onBeforeStepObservable: Observable<Scene>;
  32292. /**
  32293. * An event triggered after calculating deterministic simulation step
  32294. */
  32295. onAfterStepObservable: Observable<Scene>;
  32296. /**
  32297. * An event triggered when the activeCamera property is updated
  32298. */
  32299. onActiveCameraChanged: Observable<Scene>;
  32300. /**
  32301. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32302. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32303. * 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)
  32304. */
  32305. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32306. /**
  32307. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32308. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32309. * 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)
  32310. */
  32311. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32312. /**
  32313. * This Observable will when a mesh has been imported into the scene.
  32314. */
  32315. onMeshImportedObservable: Observable<AbstractMesh>;
  32316. private _registeredForLateAnimationBindings;
  32317. /**
  32318. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32319. */
  32320. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32321. /**
  32322. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32323. */
  32324. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32325. /**
  32326. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32327. */
  32328. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32329. private _onPointerMove;
  32330. private _onPointerDown;
  32331. private _onPointerUp;
  32332. /** Callback called when a pointer move is detected */
  32333. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32334. /** Callback called when a pointer down is detected */
  32335. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32336. /** Callback called when a pointer up is detected */
  32337. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32338. /** Callback called when a pointer pick is detected */
  32339. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32340. /**
  32341. * 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).
  32342. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32343. */
  32344. onPrePointerObservable: Observable<PointerInfoPre>;
  32345. /**
  32346. * Observable event triggered each time an input event is received from the rendering canvas
  32347. */
  32348. onPointerObservable: Observable<PointerInfo>;
  32349. /**
  32350. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32351. */
  32352. readonly unTranslatedPointer: Vector2;
  32353. /** The distance in pixel that you have to move to prevent some events */
  32354. static DragMovementThreshold: number;
  32355. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32356. static LongPressDelay: number;
  32357. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32358. static DoubleClickDelay: number;
  32359. /** If you need to check double click without raising a single click at first click, enable this flag */
  32360. static ExclusiveDoubleClickMode: boolean;
  32361. private _initClickEvent;
  32362. private _initActionManager;
  32363. private _delayedSimpleClick;
  32364. private _delayedSimpleClickTimeout;
  32365. private _previousDelayedSimpleClickTimeout;
  32366. private _meshPickProceed;
  32367. private _previousButtonPressed;
  32368. private _currentPickResult;
  32369. private _previousPickResult;
  32370. private _totalPointersPressed;
  32371. private _doubleClickOccured;
  32372. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32373. cameraToUseForPointers: Nullable<Camera>;
  32374. private _pointerX;
  32375. private _pointerY;
  32376. private _unTranslatedPointerX;
  32377. private _unTranslatedPointerY;
  32378. private _startingPointerPosition;
  32379. private _previousStartingPointerPosition;
  32380. private _startingPointerTime;
  32381. private _previousStartingPointerTime;
  32382. private _pointerCaptures;
  32383. private _timeAccumulator;
  32384. private _currentStepId;
  32385. private _currentInternalStep;
  32386. /** @hidden */
  32387. _mirroredCameraPosition: Nullable<Vector3>;
  32388. /**
  32389. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32390. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32391. */
  32392. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32393. /**
  32394. * Observable event triggered each time an keyboard event is received from the hosting window
  32395. */
  32396. onKeyboardObservable: Observable<KeyboardInfo>;
  32397. private _onKeyDown;
  32398. private _onKeyUp;
  32399. private _onCanvasFocusObserver;
  32400. private _onCanvasBlurObserver;
  32401. private _useRightHandedSystem;
  32402. /**
  32403. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32404. */
  32405. useRightHandedSystem: boolean;
  32406. /**
  32407. * Sets the step Id used by deterministic lock step
  32408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32409. * @param newStepId defines the step Id
  32410. */
  32411. setStepId(newStepId: number): void;
  32412. /**
  32413. * Gets the step Id used by deterministic lock step
  32414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32415. * @returns the step Id
  32416. */
  32417. getStepId(): number;
  32418. /**
  32419. * Gets the internal step used by deterministic lock step
  32420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32421. * @returns the internal step
  32422. */
  32423. getInternalStep(): number;
  32424. private _fogEnabled;
  32425. /**
  32426. * Gets or sets a boolean indicating if fog is enabled on this scene
  32427. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32428. * (Default is true)
  32429. */
  32430. fogEnabled: boolean;
  32431. private _fogMode;
  32432. /**
  32433. * Gets or sets the fog mode to use
  32434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32435. * | mode | value |
  32436. * | --- | --- |
  32437. * | FOGMODE_NONE | 0 |
  32438. * | FOGMODE_EXP | 1 |
  32439. * | FOGMODE_EXP2 | 2 |
  32440. * | FOGMODE_LINEAR | 3 |
  32441. */
  32442. fogMode: number;
  32443. /**
  32444. * Gets or sets the fog color to use
  32445. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32446. * (Default is Color3(0.2, 0.2, 0.3))
  32447. */
  32448. fogColor: Color3;
  32449. /**
  32450. * Gets or sets the fog density to use
  32451. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32452. * (Default is 0.1)
  32453. */
  32454. fogDensity: number;
  32455. /**
  32456. * Gets or sets the fog start distance to use
  32457. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32458. * (Default is 0)
  32459. */
  32460. fogStart: number;
  32461. /**
  32462. * Gets or sets the fog end distance to use
  32463. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32464. * (Default is 1000)
  32465. */
  32466. fogEnd: number;
  32467. private _shadowsEnabled;
  32468. /**
  32469. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32470. */
  32471. shadowsEnabled: boolean;
  32472. private _lightsEnabled;
  32473. /**
  32474. * Gets or sets a boolean indicating if lights are enabled on this scene
  32475. */
  32476. lightsEnabled: boolean;
  32477. /** All of the active cameras added to this scene. */
  32478. activeCameras: Camera[];
  32479. private _activeCamera;
  32480. /** Gets or sets the current active camera */
  32481. activeCamera: Nullable<Camera>;
  32482. private _defaultMaterial;
  32483. /** The default material used on meshes when no material is affected */
  32484. /** The default material used on meshes when no material is affected */
  32485. defaultMaterial: Material;
  32486. private _texturesEnabled;
  32487. /**
  32488. * Gets or sets a boolean indicating if textures are enabled on this scene
  32489. */
  32490. texturesEnabled: boolean;
  32491. /**
  32492. * Gets or sets a boolean indicating if particles are enabled on this scene
  32493. */
  32494. particlesEnabled: boolean;
  32495. /**
  32496. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32497. */
  32498. spritesEnabled: boolean;
  32499. private _skeletonsEnabled;
  32500. /**
  32501. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32502. */
  32503. skeletonsEnabled: boolean;
  32504. /**
  32505. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32506. */
  32507. lensFlaresEnabled: boolean;
  32508. /**
  32509. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32511. */
  32512. collisionsEnabled: boolean;
  32513. /** @hidden */
  32514. collisionCoordinator: ICollisionCoordinator;
  32515. /**
  32516. * Defines the gravity applied to this scene (used only for collisions)
  32517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32518. */
  32519. gravity: Vector3;
  32520. /**
  32521. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32522. */
  32523. postProcessesEnabled: boolean;
  32524. /**
  32525. * The list of postprocesses added to the scene
  32526. */
  32527. postProcesses: PostProcess[];
  32528. /**
  32529. * Gets the current postprocess manager
  32530. */
  32531. postProcessManager: PostProcessManager;
  32532. /**
  32533. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32534. */
  32535. renderTargetsEnabled: boolean;
  32536. /**
  32537. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32538. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32539. */
  32540. dumpNextRenderTargets: boolean;
  32541. /**
  32542. * The list of user defined render targets added to the scene
  32543. */
  32544. customRenderTargets: RenderTargetTexture[];
  32545. /**
  32546. * Defines if texture loading must be delayed
  32547. * If true, textures will only be loaded when they need to be rendered
  32548. */
  32549. useDelayedTextureLoading: boolean;
  32550. /**
  32551. * Gets the list of meshes imported to the scene through SceneLoader
  32552. */
  32553. importedMeshesFiles: String[];
  32554. /**
  32555. * Gets or sets a boolean indicating if probes are enabled on this scene
  32556. */
  32557. probesEnabled: boolean;
  32558. /**
  32559. * Gets or sets the current offline provider to use to store scene data
  32560. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32561. */
  32562. offlineProvider: IOfflineProvider;
  32563. /**
  32564. * Gets or sets the action manager associated with the scene
  32565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32566. */
  32567. actionManager: ActionManager;
  32568. private _meshesForIntersections;
  32569. /**
  32570. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32571. */
  32572. proceduralTexturesEnabled: boolean;
  32573. private _engine;
  32574. private _totalVertices;
  32575. /** @hidden */
  32576. _activeIndices: PerfCounter;
  32577. /** @hidden */
  32578. _activeParticles: PerfCounter;
  32579. /** @hidden */
  32580. _activeBones: PerfCounter;
  32581. private _animationRatio;
  32582. private _animationTimeLast;
  32583. private _animationTime;
  32584. /**
  32585. * Gets or sets a general scale for animation speed
  32586. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32587. */
  32588. animationTimeScale: number;
  32589. /** @hidden */
  32590. _cachedMaterial: Nullable<Material>;
  32591. /** @hidden */
  32592. _cachedEffect: Nullable<Effect>;
  32593. /** @hidden */
  32594. _cachedVisibility: Nullable<number>;
  32595. private _renderId;
  32596. private _frameId;
  32597. private _executeWhenReadyTimeoutId;
  32598. private _intermediateRendering;
  32599. private _viewUpdateFlag;
  32600. private _projectionUpdateFlag;
  32601. private _alternateViewUpdateFlag;
  32602. private _alternateProjectionUpdateFlag;
  32603. /** @hidden */
  32604. _toBeDisposed: Nullable<IDisposable>[];
  32605. private _activeRequests;
  32606. private _pendingData;
  32607. private _isDisposed;
  32608. /**
  32609. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32610. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32611. */
  32612. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32613. private _activeMeshes;
  32614. private _processedMaterials;
  32615. private _renderTargets;
  32616. /** @hidden */
  32617. _activeParticleSystems: SmartArray<IParticleSystem>;
  32618. private _activeSkeletons;
  32619. private _softwareSkinnedMeshes;
  32620. private _renderingManager;
  32621. /** @hidden */
  32622. _activeAnimatables: Animatable[];
  32623. private _transformMatrix;
  32624. private _sceneUbo;
  32625. private _alternateSceneUbo;
  32626. private _pickWithRayInverseMatrix;
  32627. private _viewMatrix;
  32628. private _projectionMatrix;
  32629. private _alternateViewMatrix;
  32630. private _alternateProjectionMatrix;
  32631. private _alternateTransformMatrix;
  32632. private _useAlternateCameraConfiguration;
  32633. private _alternateRendering;
  32634. private _wheelEventName;
  32635. /** @hidden */
  32636. _forcedViewPosition: Nullable<Vector3>;
  32637. /** @hidden */
  32638. readonly _isAlternateRenderingEnabled: boolean;
  32639. private _frustumPlanes;
  32640. /**
  32641. * Gets the list of frustum planes (built from the active camera)
  32642. */
  32643. readonly frustumPlanes: Plane[];
  32644. /**
  32645. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32646. * This is useful if there are more lights that the maximum simulteanous authorized
  32647. */
  32648. requireLightSorting: boolean;
  32649. /** @hidden */
  32650. readonly useMaterialMeshMap: boolean;
  32651. /** @hidden */
  32652. readonly useClonedMeshhMap: boolean;
  32653. private _pointerOverMesh;
  32654. private _pickedDownMesh;
  32655. private _pickedUpMesh;
  32656. private _externalData;
  32657. private _uid;
  32658. /**
  32659. * @hidden
  32660. * Backing store of defined scene components.
  32661. */
  32662. _components: ISceneComponent[];
  32663. /**
  32664. * @hidden
  32665. * Backing store of defined scene components.
  32666. */
  32667. _serializableComponents: ISceneSerializableComponent[];
  32668. /**
  32669. * List of components to register on the next registration step.
  32670. */
  32671. private _transientComponents;
  32672. /**
  32673. * Registers the transient components if needed.
  32674. */
  32675. private _registerTransientComponents;
  32676. /**
  32677. * @hidden
  32678. * Add a component to the scene.
  32679. * Note that the ccomponent could be registered on th next frame if this is called after
  32680. * the register component stage.
  32681. * @param component Defines the component to add to the scene
  32682. */
  32683. _addComponent(component: ISceneComponent): void;
  32684. /**
  32685. * @hidden
  32686. * Gets a component from the scene.
  32687. * @param name defines the name of the component to retrieve
  32688. * @returns the component or null if not present
  32689. */
  32690. _getComponent(name: string): Nullable<ISceneComponent>;
  32691. /**
  32692. * @hidden
  32693. * Defines the actions happening before camera updates.
  32694. */
  32695. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32696. /**
  32697. * @hidden
  32698. * Defines the actions happening before clear the canvas.
  32699. */
  32700. _beforeClearStage: Stage<SimpleStageAction>;
  32701. /**
  32702. * @hidden
  32703. * Defines the actions when collecting render targets for the frame.
  32704. */
  32705. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32706. /**
  32707. * @hidden
  32708. * Defines the actions happening for one camera in the frame.
  32709. */
  32710. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32711. /**
  32712. * @hidden
  32713. * Defines the actions happening during the per mesh ready checks.
  32714. */
  32715. _isReadyForMeshStage: Stage<MeshStageAction>;
  32716. /**
  32717. * @hidden
  32718. * Defines the actions happening before evaluate active mesh checks.
  32719. */
  32720. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32721. /**
  32722. * @hidden
  32723. * Defines the actions happening during the evaluate sub mesh checks.
  32724. */
  32725. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32726. /**
  32727. * @hidden
  32728. * Defines the actions happening during the active mesh stage.
  32729. */
  32730. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32731. /**
  32732. * @hidden
  32733. * Defines the actions happening during the per camera render target step.
  32734. */
  32735. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32736. /**
  32737. * @hidden
  32738. * Defines the actions happening just before the active camera is drawing.
  32739. */
  32740. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32741. /**
  32742. * @hidden
  32743. * Defines the actions happening just before a render target is drawing.
  32744. */
  32745. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32746. /**
  32747. * @hidden
  32748. * Defines the actions happening just before a rendering group is drawing.
  32749. */
  32750. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32751. /**
  32752. * @hidden
  32753. * Defines the actions happening just before a mesh is drawing.
  32754. */
  32755. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32756. /**
  32757. * @hidden
  32758. * Defines the actions happening just after a mesh has been drawn.
  32759. */
  32760. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32761. /**
  32762. * @hidden
  32763. * Defines the actions happening just after a rendering group has been drawn.
  32764. */
  32765. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32766. /**
  32767. * @hidden
  32768. * Defines the actions happening just after the active camera has been drawn.
  32769. */
  32770. _afterCameraDrawStage: Stage<CameraStageAction>;
  32771. /**
  32772. * @hidden
  32773. * Defines the actions happening just after a render target has been drawn.
  32774. */
  32775. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32776. /**
  32777. * @hidden
  32778. * Defines the actions happening just after rendering all cameras and computing intersections.
  32779. */
  32780. _afterRenderStage: Stage<SimpleStageAction>;
  32781. /**
  32782. * @hidden
  32783. * Defines the actions happening when a pointer move event happens.
  32784. */
  32785. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32786. /**
  32787. * @hidden
  32788. * Defines the actions happening when a pointer down event happens.
  32789. */
  32790. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32791. /**
  32792. * @hidden
  32793. * Defines the actions happening when a pointer up event happens.
  32794. */
  32795. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32796. /**
  32797. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32798. */
  32799. private geometriesByUniqueId;
  32800. /**
  32801. * Creates a new Scene
  32802. * @param engine defines the engine to use to render this scene
  32803. */
  32804. constructor(engine: Engine, options?: SceneOptions);
  32805. private _defaultMeshCandidates;
  32806. /**
  32807. * @hidden
  32808. */
  32809. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32810. private _defaultSubMeshCandidates;
  32811. /**
  32812. * @hidden
  32813. */
  32814. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32815. /**
  32816. * Sets the default candidate providers for the scene.
  32817. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32818. * and getCollidingSubMeshCandidates to their default function
  32819. */
  32820. setDefaultCandidateProviders(): void;
  32821. /**
  32822. * Gets a boolean indicating if collisions are processed on a web worker
  32823. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  32824. */
  32825. workerCollisions: boolean;
  32826. /**
  32827. * Gets the mesh that is currently under the pointer
  32828. */
  32829. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32830. /**
  32831. * Gets or sets the current on-screen X position of the pointer
  32832. */
  32833. pointerX: number;
  32834. /**
  32835. * Gets or sets the current on-screen Y position of the pointer
  32836. */
  32837. pointerY: number;
  32838. /**
  32839. * Gets the cached material (ie. the latest rendered one)
  32840. * @returns the cached material
  32841. */
  32842. getCachedMaterial(): Nullable<Material>;
  32843. /**
  32844. * Gets the cached effect (ie. the latest rendered one)
  32845. * @returns the cached effect
  32846. */
  32847. getCachedEffect(): Nullable<Effect>;
  32848. /**
  32849. * Gets the cached visibility state (ie. the latest rendered one)
  32850. * @returns the cached visibility state
  32851. */
  32852. getCachedVisibility(): Nullable<number>;
  32853. /**
  32854. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32855. * @param material defines the current material
  32856. * @param effect defines the current effect
  32857. * @param visibility defines the current visibility state
  32858. * @returns true if one parameter is not cached
  32859. */
  32860. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32861. /**
  32862. * Gets the engine associated with the scene
  32863. * @returns an Engine
  32864. */
  32865. getEngine(): Engine;
  32866. /**
  32867. * Gets the total number of vertices rendered per frame
  32868. * @returns the total number of vertices rendered per frame
  32869. */
  32870. getTotalVertices(): number;
  32871. /**
  32872. * Gets the performance counter for total vertices
  32873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32874. */
  32875. readonly totalVerticesPerfCounter: PerfCounter;
  32876. /**
  32877. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32878. * @returns the total number of active indices rendered per frame
  32879. */
  32880. getActiveIndices(): number;
  32881. /**
  32882. * Gets the performance counter for active indices
  32883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32884. */
  32885. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32886. /**
  32887. * Gets the total number of active particles rendered per frame
  32888. * @returns the total number of active particles rendered per frame
  32889. */
  32890. getActiveParticles(): number;
  32891. /**
  32892. * Gets the performance counter for active particles
  32893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32894. */
  32895. readonly activeParticlesPerfCounter: PerfCounter;
  32896. /**
  32897. * Gets the total number of active bones rendered per frame
  32898. * @returns the total number of active bones rendered per frame
  32899. */
  32900. getActiveBones(): number;
  32901. /**
  32902. * Gets the performance counter for active bones
  32903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32904. */
  32905. readonly activeBonesPerfCounter: PerfCounter;
  32906. /**
  32907. * Gets the array of active meshes
  32908. * @returns an array of AbstractMesh
  32909. */
  32910. getActiveMeshes(): SmartArray<AbstractMesh>;
  32911. /**
  32912. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32913. * @returns a number
  32914. */
  32915. getAnimationRatio(): number;
  32916. /**
  32917. * Gets an unique Id for the current render phase
  32918. * @returns a number
  32919. */
  32920. getRenderId(): number;
  32921. /**
  32922. * Gets an unique Id for the current frame
  32923. * @returns a number
  32924. */
  32925. getFrameId(): number;
  32926. /** Call this function if you want to manually increment the render Id*/
  32927. incrementRenderId(): void;
  32928. private _updatePointerPosition;
  32929. private _createUbo;
  32930. private _createAlternateUbo;
  32931. private _setRayOnPointerInfo;
  32932. /**
  32933. * Use this method to simulate a pointer move on a mesh
  32934. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32935. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32936. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32937. * @returns the current scene
  32938. */
  32939. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32940. private _processPointerMove;
  32941. private _checkPrePointerObservable;
  32942. /**
  32943. * Use this method to simulate a pointer down on a mesh
  32944. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32945. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32946. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32947. * @returns the current scene
  32948. */
  32949. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32950. private _processPointerDown;
  32951. /**
  32952. * Use this method to simulate a pointer up on a mesh
  32953. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32954. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32955. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32956. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32957. * @returns the current scene
  32958. */
  32959. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32960. private _processPointerUp;
  32961. /**
  32962. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32963. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32964. * @returns true if the pointer was captured
  32965. */
  32966. isPointerCaptured(pointerId?: number): boolean;
  32967. /** @hidden */
  32968. _isPointerSwiping(): boolean;
  32969. /**
  32970. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32971. * @param attachUp defines if you want to attach events to pointerup
  32972. * @param attachDown defines if you want to attach events to pointerdown
  32973. * @param attachMove defines if you want to attach events to pointermove
  32974. */
  32975. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32976. /** Detaches all event handlers*/
  32977. detachControl(): void;
  32978. /**
  32979. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32980. * Delay loaded resources are not taking in account
  32981. * @return true if all required resources are ready
  32982. */
  32983. isReady(): boolean;
  32984. /** Resets all cached information relative to material (including effect and visibility) */
  32985. resetCachedMaterial(): void;
  32986. /**
  32987. * Registers a function to be called before every frame render
  32988. * @param func defines the function to register
  32989. */
  32990. registerBeforeRender(func: () => void): void;
  32991. /**
  32992. * Unregisters a function called before every frame render
  32993. * @param func defines the function to unregister
  32994. */
  32995. unregisterBeforeRender(func: () => void): void;
  32996. /**
  32997. * Registers a function to be called after every frame render
  32998. * @param func defines the function to register
  32999. */
  33000. registerAfterRender(func: () => void): void;
  33001. /**
  33002. * Unregisters a function called after every frame render
  33003. * @param func defines the function to unregister
  33004. */
  33005. unregisterAfterRender(func: () => void): void;
  33006. private _executeOnceBeforeRender;
  33007. /**
  33008. * The provided function will run before render once and will be disposed afterwards.
  33009. * A timeout delay can be provided so that the function will be executed in N ms.
  33010. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33011. * @param func The function to be executed.
  33012. * @param timeout optional delay in ms
  33013. */
  33014. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33015. /** @hidden */
  33016. _addPendingData(data: any): void;
  33017. /** @hidden */
  33018. _removePendingData(data: any): void;
  33019. /**
  33020. * Returns the number of items waiting to be loaded
  33021. * @returns the number of items waiting to be loaded
  33022. */
  33023. getWaitingItemsCount(): number;
  33024. /**
  33025. * Returns a boolean indicating if the scene is still loading data
  33026. */
  33027. readonly isLoading: boolean;
  33028. /**
  33029. * Registers a function to be executed when the scene is ready
  33030. * @param {Function} func - the function to be executed
  33031. */
  33032. executeWhenReady(func: () => void): void;
  33033. /**
  33034. * Returns a promise that resolves when the scene is ready
  33035. * @returns A promise that resolves when the scene is ready
  33036. */
  33037. whenReadyAsync(): Promise<void>;
  33038. /** @hidden */
  33039. _checkIsReady(): void;
  33040. /**
  33041. * Will start the animation sequence of a given target
  33042. * @param target defines the target
  33043. * @param from defines from which frame should animation start
  33044. * @param to defines until which frame should animation run.
  33045. * @param weight defines the weight to apply to the animation (1.0 by default)
  33046. * @param loop defines if the animation loops
  33047. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33048. * @param onAnimationEnd defines the function to be executed when the animation ends
  33049. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33050. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33051. * @param onAnimationLoop defines the callback to call when an animation loops
  33052. * @returns the animatable object created for this animation
  33053. */
  33054. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33055. /**
  33056. * Will start the animation sequence of a given target
  33057. * @param target defines the target
  33058. * @param from defines from which frame should animation start
  33059. * @param to defines until which frame should animation run.
  33060. * @param loop defines if the animation loops
  33061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33062. * @param onAnimationEnd defines the function to be executed when the animation ends
  33063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33065. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  33066. * @param onAnimationLoop defines the callback to call when an animation loops
  33067. * @returns the animatable object created for this animation
  33068. */
  33069. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33070. /**
  33071. * Will start the animation sequence of a given target and its hierarchy
  33072. * @param target defines the target
  33073. * @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.
  33074. * @param from defines from which frame should animation start
  33075. * @param to defines until which frame should animation run.
  33076. * @param loop defines if the animation loops
  33077. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33078. * @param onAnimationEnd defines the function to be executed when the animation ends
  33079. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33080. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33081. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33082. * @param onAnimationLoop defines the callback to call when an animation loops
  33083. * @returns the list of created animatables
  33084. */
  33085. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  33086. /**
  33087. * Begin a new animation on a given node
  33088. * @param target defines the target where the animation will take place
  33089. * @param animations defines the list of animations to start
  33090. * @param from defines the initial value
  33091. * @param to defines the final value
  33092. * @param loop defines if you want animation to loop (off by default)
  33093. * @param speedRatio defines the speed ratio to apply to all animations
  33094. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33095. * @param onAnimationLoop defines the callback to call when an animation loops
  33096. * @returns the list of created animatables
  33097. */
  33098. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  33099. /**
  33100. * Begin a new animation on a given node and its hierarchy
  33101. * @param target defines the root node where the animation will take place
  33102. * @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.
  33103. * @param animations defines the list of animations to start
  33104. * @param from defines the initial value
  33105. * @param to defines the final value
  33106. * @param loop defines if you want animation to loop (off by default)
  33107. * @param speedRatio defines the speed ratio to apply to all animations
  33108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33109. * @param onAnimationLoop defines the callback to call when an animation loops
  33110. * @returns the list of animatables created for all nodes
  33111. */
  33112. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  33113. /**
  33114. * Gets the animatable associated with a specific target
  33115. * @param target defines the target of the animatable
  33116. * @returns the required animatable if found
  33117. */
  33118. getAnimatableByTarget(target: any): Nullable<Animatable>;
  33119. /**
  33120. * Gets all animatables associated with a given target
  33121. * @param target defines the target to look animatables for
  33122. * @returns an array of Animatables
  33123. */
  33124. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  33125. /**
  33126. * Gets all animatable attached to the scene
  33127. */
  33128. readonly animatables: Animatable[];
  33129. /**
  33130. * Will stop the animation of the given target
  33131. * @param target - the target
  33132. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33133. * @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)
  33134. */
  33135. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33136. /**
  33137. * Stops and removes all animations that have been applied to the scene
  33138. */
  33139. stopAllAnimations(): void;
  33140. /**
  33141. * Resets the last animation time frame.
  33142. * Useful to override when animations start running when loading a scene for the first time.
  33143. */
  33144. resetLastAnimationTimeFrame(): void;
  33145. private _animate;
  33146. /** @hidden */
  33147. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  33148. private _processLateAnimationBindingsForMatrices;
  33149. private _processLateAnimationBindingsForQuaternions;
  33150. private _processLateAnimationBindings;
  33151. /** @hidden */
  33152. _switchToAlternateCameraConfiguration(active: boolean): void;
  33153. /**
  33154. * Gets the current view matrix
  33155. * @returns a Matrix
  33156. */
  33157. getViewMatrix(): Matrix;
  33158. /**
  33159. * Gets the current projection matrix
  33160. * @returns a Matrix
  33161. */
  33162. getProjectionMatrix(): Matrix;
  33163. /**
  33164. * Gets the current transform matrix
  33165. * @returns a Matrix made of View * Projection
  33166. */
  33167. getTransformMatrix(): Matrix;
  33168. /**
  33169. * Sets the current transform matrix
  33170. * @param view defines the View matrix to use
  33171. * @param projection defines the Projection matrix to use
  33172. */
  33173. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33174. /** @hidden */
  33175. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33176. /**
  33177. * Gets the uniform buffer used to store scene data
  33178. * @returns a UniformBuffer
  33179. */
  33180. getSceneUniformBuffer(): UniformBuffer;
  33181. /**
  33182. * Gets an unique (relatively to the current scene) Id
  33183. * @returns an unique number for the scene
  33184. */
  33185. getUniqueId(): number;
  33186. /**
  33187. * Add a mesh to the list of scene's meshes
  33188. * @param newMesh defines the mesh to add
  33189. * @param recursive if all child meshes should also be added to the scene
  33190. */
  33191. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33192. /**
  33193. * Remove a mesh for the list of scene's meshes
  33194. * @param toRemove defines the mesh to remove
  33195. * @param recursive if all child meshes should also be removed from the scene
  33196. * @returns the index where the mesh was in the mesh list
  33197. */
  33198. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33199. /**
  33200. * Add a transform node to the list of scene's transform nodes
  33201. * @param newTransformNode defines the transform node to add
  33202. */
  33203. addTransformNode(newTransformNode: TransformNode): void;
  33204. /**
  33205. * Remove a transform node for the list of scene's transform nodes
  33206. * @param toRemove defines the transform node to remove
  33207. * @returns the index where the transform node was in the transform node list
  33208. */
  33209. removeTransformNode(toRemove: TransformNode): number;
  33210. /**
  33211. * Remove a skeleton for the list of scene's skeletons
  33212. * @param toRemove defines the skeleton to remove
  33213. * @returns the index where the skeleton was in the skeleton list
  33214. */
  33215. removeSkeleton(toRemove: Skeleton): number;
  33216. /**
  33217. * Remove a morph target for the list of scene's morph targets
  33218. * @param toRemove defines the morph target to remove
  33219. * @returns the index where the morph target was in the morph target list
  33220. */
  33221. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33222. /**
  33223. * Remove a light for the list of scene's lights
  33224. * @param toRemove defines the light to remove
  33225. * @returns the index where the light was in the light list
  33226. */
  33227. removeLight(toRemove: Light): number;
  33228. /**
  33229. * Remove a camera for the list of scene's cameras
  33230. * @param toRemove defines the camera to remove
  33231. * @returns the index where the camera was in the camera list
  33232. */
  33233. removeCamera(toRemove: Camera): number;
  33234. /**
  33235. * Remove a particle system for the list of scene's particle systems
  33236. * @param toRemove defines the particle system to remove
  33237. * @returns the index where the particle system was in the particle system list
  33238. */
  33239. removeParticleSystem(toRemove: IParticleSystem): number;
  33240. /**
  33241. * Remove a animation for the list of scene's animations
  33242. * @param toRemove defines the animation to remove
  33243. * @returns the index where the animation was in the animation list
  33244. */
  33245. removeAnimation(toRemove: Animation): number;
  33246. /**
  33247. * Removes the given animation group from this scene.
  33248. * @param toRemove The animation group to remove
  33249. * @returns The index of the removed animation group
  33250. */
  33251. removeAnimationGroup(toRemove: AnimationGroup): number;
  33252. /**
  33253. * Removes the given multi-material from this scene.
  33254. * @param toRemove The multi-material to remove
  33255. * @returns The index of the removed multi-material
  33256. */
  33257. removeMultiMaterial(toRemove: MultiMaterial): number;
  33258. /**
  33259. * Removes the given material from this scene.
  33260. * @param toRemove The material to remove
  33261. * @returns The index of the removed material
  33262. */
  33263. removeMaterial(toRemove: Material): number;
  33264. /**
  33265. * Removes the given action manager from this scene.
  33266. * @param toRemove The action manager to remove
  33267. * @returns The index of the removed action manager
  33268. */
  33269. removeActionManager(toRemove: ActionManager): number;
  33270. /**
  33271. * Removes the given texture from this scene.
  33272. * @param toRemove The texture to remove
  33273. * @returns The index of the removed texture
  33274. */
  33275. removeTexture(toRemove: BaseTexture): number;
  33276. /**
  33277. * Adds the given light to this scene
  33278. * @param newLight The light to add
  33279. */
  33280. addLight(newLight: Light): void;
  33281. /**
  33282. * Sorts the list list based on light priorities
  33283. */
  33284. sortLightsByPriority(): void;
  33285. /**
  33286. * Adds the given camera to this scene
  33287. * @param newCamera The camera to add
  33288. */
  33289. addCamera(newCamera: Camera): void;
  33290. /**
  33291. * Adds the given skeleton to this scene
  33292. * @param newSkeleton The skeleton to add
  33293. */
  33294. addSkeleton(newSkeleton: Skeleton): void;
  33295. /**
  33296. * Adds the given particle system to this scene
  33297. * @param newParticleSystem The particle system to add
  33298. */
  33299. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33300. /**
  33301. * Adds the given animation to this scene
  33302. * @param newAnimation The animation to add
  33303. */
  33304. addAnimation(newAnimation: Animation): void;
  33305. /**
  33306. * Adds the given animation group to this scene.
  33307. * @param newAnimationGroup The animation group to add
  33308. */
  33309. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33310. /**
  33311. * Adds the given multi-material to this scene
  33312. * @param newMultiMaterial The multi-material to add
  33313. */
  33314. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33315. /**
  33316. * Adds the given material to this scene
  33317. * @param newMaterial The material to add
  33318. */
  33319. addMaterial(newMaterial: Material): void;
  33320. /**
  33321. * Adds the given morph target to this scene
  33322. * @param newMorphTargetManager The morph target to add
  33323. */
  33324. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33325. /**
  33326. * Adds the given geometry to this scene
  33327. * @param newGeometry The geometry to add
  33328. */
  33329. addGeometry(newGeometry: Geometry): void;
  33330. /**
  33331. * Adds the given action manager to this scene
  33332. * @param newActionManager The action manager to add
  33333. */
  33334. addActionManager(newActionManager: ActionManager): void;
  33335. /**
  33336. * Adds the given texture to this scene.
  33337. * @param newTexture The texture to add
  33338. */
  33339. addTexture(newTexture: BaseTexture): void;
  33340. /**
  33341. * Switch active camera
  33342. * @param newCamera defines the new active camera
  33343. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33344. */
  33345. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33346. /**
  33347. * sets the active camera of the scene using its ID
  33348. * @param id defines the camera's ID
  33349. * @return the new active camera or null if none found.
  33350. */
  33351. setActiveCameraByID(id: string): Nullable<Camera>;
  33352. /**
  33353. * sets the active camera of the scene using its name
  33354. * @param name defines the camera's name
  33355. * @returns the new active camera or null if none found.
  33356. */
  33357. setActiveCameraByName(name: string): Nullable<Camera>;
  33358. /**
  33359. * get an animation group using its name
  33360. * @param name defines the material's name
  33361. * @return the animation group or null if none found.
  33362. */
  33363. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33364. /**
  33365. * get a material using its id
  33366. * @param id defines the material's ID
  33367. * @return the material or null if none found.
  33368. */
  33369. getMaterialByID(id: string): Nullable<Material>;
  33370. /**
  33371. * Gets a material using its name
  33372. * @param name defines the material's name
  33373. * @return the material or null if none found.
  33374. */
  33375. getMaterialByName(name: string): Nullable<Material>;
  33376. /**
  33377. * Gets a camera using its id
  33378. * @param id defines the id to look for
  33379. * @returns the camera or null if not found
  33380. */
  33381. getCameraByID(id: string): Nullable<Camera>;
  33382. /**
  33383. * Gets a camera using its unique id
  33384. * @param uniqueId defines the unique id to look for
  33385. * @returns the camera or null if not found
  33386. */
  33387. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33388. /**
  33389. * Gets a camera using its name
  33390. * @param name defines the camera's name
  33391. * @return the camera or null if none found.
  33392. */
  33393. getCameraByName(name: string): Nullable<Camera>;
  33394. /**
  33395. * Gets a bone using its id
  33396. * @param id defines the bone's id
  33397. * @return the bone or null if not found
  33398. */
  33399. getBoneByID(id: string): Nullable<Bone>;
  33400. /**
  33401. * Gets a bone using its id
  33402. * @param name defines the bone's name
  33403. * @return the bone or null if not found
  33404. */
  33405. getBoneByName(name: string): Nullable<Bone>;
  33406. /**
  33407. * Gets a light node using its name
  33408. * @param name defines the the light's name
  33409. * @return the light or null if none found.
  33410. */
  33411. getLightByName(name: string): Nullable<Light>;
  33412. /**
  33413. * Gets a light node using its id
  33414. * @param id defines the light's id
  33415. * @return the light or null if none found.
  33416. */
  33417. getLightByID(id: string): Nullable<Light>;
  33418. /**
  33419. * Gets a light node using its scene-generated unique ID
  33420. * @param uniqueId defines the light's unique id
  33421. * @return the light or null if none found.
  33422. */
  33423. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33424. /**
  33425. * Gets a particle system by id
  33426. * @param id defines the particle system id
  33427. * @return the corresponding system or null if none found
  33428. */
  33429. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33430. /**
  33431. * Gets a geometry using its ID
  33432. * @param id defines the geometry's id
  33433. * @return the geometry or null if none found.
  33434. */
  33435. getGeometryByID(id: string): Nullable<Geometry>;
  33436. private _getGeometryByUniqueID;
  33437. /**
  33438. * Add a new geometry to this scene
  33439. * @param geometry defines the geometry to be added to the scene.
  33440. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33441. * @return a boolean defining if the geometry was added or not
  33442. */
  33443. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33444. /**
  33445. * Removes an existing geometry
  33446. * @param geometry defines the geometry to be removed from the scene
  33447. * @return a boolean defining if the geometry was removed or not
  33448. */
  33449. removeGeometry(geometry: Geometry): boolean;
  33450. /**
  33451. * Gets the list of geometries attached to the scene
  33452. * @returns an array of Geometry
  33453. */
  33454. getGeometries(): Geometry[];
  33455. /**
  33456. * Gets the first added mesh found of a given ID
  33457. * @param id defines the id to search for
  33458. * @return the mesh found or null if not found at all
  33459. */
  33460. getMeshByID(id: string): Nullable<AbstractMesh>;
  33461. /**
  33462. * Gets a list of meshes using their id
  33463. * @param id defines the id to search for
  33464. * @returns a list of meshes
  33465. */
  33466. getMeshesByID(id: string): Array<AbstractMesh>;
  33467. /**
  33468. * Gets the first added transform node found of a given ID
  33469. * @param id defines the id to search for
  33470. * @return the found transform node or null if not found at all.
  33471. */
  33472. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33473. /**
  33474. * Gets a list of transform nodes using their id
  33475. * @param id defines the id to search for
  33476. * @returns a list of transform nodes
  33477. */
  33478. getTransformNodesByID(id: string): Array<TransformNode>;
  33479. /**
  33480. * Gets a mesh with its auto-generated unique id
  33481. * @param uniqueId defines the unique id to search for
  33482. * @return the found mesh or null if not found at all.
  33483. */
  33484. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33485. /**
  33486. * Gets a the last added mesh using a given id
  33487. * @param id defines the id to search for
  33488. * @return the found mesh or null if not found at all.
  33489. */
  33490. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33491. /**
  33492. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33493. * @param id defines the id to search for
  33494. * @return the found node or null if not found at all
  33495. */
  33496. getLastEntryByID(id: string): Nullable<Node>;
  33497. /**
  33498. * Gets a node (Mesh, Camera, Light) using a given id
  33499. * @param id defines the id to search for
  33500. * @return the found node or null if not found at all
  33501. */
  33502. getNodeByID(id: string): Nullable<Node>;
  33503. /**
  33504. * Gets a node (Mesh, Camera, Light) using a given name
  33505. * @param name defines the name to search for
  33506. * @return the found node or null if not found at all.
  33507. */
  33508. getNodeByName(name: string): Nullable<Node>;
  33509. /**
  33510. * Gets a mesh using a given name
  33511. * @param name defines the name to search for
  33512. * @return the found mesh or null if not found at all.
  33513. */
  33514. getMeshByName(name: string): Nullable<AbstractMesh>;
  33515. /**
  33516. * Gets a transform node using a given name
  33517. * @param name defines the name to search for
  33518. * @return the found transform node or null if not found at all.
  33519. */
  33520. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33521. /**
  33522. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33523. * @param id defines the id to search for
  33524. * @return the found skeleton or null if not found at all.
  33525. */
  33526. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33527. /**
  33528. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33529. * @param id defines the id to search for
  33530. * @return the found skeleton or null if not found at all.
  33531. */
  33532. getSkeletonById(id: string): Nullable<Skeleton>;
  33533. /**
  33534. * Gets a skeleton using a given name
  33535. * @param name defines the name to search for
  33536. * @return the found skeleton or null if not found at all.
  33537. */
  33538. getSkeletonByName(name: string): Nullable<Skeleton>;
  33539. /**
  33540. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33541. * @param id defines the id to search for
  33542. * @return the found morph target manager or null if not found at all.
  33543. */
  33544. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33545. /**
  33546. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33547. * @param id defines the id to search for
  33548. * @return the found morph target or null if not found at all.
  33549. */
  33550. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33551. /**
  33552. * Gets a boolean indicating if the given mesh is active
  33553. * @param mesh defines the mesh to look for
  33554. * @returns true if the mesh is in the active list
  33555. */
  33556. isActiveMesh(mesh: AbstractMesh): boolean;
  33557. /**
  33558. * Return a unique id as a string which can serve as an identifier for the scene
  33559. */
  33560. readonly uid: string;
  33561. /**
  33562. * Add an externaly attached data from its key.
  33563. * This method call will fail and return false, if such key already exists.
  33564. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33565. * @param key the unique key that identifies the data
  33566. * @param data the data object to associate to the key for this Engine instance
  33567. * @return true if no such key were already present and the data was added successfully, false otherwise
  33568. */
  33569. addExternalData<T>(key: string, data: T): boolean;
  33570. /**
  33571. * Get an externaly attached data from its key
  33572. * @param key the unique key that identifies the data
  33573. * @return the associated data, if present (can be null), or undefined if not present
  33574. */
  33575. getExternalData<T>(key: string): Nullable<T>;
  33576. /**
  33577. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33578. * @param key the unique key that identifies the data
  33579. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33580. * @return the associated data, can be null if the factory returned null.
  33581. */
  33582. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33583. /**
  33584. * Remove an externaly attached data from the Engine instance
  33585. * @param key the unique key that identifies the data
  33586. * @return true if the data was successfully removed, false if it doesn't exist
  33587. */
  33588. removeExternalData(key: string): boolean;
  33589. private _evaluateSubMesh;
  33590. /**
  33591. * Clear the processed materials smart array preventing retention point in material dispose.
  33592. */
  33593. freeProcessedMaterials(): void;
  33594. private _preventFreeActiveMeshesAndRenderingGroups;
  33595. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33596. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33597. * when disposing several meshes in a row or a hierarchy of meshes.
  33598. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33599. */
  33600. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33601. /**
  33602. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33603. */
  33604. freeActiveMeshes(): void;
  33605. /**
  33606. * Clear the info related to rendering groups preventing retention points during dispose.
  33607. */
  33608. freeRenderingGroups(): void;
  33609. /** @hidden */
  33610. _isInIntermediateRendering(): boolean;
  33611. /**
  33612. * Lambda returning the list of potentially active meshes.
  33613. */
  33614. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33615. /**
  33616. * Lambda returning the list of potentially active sub meshes.
  33617. */
  33618. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33619. /**
  33620. * Lambda returning the list of potentially intersecting sub meshes.
  33621. */
  33622. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33623. /**
  33624. * Lambda returning the list of potentially colliding sub meshes.
  33625. */
  33626. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33627. private _activeMeshesFrozen;
  33628. /**
  33629. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33630. * @returns the current scene
  33631. */
  33632. freezeActiveMeshes(): Scene;
  33633. /**
  33634. * Use this function to restart evaluating active meshes on every frame
  33635. * @returns the current scene
  33636. */
  33637. unfreezeActiveMeshes(): Scene;
  33638. private _evaluateActiveMeshes;
  33639. private _activeMesh;
  33640. /**
  33641. * Update the transform matrix to update from the current active camera
  33642. * @param force defines a boolean used to force the update even if cache is up to date
  33643. */
  33644. updateTransformMatrix(force?: boolean): void;
  33645. /**
  33646. * 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)
  33647. * @param alternateCamera defines the camera to use
  33648. */
  33649. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33650. /** @hidden */
  33651. _allowPostProcessClearColor: boolean;
  33652. private _renderForCamera;
  33653. private _processSubCameras;
  33654. private _checkIntersections;
  33655. /** @hidden */
  33656. _advancePhysicsEngineStep(step: number): void;
  33657. /**
  33658. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33659. */
  33660. getDeterministicFrameTime: () => number;
  33661. /**
  33662. * Render the scene
  33663. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33664. */
  33665. render(updateCameras?: boolean): void;
  33666. /**
  33667. * Freeze all materials
  33668. * A frozen material will not be updatable but should be faster to render
  33669. */
  33670. freezeMaterials(): void;
  33671. /**
  33672. * Unfreeze all materials
  33673. * A frozen material will not be updatable but should be faster to render
  33674. */
  33675. unfreezeMaterials(): void;
  33676. /**
  33677. * Releases all held ressources
  33678. */
  33679. dispose(): void;
  33680. /**
  33681. * Gets if the scene is already disposed
  33682. */
  33683. readonly isDisposed: boolean;
  33684. /**
  33685. * Call this function to reduce memory footprint of the scene.
  33686. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33687. */
  33688. clearCachedVertexData(): void;
  33689. /**
  33690. * This function will remove the local cached buffer data from texture.
  33691. * It will save memory but will prevent the texture from being rebuilt
  33692. */
  33693. cleanCachedTextureBuffer(): void;
  33694. /**
  33695. * Get the world extend vectors with an optional filter
  33696. *
  33697. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33698. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33699. */
  33700. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33701. min: Vector3;
  33702. max: Vector3;
  33703. };
  33704. /**
  33705. * Creates a ray that can be used to pick in the scene
  33706. * @param x defines the x coordinate of the origin (on-screen)
  33707. * @param y defines the y coordinate of the origin (on-screen)
  33708. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33709. * @param camera defines the camera to use for the picking
  33710. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33711. * @returns a Ray
  33712. */
  33713. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33714. /**
  33715. * Creates a ray that can be used to pick in the scene
  33716. * @param x defines the x coordinate of the origin (on-screen)
  33717. * @param y defines the y coordinate of the origin (on-screen)
  33718. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33719. * @param result defines the ray where to store the picking ray
  33720. * @param camera defines the camera to use for the picking
  33721. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33722. * @returns the current scene
  33723. */
  33724. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33725. /**
  33726. * Creates a ray that can be used to pick in the scene
  33727. * @param x defines the x coordinate of the origin (on-screen)
  33728. * @param y defines the y coordinate of the origin (on-screen)
  33729. * @param camera defines the camera to use for the picking
  33730. * @returns a Ray
  33731. */
  33732. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33733. /**
  33734. * Creates a ray that can be used to pick in the scene
  33735. * @param x defines the x coordinate of the origin (on-screen)
  33736. * @param y defines the y coordinate of the origin (on-screen)
  33737. * @param result defines the ray where to store the picking ray
  33738. * @param camera defines the camera to use for the picking
  33739. * @returns the current scene
  33740. */
  33741. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33742. private _internalPick;
  33743. private _internalMultiPick;
  33744. private _tempPickingRay;
  33745. /** Launch a ray to try to pick a mesh in the scene
  33746. * @param x position on screen
  33747. * @param y position on screen
  33748. * @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
  33749. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33750. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33751. * @returns a PickingInfo
  33752. */
  33753. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33754. private _cachedRayForTransform;
  33755. /** Use the given ray to pick a mesh in the scene
  33756. * @param ray The ray to use to pick meshes
  33757. * @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
  33758. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33759. * @returns a PickingInfo
  33760. */
  33761. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33762. /**
  33763. * Launch a ray to try to pick a mesh in the scene
  33764. * @param x X position on screen
  33765. * @param y Y position on screen
  33766. * @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
  33767. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33768. * @returns an array of PickingInfo
  33769. */
  33770. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33771. /**
  33772. * Launch a ray to try to pick a mesh in the scene
  33773. * @param ray Ray to use
  33774. * @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
  33775. * @returns an array of PickingInfo
  33776. */
  33777. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33778. /**
  33779. * Force the value of meshUnderPointer
  33780. * @param mesh defines the mesh to use
  33781. */
  33782. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33783. /**
  33784. * Gets the mesh under the pointer
  33785. * @returns a Mesh or null if no mesh is under the pointer
  33786. */
  33787. getPointerOverMesh(): Nullable<AbstractMesh>;
  33788. /** @hidden */
  33789. _rebuildGeometries(): void;
  33790. /** @hidden */
  33791. _rebuildTextures(): void;
  33792. private _getByTags;
  33793. /**
  33794. * Get a list of meshes by tags
  33795. * @param tagsQuery defines the tags query to use
  33796. * @param forEach defines a predicate used to filter results
  33797. * @returns an array of Mesh
  33798. */
  33799. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33800. /**
  33801. * Get a list of cameras by tags
  33802. * @param tagsQuery defines the tags query to use
  33803. * @param forEach defines a predicate used to filter results
  33804. * @returns an array of Camera
  33805. */
  33806. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33807. /**
  33808. * Get a list of lights by tags
  33809. * @param tagsQuery defines the tags query to use
  33810. * @param forEach defines a predicate used to filter results
  33811. * @returns an array of Light
  33812. */
  33813. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33814. /**
  33815. * Get a list of materials by tags
  33816. * @param tagsQuery defines the tags query to use
  33817. * @param forEach defines a predicate used to filter results
  33818. * @returns an array of Material
  33819. */
  33820. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33821. /**
  33822. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33823. * This allowed control for front to back rendering or reversly depending of the special needs.
  33824. *
  33825. * @param renderingGroupId The rendering group id corresponding to its index
  33826. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33827. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33828. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33829. */
  33830. 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;
  33831. /**
  33832. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33833. *
  33834. * @param renderingGroupId The rendering group id corresponding to its index
  33835. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33836. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33837. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33838. */
  33839. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33840. /**
  33841. * Gets the current auto clear configuration for one rendering group of the rendering
  33842. * manager.
  33843. * @param index the rendering group index to get the information for
  33844. * @returns The auto clear setup for the requested rendering group
  33845. */
  33846. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33847. private _blockMaterialDirtyMechanism;
  33848. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33849. blockMaterialDirtyMechanism: boolean;
  33850. /**
  33851. * Will flag all materials as dirty to trigger new shader compilation
  33852. * @param flag defines the flag used to specify which material part must be marked as dirty
  33853. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33854. */
  33855. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33856. /** @hidden */
  33857. _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;
  33858. /** @hidden */
  33859. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33860. }
  33861. }
  33862. declare module BABYLON {
  33863. /**
  33864. * Set of assets to keep when moving a scene into an asset container.
  33865. */
  33866. export class KeepAssets extends AbstractScene {
  33867. }
  33868. /**
  33869. * Container with a set of assets that can be added or removed from a scene.
  33870. */
  33871. export class AssetContainer extends AbstractScene {
  33872. /**
  33873. * The scene the AssetContainer belongs to.
  33874. */
  33875. scene: Scene;
  33876. /**
  33877. * Instantiates an AssetContainer.
  33878. * @param scene The scene the AssetContainer belongs to.
  33879. */
  33880. constructor(scene: Scene);
  33881. /**
  33882. * Adds all the assets from the container to the scene.
  33883. */
  33884. addAllToScene(): void;
  33885. /**
  33886. * Removes all the assets in the container from the scene
  33887. */
  33888. removeAllFromScene(): void;
  33889. /**
  33890. * Disposes all the assets in the container
  33891. */
  33892. dispose(): void;
  33893. private _moveAssets;
  33894. /**
  33895. * Removes all the assets contained in the scene and adds them to the container.
  33896. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33897. */
  33898. moveAllFromScene(keepAssets?: KeepAssets): void;
  33899. /**
  33900. * 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.
  33901. * @returns the root mesh
  33902. */
  33903. createRootMesh(): Mesh;
  33904. }
  33905. }
  33906. declare module BABYLON {
  33907. /**
  33908. * Defines how the parser contract is defined.
  33909. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33910. */
  33911. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33912. /**
  33913. * Defines how the individual parser contract is defined.
  33914. * These parser can parse an individual asset
  33915. */
  33916. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33917. /**
  33918. * Base class of the scene acting as a container for the different elements composing a scene.
  33919. * This class is dynamically extended by the different components of the scene increasing
  33920. * flexibility and reducing coupling
  33921. */
  33922. export abstract class AbstractScene {
  33923. /**
  33924. * Stores the list of available parsers in the application.
  33925. */
  33926. private static _BabylonFileParsers;
  33927. /**
  33928. * Stores the list of available individual parsers in the application.
  33929. */
  33930. private static _IndividualBabylonFileParsers;
  33931. /**
  33932. * Adds a parser in the list of available ones
  33933. * @param name Defines the name of the parser
  33934. * @param parser Defines the parser to add
  33935. */
  33936. static AddParser(name: string, parser: BabylonFileParser): void;
  33937. /**
  33938. * Gets a general parser from the list of avaialble ones
  33939. * @param name Defines the name of the parser
  33940. * @returns the requested parser or null
  33941. */
  33942. static GetParser(name: string): Nullable<BabylonFileParser>;
  33943. /**
  33944. * Adds n individual parser in the list of available ones
  33945. * @param name Defines the name of the parser
  33946. * @param parser Defines the parser to add
  33947. */
  33948. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33949. /**
  33950. * Gets an individual parser from the list of avaialble ones
  33951. * @param name Defines the name of the parser
  33952. * @returns the requested parser or null
  33953. */
  33954. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33955. /**
  33956. * Parser json data and populate both a scene and its associated container object
  33957. * @param jsonData Defines the data to parse
  33958. * @param scene Defines the scene to parse the data for
  33959. * @param container Defines the container attached to the parsing sequence
  33960. * @param rootUrl Defines the root url of the data
  33961. */
  33962. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33963. /**
  33964. * Gets the list of root nodes (ie. nodes with no parent)
  33965. */
  33966. rootNodes: Node[];
  33967. /** All of the cameras added to this scene
  33968. * @see http://doc.babylonjs.com/babylon101/cameras
  33969. */
  33970. cameras: Camera[];
  33971. /**
  33972. * All of the lights added to this scene
  33973. * @see http://doc.babylonjs.com/babylon101/lights
  33974. */
  33975. lights: Light[];
  33976. /**
  33977. * All of the (abstract) meshes added to this scene
  33978. */
  33979. meshes: AbstractMesh[];
  33980. /**
  33981. * The list of skeletons added to the scene
  33982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33983. */
  33984. skeletons: Skeleton[];
  33985. /**
  33986. * All of the particle systems added to this scene
  33987. * @see http://doc.babylonjs.com/babylon101/particles
  33988. */
  33989. particleSystems: IParticleSystem[];
  33990. /**
  33991. * Gets a list of Animations associated with the scene
  33992. */
  33993. animations: Animation[];
  33994. /**
  33995. * All of the animation groups added to this scene
  33996. * @see http://doc.babylonjs.com/how_to/group
  33997. */
  33998. animationGroups: AnimationGroup[];
  33999. /**
  34000. * All of the multi-materials added to this scene
  34001. * @see http://doc.babylonjs.com/how_to/multi_materials
  34002. */
  34003. multiMaterials: MultiMaterial[];
  34004. /**
  34005. * All of the materials added to this scene
  34006. * In the context of a Scene, it is not supposed to be modified manually.
  34007. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34008. * Note also that the order of the Material wihin the array is not significant and might change.
  34009. * @see http://doc.babylonjs.com/babylon101/materials
  34010. */
  34011. materials: Material[];
  34012. /**
  34013. * The list of morph target managers added to the scene
  34014. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34015. */
  34016. morphTargetManagers: MorphTargetManager[];
  34017. /**
  34018. * The list of geometries used in the scene.
  34019. */
  34020. geometries: Geometry[];
  34021. /**
  34022. * All of the tranform nodes added to this scene
  34023. * In the context of a Scene, it is not supposed to be modified manually.
  34024. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34025. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34026. * @see http://doc.babylonjs.com/how_to/transformnode
  34027. */
  34028. transformNodes: TransformNode[];
  34029. /**
  34030. * ActionManagers available on the scene.
  34031. */
  34032. actionManagers: ActionManager[];
  34033. /**
  34034. * Textures to keep.
  34035. */
  34036. textures: BaseTexture[];
  34037. }
  34038. }
  34039. declare module BABYLON {
  34040. /**
  34041. * Defines a sound that can be played in the application.
  34042. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34044. */
  34045. export class Sound {
  34046. /**
  34047. * The name of the sound in the scene.
  34048. */
  34049. name: string;
  34050. /**
  34051. * Does the sound autoplay once loaded.
  34052. */
  34053. autoplay: boolean;
  34054. /**
  34055. * Does the sound loop after it finishes playing once.
  34056. */
  34057. loop: boolean;
  34058. /**
  34059. * Does the sound use a custom attenuation curve to simulate the falloff
  34060. * happening when the source gets further away from the camera.
  34061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34062. */
  34063. useCustomAttenuation: boolean;
  34064. /**
  34065. * The sound track id this sound belongs to.
  34066. */
  34067. soundTrackId: number;
  34068. /**
  34069. * Is this sound currently played.
  34070. */
  34071. isPlaying: boolean;
  34072. /**
  34073. * Is this sound currently paused.
  34074. */
  34075. isPaused: boolean;
  34076. /**
  34077. * Does this sound enables spatial sound.
  34078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34079. */
  34080. spatialSound: boolean;
  34081. /**
  34082. * Define the reference distance the sound should be heard perfectly.
  34083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34084. */
  34085. refDistance: number;
  34086. /**
  34087. * Define the roll off factor of spatial sounds.
  34088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34089. */
  34090. rolloffFactor: number;
  34091. /**
  34092. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34094. */
  34095. maxDistance: number;
  34096. /**
  34097. * Define the distance attenuation model the sound will follow.
  34098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34099. */
  34100. distanceModel: string;
  34101. /**
  34102. * @hidden
  34103. * Back Compat
  34104. **/
  34105. onended: () => any;
  34106. /**
  34107. * Observable event when the current playing sound finishes.
  34108. */
  34109. onEndedObservable: Observable<Sound>;
  34110. private _panningModel;
  34111. private _playbackRate;
  34112. private _streaming;
  34113. private _startTime;
  34114. private _startOffset;
  34115. private _position;
  34116. /** @hidden */
  34117. _positionInEmitterSpace: boolean;
  34118. private _localDirection;
  34119. private _volume;
  34120. private _isReadyToPlay;
  34121. private _isDirectional;
  34122. private _readyToPlayCallback;
  34123. private _audioBuffer;
  34124. private _soundSource;
  34125. private _streamingSource;
  34126. private _soundPanner;
  34127. private _soundGain;
  34128. private _inputAudioNode;
  34129. private _outputAudioNode;
  34130. private _coneInnerAngle;
  34131. private _coneOuterAngle;
  34132. private _coneOuterGain;
  34133. private _scene;
  34134. private _connectedTransformNode;
  34135. private _customAttenuationFunction;
  34136. private _registerFunc;
  34137. private _isOutputConnected;
  34138. private _htmlAudioElement;
  34139. private _urlType;
  34140. /** @hidden */
  34141. static _SceneComponentInitialization: (scene: Scene) => void;
  34142. /**
  34143. * Create a sound and attach it to a scene
  34144. * @param name Name of your sound
  34145. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34146. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34147. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34148. */
  34149. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34150. /**
  34151. * Release the sound and its associated resources
  34152. */
  34153. dispose(): void;
  34154. /**
  34155. * Gets if the sounds is ready to be played or not.
  34156. * @returns true if ready, otherwise false
  34157. */
  34158. isReady(): boolean;
  34159. private _soundLoaded;
  34160. /**
  34161. * Sets the data of the sound from an audiobuffer
  34162. * @param audioBuffer The audioBuffer containing the data
  34163. */
  34164. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34165. /**
  34166. * Updates the current sounds options such as maxdistance, loop...
  34167. * @param options A JSON object containing values named as the object properties
  34168. */
  34169. updateOptions(options: any): void;
  34170. private _createSpatialParameters;
  34171. private _updateSpatialParameters;
  34172. /**
  34173. * Switch the panning model to HRTF:
  34174. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34176. */
  34177. switchPanningModelToHRTF(): void;
  34178. /**
  34179. * Switch the panning model to Equal Power:
  34180. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34182. */
  34183. switchPanningModelToEqualPower(): void;
  34184. private _switchPanningModel;
  34185. /**
  34186. * Connect this sound to a sound track audio node like gain...
  34187. * @param soundTrackAudioNode the sound track audio node to connect to
  34188. */
  34189. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34190. /**
  34191. * Transform this sound into a directional source
  34192. * @param coneInnerAngle Size of the inner cone in degree
  34193. * @param coneOuterAngle Size of the outer cone in degree
  34194. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34195. */
  34196. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34197. /**
  34198. * Gets or sets the inner angle for the directional cone.
  34199. */
  34200. /**
  34201. * Gets or sets the inner angle for the directional cone.
  34202. */
  34203. directionalConeInnerAngle: number;
  34204. /**
  34205. * Gets or sets the outer angle for the directional cone.
  34206. */
  34207. /**
  34208. * Gets or sets the outer angle for the directional cone.
  34209. */
  34210. directionalConeOuterAngle: number;
  34211. /**
  34212. * Sets the position of the emitter if spatial sound is enabled
  34213. * @param newPosition Defines the new posisiton
  34214. */
  34215. setPosition(newPosition: Vector3): void;
  34216. /**
  34217. * Sets the local direction of the emitter if spatial sound is enabled
  34218. * @param newLocalDirection Defines the new local direction
  34219. */
  34220. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34221. private _updateDirection;
  34222. /** @hidden */
  34223. updateDistanceFromListener(): void;
  34224. /**
  34225. * Sets a new custom attenuation function for the sound.
  34226. * @param callback Defines the function used for the attenuation
  34227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34228. */
  34229. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34230. /**
  34231. * Play the sound
  34232. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34233. * @param offset (optional) Start the sound setting it at a specific time
  34234. */
  34235. play(time?: number, offset?: number): void;
  34236. private _onended;
  34237. /**
  34238. * Stop the sound
  34239. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34240. */
  34241. stop(time?: number): void;
  34242. /**
  34243. * Put the sound in pause
  34244. */
  34245. pause(): void;
  34246. /**
  34247. * Sets a dedicated volume for this sounds
  34248. * @param newVolume Define the new volume of the sound
  34249. * @param time Define in how long the sound should be at this value
  34250. */
  34251. setVolume(newVolume: number, time?: number): void;
  34252. /**
  34253. * Set the sound play back rate
  34254. * @param newPlaybackRate Define the playback rate the sound should be played at
  34255. */
  34256. setPlaybackRate(newPlaybackRate: number): void;
  34257. /**
  34258. * Gets the volume of the sound.
  34259. * @returns the volume of the sound
  34260. */
  34261. getVolume(): number;
  34262. /**
  34263. * Attach the sound to a dedicated mesh
  34264. * @param transformNode The transform node to connect the sound with
  34265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34266. */
  34267. attachToMesh(transformNode: TransformNode): void;
  34268. /**
  34269. * Detach the sound from the previously attached mesh
  34270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34271. */
  34272. detachFromMesh(): void;
  34273. private _onRegisterAfterWorldMatrixUpdate;
  34274. /**
  34275. * Clone the current sound in the scene.
  34276. * @returns the new sound clone
  34277. */
  34278. clone(): Nullable<Sound>;
  34279. /**
  34280. * Gets the current underlying audio buffer containing the data
  34281. * @returns the audio buffer
  34282. */
  34283. getAudioBuffer(): Nullable<AudioBuffer>;
  34284. /**
  34285. * Serializes the Sound in a JSON representation
  34286. * @returns the JSON representation of the sound
  34287. */
  34288. serialize(): any;
  34289. /**
  34290. * Parse a JSON representation of a sound to innstantiate in a given scene
  34291. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34292. * @param scene Define the scene the new parsed sound should be created in
  34293. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34294. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34295. * @returns the newly parsed sound
  34296. */
  34297. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34298. }
  34299. }
  34300. declare module BABYLON {
  34301. /**
  34302. * This defines an action helpful to play a defined sound on a triggered action.
  34303. */
  34304. export class PlaySoundAction extends Action {
  34305. private _sound;
  34306. /**
  34307. * Instantiate the action
  34308. * @param triggerOptions defines the trigger options
  34309. * @param sound defines the sound to play
  34310. * @param condition defines the trigger related conditions
  34311. */
  34312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34313. /** @hidden */
  34314. _prepare(): void;
  34315. /**
  34316. * Execute the action and play the sound.
  34317. */
  34318. execute(): void;
  34319. /**
  34320. * Serializes the actions and its related information.
  34321. * @param parent defines the object to serialize in
  34322. * @returns the serialized object
  34323. */
  34324. serialize(parent: any): any;
  34325. }
  34326. /**
  34327. * This defines an action helpful to stop a defined sound on a triggered action.
  34328. */
  34329. export class StopSoundAction extends Action {
  34330. private _sound;
  34331. /**
  34332. * Instantiate the action
  34333. * @param triggerOptions defines the trigger options
  34334. * @param sound defines the sound to stop
  34335. * @param condition defines the trigger related conditions
  34336. */
  34337. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34338. /** @hidden */
  34339. _prepare(): void;
  34340. /**
  34341. * Execute the action and stop the sound.
  34342. */
  34343. execute(): void;
  34344. /**
  34345. * Serializes the actions and its related information.
  34346. * @param parent defines the object to serialize in
  34347. * @returns the serialized object
  34348. */
  34349. serialize(parent: any): any;
  34350. }
  34351. }
  34352. declare module BABYLON {
  34353. /**
  34354. * This defines an action responsible to change the value of a property
  34355. * by interpolating between its current value and the newly set one once triggered.
  34356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34357. */
  34358. export class InterpolateValueAction extends Action {
  34359. /**
  34360. * Defines the path of the property where the value should be interpolated
  34361. */
  34362. propertyPath: string;
  34363. /**
  34364. * Defines the target value at the end of the interpolation.
  34365. */
  34366. value: any;
  34367. /**
  34368. * Defines the time it will take for the property to interpolate to the value.
  34369. */
  34370. duration: number;
  34371. /**
  34372. * Defines if the other scene animations should be stopped when the action has been triggered
  34373. */
  34374. stopOtherAnimations?: boolean;
  34375. /**
  34376. * Defines a callback raised once the interpolation animation has been done.
  34377. */
  34378. onInterpolationDone?: () => void;
  34379. /**
  34380. * Observable triggered once the interpolation animation has been done.
  34381. */
  34382. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34383. private _target;
  34384. private _effectiveTarget;
  34385. private _property;
  34386. /**
  34387. * Instantiate the action
  34388. * @param triggerOptions defines the trigger options
  34389. * @param target defines the object containing the value to interpolate
  34390. * @param propertyPath defines the path to the property in the target object
  34391. * @param value defines the target value at the end of the interpolation
  34392. * @param duration deines the time it will take for the property to interpolate to the value.
  34393. * @param condition defines the trigger related conditions
  34394. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34395. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34396. */
  34397. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34398. /** @hidden */
  34399. _prepare(): void;
  34400. /**
  34401. * Execute the action starts the value interpolation.
  34402. */
  34403. execute(): void;
  34404. /**
  34405. * Serializes the actions and its related information.
  34406. * @param parent defines the object to serialize in
  34407. * @returns the serialized object
  34408. */
  34409. serialize(parent: any): any;
  34410. }
  34411. }
  34412. declare module BABYLON {
  34413. /**
  34414. * Options allowed during the creation of a sound track.
  34415. */
  34416. export interface ISoundTrackOptions {
  34417. /**
  34418. * The volume the sound track should take during creation
  34419. */
  34420. volume?: number;
  34421. /**
  34422. * Define if the sound track is the main sound track of the scene
  34423. */
  34424. mainTrack?: boolean;
  34425. }
  34426. /**
  34427. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34428. * It will be also used in a future release to apply effects on a specific track.
  34429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34430. */
  34431. export class SoundTrack {
  34432. /**
  34433. * The unique identifier of the sound track in the scene.
  34434. */
  34435. id: number;
  34436. /**
  34437. * The list of sounds included in the sound track.
  34438. */
  34439. soundCollection: Array<Sound>;
  34440. private _outputAudioNode;
  34441. private _scene;
  34442. private _isMainTrack;
  34443. private _connectedAnalyser;
  34444. private _options;
  34445. private _isInitialized;
  34446. /**
  34447. * Creates a new sound track.
  34448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34449. * @param scene Define the scene the sound track belongs to
  34450. * @param options
  34451. */
  34452. constructor(scene: Scene, options?: ISoundTrackOptions);
  34453. private _initializeSoundTrackAudioGraph;
  34454. /**
  34455. * Release the sound track and its associated resources
  34456. */
  34457. dispose(): void;
  34458. /**
  34459. * Adds a sound to this sound track
  34460. * @param sound define the cound to add
  34461. * @ignoreNaming
  34462. */
  34463. AddSound(sound: Sound): void;
  34464. /**
  34465. * Removes a sound to this sound track
  34466. * @param sound define the cound to remove
  34467. * @ignoreNaming
  34468. */
  34469. RemoveSound(sound: Sound): void;
  34470. /**
  34471. * Set a global volume for the full sound track.
  34472. * @param newVolume Define the new volume of the sound track
  34473. */
  34474. setVolume(newVolume: number): void;
  34475. /**
  34476. * Switch the panning model to HRTF:
  34477. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34479. */
  34480. switchPanningModelToHRTF(): void;
  34481. /**
  34482. * Switch the panning model to Equal Power:
  34483. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34485. */
  34486. switchPanningModelToEqualPower(): void;
  34487. /**
  34488. * Connect the sound track to an audio analyser allowing some amazing
  34489. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34491. * @param analyser The analyser to connect to the engine
  34492. */
  34493. connectToAnalyser(analyser: Analyser): void;
  34494. }
  34495. }
  34496. declare module BABYLON {
  34497. interface AbstractScene {
  34498. /**
  34499. * The list of sounds used in the scene.
  34500. */
  34501. sounds: Nullable<Array<Sound>>;
  34502. }
  34503. interface Scene {
  34504. /**
  34505. * @hidden
  34506. * Backing field
  34507. */
  34508. _mainSoundTrack: SoundTrack;
  34509. /**
  34510. * The main sound track played by the scene.
  34511. * It cotains your primary collection of sounds.
  34512. */
  34513. mainSoundTrack: SoundTrack;
  34514. /**
  34515. * The list of sound tracks added to the scene
  34516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34517. */
  34518. soundTracks: Nullable<Array<SoundTrack>>;
  34519. /**
  34520. * Gets a sound using a given name
  34521. * @param name defines the name to search for
  34522. * @return the found sound or null if not found at all.
  34523. */
  34524. getSoundByName(name: string): Nullable<Sound>;
  34525. /**
  34526. * Gets or sets if audio support is enabled
  34527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34528. */
  34529. audioEnabled: boolean;
  34530. /**
  34531. * Gets or sets if audio will be output to headphones
  34532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34533. */
  34534. headphone: boolean;
  34535. }
  34536. /**
  34537. * Defines the sound scene component responsible to manage any sounds
  34538. * in a given scene.
  34539. */
  34540. export class AudioSceneComponent implements ISceneSerializableComponent {
  34541. /**
  34542. * The component name helpfull to identify the component in the list of scene components.
  34543. */
  34544. readonly name: string;
  34545. /**
  34546. * The scene the component belongs to.
  34547. */
  34548. scene: Scene;
  34549. private _audioEnabled;
  34550. /**
  34551. * Gets whether audio is enabled or not.
  34552. * Please use related enable/disable method to switch state.
  34553. */
  34554. readonly audioEnabled: boolean;
  34555. private _headphone;
  34556. /**
  34557. * Gets whether audio is outputing to headphone or not.
  34558. * Please use the according Switch methods to change output.
  34559. */
  34560. readonly headphone: boolean;
  34561. /**
  34562. * Creates a new instance of the component for the given scene
  34563. * @param scene Defines the scene to register the component in
  34564. */
  34565. constructor(scene: Scene);
  34566. /**
  34567. * Registers the component in a given scene
  34568. */
  34569. register(): void;
  34570. /**
  34571. * Rebuilds the elements related to this component in case of
  34572. * context lost for instance.
  34573. */
  34574. rebuild(): void;
  34575. /**
  34576. * Serializes the component data to the specified json object
  34577. * @param serializationObject The object to serialize to
  34578. */
  34579. serialize(serializationObject: any): void;
  34580. /**
  34581. * Adds all the element from the container to the scene
  34582. * @param container the container holding the elements
  34583. */
  34584. addFromContainer(container: AbstractScene): void;
  34585. /**
  34586. * Removes all the elements in the container from the scene
  34587. * @param container contains the elements to remove
  34588. */
  34589. removeFromContainer(container: AbstractScene): void;
  34590. /**
  34591. * Disposes the component and the associated ressources.
  34592. */
  34593. dispose(): void;
  34594. /**
  34595. * Disables audio in the associated scene.
  34596. */
  34597. disableAudio(): void;
  34598. /**
  34599. * Enables audio in the associated scene.
  34600. */
  34601. enableAudio(): void;
  34602. /**
  34603. * Switch audio to headphone output.
  34604. */
  34605. switchAudioModeForHeadphones(): void;
  34606. /**
  34607. * Switch audio to normal speakers.
  34608. */
  34609. switchAudioModeForNormalSpeakers(): void;
  34610. private _afterRender;
  34611. }
  34612. }
  34613. declare module BABYLON {
  34614. /**
  34615. * Wraps one or more Sound objects and selects one with random weight for playback.
  34616. */
  34617. export class WeightedSound {
  34618. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34619. loop: boolean;
  34620. private _coneInnerAngle;
  34621. private _coneOuterAngle;
  34622. private _volume;
  34623. /** A Sound is currently playing. */
  34624. isPlaying: boolean;
  34625. /** A Sound is currently paused. */
  34626. isPaused: boolean;
  34627. private _sounds;
  34628. private _weights;
  34629. private _currentIndex?;
  34630. /**
  34631. * Creates a new WeightedSound from the list of sounds given.
  34632. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34633. * @param sounds Array of Sounds that will be selected from.
  34634. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34635. */
  34636. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34637. /**
  34638. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34639. */
  34640. /**
  34641. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34642. */
  34643. directionalConeInnerAngle: number;
  34644. /**
  34645. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34646. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34647. */
  34648. /**
  34649. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34650. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34651. */
  34652. directionalConeOuterAngle: number;
  34653. /**
  34654. * Playback volume.
  34655. */
  34656. /**
  34657. * Playback volume.
  34658. */
  34659. volume: number;
  34660. private _onended;
  34661. /**
  34662. * Suspend playback
  34663. */
  34664. pause(): void;
  34665. /**
  34666. * Stop playback
  34667. */
  34668. stop(): void;
  34669. /**
  34670. * Start playback.
  34671. * @param startOffset Position the clip head at a specific time in seconds.
  34672. */
  34673. play(startOffset?: number): void;
  34674. }
  34675. }
  34676. declare module BABYLON {
  34677. /**
  34678. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34680. */
  34681. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34682. /**
  34683. * Gets the name of the behavior.
  34684. */
  34685. readonly name: string;
  34686. /**
  34687. * The easing function used by animations
  34688. */
  34689. static EasingFunction: BackEase;
  34690. /**
  34691. * The easing mode used by animations
  34692. */
  34693. static EasingMode: number;
  34694. /**
  34695. * The duration of the animation, in milliseconds
  34696. */
  34697. transitionDuration: number;
  34698. /**
  34699. * Length of the distance animated by the transition when lower radius is reached
  34700. */
  34701. lowerRadiusTransitionRange: number;
  34702. /**
  34703. * Length of the distance animated by the transition when upper radius is reached
  34704. */
  34705. upperRadiusTransitionRange: number;
  34706. private _autoTransitionRange;
  34707. /**
  34708. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34709. */
  34710. /**
  34711. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34712. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34713. */
  34714. autoTransitionRange: boolean;
  34715. private _attachedCamera;
  34716. private _onAfterCheckInputsObserver;
  34717. private _onMeshTargetChangedObserver;
  34718. /**
  34719. * Initializes the behavior.
  34720. */
  34721. init(): void;
  34722. /**
  34723. * Attaches the behavior to its arc rotate camera.
  34724. * @param camera Defines the camera to attach the behavior to
  34725. */
  34726. attach(camera: ArcRotateCamera): void;
  34727. /**
  34728. * Detaches the behavior from its current arc rotate camera.
  34729. */
  34730. detach(): void;
  34731. private _radiusIsAnimating;
  34732. private _radiusBounceTransition;
  34733. private _animatables;
  34734. private _cachedWheelPrecision;
  34735. /**
  34736. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34737. * @param radiusLimit The limit to check against.
  34738. * @return Bool to indicate if at limit.
  34739. */
  34740. private _isRadiusAtLimit;
  34741. /**
  34742. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34743. * @param radiusDelta The delta by which to animate to. Can be negative.
  34744. */
  34745. private _applyBoundRadiusAnimation;
  34746. /**
  34747. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34748. */
  34749. protected _clearAnimationLocks(): void;
  34750. /**
  34751. * Stops and removes all animations that have been applied to the camera
  34752. */
  34753. stopAllAnimations(): void;
  34754. }
  34755. }
  34756. declare module BABYLON {
  34757. /**
  34758. * The framing behavior (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.
  34759. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34760. */
  34761. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34762. /**
  34763. * Gets the name of the behavior.
  34764. */
  34765. readonly name: string;
  34766. private _mode;
  34767. private _radiusScale;
  34768. private _positionScale;
  34769. private _defaultElevation;
  34770. private _elevationReturnTime;
  34771. private _elevationReturnWaitTime;
  34772. private _zoomStopsAnimation;
  34773. private _framingTime;
  34774. /**
  34775. * The easing function used by animations
  34776. */
  34777. static EasingFunction: ExponentialEase;
  34778. /**
  34779. * The easing mode used by animations
  34780. */
  34781. static EasingMode: number;
  34782. /**
  34783. * Sets the current mode used by the behavior
  34784. */
  34785. /**
  34786. * Gets current mode used by the behavior.
  34787. */
  34788. mode: number;
  34789. /**
  34790. * Sets the scale applied to the radius (1 by default)
  34791. */
  34792. /**
  34793. * Gets the scale applied to the radius
  34794. */
  34795. radiusScale: number;
  34796. /**
  34797. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34798. */
  34799. /**
  34800. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34801. */
  34802. positionScale: number;
  34803. /**
  34804. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34805. * behaviour is triggered, in radians.
  34806. */
  34807. /**
  34808. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34809. * behaviour is triggered, in radians.
  34810. */
  34811. defaultElevation: number;
  34812. /**
  34813. * Sets the time (in milliseconds) taken to return to the default beta position.
  34814. * Negative value indicates camera should not return to default.
  34815. */
  34816. /**
  34817. * Gets the time (in milliseconds) taken to return to the default beta position.
  34818. * Negative value indicates camera should not return to default.
  34819. */
  34820. elevationReturnTime: number;
  34821. /**
  34822. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34823. */
  34824. /**
  34825. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34826. */
  34827. elevationReturnWaitTime: number;
  34828. /**
  34829. * Sets the flag that indicates if user zooming should stop animation.
  34830. */
  34831. /**
  34832. * Gets the flag that indicates if user zooming should stop animation.
  34833. */
  34834. zoomStopsAnimation: boolean;
  34835. /**
  34836. * Sets the transition time when framing the mesh, in milliseconds
  34837. */
  34838. /**
  34839. * Gets the transition time when framing the mesh, in milliseconds
  34840. */
  34841. framingTime: number;
  34842. /**
  34843. * Define if the behavior should automatically change the configured
  34844. * camera limits and sensibilities.
  34845. */
  34846. autoCorrectCameraLimitsAndSensibility: boolean;
  34847. private _onPrePointerObservableObserver;
  34848. private _onAfterCheckInputsObserver;
  34849. private _onMeshTargetChangedObserver;
  34850. private _attachedCamera;
  34851. private _isPointerDown;
  34852. private _lastInteractionTime;
  34853. /**
  34854. * Initializes the behavior.
  34855. */
  34856. init(): void;
  34857. /**
  34858. * Attaches the behavior to its arc rotate camera.
  34859. * @param camera Defines the camera to attach the behavior to
  34860. */
  34861. attach(camera: ArcRotateCamera): void;
  34862. /**
  34863. * Detaches the behavior from its current arc rotate camera.
  34864. */
  34865. detach(): void;
  34866. private _animatables;
  34867. private _betaIsAnimating;
  34868. private _betaTransition;
  34869. private _radiusTransition;
  34870. private _vectorTransition;
  34871. /**
  34872. * Targets the given mesh and updates zoom level accordingly.
  34873. * @param mesh The mesh to target.
  34874. * @param radius Optional. If a cached radius position already exists, overrides default.
  34875. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34876. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34877. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34878. */
  34879. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34880. /**
  34881. * Targets the given mesh with its children and updates zoom level accordingly.
  34882. * @param mesh The mesh to target.
  34883. * @param radius Optional. If a cached radius position already exists, overrides default.
  34884. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34885. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34886. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34887. */
  34888. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34889. /**
  34890. * Targets the given meshes with their children and updates zoom level accordingly.
  34891. * @param meshes The mesh to target.
  34892. * @param radius Optional. If a cached radius position already exists, overrides default.
  34893. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34894. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34895. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34896. */
  34897. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34898. /**
  34899. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34900. * @param minimumWorld Determines the smaller position of the bounding box extend
  34901. * @param maximumWorld Determines the bigger position of the bounding box extend
  34902. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34903. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34904. */
  34905. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34906. /**
  34907. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34908. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34909. * frustum width.
  34910. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34911. * to fully enclose the mesh in the viewing frustum.
  34912. */
  34913. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34914. /**
  34915. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34916. * is automatically returned to its default position (expected to be above ground plane).
  34917. */
  34918. private _maintainCameraAboveGround;
  34919. /**
  34920. * Returns the frustum slope based on the canvas ratio and camera FOV
  34921. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34922. */
  34923. private _getFrustumSlope;
  34924. /**
  34925. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34926. */
  34927. private _clearAnimationLocks;
  34928. /**
  34929. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34930. */
  34931. private _applyUserInteraction;
  34932. /**
  34933. * Stops and removes all animations that have been applied to the camera
  34934. */
  34935. stopAllAnimations(): void;
  34936. /**
  34937. * Gets a value indicating if the user is moving the camera
  34938. */
  34939. readonly isUserIsMoving: boolean;
  34940. /**
  34941. * The camera can move all the way towards the mesh.
  34942. */
  34943. static IgnoreBoundsSizeMode: number;
  34944. /**
  34945. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34946. */
  34947. static FitFrustumSidesMode: number;
  34948. }
  34949. }
  34950. declare module BABYLON {
  34951. /**
  34952. * Manage the pointers inputs to control an arc rotate camera.
  34953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34954. */
  34955. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34956. /**
  34957. * Defines the camera the input is attached to.
  34958. */
  34959. camera: ArcRotateCamera;
  34960. /**
  34961. * Defines the buttons associated with the input to handle camera move.
  34962. */
  34963. buttons: number[];
  34964. /**
  34965. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34966. */
  34967. angularSensibilityX: number;
  34968. /**
  34969. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34970. */
  34971. angularSensibilityY: number;
  34972. /**
  34973. * Defines the pointer pinch precision or how fast is the camera zooming.
  34974. */
  34975. pinchPrecision: number;
  34976. /**
  34977. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34978. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34979. */
  34980. pinchDeltaPercentage: number;
  34981. /**
  34982. * Defines the pointer panning sensibility or how fast is the camera moving.
  34983. */
  34984. panningSensibility: number;
  34985. /**
  34986. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34987. */
  34988. multiTouchPanning: boolean;
  34989. /**
  34990. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34991. */
  34992. multiTouchPanAndZoom: boolean;
  34993. /**
  34994. * Revers pinch action direction.
  34995. */
  34996. pinchInwards: boolean;
  34997. private _isPanClick;
  34998. private _pointerInput;
  34999. private _observer;
  35000. private _onMouseMove;
  35001. private _onGestureStart;
  35002. private _onGesture;
  35003. private _MSGestureHandler;
  35004. private _onLostFocus;
  35005. private _onContextMenu;
  35006. /**
  35007. * Attach the input controls to a specific dom element to get the input from.
  35008. * @param element Defines the element the controls should be listened from
  35009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35010. */
  35011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35012. /**
  35013. * Detach the current controls from the specified dom element.
  35014. * @param element Defines the element to stop listening the inputs from
  35015. */
  35016. detachControl(element: Nullable<HTMLElement>): void;
  35017. /**
  35018. * Gets the class name of the current intput.
  35019. * @returns the class name
  35020. */
  35021. getClassName(): string;
  35022. /**
  35023. * Get the friendly name associated with the input class.
  35024. * @returns the input friendly name
  35025. */
  35026. getSimpleName(): string;
  35027. }
  35028. }
  35029. declare module BABYLON {
  35030. /**
  35031. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35033. */
  35034. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35035. /**
  35036. * Defines the camera the input is attached to.
  35037. */
  35038. camera: ArcRotateCamera;
  35039. /**
  35040. * Defines the list of key codes associated with the up action (increase alpha)
  35041. */
  35042. keysUp: number[];
  35043. /**
  35044. * Defines the list of key codes associated with the down action (decrease alpha)
  35045. */
  35046. keysDown: number[];
  35047. /**
  35048. * Defines the list of key codes associated with the left action (increase beta)
  35049. */
  35050. keysLeft: number[];
  35051. /**
  35052. * Defines the list of key codes associated with the right action (decrease beta)
  35053. */
  35054. keysRight: number[];
  35055. /**
  35056. * Defines the list of key codes associated with the reset action.
  35057. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35058. */
  35059. keysReset: number[];
  35060. /**
  35061. * Defines the panning sensibility of the inputs.
  35062. * (How fast is the camera paning)
  35063. */
  35064. panningSensibility: number;
  35065. /**
  35066. * Defines the zooming sensibility of the inputs.
  35067. * (How fast is the camera zooming)
  35068. */
  35069. zoomingSensibility: number;
  35070. /**
  35071. * Defines wether maintaining the alt key down switch the movement mode from
  35072. * orientation to zoom.
  35073. */
  35074. useAltToZoom: boolean;
  35075. /**
  35076. * Rotation speed of the camera
  35077. */
  35078. angularSpeed: number;
  35079. private _keys;
  35080. private _ctrlPressed;
  35081. private _altPressed;
  35082. private _onCanvasBlurObserver;
  35083. private _onKeyboardObserver;
  35084. private _engine;
  35085. private _scene;
  35086. /**
  35087. * Attach the input controls to a specific dom element to get the input from.
  35088. * @param element Defines the element the controls should be listened from
  35089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35090. */
  35091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35092. /**
  35093. * Detach the current controls from the specified dom element.
  35094. * @param element Defines the element to stop listening the inputs from
  35095. */
  35096. detachControl(element: Nullable<HTMLElement>): void;
  35097. /**
  35098. * Update the current camera state depending on the inputs that have been used this frame.
  35099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35100. */
  35101. checkInputs(): void;
  35102. /**
  35103. * Gets the class name of the current intput.
  35104. * @returns the class name
  35105. */
  35106. getClassName(): string;
  35107. /**
  35108. * Get the friendly name associated with the input class.
  35109. * @returns the input friendly name
  35110. */
  35111. getSimpleName(): string;
  35112. }
  35113. }
  35114. declare module BABYLON {
  35115. /**
  35116. * Manage the mouse wheel inputs to control an arc rotate camera.
  35117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35118. */
  35119. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35120. /**
  35121. * Defines the camera the input is attached to.
  35122. */
  35123. camera: ArcRotateCamera;
  35124. /**
  35125. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35126. */
  35127. wheelPrecision: number;
  35128. /**
  35129. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35130. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35131. */
  35132. wheelDeltaPercentage: number;
  35133. private _wheel;
  35134. private _observer;
  35135. /**
  35136. * Attach the input controls to a specific dom element to get the input from.
  35137. * @param element Defines the element the controls should be listened from
  35138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35139. */
  35140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35141. /**
  35142. * Detach the current controls from the specified dom element.
  35143. * @param element Defines the element to stop listening the inputs from
  35144. */
  35145. detachControl(element: Nullable<HTMLElement>): void;
  35146. /**
  35147. * Gets the class name of the current intput.
  35148. * @returns the class name
  35149. */
  35150. getClassName(): string;
  35151. /**
  35152. * Get the friendly name associated with the input class.
  35153. * @returns the input friendly name
  35154. */
  35155. getSimpleName(): string;
  35156. }
  35157. }
  35158. declare module BABYLON {
  35159. /**
  35160. * Default Inputs manager for the ArcRotateCamera.
  35161. * It groups all the default supported inputs for ease of use.
  35162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35163. */
  35164. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35165. /**
  35166. * Instantiates a new ArcRotateCameraInputsManager.
  35167. * @param camera Defines the camera the inputs belong to
  35168. */
  35169. constructor(camera: ArcRotateCamera);
  35170. /**
  35171. * Add mouse wheel input support to the input manager.
  35172. * @returns the current input manager
  35173. */
  35174. addMouseWheel(): ArcRotateCameraInputsManager;
  35175. /**
  35176. * Add pointers input support to the input manager.
  35177. * @returns the current input manager
  35178. */
  35179. addPointers(): ArcRotateCameraInputsManager;
  35180. /**
  35181. * Add keyboard input support to the input manager.
  35182. * @returns the current input manager
  35183. */
  35184. addKeyboard(): ArcRotateCameraInputsManager;
  35185. }
  35186. }
  35187. declare module BABYLON {
  35188. /**
  35189. * This represents an orbital type of camera.
  35190. *
  35191. * 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.
  35192. * 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.
  35193. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35194. */
  35195. export class ArcRotateCamera extends TargetCamera {
  35196. /**
  35197. * Defines the rotation angle of the camera along the longitudinal axis.
  35198. */
  35199. alpha: number;
  35200. /**
  35201. * Defines the rotation angle of the camera along the latitudinal axis.
  35202. */
  35203. beta: number;
  35204. /**
  35205. * Defines the radius of the camera from it s target point.
  35206. */
  35207. radius: number;
  35208. protected _target: Vector3;
  35209. protected _targetHost: Nullable<AbstractMesh>;
  35210. /**
  35211. * Defines the target point of the camera.
  35212. * The camera looks towards it form the radius distance.
  35213. */
  35214. target: Vector3;
  35215. /**
  35216. * Current inertia value on the longitudinal axis.
  35217. * The bigger this number the longer it will take for the camera to stop.
  35218. */
  35219. inertialAlphaOffset: number;
  35220. /**
  35221. * Current inertia value on the latitudinal axis.
  35222. * The bigger this number the longer it will take for the camera to stop.
  35223. */
  35224. inertialBetaOffset: number;
  35225. /**
  35226. * Current inertia value on the radius axis.
  35227. * The bigger this number the longer it will take for the camera to stop.
  35228. */
  35229. inertialRadiusOffset: number;
  35230. /**
  35231. * Minimum allowed angle on the longitudinal axis.
  35232. * This can help limiting how the Camera is able to move in the scene.
  35233. */
  35234. lowerAlphaLimit: Nullable<number>;
  35235. /**
  35236. * Maximum allowed angle on the longitudinal axis.
  35237. * This can help limiting how the Camera is able to move in the scene.
  35238. */
  35239. upperAlphaLimit: Nullable<number>;
  35240. /**
  35241. * Minimum allowed angle on the latitudinal axis.
  35242. * This can help limiting how the Camera is able to move in the scene.
  35243. */
  35244. lowerBetaLimit: number;
  35245. /**
  35246. * Maximum allowed angle on the latitudinal axis.
  35247. * This can help limiting how the Camera is able to move in the scene.
  35248. */
  35249. upperBetaLimit: number;
  35250. /**
  35251. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35252. * This can help limiting how the Camera is able to move in the scene.
  35253. */
  35254. lowerRadiusLimit: Nullable<number>;
  35255. /**
  35256. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35257. * This can help limiting how the Camera is able to move in the scene.
  35258. */
  35259. upperRadiusLimit: Nullable<number>;
  35260. /**
  35261. * Defines the current inertia value used during panning of the camera along the X axis.
  35262. */
  35263. inertialPanningX: number;
  35264. /**
  35265. * Defines the current inertia value used during panning of the camera along the Y axis.
  35266. */
  35267. inertialPanningY: number;
  35268. /**
  35269. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35270. * Basically if your fingers moves away from more than this distance you will be considered
  35271. * in pinch mode.
  35272. */
  35273. pinchToPanMaxDistance: number;
  35274. /**
  35275. * Defines the maximum distance the camera can pan.
  35276. * This could help keeping the cammera always in your scene.
  35277. */
  35278. panningDistanceLimit: Nullable<number>;
  35279. /**
  35280. * Defines the target of the camera before paning.
  35281. */
  35282. panningOriginTarget: Vector3;
  35283. /**
  35284. * Defines the value of the inertia used during panning.
  35285. * 0 would mean stop inertia and one would mean no decelleration at all.
  35286. */
  35287. panningInertia: number;
  35288. /**
  35289. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35290. */
  35291. angularSensibilityX: number;
  35292. /**
  35293. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35294. */
  35295. angularSensibilityY: number;
  35296. /**
  35297. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35298. */
  35299. pinchPrecision: number;
  35300. /**
  35301. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35302. * It will be used instead of pinchDeltaPrecision if different from 0.
  35303. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35304. */
  35305. pinchDeltaPercentage: number;
  35306. /**
  35307. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35308. */
  35309. panningSensibility: number;
  35310. /**
  35311. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35312. */
  35313. keysUp: number[];
  35314. /**
  35315. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35316. */
  35317. keysDown: number[];
  35318. /**
  35319. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35320. */
  35321. keysLeft: number[];
  35322. /**
  35323. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35324. */
  35325. keysRight: number[];
  35326. /**
  35327. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35328. */
  35329. wheelPrecision: number;
  35330. /**
  35331. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35332. * It will be used instead of pinchDeltaPrecision if different from 0.
  35333. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35334. */
  35335. wheelDeltaPercentage: number;
  35336. /**
  35337. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35338. */
  35339. zoomOnFactor: number;
  35340. /**
  35341. * Defines a screen offset for the camera position.
  35342. */
  35343. targetScreenOffset: Vector2;
  35344. /**
  35345. * Allows the camera to be completely reversed.
  35346. * If false the camera can not arrive upside down.
  35347. */
  35348. allowUpsideDown: boolean;
  35349. /**
  35350. * Define if double tap/click is used to restore the previously saved state of the camera.
  35351. */
  35352. useInputToRestoreState: boolean;
  35353. /** @hidden */
  35354. _viewMatrix: Matrix;
  35355. /** @hidden */
  35356. _useCtrlForPanning: boolean;
  35357. /** @hidden */
  35358. _panningMouseButton: number;
  35359. /**
  35360. * Defines the input associated to the camera.
  35361. */
  35362. inputs: ArcRotateCameraInputsManager;
  35363. /** @hidden */
  35364. _reset: () => void;
  35365. /**
  35366. * Defines the allowed panning axis.
  35367. */
  35368. panningAxis: Vector3;
  35369. protected _localDirection: Vector3;
  35370. protected _transformedDirection: Vector3;
  35371. private _bouncingBehavior;
  35372. /**
  35373. * Gets the bouncing behavior of the camera if it has been enabled.
  35374. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35375. */
  35376. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35377. /**
  35378. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35379. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35380. */
  35381. useBouncingBehavior: boolean;
  35382. private _framingBehavior;
  35383. /**
  35384. * Gets the framing behavior of the camera if it has been enabled.
  35385. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35386. */
  35387. readonly framingBehavior: Nullable<FramingBehavior>;
  35388. /**
  35389. * Defines if the framing behavior of the camera is enabled on the camera.
  35390. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35391. */
  35392. useFramingBehavior: boolean;
  35393. private _autoRotationBehavior;
  35394. /**
  35395. * Gets the auto rotation behavior of the camera if it has been enabled.
  35396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35397. */
  35398. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35399. /**
  35400. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35402. */
  35403. useAutoRotationBehavior: boolean;
  35404. /**
  35405. * Observable triggered when the mesh target has been changed on the camera.
  35406. */
  35407. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35408. /**
  35409. * Event raised when the camera is colliding with a mesh.
  35410. */
  35411. onCollide: (collidedMesh: AbstractMesh) => void;
  35412. /**
  35413. * Defines whether the camera should check collision with the objects oh the scene.
  35414. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35415. */
  35416. checkCollisions: boolean;
  35417. /**
  35418. * Defines the collision radius of the camera.
  35419. * This simulates a sphere around the camera.
  35420. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35421. */
  35422. collisionRadius: Vector3;
  35423. protected _collider: Collider;
  35424. protected _previousPosition: Vector3;
  35425. protected _collisionVelocity: Vector3;
  35426. protected _newPosition: Vector3;
  35427. protected _previousAlpha: number;
  35428. protected _previousBeta: number;
  35429. protected _previousRadius: number;
  35430. protected _collisionTriggered: boolean;
  35431. protected _targetBoundingCenter: Nullable<Vector3>;
  35432. private _computationVector;
  35433. private _tempAxisVector;
  35434. private _tempAxisRotationMatrix;
  35435. /**
  35436. * Instantiates a new ArcRotateCamera in a given scene
  35437. * @param name Defines the name of the camera
  35438. * @param alpha Defines the camera rotation along the logitudinal axis
  35439. * @param beta Defines the camera rotation along the latitudinal axis
  35440. * @param radius Defines the camera distance from its target
  35441. * @param target Defines the camera target
  35442. * @param scene Defines the scene the camera belongs to
  35443. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35444. */
  35445. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35446. /** @hidden */
  35447. _initCache(): void;
  35448. /** @hidden */
  35449. _updateCache(ignoreParentClass?: boolean): void;
  35450. protected _getTargetPosition(): Vector3;
  35451. private _storedAlpha;
  35452. private _storedBeta;
  35453. private _storedRadius;
  35454. private _storedTarget;
  35455. /**
  35456. * Stores the current state of the camera (alpha, beta, radius and target)
  35457. * @returns the camera itself
  35458. */
  35459. storeState(): Camera;
  35460. /**
  35461. * @hidden
  35462. * Restored camera state. You must call storeState() first
  35463. */
  35464. _restoreStateValues(): boolean;
  35465. /** @hidden */
  35466. _isSynchronizedViewMatrix(): boolean;
  35467. /**
  35468. * Attached controls to the current camera.
  35469. * @param element Defines the element the controls should be listened from
  35470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35471. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35472. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35473. */
  35474. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35475. /**
  35476. * Detach the current controls from the camera.
  35477. * The camera will stop reacting to inputs.
  35478. * @param element Defines the element to stop listening the inputs from
  35479. */
  35480. detachControl(element: HTMLElement): void;
  35481. /** @hidden */
  35482. _checkInputs(): void;
  35483. protected _checkLimits(): void;
  35484. /**
  35485. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35486. */
  35487. rebuildAnglesAndRadius(): void;
  35488. /**
  35489. * Use a position to define the current camera related information like aplha, beta and radius
  35490. * @param position Defines the position to set the camera at
  35491. */
  35492. setPosition(position: Vector3): void;
  35493. /**
  35494. * Defines the target the camera should look at.
  35495. * This will automatically adapt alpha beta and radius to fit within the new target.
  35496. * @param target Defines the new target as a Vector or a mesh
  35497. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35498. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35499. */
  35500. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35501. /** @hidden */
  35502. _getViewMatrix(): Matrix;
  35503. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35504. /**
  35505. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35506. * @param meshes Defines the mesh to zoom on
  35507. * @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)
  35508. */
  35509. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35510. /**
  35511. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35512. * The target will be changed but the radius
  35513. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35514. * @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)
  35515. */
  35516. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35517. min: Vector3;
  35518. max: Vector3;
  35519. distance: number;
  35520. }, doNotUpdateMaxZ?: boolean): void;
  35521. /**
  35522. * @override
  35523. * Override Camera.createRigCamera
  35524. */
  35525. createRigCamera(name: string, cameraIndex: number): Camera;
  35526. /**
  35527. * @hidden
  35528. * @override
  35529. * Override Camera._updateRigCameras
  35530. */
  35531. _updateRigCameras(): void;
  35532. /**
  35533. * Destroy the camera and release the current resources hold by it.
  35534. */
  35535. dispose(): void;
  35536. /**
  35537. * Gets the current object class name.
  35538. * @return the class name
  35539. */
  35540. getClassName(): string;
  35541. }
  35542. }
  35543. declare module BABYLON {
  35544. /**
  35545. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35547. */
  35548. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35549. /**
  35550. * Gets the name of the behavior.
  35551. */
  35552. readonly name: string;
  35553. private _zoomStopsAnimation;
  35554. private _idleRotationSpeed;
  35555. private _idleRotationWaitTime;
  35556. private _idleRotationSpinupTime;
  35557. /**
  35558. * Sets the flag that indicates if user zooming should stop animation.
  35559. */
  35560. /**
  35561. * Gets the flag that indicates if user zooming should stop animation.
  35562. */
  35563. zoomStopsAnimation: boolean;
  35564. /**
  35565. * Sets the default speed at which the camera rotates around the model.
  35566. */
  35567. /**
  35568. * Gets the default speed at which the camera rotates around the model.
  35569. */
  35570. idleRotationSpeed: number;
  35571. /**
  35572. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35573. */
  35574. /**
  35575. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35576. */
  35577. idleRotationWaitTime: number;
  35578. /**
  35579. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35580. */
  35581. /**
  35582. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35583. */
  35584. idleRotationSpinupTime: number;
  35585. /**
  35586. * Gets a value indicating if the camera is currently rotating because of this behavior
  35587. */
  35588. readonly rotationInProgress: boolean;
  35589. private _onPrePointerObservableObserver;
  35590. private _onAfterCheckInputsObserver;
  35591. private _attachedCamera;
  35592. private _isPointerDown;
  35593. private _lastFrameTime;
  35594. private _lastInteractionTime;
  35595. private _cameraRotationSpeed;
  35596. /**
  35597. * Initializes the behavior.
  35598. */
  35599. init(): void;
  35600. /**
  35601. * Attaches the behavior to its arc rotate camera.
  35602. * @param camera Defines the camera to attach the behavior to
  35603. */
  35604. attach(camera: ArcRotateCamera): void;
  35605. /**
  35606. * Detaches the behavior from its current arc rotate camera.
  35607. */
  35608. detach(): void;
  35609. /**
  35610. * Returns true if user is scrolling.
  35611. * @return true if user is scrolling.
  35612. */
  35613. private _userIsZooming;
  35614. private _lastFrameRadius;
  35615. private _shouldAnimationStopForInteraction;
  35616. /**
  35617. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35618. */
  35619. private _applyUserInteraction;
  35620. private _userIsMoving;
  35621. }
  35622. }
  35623. declare module BABYLON {
  35624. /**
  35625. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35626. */
  35627. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35628. private ui;
  35629. /**
  35630. * The name of the behavior
  35631. */
  35632. name: string;
  35633. /**
  35634. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35635. */
  35636. distanceAwayFromFace: number;
  35637. /**
  35638. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35639. */
  35640. distanceAwayFromBottomOfFace: number;
  35641. private _faceVectors;
  35642. private _target;
  35643. private _scene;
  35644. private _onRenderObserver;
  35645. private _tmpMatrix;
  35646. private _tmpVector;
  35647. /**
  35648. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35649. * @param ui The transform node that should be attched to the mesh
  35650. */
  35651. constructor(ui: TransformNode);
  35652. /**
  35653. * Initializes the behavior
  35654. */
  35655. init(): void;
  35656. private _closestFace;
  35657. private _zeroVector;
  35658. private _lookAtTmpMatrix;
  35659. private _lookAtToRef;
  35660. /**
  35661. * Attaches the AttachToBoxBehavior to the passed in mesh
  35662. * @param target The mesh that the specified node will be attached to
  35663. */
  35664. attach(target: Mesh): void;
  35665. /**
  35666. * Detaches the behavior from the mesh
  35667. */
  35668. detach(): void;
  35669. }
  35670. }
  35671. declare module BABYLON {
  35672. /**
  35673. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35674. */
  35675. export class FadeInOutBehavior implements Behavior<Mesh> {
  35676. /**
  35677. * Time in milliseconds to delay before fading in (Default: 0)
  35678. */
  35679. delay: number;
  35680. /**
  35681. * Time in milliseconds for the mesh to fade in (Default: 300)
  35682. */
  35683. fadeInTime: number;
  35684. private _millisecondsPerFrame;
  35685. private _hovered;
  35686. private _hoverValue;
  35687. private _ownerNode;
  35688. /**
  35689. * Instatiates the FadeInOutBehavior
  35690. */
  35691. constructor();
  35692. /**
  35693. * The name of the behavior
  35694. */
  35695. readonly name: string;
  35696. /**
  35697. * Initializes the behavior
  35698. */
  35699. init(): void;
  35700. /**
  35701. * Attaches the fade behavior on the passed in mesh
  35702. * @param ownerNode The mesh that will be faded in/out once attached
  35703. */
  35704. attach(ownerNode: Mesh): void;
  35705. /**
  35706. * Detaches the behavior from the mesh
  35707. */
  35708. detach(): void;
  35709. /**
  35710. * Triggers the mesh to begin fading in or out
  35711. * @param value if the object should fade in or out (true to fade in)
  35712. */
  35713. fadeIn(value: boolean): void;
  35714. private _update;
  35715. private _setAllVisibility;
  35716. }
  35717. }
  35718. declare module BABYLON {
  35719. /**
  35720. * Class containing a set of static utilities functions for managing Pivots
  35721. * @hidden
  35722. */
  35723. export class PivotTools {
  35724. private static _PivotCached;
  35725. private static _OldPivotPoint;
  35726. private static _PivotTranslation;
  35727. private static _PivotTmpVector;
  35728. /** @hidden */
  35729. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35730. /** @hidden */
  35731. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35732. }
  35733. }
  35734. declare module BABYLON {
  35735. /**
  35736. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35737. */
  35738. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35739. private static _AnyMouseID;
  35740. private _attachedNode;
  35741. private _dragPlane;
  35742. private _scene;
  35743. private _pointerObserver;
  35744. private _beforeRenderObserver;
  35745. private static _planeScene;
  35746. /**
  35747. * 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)
  35748. */
  35749. maxDragAngle: number;
  35750. /**
  35751. * @hidden
  35752. */
  35753. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35754. /**
  35755. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35756. */
  35757. currentDraggingPointerID: number;
  35758. /**
  35759. * The last position where the pointer hit the drag plane in world space
  35760. */
  35761. lastDragPosition: Vector3;
  35762. /**
  35763. * If the behavior is currently in a dragging state
  35764. */
  35765. dragging: boolean;
  35766. /**
  35767. * 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)
  35768. */
  35769. dragDeltaRatio: number;
  35770. /**
  35771. * If the drag plane orientation should be updated during the dragging (Default: true)
  35772. */
  35773. updateDragPlane: boolean;
  35774. private _debugMode;
  35775. private _moving;
  35776. /**
  35777. * Fires each time the attached mesh is dragged with the pointer
  35778. * * delta between last drag position and current drag position in world space
  35779. * * dragDistance along the drag axis
  35780. * * dragPlaneNormal normal of the current drag plane used during the drag
  35781. * * dragPlanePoint in world space where the drag intersects the drag plane
  35782. */
  35783. onDragObservable: Observable<{
  35784. delta: Vector3;
  35785. dragPlanePoint: Vector3;
  35786. dragPlaneNormal: Vector3;
  35787. dragDistance: number;
  35788. pointerId: number;
  35789. }>;
  35790. /**
  35791. * Fires each time a drag begins (eg. mouse down on mesh)
  35792. */
  35793. onDragStartObservable: Observable<{
  35794. dragPlanePoint: Vector3;
  35795. pointerId: number;
  35796. }>;
  35797. /**
  35798. * Fires each time a drag ends (eg. mouse release after drag)
  35799. */
  35800. onDragEndObservable: Observable<{
  35801. dragPlanePoint: Vector3;
  35802. pointerId: number;
  35803. }>;
  35804. /**
  35805. * If the attached mesh should be moved when dragged
  35806. */
  35807. moveAttached: boolean;
  35808. /**
  35809. * If the drag behavior will react to drag events (Default: true)
  35810. */
  35811. enabled: boolean;
  35812. /**
  35813. * If camera controls should be detached during the drag
  35814. */
  35815. detachCameraControls: boolean;
  35816. /**
  35817. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35818. */
  35819. useObjectOrienationForDragging: boolean;
  35820. private _options;
  35821. /**
  35822. * Creates a pointer drag behavior that can be attached to a mesh
  35823. * @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)
  35824. */
  35825. constructor(options?: {
  35826. dragAxis?: Vector3;
  35827. dragPlaneNormal?: Vector3;
  35828. });
  35829. /**
  35830. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35831. */
  35832. validateDrag: (targetPosition: Vector3) => boolean;
  35833. /**
  35834. * The name of the behavior
  35835. */
  35836. readonly name: string;
  35837. /**
  35838. * Initializes the behavior
  35839. */
  35840. init(): void;
  35841. private _tmpVector;
  35842. private _alternatePickedPoint;
  35843. private _worldDragAxis;
  35844. private _targetPosition;
  35845. private _attachedElement;
  35846. /**
  35847. * Attaches the drag behavior the passed in mesh
  35848. * @param ownerNode The mesh that will be dragged around once attached
  35849. */
  35850. attach(ownerNode: AbstractMesh): void;
  35851. /**
  35852. * Force relase the drag action by code.
  35853. */
  35854. releaseDrag(): void;
  35855. private _startDragRay;
  35856. private _lastPointerRay;
  35857. /**
  35858. * Simulates the start of a pointer drag event on the behavior
  35859. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35860. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35861. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35862. */
  35863. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35864. private _startDrag;
  35865. private _dragDelta;
  35866. private _moveDrag;
  35867. private _pickWithRayOnDragPlane;
  35868. private _pointA;
  35869. private _pointB;
  35870. private _pointC;
  35871. private _lineA;
  35872. private _lineB;
  35873. private _localAxis;
  35874. private _lookAt;
  35875. private _updateDragPlanePosition;
  35876. /**
  35877. * Detaches the behavior from the mesh
  35878. */
  35879. detach(): void;
  35880. }
  35881. }
  35882. declare module BABYLON {
  35883. /**
  35884. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35885. */
  35886. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35887. private _dragBehaviorA;
  35888. private _dragBehaviorB;
  35889. private _startDistance;
  35890. private _initialScale;
  35891. private _targetScale;
  35892. private _ownerNode;
  35893. private _sceneRenderObserver;
  35894. /**
  35895. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35896. */
  35897. constructor();
  35898. /**
  35899. * The name of the behavior
  35900. */
  35901. readonly name: string;
  35902. /**
  35903. * Initializes the behavior
  35904. */
  35905. init(): void;
  35906. private _getCurrentDistance;
  35907. /**
  35908. * Attaches the scale behavior the passed in mesh
  35909. * @param ownerNode The mesh that will be scaled around once attached
  35910. */
  35911. attach(ownerNode: Mesh): void;
  35912. /**
  35913. * Detaches the behavior from the mesh
  35914. */
  35915. detach(): void;
  35916. }
  35917. }
  35918. declare module BABYLON {
  35919. /**
  35920. * 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
  35921. */
  35922. export class SixDofDragBehavior implements Behavior<Mesh> {
  35923. private static _virtualScene;
  35924. private _ownerNode;
  35925. private _sceneRenderObserver;
  35926. private _scene;
  35927. private _targetPosition;
  35928. private _virtualOriginMesh;
  35929. private _virtualDragMesh;
  35930. private _pointerObserver;
  35931. private _moving;
  35932. private _startingOrientation;
  35933. /**
  35934. * 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)
  35935. */
  35936. private zDragFactor;
  35937. /**
  35938. * If the object should rotate to face the drag origin
  35939. */
  35940. rotateDraggedObject: boolean;
  35941. /**
  35942. * If the behavior is currently in a dragging state
  35943. */
  35944. dragging: boolean;
  35945. /**
  35946. * 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)
  35947. */
  35948. dragDeltaRatio: number;
  35949. /**
  35950. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35951. */
  35952. currentDraggingPointerID: number;
  35953. /**
  35954. * If camera controls should be detached during the drag
  35955. */
  35956. detachCameraControls: boolean;
  35957. /**
  35958. * Fires each time a drag starts
  35959. */
  35960. onDragStartObservable: Observable<{}>;
  35961. /**
  35962. * Fires each time a drag ends (eg. mouse release after drag)
  35963. */
  35964. onDragEndObservable: Observable<{}>;
  35965. /**
  35966. * 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
  35967. */
  35968. constructor();
  35969. /**
  35970. * The name of the behavior
  35971. */
  35972. readonly name: string;
  35973. /**
  35974. * Initializes the behavior
  35975. */
  35976. init(): void;
  35977. /**
  35978. * Attaches the scale behavior the passed in mesh
  35979. * @param ownerNode The mesh that will be scaled around once attached
  35980. */
  35981. attach(ownerNode: Mesh): void;
  35982. /**
  35983. * Detaches the behavior from the mesh
  35984. */
  35985. detach(): void;
  35986. }
  35987. }
  35988. declare module BABYLON {
  35989. /**
  35990. * Class used to apply inverse kinematics to bones
  35991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35992. */
  35993. export class BoneIKController {
  35994. private static _tmpVecs;
  35995. private static _tmpQuat;
  35996. private static _tmpMats;
  35997. /**
  35998. * Gets or sets the target mesh
  35999. */
  36000. targetMesh: AbstractMesh;
  36001. /** Gets or sets the mesh used as pole */
  36002. poleTargetMesh: AbstractMesh;
  36003. /**
  36004. * Gets or sets the bone used as pole
  36005. */
  36006. poleTargetBone: Nullable<Bone>;
  36007. /**
  36008. * Gets or sets the target position
  36009. */
  36010. targetPosition: Vector3;
  36011. /**
  36012. * Gets or sets the pole target position
  36013. */
  36014. poleTargetPosition: Vector3;
  36015. /**
  36016. * Gets or sets the pole target local offset
  36017. */
  36018. poleTargetLocalOffset: Vector3;
  36019. /**
  36020. * Gets or sets the pole angle
  36021. */
  36022. poleAngle: number;
  36023. /**
  36024. * Gets or sets the mesh associated with the controller
  36025. */
  36026. mesh: AbstractMesh;
  36027. /**
  36028. * 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)
  36029. */
  36030. slerpAmount: number;
  36031. private _bone1Quat;
  36032. private _bone1Mat;
  36033. private _bone2Ang;
  36034. private _bone1;
  36035. private _bone2;
  36036. private _bone1Length;
  36037. private _bone2Length;
  36038. private _maxAngle;
  36039. private _maxReach;
  36040. private _rightHandedSystem;
  36041. private _bendAxis;
  36042. private _slerping;
  36043. private _adjustRoll;
  36044. /**
  36045. * Gets or sets maximum allowed angle
  36046. */
  36047. maxAngle: number;
  36048. /**
  36049. * Creates a new BoneIKController
  36050. * @param mesh defines the mesh to control
  36051. * @param bone defines the bone to control
  36052. * @param options defines options to set up the controller
  36053. */
  36054. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36055. targetMesh?: AbstractMesh;
  36056. poleTargetMesh?: AbstractMesh;
  36057. poleTargetBone?: Bone;
  36058. poleTargetLocalOffset?: Vector3;
  36059. poleAngle?: number;
  36060. bendAxis?: Vector3;
  36061. maxAngle?: number;
  36062. slerpAmount?: number;
  36063. });
  36064. private _setMaxAngle;
  36065. /**
  36066. * Force the controller to update the bones
  36067. */
  36068. update(): void;
  36069. }
  36070. }
  36071. declare module BABYLON {
  36072. /**
  36073. * Class used to make a bone look toward a point in space
  36074. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36075. */
  36076. export class BoneLookController {
  36077. private static _tmpVecs;
  36078. private static _tmpQuat;
  36079. private static _tmpMats;
  36080. /**
  36081. * The target Vector3 that the bone will look at
  36082. */
  36083. target: Vector3;
  36084. /**
  36085. * The mesh that the bone is attached to
  36086. */
  36087. mesh: AbstractMesh;
  36088. /**
  36089. * The bone that will be looking to the target
  36090. */
  36091. bone: Bone;
  36092. /**
  36093. * The up axis of the coordinate system that is used when the bone is rotated
  36094. */
  36095. upAxis: Vector3;
  36096. /**
  36097. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36098. */
  36099. upAxisSpace: Space;
  36100. /**
  36101. * Used to make an adjustment to the yaw of the bone
  36102. */
  36103. adjustYaw: number;
  36104. /**
  36105. * Used to make an adjustment to the pitch of the bone
  36106. */
  36107. adjustPitch: number;
  36108. /**
  36109. * Used to make an adjustment to the roll of the bone
  36110. */
  36111. adjustRoll: number;
  36112. /**
  36113. * 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)
  36114. */
  36115. slerpAmount: number;
  36116. private _minYaw;
  36117. private _maxYaw;
  36118. private _minPitch;
  36119. private _maxPitch;
  36120. private _minYawSin;
  36121. private _minYawCos;
  36122. private _maxYawSin;
  36123. private _maxYawCos;
  36124. private _midYawConstraint;
  36125. private _minPitchTan;
  36126. private _maxPitchTan;
  36127. private _boneQuat;
  36128. private _slerping;
  36129. private _transformYawPitch;
  36130. private _transformYawPitchInv;
  36131. private _firstFrameSkipped;
  36132. private _yawRange;
  36133. private _fowardAxis;
  36134. /**
  36135. * Gets or sets the minimum yaw angle that the bone can look to
  36136. */
  36137. minYaw: number;
  36138. /**
  36139. * Gets or sets the maximum yaw angle that the bone can look to
  36140. */
  36141. maxYaw: number;
  36142. /**
  36143. * Gets or sets the minimum pitch angle that the bone can look to
  36144. */
  36145. minPitch: number;
  36146. /**
  36147. * Gets or sets the maximum pitch angle that the bone can look to
  36148. */
  36149. maxPitch: number;
  36150. /**
  36151. * Create a BoneLookController
  36152. * @param mesh the mesh that the bone belongs to
  36153. * @param bone the bone that will be looking to the target
  36154. * @param target the target Vector3 to look at
  36155. * @param settings optional settings:
  36156. * * maxYaw: the maximum angle the bone will yaw to
  36157. * * minYaw: the minimum angle the bone will yaw to
  36158. * * maxPitch: the maximum angle the bone will pitch to
  36159. * * minPitch: the minimum angle the bone will yaw to
  36160. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36161. * * upAxis: the up axis of the coordinate system
  36162. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36163. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36164. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36165. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36166. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36167. * * adjustRoll: used to make an adjustment to the roll of the bone
  36168. **/
  36169. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36170. maxYaw?: number;
  36171. minYaw?: number;
  36172. maxPitch?: number;
  36173. minPitch?: number;
  36174. slerpAmount?: number;
  36175. upAxis?: Vector3;
  36176. upAxisSpace?: Space;
  36177. yawAxis?: Vector3;
  36178. pitchAxis?: Vector3;
  36179. adjustYaw?: number;
  36180. adjustPitch?: number;
  36181. adjustRoll?: number;
  36182. });
  36183. /**
  36184. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36185. */
  36186. update(): void;
  36187. private _getAngleDiff;
  36188. private _getAngleBetween;
  36189. private _isAngleBetween;
  36190. }
  36191. }
  36192. declare module BABYLON {
  36193. /**
  36194. * Manage the gamepad inputs to control an arc rotate camera.
  36195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36196. */
  36197. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36198. /**
  36199. * Defines the camera the input is attached to.
  36200. */
  36201. camera: ArcRotateCamera;
  36202. /**
  36203. * Defines the gamepad the input is gathering event from.
  36204. */
  36205. gamepad: Nullable<Gamepad>;
  36206. /**
  36207. * Defines the gamepad rotation sensiblity.
  36208. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36209. */
  36210. gamepadRotationSensibility: number;
  36211. /**
  36212. * Defines the gamepad move sensiblity.
  36213. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36214. */
  36215. gamepadMoveSensibility: number;
  36216. private _onGamepadConnectedObserver;
  36217. private _onGamepadDisconnectedObserver;
  36218. /**
  36219. * Attach the input controls to a specific dom element to get the input from.
  36220. * @param element Defines the element the controls should be listened from
  36221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36222. */
  36223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36224. /**
  36225. * Detach the current controls from the specified dom element.
  36226. * @param element Defines the element to stop listening the inputs from
  36227. */
  36228. detachControl(element: Nullable<HTMLElement>): void;
  36229. /**
  36230. * Update the current camera state depending on the inputs that have been used this frame.
  36231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36232. */
  36233. checkInputs(): void;
  36234. /**
  36235. * Gets the class name of the current intput.
  36236. * @returns the class name
  36237. */
  36238. getClassName(): string;
  36239. /**
  36240. * Get the friendly name associated with the input class.
  36241. * @returns the input friendly name
  36242. */
  36243. getSimpleName(): string;
  36244. }
  36245. }
  36246. declare module BABYLON {
  36247. interface ArcRotateCameraInputsManager {
  36248. /**
  36249. * Add orientation input support to the input manager.
  36250. * @returns the current input manager
  36251. */
  36252. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36253. }
  36254. /**
  36255. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36257. */
  36258. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36259. /**
  36260. * Defines the camera the input is attached to.
  36261. */
  36262. camera: ArcRotateCamera;
  36263. /**
  36264. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36265. */
  36266. alphaCorrection: number;
  36267. /**
  36268. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36269. */
  36270. gammaCorrection: number;
  36271. private _alpha;
  36272. private _gamma;
  36273. private _dirty;
  36274. private _deviceOrientationHandler;
  36275. /**
  36276. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36277. */
  36278. constructor();
  36279. /**
  36280. * Attach the input controls to a specific dom element to get the input from.
  36281. * @param element Defines the element the controls should be listened from
  36282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36283. */
  36284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36285. /** @hidden */
  36286. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36287. /**
  36288. * Update the current camera state depending on the inputs that have been used this frame.
  36289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36290. */
  36291. checkInputs(): void;
  36292. /**
  36293. * Detach the current controls from the specified dom element.
  36294. * @param element Defines the element to stop listening the inputs from
  36295. */
  36296. detachControl(element: Nullable<HTMLElement>): void;
  36297. /**
  36298. * Gets the class name of the current intput.
  36299. * @returns the class name
  36300. */
  36301. getClassName(): string;
  36302. /**
  36303. * Get the friendly name associated with the input class.
  36304. * @returns the input friendly name
  36305. */
  36306. getSimpleName(): string;
  36307. }
  36308. }
  36309. declare module BABYLON {
  36310. /**
  36311. * Listen to mouse events to control the camera.
  36312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36313. */
  36314. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36315. /**
  36316. * Defines the camera the input is attached to.
  36317. */
  36318. camera: FlyCamera;
  36319. /**
  36320. * Defines if touch is enabled. (Default is true.)
  36321. */
  36322. touchEnabled: boolean;
  36323. /**
  36324. * Defines the buttons associated with the input to handle camera rotation.
  36325. */
  36326. buttons: number[];
  36327. /**
  36328. * Assign buttons for Yaw control.
  36329. */
  36330. buttonsYaw: number[];
  36331. /**
  36332. * Assign buttons for Pitch control.
  36333. */
  36334. buttonsPitch: number[];
  36335. /**
  36336. * Assign buttons for Roll control.
  36337. */
  36338. buttonsRoll: number[];
  36339. /**
  36340. * Detect if any button is being pressed while mouse is moved.
  36341. * -1 = Mouse locked.
  36342. * 0 = Left button.
  36343. * 1 = Middle Button.
  36344. * 2 = Right Button.
  36345. */
  36346. activeButton: number;
  36347. /**
  36348. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36349. * Higher values reduce its sensitivity.
  36350. */
  36351. angularSensibility: number;
  36352. private _mousemoveCallback;
  36353. private _observer;
  36354. private _rollObserver;
  36355. private previousPosition;
  36356. private noPreventDefault;
  36357. private element;
  36358. /**
  36359. * Listen to mouse events to control the camera.
  36360. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36362. */
  36363. constructor(touchEnabled?: boolean);
  36364. /**
  36365. * Attach the mouse control to the HTML DOM element.
  36366. * @param element Defines the element that listens to the input events.
  36367. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36368. */
  36369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36370. /**
  36371. * Detach the current controls from the specified dom element.
  36372. * @param element Defines the element to stop listening the inputs from
  36373. */
  36374. detachControl(element: Nullable<HTMLElement>): void;
  36375. /**
  36376. * Gets the class name of the current input.
  36377. * @returns the class name.
  36378. */
  36379. getClassName(): string;
  36380. /**
  36381. * Get the friendly name associated with the input class.
  36382. * @returns the input's friendly name.
  36383. */
  36384. getSimpleName(): string;
  36385. private _pointerInput;
  36386. private _onMouseMove;
  36387. /**
  36388. * Rotate camera by mouse offset.
  36389. */
  36390. private rotateCamera;
  36391. }
  36392. }
  36393. declare module BABYLON {
  36394. /**
  36395. * Default Inputs manager for the FlyCamera.
  36396. * It groups all the default supported inputs for ease of use.
  36397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36398. */
  36399. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36400. /**
  36401. * Instantiates a new FlyCameraInputsManager.
  36402. * @param camera Defines the camera the inputs belong to.
  36403. */
  36404. constructor(camera: FlyCamera);
  36405. /**
  36406. * Add keyboard input support to the input manager.
  36407. * @returns the new FlyCameraKeyboardMoveInput().
  36408. */
  36409. addKeyboard(): FlyCameraInputsManager;
  36410. /**
  36411. * Add mouse input support to the input manager.
  36412. * @param touchEnabled Enable touch screen support.
  36413. * @returns the new FlyCameraMouseInput().
  36414. */
  36415. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36416. }
  36417. }
  36418. declare module BABYLON {
  36419. /**
  36420. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36421. * such as in a 3D Space Shooter or a Flight Simulator.
  36422. */
  36423. export class FlyCamera extends TargetCamera {
  36424. /**
  36425. * Define the collision ellipsoid of the camera.
  36426. * This is helpful for simulating a camera body, like a player's body.
  36427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36428. */
  36429. ellipsoid: Vector3;
  36430. /**
  36431. * Define an offset for the position of the ellipsoid around the camera.
  36432. * This can be helpful if the camera is attached away from the player's body center,
  36433. * such as at its head.
  36434. */
  36435. ellipsoidOffset: Vector3;
  36436. /**
  36437. * Enable or disable collisions of the camera with the rest of the scene objects.
  36438. */
  36439. checkCollisions: boolean;
  36440. /**
  36441. * Enable or disable gravity on the camera.
  36442. */
  36443. applyGravity: boolean;
  36444. /**
  36445. * Define the current direction the camera is moving to.
  36446. */
  36447. cameraDirection: Vector3;
  36448. /**
  36449. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36450. * This overrides and empties cameraRotation.
  36451. */
  36452. rotationQuaternion: Quaternion;
  36453. /**
  36454. * Track Roll to maintain the wanted Rolling when looking around.
  36455. */
  36456. _trackRoll: number;
  36457. /**
  36458. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36459. */
  36460. rollCorrect: number;
  36461. /**
  36462. * Mimic a banked turn, Rolling the camera when Yawing.
  36463. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36464. */
  36465. bankedTurn: boolean;
  36466. /**
  36467. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36468. */
  36469. bankedTurnLimit: number;
  36470. /**
  36471. * Value of 0 disables the banked Roll.
  36472. * Value of 1 is equal to the Yaw angle in radians.
  36473. */
  36474. bankedTurnMultiplier: number;
  36475. /**
  36476. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36477. */
  36478. inputs: FlyCameraInputsManager;
  36479. /**
  36480. * Gets the input sensibility for mouse input.
  36481. * Higher values reduce sensitivity.
  36482. */
  36483. /**
  36484. * Sets the input sensibility for a mouse input.
  36485. * Higher values reduce sensitivity.
  36486. */
  36487. angularSensibility: number;
  36488. /**
  36489. * Get the keys for camera movement forward.
  36490. */
  36491. /**
  36492. * Set the keys for camera movement forward.
  36493. */
  36494. keysForward: number[];
  36495. /**
  36496. * Get the keys for camera movement backward.
  36497. */
  36498. keysBackward: number[];
  36499. /**
  36500. * Get the keys for camera movement up.
  36501. */
  36502. /**
  36503. * Set the keys for camera movement up.
  36504. */
  36505. keysUp: number[];
  36506. /**
  36507. * Get the keys for camera movement down.
  36508. */
  36509. /**
  36510. * Set the keys for camera movement down.
  36511. */
  36512. keysDown: number[];
  36513. /**
  36514. * Get the keys for camera movement left.
  36515. */
  36516. /**
  36517. * Set the keys for camera movement left.
  36518. */
  36519. keysLeft: number[];
  36520. /**
  36521. * Set the keys for camera movement right.
  36522. */
  36523. /**
  36524. * Set the keys for camera movement right.
  36525. */
  36526. keysRight: number[];
  36527. /**
  36528. * Event raised when the camera collides with a mesh in the scene.
  36529. */
  36530. onCollide: (collidedMesh: AbstractMesh) => void;
  36531. private _collider;
  36532. private _needMoveForGravity;
  36533. private _oldPosition;
  36534. private _diffPosition;
  36535. private _newPosition;
  36536. /** @hidden */
  36537. _localDirection: Vector3;
  36538. /** @hidden */
  36539. _transformedDirection: Vector3;
  36540. /**
  36541. * Instantiates a FlyCamera.
  36542. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36543. * such as in a 3D Space Shooter or a Flight Simulator.
  36544. * @param name Define the name of the camera in the scene.
  36545. * @param position Define the starting position of the camera in the scene.
  36546. * @param scene Define the scene the camera belongs to.
  36547. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36548. */
  36549. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36550. /**
  36551. * Attach a control to the HTML DOM element.
  36552. * @param element Defines the element that listens to the input events.
  36553. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36554. */
  36555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36556. /**
  36557. * Detach a control from the HTML DOM element.
  36558. * The camera will stop reacting to that input.
  36559. * @param element Defines the element that listens to the input events.
  36560. */
  36561. detachControl(element: HTMLElement): void;
  36562. private _collisionMask;
  36563. /**
  36564. * Get the mask that the camera ignores in collision events.
  36565. */
  36566. /**
  36567. * Set the mask that the camera ignores in collision events.
  36568. */
  36569. collisionMask: number;
  36570. /** @hidden */
  36571. _collideWithWorld(displacement: Vector3): void;
  36572. /** @hidden */
  36573. private _onCollisionPositionChange;
  36574. /** @hidden */
  36575. _checkInputs(): void;
  36576. /** @hidden */
  36577. _decideIfNeedsToMove(): boolean;
  36578. /** @hidden */
  36579. _updatePosition(): void;
  36580. /**
  36581. * Restore the Roll to its target value at the rate specified.
  36582. * @param rate - Higher means slower restoring.
  36583. * @hidden
  36584. */
  36585. restoreRoll(rate: number): void;
  36586. /**
  36587. * Destroy the camera and release the current resources held by it.
  36588. */
  36589. dispose(): void;
  36590. /**
  36591. * Get the current object class name.
  36592. * @returns the class name.
  36593. */
  36594. getClassName(): string;
  36595. }
  36596. }
  36597. declare module BABYLON {
  36598. /**
  36599. * Listen to keyboard events to control the camera.
  36600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36601. */
  36602. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36603. /**
  36604. * Defines the camera the input is attached to.
  36605. */
  36606. camera: FlyCamera;
  36607. /**
  36608. * The list of keyboard keys used to control the forward move of the camera.
  36609. */
  36610. keysForward: number[];
  36611. /**
  36612. * The list of keyboard keys used to control the backward move of the camera.
  36613. */
  36614. keysBackward: number[];
  36615. /**
  36616. * The list of keyboard keys used to control the forward move of the camera.
  36617. */
  36618. keysUp: number[];
  36619. /**
  36620. * The list of keyboard keys used to control the backward move of the camera.
  36621. */
  36622. keysDown: number[];
  36623. /**
  36624. * The list of keyboard keys used to control the right strafe move of the camera.
  36625. */
  36626. keysRight: number[];
  36627. /**
  36628. * The list of keyboard keys used to control the left strafe move of the camera.
  36629. */
  36630. keysLeft: number[];
  36631. private _keys;
  36632. private _onCanvasBlurObserver;
  36633. private _onKeyboardObserver;
  36634. private _engine;
  36635. private _scene;
  36636. /**
  36637. * Attach the input controls to a specific dom element to get the input from.
  36638. * @param element Defines the element the controls should be listened from
  36639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36640. */
  36641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36642. /**
  36643. * Detach the current controls from the specified dom element.
  36644. * @param element Defines the element to stop listening the inputs from
  36645. */
  36646. detachControl(element: Nullable<HTMLElement>): void;
  36647. /**
  36648. * Gets the class name of the current intput.
  36649. * @returns the class name
  36650. */
  36651. getClassName(): string;
  36652. /** @hidden */
  36653. _onLostFocus(e: FocusEvent): void;
  36654. /**
  36655. * Get the friendly name associated with the input class.
  36656. * @returns the input friendly name
  36657. */
  36658. getSimpleName(): string;
  36659. /**
  36660. * Update the current camera state depending on the inputs that have been used this frame.
  36661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36662. */
  36663. checkInputs(): void;
  36664. }
  36665. }
  36666. declare module BABYLON {
  36667. interface FreeCameraInputsManager {
  36668. /**
  36669. * Add orientation input support to the input manager.
  36670. * @returns the current input manager
  36671. */
  36672. addDeviceOrientation(): FreeCameraInputsManager;
  36673. }
  36674. /**
  36675. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36676. * Screen rotation is taken into account.
  36677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36678. */
  36679. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36680. private _camera;
  36681. private _screenOrientationAngle;
  36682. private _constantTranform;
  36683. private _screenQuaternion;
  36684. private _alpha;
  36685. private _beta;
  36686. private _gamma;
  36687. /**
  36688. * Instantiates a new input
  36689. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36690. */
  36691. constructor();
  36692. /**
  36693. * Define the camera controlled by the input.
  36694. */
  36695. camera: FreeCamera;
  36696. /**
  36697. * Attach the input controls to a specific dom element to get the input from.
  36698. * @param element Defines the element the controls should be listened from
  36699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36700. */
  36701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36702. private _orientationChanged;
  36703. private _deviceOrientation;
  36704. /**
  36705. * Detach the current controls from the specified dom element.
  36706. * @param element Defines the element to stop listening the inputs from
  36707. */
  36708. detachControl(element: Nullable<HTMLElement>): void;
  36709. /**
  36710. * Update the current camera state depending on the inputs that have been used this frame.
  36711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36712. */
  36713. checkInputs(): void;
  36714. /**
  36715. * Gets the class name of the current intput.
  36716. * @returns the class name
  36717. */
  36718. getClassName(): string;
  36719. /**
  36720. * Get the friendly name associated with the input class.
  36721. * @returns the input friendly name
  36722. */
  36723. getSimpleName(): string;
  36724. }
  36725. }
  36726. declare module BABYLON {
  36727. /**
  36728. * Manage the gamepad inputs to control a free camera.
  36729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36730. */
  36731. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36732. /**
  36733. * Define the camera the input is attached to.
  36734. */
  36735. camera: FreeCamera;
  36736. /**
  36737. * Define the Gamepad controlling the input
  36738. */
  36739. gamepad: Nullable<Gamepad>;
  36740. /**
  36741. * Defines the gamepad rotation sensiblity.
  36742. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36743. */
  36744. gamepadAngularSensibility: number;
  36745. /**
  36746. * Defines the gamepad move sensiblity.
  36747. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36748. */
  36749. gamepadMoveSensibility: number;
  36750. private _onGamepadConnectedObserver;
  36751. private _onGamepadDisconnectedObserver;
  36752. private _cameraTransform;
  36753. private _deltaTransform;
  36754. private _vector3;
  36755. private _vector2;
  36756. /**
  36757. * Attach the input controls to a specific dom element to get the input from.
  36758. * @param element Defines the element the controls should be listened from
  36759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36760. */
  36761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36762. /**
  36763. * Detach the current controls from the specified dom element.
  36764. * @param element Defines the element to stop listening the inputs from
  36765. */
  36766. detachControl(element: Nullable<HTMLElement>): void;
  36767. /**
  36768. * Update the current camera state depending on the inputs that have been used this frame.
  36769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36770. */
  36771. checkInputs(): void;
  36772. /**
  36773. * Gets the class name of the current intput.
  36774. * @returns the class name
  36775. */
  36776. getClassName(): string;
  36777. /**
  36778. * Get the friendly name associated with the input class.
  36779. * @returns the input friendly name
  36780. */
  36781. getSimpleName(): string;
  36782. }
  36783. }
  36784. declare module BABYLON {
  36785. /**
  36786. * Defines the potential axis of a Joystick
  36787. */
  36788. export enum JoystickAxis {
  36789. /** X axis */
  36790. X = 0,
  36791. /** Y axis */
  36792. Y = 1,
  36793. /** Z axis */
  36794. Z = 2
  36795. }
  36796. /**
  36797. * Class used to define virtual joystick (used in touch mode)
  36798. */
  36799. export class VirtualJoystick {
  36800. /**
  36801. * Gets or sets a boolean indicating that left and right values must be inverted
  36802. */
  36803. reverseLeftRight: boolean;
  36804. /**
  36805. * Gets or sets a boolean indicating that up and down values must be inverted
  36806. */
  36807. reverseUpDown: boolean;
  36808. /**
  36809. * Gets the offset value for the position (ie. the change of the position value)
  36810. */
  36811. deltaPosition: Vector3;
  36812. /**
  36813. * Gets a boolean indicating if the virtual joystick was pressed
  36814. */
  36815. pressed: boolean;
  36816. /**
  36817. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36818. */
  36819. static Canvas: Nullable<HTMLCanvasElement>;
  36820. private static _globalJoystickIndex;
  36821. private static vjCanvasContext;
  36822. private static vjCanvasWidth;
  36823. private static vjCanvasHeight;
  36824. private static halfWidth;
  36825. private _action;
  36826. private _axisTargetedByLeftAndRight;
  36827. private _axisTargetedByUpAndDown;
  36828. private _joystickSensibility;
  36829. private _inversedSensibility;
  36830. private _joystickPointerID;
  36831. private _joystickColor;
  36832. private _joystickPointerPos;
  36833. private _joystickPreviousPointerPos;
  36834. private _joystickPointerStartPos;
  36835. private _deltaJoystickVector;
  36836. private _leftJoystick;
  36837. private _touches;
  36838. private _onPointerDownHandlerRef;
  36839. private _onPointerMoveHandlerRef;
  36840. private _onPointerUpHandlerRef;
  36841. private _onResize;
  36842. /**
  36843. * Creates a new virtual joystick
  36844. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36845. */
  36846. constructor(leftJoystick?: boolean);
  36847. /**
  36848. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36849. * @param newJoystickSensibility defines the new sensibility
  36850. */
  36851. setJoystickSensibility(newJoystickSensibility: number): void;
  36852. private _onPointerDown;
  36853. private _onPointerMove;
  36854. private _onPointerUp;
  36855. /**
  36856. * Change the color of the virtual joystick
  36857. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36858. */
  36859. setJoystickColor(newColor: string): void;
  36860. /**
  36861. * Defines a callback to call when the joystick is touched
  36862. * @param action defines the callback
  36863. */
  36864. setActionOnTouch(action: () => any): void;
  36865. /**
  36866. * Defines which axis you'd like to control for left & right
  36867. * @param axis defines the axis to use
  36868. */
  36869. setAxisForLeftRight(axis: JoystickAxis): void;
  36870. /**
  36871. * Defines which axis you'd like to control for up & down
  36872. * @param axis defines the axis to use
  36873. */
  36874. setAxisForUpDown(axis: JoystickAxis): void;
  36875. private _drawVirtualJoystick;
  36876. /**
  36877. * Release internal HTML canvas
  36878. */
  36879. releaseCanvas(): void;
  36880. }
  36881. }
  36882. declare module BABYLON {
  36883. interface FreeCameraInputsManager {
  36884. /**
  36885. * Add virtual joystick input support to the input manager.
  36886. * @returns the current input manager
  36887. */
  36888. addVirtualJoystick(): FreeCameraInputsManager;
  36889. }
  36890. /**
  36891. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36893. */
  36894. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36895. /**
  36896. * Defines the camera the input is attached to.
  36897. */
  36898. camera: FreeCamera;
  36899. private _leftjoystick;
  36900. private _rightjoystick;
  36901. /**
  36902. * Gets the left stick of the virtual joystick.
  36903. * @returns The virtual Joystick
  36904. */
  36905. getLeftJoystick(): VirtualJoystick;
  36906. /**
  36907. * Gets the right stick of the virtual joystick.
  36908. * @returns The virtual Joystick
  36909. */
  36910. getRightJoystick(): VirtualJoystick;
  36911. /**
  36912. * Update the current camera state depending on the inputs that have been used this frame.
  36913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36914. */
  36915. checkInputs(): void;
  36916. /**
  36917. * Attach the input controls to a specific dom element to get the input from.
  36918. * @param element Defines the element the controls should be listened from
  36919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36920. */
  36921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36922. /**
  36923. * Detach the current controls from the specified dom element.
  36924. * @param element Defines the element to stop listening the inputs from
  36925. */
  36926. detachControl(element: Nullable<HTMLElement>): void;
  36927. /**
  36928. * Gets the class name of the current intput.
  36929. * @returns the class name
  36930. */
  36931. getClassName(): string;
  36932. /**
  36933. * Get the friendly name associated with the input class.
  36934. * @returns the input friendly name
  36935. */
  36936. getSimpleName(): string;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * This represents a FPS type of camera controlled by touch.
  36942. * This is like a universal camera minus the Gamepad controls.
  36943. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36944. */
  36945. export class TouchCamera extends FreeCamera {
  36946. /**
  36947. * Defines the touch sensibility for rotation.
  36948. * The higher the faster.
  36949. */
  36950. touchAngularSensibility: number;
  36951. /**
  36952. * Defines the touch sensibility for move.
  36953. * The higher the faster.
  36954. */
  36955. touchMoveSensibility: number;
  36956. /**
  36957. * Instantiates a new touch camera.
  36958. * This represents a FPS type of camera controlled by touch.
  36959. * This is like a universal camera minus the Gamepad controls.
  36960. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36961. * @param name Define the name of the camera in the scene
  36962. * @param position Define the start position of the camera in the scene
  36963. * @param scene Define the scene the camera belongs to
  36964. */
  36965. constructor(name: string, position: Vector3, scene: Scene);
  36966. /**
  36967. * Gets the current object class name.
  36968. * @return the class name
  36969. */
  36970. getClassName(): string;
  36971. /** @hidden */
  36972. _setupInputs(): void;
  36973. }
  36974. }
  36975. declare module BABYLON {
  36976. /**
  36977. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36978. * being tilted forward or back and left or right.
  36979. */
  36980. export class DeviceOrientationCamera extends FreeCamera {
  36981. private _initialQuaternion;
  36982. private _quaternionCache;
  36983. /**
  36984. * Creates a new device orientation camera
  36985. * @param name The name of the camera
  36986. * @param position The start position camera
  36987. * @param scene The scene the camera belongs to
  36988. */
  36989. constructor(name: string, position: Vector3, scene: Scene);
  36990. /**
  36991. * Gets the current instance class name ("DeviceOrientationCamera").
  36992. * This helps avoiding instanceof at run time.
  36993. * @returns the class name
  36994. */
  36995. getClassName(): string;
  36996. /**
  36997. * @hidden
  36998. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36999. */
  37000. _checkInputs(): void;
  37001. /**
  37002. * Reset the camera to its default orientation on the specified axis only.
  37003. * @param axis The axis to reset
  37004. */
  37005. resetToCurrentRotation(axis?: Axis): void;
  37006. }
  37007. }
  37008. declare module BABYLON {
  37009. /**
  37010. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37012. */
  37013. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37014. /**
  37015. * Defines the camera the input is attached to.
  37016. */
  37017. camera: FollowCamera;
  37018. /**
  37019. * Defines the list of key codes associated with the up action (increase heightOffset)
  37020. */
  37021. keysUp: number[];
  37022. /**
  37023. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37024. */
  37025. keysDown: number[];
  37026. /**
  37027. * Defines the list of key codes associated with the left action (increase rotation)
  37028. */
  37029. keysLeft: number[];
  37030. /**
  37031. * Defines the list of key codes associated with the right action (decrease rotation)
  37032. */
  37033. keysRight: number[];
  37034. /**
  37035. * Defines the rate of change of heightOffset.
  37036. */
  37037. heightSensibility: number;
  37038. /**
  37039. * Defines the rate of change of rotationOffset.
  37040. */
  37041. rotationSensibility: number;
  37042. /**
  37043. * Defines the rate of change of radius.
  37044. */
  37045. radiusSensibility: number;
  37046. /**
  37047. * Defines the minimum heightOffset value.
  37048. */
  37049. minHeightOffset: number;
  37050. /**
  37051. * Defines the minimum radius value.
  37052. */
  37053. minRadius: number;
  37054. private _keys;
  37055. private _altPressed;
  37056. private _onCanvasBlurObserver;
  37057. private _onKeyboardObserver;
  37058. private _engine;
  37059. private _scene;
  37060. /**
  37061. * Attach the input controls to a specific dom element to get the input from.
  37062. * @param element Defines the element the controls should be listened from
  37063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37064. */
  37065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37066. /**
  37067. * Detach the current controls from the specified dom element.
  37068. * @param element Defines the element to stop listening the inputs from
  37069. */
  37070. detachControl(element: Nullable<HTMLElement>): void;
  37071. /**
  37072. * Update the current camera state depending on the inputs that have been used this frame.
  37073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37074. */
  37075. checkInputs(): void;
  37076. /**
  37077. * Gets the class name of the current intput.
  37078. * @returns the class name
  37079. */
  37080. getClassName(): string;
  37081. /**
  37082. * Get the friendly name associated with the input class.
  37083. * @returns the input friendly name
  37084. */
  37085. getSimpleName(): string;
  37086. }
  37087. }
  37088. declare module BABYLON {
  37089. /**
  37090. * Default Inputs manager for the FollowCamera.
  37091. * It groups all the default supported inputs for ease of use.
  37092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37093. */
  37094. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37095. /**
  37096. * Instantiates a new FollowCameraInputsManager.
  37097. * @param camera Defines the camera the inputs belong to
  37098. */
  37099. constructor(camera: FollowCamera);
  37100. /**
  37101. * Add keyboard input support to the input manager.
  37102. * @returns the current input manager
  37103. */
  37104. addKeyboard(): FollowCameraInputsManager;
  37105. /**
  37106. * Add mouse wheel input support to the input manager.
  37107. * @returns the current input manager
  37108. */
  37109. addMouseWheel(): FollowCameraInputsManager;
  37110. /**
  37111. * Add pointers input support to the input manager.
  37112. * @returns the current input manager
  37113. */
  37114. addPointers(): FollowCameraInputsManager;
  37115. /**
  37116. * Add orientation input support to the input manager.
  37117. * @returns the current input manager
  37118. */
  37119. addVRDeviceOrientation(): FollowCameraInputsManager;
  37120. }
  37121. }
  37122. declare module BABYLON {
  37123. /**
  37124. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37125. * an arc rotate version arcFollowCamera are available.
  37126. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37127. */
  37128. export class FollowCamera extends TargetCamera {
  37129. /**
  37130. * Distance the follow camera should follow an object at
  37131. */
  37132. radius: number;
  37133. /**
  37134. * Define a rotation offset between the camera and the object it follows
  37135. */
  37136. rotationOffset: number;
  37137. /**
  37138. * Define a height offset between the camera and the object it follows.
  37139. * It can help following an object from the top (like a car chaing a plane)
  37140. */
  37141. heightOffset: number;
  37142. /**
  37143. * Define how fast the camera can accelerate to follow it s target.
  37144. */
  37145. cameraAcceleration: number;
  37146. /**
  37147. * Define the speed limit of the camera following an object.
  37148. */
  37149. maxCameraSpeed: number;
  37150. /**
  37151. * Define the target of the camera.
  37152. */
  37153. lockedTarget: Nullable<AbstractMesh>;
  37154. /**
  37155. * Defines the input associated with the camera.
  37156. */
  37157. inputs: FollowCameraInputsManager;
  37158. /**
  37159. * Instantiates the follow camera.
  37160. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37161. * @param name Define the name of the camera in the scene
  37162. * @param position Define the position of the camera
  37163. * @param scene Define the scene the camera belong to
  37164. * @param lockedTarget Define the target of the camera
  37165. */
  37166. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37167. private _follow;
  37168. /**
  37169. * Attached controls to the current camera.
  37170. * @param element Defines the element the controls should be listened from
  37171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37172. */
  37173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37174. /**
  37175. * Detach the current controls from the camera.
  37176. * The camera will stop reacting to inputs.
  37177. * @param element Defines the element to stop listening the inputs from
  37178. */
  37179. detachControl(element: HTMLElement): void;
  37180. /** @hidden */
  37181. _checkInputs(): void;
  37182. /**
  37183. * Gets the camera class name.
  37184. * @returns the class name
  37185. */
  37186. getClassName(): string;
  37187. }
  37188. /**
  37189. * Arc Rotate version of the follow camera.
  37190. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37191. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37192. */
  37193. export class ArcFollowCamera extends TargetCamera {
  37194. /** The longitudinal angle of the camera */
  37195. alpha: number;
  37196. /** The latitudinal angle of the camera */
  37197. beta: number;
  37198. /** The radius of the camera from its target */
  37199. radius: number;
  37200. /** Define the camera target (the messh it should follow) */
  37201. target: Nullable<AbstractMesh>;
  37202. private _cartesianCoordinates;
  37203. /**
  37204. * Instantiates a new ArcFollowCamera
  37205. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37206. * @param name Define the name of the camera
  37207. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37208. * @param beta Define the rotation angle of the camera around the elevation axis
  37209. * @param radius Define the radius of the camera from its target point
  37210. * @param target Define the target of the camera
  37211. * @param scene Define the scene the camera belongs to
  37212. */
  37213. constructor(name: string,
  37214. /** The longitudinal angle of the camera */
  37215. alpha: number,
  37216. /** The latitudinal angle of the camera */
  37217. beta: number,
  37218. /** The radius of the camera from its target */
  37219. radius: number,
  37220. /** Define the camera target (the messh it should follow) */
  37221. target: Nullable<AbstractMesh>, scene: Scene);
  37222. private _follow;
  37223. /** @hidden */
  37224. _checkInputs(): void;
  37225. /**
  37226. * Returns the class name of the object.
  37227. * It is mostly used internally for serialization purposes.
  37228. */
  37229. getClassName(): string;
  37230. }
  37231. }
  37232. declare module BABYLON {
  37233. /**
  37234. * 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,
  37235. * which still works and will still be found in many Playgrounds.
  37236. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37237. */
  37238. export class UniversalCamera extends TouchCamera {
  37239. /**
  37240. * Defines the gamepad rotation sensiblity.
  37241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37242. */
  37243. gamepadAngularSensibility: number;
  37244. /**
  37245. * Defines the gamepad move sensiblity.
  37246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37247. */
  37248. gamepadMoveSensibility: number;
  37249. /**
  37250. * 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,
  37251. * which still works and will still be found in many Playgrounds.
  37252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37253. * @param name Define the name of the camera in the scene
  37254. * @param position Define the start position of the camera in the scene
  37255. * @param scene Define the scene the camera belongs to
  37256. */
  37257. constructor(name: string, position: Vector3, scene: Scene);
  37258. /**
  37259. * Gets the current object class name.
  37260. * @return the class name
  37261. */
  37262. getClassName(): string;
  37263. }
  37264. }
  37265. declare module BABYLON {
  37266. /**
  37267. * This represents a FPS type of camera. This is only here for back compat purpose.
  37268. * Please use the UniversalCamera instead as both are identical.
  37269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37270. */
  37271. export class GamepadCamera extends UniversalCamera {
  37272. /**
  37273. * Instantiates a new Gamepad Camera
  37274. * This represents a FPS type of camera. This is only here for back compat purpose.
  37275. * Please use the UniversalCamera instead as both are identical.
  37276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37277. * @param name Define the name of the camera in the scene
  37278. * @param position Define the start position of the camera in the scene
  37279. * @param scene Define the scene the camera belongs to
  37280. */
  37281. constructor(name: string, position: Vector3, scene: Scene);
  37282. /**
  37283. * Gets the current object class name.
  37284. * @return the class name
  37285. */
  37286. getClassName(): string;
  37287. }
  37288. }
  37289. declare module BABYLON {
  37290. /** @hidden */
  37291. export var passPixelShader: {
  37292. name: string;
  37293. shader: string;
  37294. };
  37295. }
  37296. declare module BABYLON {
  37297. /** @hidden */
  37298. export var passCubePixelShader: {
  37299. name: string;
  37300. shader: string;
  37301. };
  37302. }
  37303. declare module BABYLON {
  37304. /**
  37305. * PassPostProcess which produces an output the same as it's input
  37306. */
  37307. export class PassPostProcess extends PostProcess {
  37308. /**
  37309. * Creates the PassPostProcess
  37310. * @param name The name of the effect.
  37311. * @param options The required width/height ratio to downsize to before computing the render pass.
  37312. * @param camera The camera to apply the render pass to.
  37313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37314. * @param engine The engine which the post process will be applied. (default: current engine)
  37315. * @param reusable If the post process can be reused on the same frame. (default: false)
  37316. * @param textureType The type of texture to be used when performing the post processing.
  37317. * @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)
  37318. */
  37319. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37320. }
  37321. /**
  37322. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37323. */
  37324. export class PassCubePostProcess extends PostProcess {
  37325. private _face;
  37326. /**
  37327. * Gets or sets the cube face to display.
  37328. * * 0 is +X
  37329. * * 1 is -X
  37330. * * 2 is +Y
  37331. * * 3 is -Y
  37332. * * 4 is +Z
  37333. * * 5 is -Z
  37334. */
  37335. face: number;
  37336. /**
  37337. * Creates the PassCubePostProcess
  37338. * @param name The name of the effect.
  37339. * @param options The required width/height ratio to downsize to before computing the render pass.
  37340. * @param camera The camera to apply the render pass to.
  37341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37342. * @param engine The engine which the post process will be applied. (default: current engine)
  37343. * @param reusable If the post process can be reused on the same frame. (default: false)
  37344. * @param textureType The type of texture to be used when performing the post processing.
  37345. * @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)
  37346. */
  37347. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37348. }
  37349. }
  37350. declare module BABYLON {
  37351. /** @hidden */
  37352. export var anaglyphPixelShader: {
  37353. name: string;
  37354. shader: string;
  37355. };
  37356. }
  37357. declare module BABYLON {
  37358. /**
  37359. * Postprocess used to generate anaglyphic rendering
  37360. */
  37361. export class AnaglyphPostProcess extends PostProcess {
  37362. private _passedProcess;
  37363. /**
  37364. * Creates a new AnaglyphPostProcess
  37365. * @param name defines postprocess name
  37366. * @param options defines creation options or target ratio scale
  37367. * @param rigCameras defines cameras using this postprocess
  37368. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37369. * @param engine defines hosting engine
  37370. * @param reusable defines if the postprocess will be reused multiple times per frame
  37371. */
  37372. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37378. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37379. */
  37380. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37381. /**
  37382. * Creates a new AnaglyphArcRotateCamera
  37383. * @param name defines camera name
  37384. * @param alpha defines alpha angle (in radians)
  37385. * @param beta defines beta angle (in radians)
  37386. * @param radius defines radius
  37387. * @param target defines camera target
  37388. * @param interaxialDistance defines distance between each color axis
  37389. * @param scene defines the hosting scene
  37390. */
  37391. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37392. /**
  37393. * Gets camera class name
  37394. * @returns AnaglyphArcRotateCamera
  37395. */
  37396. getClassName(): string;
  37397. }
  37398. }
  37399. declare module BABYLON {
  37400. /**
  37401. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37402. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37403. */
  37404. export class AnaglyphFreeCamera extends FreeCamera {
  37405. /**
  37406. * Creates a new AnaglyphFreeCamera
  37407. * @param name defines camera name
  37408. * @param position defines initial position
  37409. * @param interaxialDistance defines distance between each color axis
  37410. * @param scene defines the hosting scene
  37411. */
  37412. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37413. /**
  37414. * Gets camera class name
  37415. * @returns AnaglyphFreeCamera
  37416. */
  37417. getClassName(): string;
  37418. }
  37419. }
  37420. declare module BABYLON {
  37421. /**
  37422. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37423. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37424. */
  37425. export class AnaglyphGamepadCamera extends GamepadCamera {
  37426. /**
  37427. * Creates a new AnaglyphGamepadCamera
  37428. * @param name defines camera name
  37429. * @param position defines initial position
  37430. * @param interaxialDistance defines distance between each color axis
  37431. * @param scene defines the hosting scene
  37432. */
  37433. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37434. /**
  37435. * Gets camera class name
  37436. * @returns AnaglyphGamepadCamera
  37437. */
  37438. getClassName(): string;
  37439. }
  37440. }
  37441. declare module BABYLON {
  37442. /**
  37443. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37444. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37445. */
  37446. export class AnaglyphUniversalCamera extends UniversalCamera {
  37447. /**
  37448. * Creates a new AnaglyphUniversalCamera
  37449. * @param name defines camera name
  37450. * @param position defines initial position
  37451. * @param interaxialDistance defines distance between each color axis
  37452. * @param scene defines the hosting scene
  37453. */
  37454. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37455. /**
  37456. * Gets camera class name
  37457. * @returns AnaglyphUniversalCamera
  37458. */
  37459. getClassName(): string;
  37460. }
  37461. }
  37462. declare module BABYLON {
  37463. /** @hidden */
  37464. export var stereoscopicInterlacePixelShader: {
  37465. name: string;
  37466. shader: string;
  37467. };
  37468. }
  37469. declare module BABYLON {
  37470. /**
  37471. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37472. */
  37473. export class StereoscopicInterlacePostProcess extends PostProcess {
  37474. private _stepSize;
  37475. private _passedProcess;
  37476. /**
  37477. * Initializes a StereoscopicInterlacePostProcess
  37478. * @param name The name of the effect.
  37479. * @param rigCameras The rig cameras to be appled to the post process
  37480. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37482. * @param engine The engine which the post process will be applied. (default: current engine)
  37483. * @param reusable If the post process can be reused on the same frame. (default: false)
  37484. */
  37485. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37486. }
  37487. }
  37488. declare module BABYLON {
  37489. /**
  37490. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37491. * @see http://doc.babylonjs.com/features/cameras
  37492. */
  37493. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37494. /**
  37495. * Creates a new StereoscopicArcRotateCamera
  37496. * @param name defines camera name
  37497. * @param alpha defines alpha angle (in radians)
  37498. * @param beta defines beta angle (in radians)
  37499. * @param radius defines radius
  37500. * @param target defines camera target
  37501. * @param interaxialDistance defines distance between each color axis
  37502. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37503. * @param scene defines the hosting scene
  37504. */
  37505. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37506. /**
  37507. * Gets camera class name
  37508. * @returns StereoscopicArcRotateCamera
  37509. */
  37510. getClassName(): string;
  37511. }
  37512. }
  37513. declare module BABYLON {
  37514. /**
  37515. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37516. * @see http://doc.babylonjs.com/features/cameras
  37517. */
  37518. export class StereoscopicFreeCamera extends FreeCamera {
  37519. /**
  37520. * Creates a new StereoscopicFreeCamera
  37521. * @param name defines camera name
  37522. * @param position defines initial position
  37523. * @param interaxialDistance defines distance between each color axis
  37524. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37525. * @param scene defines the hosting scene
  37526. */
  37527. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37528. /**
  37529. * Gets camera class name
  37530. * @returns StereoscopicFreeCamera
  37531. */
  37532. getClassName(): string;
  37533. }
  37534. }
  37535. declare module BABYLON {
  37536. /**
  37537. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37538. * @see http://doc.babylonjs.com/features/cameras
  37539. */
  37540. export class StereoscopicGamepadCamera extends GamepadCamera {
  37541. /**
  37542. * Creates a new StereoscopicGamepadCamera
  37543. * @param name defines camera name
  37544. * @param position defines initial position
  37545. * @param interaxialDistance defines distance between each color axis
  37546. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37547. * @param scene defines the hosting scene
  37548. */
  37549. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37550. /**
  37551. * Gets camera class name
  37552. * @returns StereoscopicGamepadCamera
  37553. */
  37554. getClassName(): string;
  37555. }
  37556. }
  37557. declare module BABYLON {
  37558. /**
  37559. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37560. * @see http://doc.babylonjs.com/features/cameras
  37561. */
  37562. export class StereoscopicUniversalCamera extends UniversalCamera {
  37563. /**
  37564. * Creates a new StereoscopicUniversalCamera
  37565. * @param name defines camera name
  37566. * @param position defines initial position
  37567. * @param interaxialDistance defines distance between each color axis
  37568. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37569. * @param scene defines the hosting scene
  37570. */
  37571. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37572. /**
  37573. * Gets camera class name
  37574. * @returns StereoscopicUniversalCamera
  37575. */
  37576. getClassName(): string;
  37577. }
  37578. }
  37579. declare module BABYLON {
  37580. /**
  37581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37582. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37583. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37584. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37585. */
  37586. export class VirtualJoysticksCamera extends FreeCamera {
  37587. /**
  37588. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37589. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37590. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37591. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37592. * @param name Define the name of the camera in the scene
  37593. * @param position Define the start position of the camera in the scene
  37594. * @param scene Define the scene the camera belongs to
  37595. */
  37596. constructor(name: string, position: Vector3, scene: Scene);
  37597. /**
  37598. * Gets the current object class name.
  37599. * @return the class name
  37600. */
  37601. getClassName(): string;
  37602. }
  37603. }
  37604. declare module BABYLON {
  37605. /**
  37606. * This represents all the required metrics to create a VR camera.
  37607. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37608. */
  37609. export class VRCameraMetrics {
  37610. /**
  37611. * Define the horizontal resolution off the screen.
  37612. */
  37613. hResolution: number;
  37614. /**
  37615. * Define the vertical resolution off the screen.
  37616. */
  37617. vResolution: number;
  37618. /**
  37619. * Define the horizontal screen size.
  37620. */
  37621. hScreenSize: number;
  37622. /**
  37623. * Define the vertical screen size.
  37624. */
  37625. vScreenSize: number;
  37626. /**
  37627. * Define the vertical screen center position.
  37628. */
  37629. vScreenCenter: number;
  37630. /**
  37631. * Define the distance of the eyes to the screen.
  37632. */
  37633. eyeToScreenDistance: number;
  37634. /**
  37635. * Define the distance between both lenses
  37636. */
  37637. lensSeparationDistance: number;
  37638. /**
  37639. * Define the distance between both viewer's eyes.
  37640. */
  37641. interpupillaryDistance: number;
  37642. /**
  37643. * Define the distortion factor of the VR postprocess.
  37644. * Please, touch with care.
  37645. */
  37646. distortionK: number[];
  37647. /**
  37648. * Define the chromatic aberration correction factors for the VR post process.
  37649. */
  37650. chromaAbCorrection: number[];
  37651. /**
  37652. * Define the scale factor of the post process.
  37653. * The smaller the better but the slower.
  37654. */
  37655. postProcessScaleFactor: number;
  37656. /**
  37657. * Define an offset for the lens center.
  37658. */
  37659. lensCenterOffset: number;
  37660. /**
  37661. * Define if the current vr camera should compensate the distortion of the lense or not.
  37662. */
  37663. compensateDistortion: boolean;
  37664. /**
  37665. * Gets the rendering aspect ratio based on the provided resolutions.
  37666. */
  37667. readonly aspectRatio: number;
  37668. /**
  37669. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37670. */
  37671. readonly aspectRatioFov: number;
  37672. /**
  37673. * @hidden
  37674. */
  37675. readonly leftHMatrix: Matrix;
  37676. /**
  37677. * @hidden
  37678. */
  37679. readonly rightHMatrix: Matrix;
  37680. /**
  37681. * @hidden
  37682. */
  37683. readonly leftPreViewMatrix: Matrix;
  37684. /**
  37685. * @hidden
  37686. */
  37687. readonly rightPreViewMatrix: Matrix;
  37688. /**
  37689. * Get the default VRMetrics based on the most generic setup.
  37690. * @returns the default vr metrics
  37691. */
  37692. static GetDefault(): VRCameraMetrics;
  37693. }
  37694. }
  37695. declare module BABYLON {
  37696. /** @hidden */
  37697. export var vrDistortionCorrectionPixelShader: {
  37698. name: string;
  37699. shader: string;
  37700. };
  37701. }
  37702. declare module BABYLON {
  37703. /**
  37704. * VRDistortionCorrectionPostProcess used for mobile VR
  37705. */
  37706. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37707. private _isRightEye;
  37708. private _distortionFactors;
  37709. private _postProcessScaleFactor;
  37710. private _lensCenterOffset;
  37711. private _scaleIn;
  37712. private _scaleFactor;
  37713. private _lensCenter;
  37714. /**
  37715. * Initializes the VRDistortionCorrectionPostProcess
  37716. * @param name The name of the effect.
  37717. * @param camera The camera to apply the render pass to.
  37718. * @param isRightEye If this is for the right eye distortion
  37719. * @param vrMetrics All the required metrics for the VR camera
  37720. */
  37721. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37722. }
  37723. }
  37724. declare module BABYLON {
  37725. /**
  37726. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37727. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37728. */
  37729. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37730. /**
  37731. * Creates a new VRDeviceOrientationArcRotateCamera
  37732. * @param name defines camera name
  37733. * @param alpha defines the camera rotation along the logitudinal axis
  37734. * @param beta defines the camera rotation along the latitudinal axis
  37735. * @param radius defines the camera distance from its target
  37736. * @param target defines the camera target
  37737. * @param scene defines the scene the camera belongs to
  37738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37740. */
  37741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37742. /**
  37743. * Gets camera class name
  37744. * @returns VRDeviceOrientationArcRotateCamera
  37745. */
  37746. getClassName(): string;
  37747. }
  37748. }
  37749. declare module BABYLON {
  37750. /**
  37751. * Camera used to simulate VR rendering (based on FreeCamera)
  37752. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37753. */
  37754. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37755. /**
  37756. * Creates a new VRDeviceOrientationFreeCamera
  37757. * @param name defines camera name
  37758. * @param position defines the start position of the camera
  37759. * @param scene defines the scene the camera belongs to
  37760. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37761. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37762. */
  37763. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37764. /**
  37765. * Gets camera class name
  37766. * @returns VRDeviceOrientationFreeCamera
  37767. */
  37768. getClassName(): string;
  37769. }
  37770. }
  37771. declare module BABYLON {
  37772. /**
  37773. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37774. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37775. */
  37776. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37777. /**
  37778. * Creates a new VRDeviceOrientationGamepadCamera
  37779. * @param name defines camera name
  37780. * @param position defines the start position of the camera
  37781. * @param scene defines the scene the camera belongs to
  37782. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37783. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37784. */
  37785. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37786. /**
  37787. * Gets camera class name
  37788. * @returns VRDeviceOrientationGamepadCamera
  37789. */
  37790. getClassName(): string;
  37791. }
  37792. }
  37793. declare module BABYLON {
  37794. /**
  37795. * Defines supported buttons for XBox360 compatible gamepads
  37796. */
  37797. export enum Xbox360Button {
  37798. /** A */
  37799. A = 0,
  37800. /** B */
  37801. B = 1,
  37802. /** X */
  37803. X = 2,
  37804. /** Y */
  37805. Y = 3,
  37806. /** Start */
  37807. Start = 4,
  37808. /** Back */
  37809. Back = 5,
  37810. /** Left button */
  37811. LB = 6,
  37812. /** Right button */
  37813. RB = 7,
  37814. /** Left stick */
  37815. LeftStick = 8,
  37816. /** Right stick */
  37817. RightStick = 9
  37818. }
  37819. /** Defines values for XBox360 DPad */
  37820. export enum Xbox360Dpad {
  37821. /** Up */
  37822. Up = 0,
  37823. /** Down */
  37824. Down = 1,
  37825. /** Left */
  37826. Left = 2,
  37827. /** Right */
  37828. Right = 3
  37829. }
  37830. /**
  37831. * Defines a XBox360 gamepad
  37832. */
  37833. export class Xbox360Pad extends Gamepad {
  37834. private _leftTrigger;
  37835. private _rightTrigger;
  37836. private _onlefttriggerchanged;
  37837. private _onrighttriggerchanged;
  37838. private _onbuttondown;
  37839. private _onbuttonup;
  37840. private _ondpaddown;
  37841. private _ondpadup;
  37842. /** Observable raised when a button is pressed */
  37843. onButtonDownObservable: Observable<Xbox360Button>;
  37844. /** Observable raised when a button is released */
  37845. onButtonUpObservable: Observable<Xbox360Button>;
  37846. /** Observable raised when a pad is pressed */
  37847. onPadDownObservable: Observable<Xbox360Dpad>;
  37848. /** Observable raised when a pad is released */
  37849. onPadUpObservable: Observable<Xbox360Dpad>;
  37850. private _buttonA;
  37851. private _buttonB;
  37852. private _buttonX;
  37853. private _buttonY;
  37854. private _buttonBack;
  37855. private _buttonStart;
  37856. private _buttonLB;
  37857. private _buttonRB;
  37858. private _buttonLeftStick;
  37859. private _buttonRightStick;
  37860. private _dPadUp;
  37861. private _dPadDown;
  37862. private _dPadLeft;
  37863. private _dPadRight;
  37864. private _isXboxOnePad;
  37865. /**
  37866. * Creates a new XBox360 gamepad object
  37867. * @param id defines the id of this gamepad
  37868. * @param index defines its index
  37869. * @param gamepad defines the internal HTML gamepad object
  37870. * @param xboxOne defines if it is a XBox One gamepad
  37871. */
  37872. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37873. /**
  37874. * Defines the callback to call when left trigger is pressed
  37875. * @param callback defines the callback to use
  37876. */
  37877. onlefttriggerchanged(callback: (value: number) => void): void;
  37878. /**
  37879. * Defines the callback to call when right trigger is pressed
  37880. * @param callback defines the callback to use
  37881. */
  37882. onrighttriggerchanged(callback: (value: number) => void): void;
  37883. /**
  37884. * Gets the left trigger value
  37885. */
  37886. /**
  37887. * Sets the left trigger value
  37888. */
  37889. leftTrigger: number;
  37890. /**
  37891. * Gets the right trigger value
  37892. */
  37893. /**
  37894. * Sets the right trigger value
  37895. */
  37896. rightTrigger: number;
  37897. /**
  37898. * Defines the callback to call when a button is pressed
  37899. * @param callback defines the callback to use
  37900. */
  37901. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37902. /**
  37903. * Defines the callback to call when a button is released
  37904. * @param callback defines the callback to use
  37905. */
  37906. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37907. /**
  37908. * Defines the callback to call when a pad is pressed
  37909. * @param callback defines the callback to use
  37910. */
  37911. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37912. /**
  37913. * Defines the callback to call when a pad is released
  37914. * @param callback defines the callback to use
  37915. */
  37916. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37917. private _setButtonValue;
  37918. private _setDPadValue;
  37919. /**
  37920. * Gets the value of the `A` button
  37921. */
  37922. /**
  37923. * Sets the value of the `A` button
  37924. */
  37925. buttonA: number;
  37926. /**
  37927. * Gets the value of the `B` button
  37928. */
  37929. /**
  37930. * Sets the value of the `B` button
  37931. */
  37932. buttonB: number;
  37933. /**
  37934. * Gets the value of the `X` button
  37935. */
  37936. /**
  37937. * Sets the value of the `X` button
  37938. */
  37939. buttonX: number;
  37940. /**
  37941. * Gets the value of the `Y` button
  37942. */
  37943. /**
  37944. * Sets the value of the `Y` button
  37945. */
  37946. buttonY: number;
  37947. /**
  37948. * Gets the value of the `Start` button
  37949. */
  37950. /**
  37951. * Sets the value of the `Start` button
  37952. */
  37953. buttonStart: number;
  37954. /**
  37955. * Gets the value of the `Back` button
  37956. */
  37957. /**
  37958. * Sets the value of the `Back` button
  37959. */
  37960. buttonBack: number;
  37961. /**
  37962. * Gets the value of the `Left` button
  37963. */
  37964. /**
  37965. * Sets the value of the `Left` button
  37966. */
  37967. buttonLB: number;
  37968. /**
  37969. * Gets the value of the `Right` button
  37970. */
  37971. /**
  37972. * Sets the value of the `Right` button
  37973. */
  37974. buttonRB: number;
  37975. /**
  37976. * Gets the value of the Left joystick
  37977. */
  37978. /**
  37979. * Sets the value of the Left joystick
  37980. */
  37981. buttonLeftStick: number;
  37982. /**
  37983. * Gets the value of the Right joystick
  37984. */
  37985. /**
  37986. * Sets the value of the Right joystick
  37987. */
  37988. buttonRightStick: number;
  37989. /**
  37990. * Gets the value of D-pad up
  37991. */
  37992. /**
  37993. * Sets the value of D-pad up
  37994. */
  37995. dPadUp: number;
  37996. /**
  37997. * Gets the value of D-pad down
  37998. */
  37999. /**
  38000. * Sets the value of D-pad down
  38001. */
  38002. dPadDown: number;
  38003. /**
  38004. * Gets the value of D-pad left
  38005. */
  38006. /**
  38007. * Sets the value of D-pad left
  38008. */
  38009. dPadLeft: number;
  38010. /**
  38011. * Gets the value of D-pad right
  38012. */
  38013. /**
  38014. * Sets the value of D-pad right
  38015. */
  38016. dPadRight: number;
  38017. /**
  38018. * Force the gamepad to synchronize with device values
  38019. */
  38020. update(): void;
  38021. /**
  38022. * Disposes the gamepad
  38023. */
  38024. dispose(): void;
  38025. }
  38026. }
  38027. declare module BABYLON {
  38028. /**
  38029. * Base class of materials working in push mode in babylon JS
  38030. * @hidden
  38031. */
  38032. export class PushMaterial extends Material {
  38033. protected _activeEffect: Effect;
  38034. protected _normalMatrix: Matrix;
  38035. /**
  38036. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38037. * This means that the material can keep using a previous shader while a new one is being compiled.
  38038. * This is mostly used when shader parallel compilation is supported (true by default)
  38039. */
  38040. allowShaderHotSwapping: boolean;
  38041. constructor(name: string, scene: Scene);
  38042. getEffect(): Effect;
  38043. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38044. /**
  38045. * Binds the given world matrix to the active effect
  38046. *
  38047. * @param world the matrix to bind
  38048. */
  38049. bindOnlyWorldMatrix(world: Matrix): void;
  38050. /**
  38051. * Binds the given normal matrix to the active effect
  38052. *
  38053. * @param normalMatrix the matrix to bind
  38054. */
  38055. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38056. bind(world: Matrix, mesh?: Mesh): void;
  38057. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38058. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38059. }
  38060. }
  38061. declare module BABYLON {
  38062. /**
  38063. * This groups all the flags used to control the materials channel.
  38064. */
  38065. export class MaterialFlags {
  38066. private static _DiffuseTextureEnabled;
  38067. /**
  38068. * Are diffuse textures enabled in the application.
  38069. */
  38070. static DiffuseTextureEnabled: boolean;
  38071. private static _AmbientTextureEnabled;
  38072. /**
  38073. * Are ambient textures enabled in the application.
  38074. */
  38075. static AmbientTextureEnabled: boolean;
  38076. private static _OpacityTextureEnabled;
  38077. /**
  38078. * Are opacity textures enabled in the application.
  38079. */
  38080. static OpacityTextureEnabled: boolean;
  38081. private static _ReflectionTextureEnabled;
  38082. /**
  38083. * Are reflection textures enabled in the application.
  38084. */
  38085. static ReflectionTextureEnabled: boolean;
  38086. private static _EmissiveTextureEnabled;
  38087. /**
  38088. * Are emissive textures enabled in the application.
  38089. */
  38090. static EmissiveTextureEnabled: boolean;
  38091. private static _SpecularTextureEnabled;
  38092. /**
  38093. * Are specular textures enabled in the application.
  38094. */
  38095. static SpecularTextureEnabled: boolean;
  38096. private static _BumpTextureEnabled;
  38097. /**
  38098. * Are bump textures enabled in the application.
  38099. */
  38100. static BumpTextureEnabled: boolean;
  38101. private static _LightmapTextureEnabled;
  38102. /**
  38103. * Are lightmap textures enabled in the application.
  38104. */
  38105. static LightmapTextureEnabled: boolean;
  38106. private static _RefractionTextureEnabled;
  38107. /**
  38108. * Are refraction textures enabled in the application.
  38109. */
  38110. static RefractionTextureEnabled: boolean;
  38111. private static _ColorGradingTextureEnabled;
  38112. /**
  38113. * Are color grading textures enabled in the application.
  38114. */
  38115. static ColorGradingTextureEnabled: boolean;
  38116. private static _FresnelEnabled;
  38117. /**
  38118. * Are fresnels enabled in the application.
  38119. */
  38120. static FresnelEnabled: boolean;
  38121. }
  38122. }
  38123. declare module BABYLON {
  38124. /** @hidden */
  38125. export var defaultFragmentDeclaration: {
  38126. name: string;
  38127. shader: string;
  38128. };
  38129. }
  38130. declare module BABYLON {
  38131. /** @hidden */
  38132. export var defaultUboDeclaration: {
  38133. name: string;
  38134. shader: string;
  38135. };
  38136. }
  38137. declare module BABYLON {
  38138. /** @hidden */
  38139. export var lightFragmentDeclaration: {
  38140. name: string;
  38141. shader: string;
  38142. };
  38143. }
  38144. declare module BABYLON {
  38145. /** @hidden */
  38146. export var lightUboDeclaration: {
  38147. name: string;
  38148. shader: string;
  38149. };
  38150. }
  38151. declare module BABYLON {
  38152. /** @hidden */
  38153. export var lightsFragmentFunctions: {
  38154. name: string;
  38155. shader: string;
  38156. };
  38157. }
  38158. declare module BABYLON {
  38159. /** @hidden */
  38160. export var shadowsFragmentFunctions: {
  38161. name: string;
  38162. shader: string;
  38163. };
  38164. }
  38165. declare module BABYLON {
  38166. /** @hidden */
  38167. export var fresnelFunction: {
  38168. name: string;
  38169. shader: string;
  38170. };
  38171. }
  38172. declare module BABYLON {
  38173. /** @hidden */
  38174. export var reflectionFunction: {
  38175. name: string;
  38176. shader: string;
  38177. };
  38178. }
  38179. declare module BABYLON {
  38180. /** @hidden */
  38181. export var bumpFragmentFunctions: {
  38182. name: string;
  38183. shader: string;
  38184. };
  38185. }
  38186. declare module BABYLON {
  38187. /** @hidden */
  38188. export var logDepthDeclaration: {
  38189. name: string;
  38190. shader: string;
  38191. };
  38192. }
  38193. declare module BABYLON {
  38194. /** @hidden */
  38195. export var bumpFragment: {
  38196. name: string;
  38197. shader: string;
  38198. };
  38199. }
  38200. declare module BABYLON {
  38201. /** @hidden */
  38202. export var depthPrePass: {
  38203. name: string;
  38204. shader: string;
  38205. };
  38206. }
  38207. declare module BABYLON {
  38208. /** @hidden */
  38209. export var lightFragment: {
  38210. name: string;
  38211. shader: string;
  38212. };
  38213. }
  38214. declare module BABYLON {
  38215. /** @hidden */
  38216. export var logDepthFragment: {
  38217. name: string;
  38218. shader: string;
  38219. };
  38220. }
  38221. declare module BABYLON {
  38222. /** @hidden */
  38223. export var defaultPixelShader: {
  38224. name: string;
  38225. shader: string;
  38226. };
  38227. }
  38228. declare module BABYLON {
  38229. /** @hidden */
  38230. export var defaultVertexDeclaration: {
  38231. name: string;
  38232. shader: string;
  38233. };
  38234. }
  38235. declare module BABYLON {
  38236. /** @hidden */
  38237. export var bumpVertexDeclaration: {
  38238. name: string;
  38239. shader: string;
  38240. };
  38241. }
  38242. declare module BABYLON {
  38243. /** @hidden */
  38244. export var bumpVertex: {
  38245. name: string;
  38246. shader: string;
  38247. };
  38248. }
  38249. declare module BABYLON {
  38250. /** @hidden */
  38251. export var fogVertex: {
  38252. name: string;
  38253. shader: string;
  38254. };
  38255. }
  38256. declare module BABYLON {
  38257. /** @hidden */
  38258. export var shadowsVertex: {
  38259. name: string;
  38260. shader: string;
  38261. };
  38262. }
  38263. declare module BABYLON {
  38264. /** @hidden */
  38265. export var pointCloudVertex: {
  38266. name: string;
  38267. shader: string;
  38268. };
  38269. }
  38270. declare module BABYLON {
  38271. /** @hidden */
  38272. export var logDepthVertex: {
  38273. name: string;
  38274. shader: string;
  38275. };
  38276. }
  38277. declare module BABYLON {
  38278. /** @hidden */
  38279. export var defaultVertexShader: {
  38280. name: string;
  38281. shader: string;
  38282. };
  38283. }
  38284. declare module BABYLON {
  38285. /** @hidden */
  38286. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38287. MAINUV1: boolean;
  38288. MAINUV2: boolean;
  38289. DIFFUSE: boolean;
  38290. DIFFUSEDIRECTUV: number;
  38291. AMBIENT: boolean;
  38292. AMBIENTDIRECTUV: number;
  38293. OPACITY: boolean;
  38294. OPACITYDIRECTUV: number;
  38295. OPACITYRGB: boolean;
  38296. REFLECTION: boolean;
  38297. EMISSIVE: boolean;
  38298. EMISSIVEDIRECTUV: number;
  38299. SPECULAR: boolean;
  38300. SPECULARDIRECTUV: number;
  38301. BUMP: boolean;
  38302. BUMPDIRECTUV: number;
  38303. PARALLAX: boolean;
  38304. PARALLAXOCCLUSION: boolean;
  38305. SPECULAROVERALPHA: boolean;
  38306. CLIPPLANE: boolean;
  38307. CLIPPLANE2: boolean;
  38308. CLIPPLANE3: boolean;
  38309. CLIPPLANE4: boolean;
  38310. ALPHATEST: boolean;
  38311. DEPTHPREPASS: boolean;
  38312. ALPHAFROMDIFFUSE: boolean;
  38313. POINTSIZE: boolean;
  38314. FOG: boolean;
  38315. SPECULARTERM: boolean;
  38316. DIFFUSEFRESNEL: boolean;
  38317. OPACITYFRESNEL: boolean;
  38318. REFLECTIONFRESNEL: boolean;
  38319. REFRACTIONFRESNEL: boolean;
  38320. EMISSIVEFRESNEL: boolean;
  38321. FRESNEL: boolean;
  38322. NORMAL: boolean;
  38323. UV1: boolean;
  38324. UV2: boolean;
  38325. VERTEXCOLOR: boolean;
  38326. VERTEXALPHA: boolean;
  38327. NUM_BONE_INFLUENCERS: number;
  38328. BonesPerMesh: number;
  38329. BONETEXTURE: boolean;
  38330. INSTANCES: boolean;
  38331. GLOSSINESS: boolean;
  38332. ROUGHNESS: boolean;
  38333. EMISSIVEASILLUMINATION: boolean;
  38334. LINKEMISSIVEWITHDIFFUSE: boolean;
  38335. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38336. LIGHTMAP: boolean;
  38337. LIGHTMAPDIRECTUV: number;
  38338. OBJECTSPACE_NORMALMAP: boolean;
  38339. USELIGHTMAPASSHADOWMAP: boolean;
  38340. REFLECTIONMAP_3D: boolean;
  38341. REFLECTIONMAP_SPHERICAL: boolean;
  38342. REFLECTIONMAP_PLANAR: boolean;
  38343. REFLECTIONMAP_CUBIC: boolean;
  38344. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38345. REFLECTIONMAP_PROJECTION: boolean;
  38346. REFLECTIONMAP_SKYBOX: boolean;
  38347. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38348. REFLECTIONMAP_EXPLICIT: boolean;
  38349. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38350. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38351. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38352. INVERTCUBICMAP: boolean;
  38353. LOGARITHMICDEPTH: boolean;
  38354. REFRACTION: boolean;
  38355. REFRACTIONMAP_3D: boolean;
  38356. REFLECTIONOVERALPHA: boolean;
  38357. TWOSIDEDLIGHTING: boolean;
  38358. SHADOWFLOAT: boolean;
  38359. MORPHTARGETS: boolean;
  38360. MORPHTARGETS_NORMAL: boolean;
  38361. MORPHTARGETS_TANGENT: boolean;
  38362. NUM_MORPH_INFLUENCERS: number;
  38363. NONUNIFORMSCALING: boolean;
  38364. PREMULTIPLYALPHA: boolean;
  38365. IMAGEPROCESSING: boolean;
  38366. VIGNETTE: boolean;
  38367. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38368. VIGNETTEBLENDMODEOPAQUE: boolean;
  38369. TONEMAPPING: boolean;
  38370. TONEMAPPING_ACES: boolean;
  38371. CONTRAST: boolean;
  38372. COLORCURVES: boolean;
  38373. COLORGRADING: boolean;
  38374. COLORGRADING3D: boolean;
  38375. SAMPLER3DGREENDEPTH: boolean;
  38376. SAMPLER3DBGRMAP: boolean;
  38377. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38378. /**
  38379. * If the reflection texture on this material is in linear color space
  38380. * @hidden
  38381. */
  38382. IS_REFLECTION_LINEAR: boolean;
  38383. /**
  38384. * If the refraction texture on this material is in linear color space
  38385. * @hidden
  38386. */
  38387. IS_REFRACTION_LINEAR: boolean;
  38388. EXPOSURE: boolean;
  38389. constructor();
  38390. setReflectionMode(modeToEnable: string): void;
  38391. }
  38392. /**
  38393. * This is the default material used in Babylon. It is the best trade off between quality
  38394. * and performances.
  38395. * @see http://doc.babylonjs.com/babylon101/materials
  38396. */
  38397. export class StandardMaterial extends PushMaterial {
  38398. private _diffuseTexture;
  38399. /**
  38400. * The basic texture of the material as viewed under a light.
  38401. */
  38402. diffuseTexture: Nullable<BaseTexture>;
  38403. private _ambientTexture;
  38404. /**
  38405. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38406. */
  38407. ambientTexture: Nullable<BaseTexture>;
  38408. private _opacityTexture;
  38409. /**
  38410. * Define the transparency of the material from a texture.
  38411. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38412. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38413. */
  38414. opacityTexture: Nullable<BaseTexture>;
  38415. private _reflectionTexture;
  38416. /**
  38417. * Define the texture used to display the reflection.
  38418. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38419. */
  38420. reflectionTexture: Nullable<BaseTexture>;
  38421. private _emissiveTexture;
  38422. /**
  38423. * Define texture of the material as if self lit.
  38424. * This will be mixed in the final result even in the absence of light.
  38425. */
  38426. emissiveTexture: Nullable<BaseTexture>;
  38427. private _specularTexture;
  38428. /**
  38429. * Define how the color and intensity of the highlight given by the light in the material.
  38430. */
  38431. specularTexture: Nullable<BaseTexture>;
  38432. private _bumpTexture;
  38433. /**
  38434. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38435. * 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.
  38436. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38437. */
  38438. bumpTexture: Nullable<BaseTexture>;
  38439. private _lightmapTexture;
  38440. /**
  38441. * Complex lighting can be computationally expensive to compute at runtime.
  38442. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38443. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38444. */
  38445. lightmapTexture: Nullable<BaseTexture>;
  38446. private _refractionTexture;
  38447. /**
  38448. * Define the texture used to display the refraction.
  38449. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38450. */
  38451. refractionTexture: Nullable<BaseTexture>;
  38452. /**
  38453. * The color of the material lit by the environmental background lighting.
  38454. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38455. */
  38456. ambientColor: Color3;
  38457. /**
  38458. * The basic color of the material as viewed under a light.
  38459. */
  38460. diffuseColor: Color3;
  38461. /**
  38462. * Define how the color and intensity of the highlight given by the light in the material.
  38463. */
  38464. specularColor: Color3;
  38465. /**
  38466. * Define the color of the material as if self lit.
  38467. * This will be mixed in the final result even in the absence of light.
  38468. */
  38469. emissiveColor: Color3;
  38470. /**
  38471. * Defines how sharp are the highlights in the material.
  38472. * The bigger the value the sharper giving a more glossy feeling to the result.
  38473. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38474. */
  38475. specularPower: number;
  38476. private _useAlphaFromDiffuseTexture;
  38477. /**
  38478. * Does the transparency come from the diffuse texture alpha channel.
  38479. */
  38480. useAlphaFromDiffuseTexture: boolean;
  38481. private _useEmissiveAsIllumination;
  38482. /**
  38483. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38484. */
  38485. useEmissiveAsIllumination: boolean;
  38486. private _linkEmissiveWithDiffuse;
  38487. /**
  38488. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38489. * the emissive level when the final color is close to one.
  38490. */
  38491. linkEmissiveWithDiffuse: boolean;
  38492. private _useSpecularOverAlpha;
  38493. /**
  38494. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38495. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38496. */
  38497. useSpecularOverAlpha: boolean;
  38498. private _useReflectionOverAlpha;
  38499. /**
  38500. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38501. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38502. */
  38503. useReflectionOverAlpha: boolean;
  38504. private _disableLighting;
  38505. /**
  38506. * Does lights from the scene impacts this material.
  38507. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38508. */
  38509. disableLighting: boolean;
  38510. private _useObjectSpaceNormalMap;
  38511. /**
  38512. * Allows using an object space normal map (instead of tangent space).
  38513. */
  38514. useObjectSpaceNormalMap: boolean;
  38515. private _useParallax;
  38516. /**
  38517. * Is parallax enabled or not.
  38518. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38519. */
  38520. useParallax: boolean;
  38521. private _useParallaxOcclusion;
  38522. /**
  38523. * Is parallax occlusion enabled or not.
  38524. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38525. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38526. */
  38527. useParallaxOcclusion: boolean;
  38528. /**
  38529. * 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.
  38530. */
  38531. parallaxScaleBias: number;
  38532. private _roughness;
  38533. /**
  38534. * Helps to define how blurry the reflections should appears in the material.
  38535. */
  38536. roughness: number;
  38537. /**
  38538. * In case of refraction, define the value of the indice of refraction.
  38539. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38540. */
  38541. indexOfRefraction: number;
  38542. /**
  38543. * Invert the refraction texture alongside the y axis.
  38544. * It can be useful with procedural textures or probe for instance.
  38545. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38546. */
  38547. invertRefractionY: boolean;
  38548. /**
  38549. * Defines the alpha limits in alpha test mode.
  38550. */
  38551. alphaCutOff: number;
  38552. private _useLightmapAsShadowmap;
  38553. /**
  38554. * In case of light mapping, define whether the map contains light or shadow informations.
  38555. */
  38556. useLightmapAsShadowmap: boolean;
  38557. private _diffuseFresnelParameters;
  38558. /**
  38559. * Define the diffuse fresnel parameters of the material.
  38560. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38561. */
  38562. diffuseFresnelParameters: FresnelParameters;
  38563. private _opacityFresnelParameters;
  38564. /**
  38565. * Define the opacity fresnel parameters of the material.
  38566. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38567. */
  38568. opacityFresnelParameters: FresnelParameters;
  38569. private _reflectionFresnelParameters;
  38570. /**
  38571. * Define the reflection fresnel parameters of the material.
  38572. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38573. */
  38574. reflectionFresnelParameters: FresnelParameters;
  38575. private _refractionFresnelParameters;
  38576. /**
  38577. * Define the refraction fresnel parameters of the material.
  38578. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38579. */
  38580. refractionFresnelParameters: FresnelParameters;
  38581. private _emissiveFresnelParameters;
  38582. /**
  38583. * Define the emissive fresnel parameters of the material.
  38584. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38585. */
  38586. emissiveFresnelParameters: FresnelParameters;
  38587. private _useReflectionFresnelFromSpecular;
  38588. /**
  38589. * If true automatically deducts the fresnels values from the material specularity.
  38590. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38591. */
  38592. useReflectionFresnelFromSpecular: boolean;
  38593. private _useGlossinessFromSpecularMapAlpha;
  38594. /**
  38595. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38596. */
  38597. useGlossinessFromSpecularMapAlpha: boolean;
  38598. private _maxSimultaneousLights;
  38599. /**
  38600. * Defines the maximum number of lights that can be used in the material
  38601. */
  38602. maxSimultaneousLights: number;
  38603. private _invertNormalMapX;
  38604. /**
  38605. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38606. */
  38607. invertNormalMapX: boolean;
  38608. private _invertNormalMapY;
  38609. /**
  38610. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38611. */
  38612. invertNormalMapY: boolean;
  38613. private _twoSidedLighting;
  38614. /**
  38615. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38616. */
  38617. twoSidedLighting: boolean;
  38618. /**
  38619. * Default configuration related to image processing available in the standard Material.
  38620. */
  38621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38622. /**
  38623. * Gets the image processing configuration used either in this material.
  38624. */
  38625. /**
  38626. * Sets the Default image processing configuration used either in the this material.
  38627. *
  38628. * If sets to null, the scene one is in use.
  38629. */
  38630. imageProcessingConfiguration: ImageProcessingConfiguration;
  38631. /**
  38632. * Keep track of the image processing observer to allow dispose and replace.
  38633. */
  38634. private _imageProcessingObserver;
  38635. /**
  38636. * Attaches a new image processing configuration to the Standard Material.
  38637. * @param configuration
  38638. */
  38639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38640. /**
  38641. * Gets wether the color curves effect is enabled.
  38642. */
  38643. /**
  38644. * Sets wether the color curves effect is enabled.
  38645. */
  38646. cameraColorCurvesEnabled: boolean;
  38647. /**
  38648. * Gets wether the color grading effect is enabled.
  38649. */
  38650. /**
  38651. * Gets wether the color grading effect is enabled.
  38652. */
  38653. cameraColorGradingEnabled: boolean;
  38654. /**
  38655. * Gets wether tonemapping is enabled or not.
  38656. */
  38657. /**
  38658. * Sets wether tonemapping is enabled or not
  38659. */
  38660. cameraToneMappingEnabled: boolean;
  38661. /**
  38662. * The camera exposure used on this material.
  38663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38664. * This corresponds to a photographic exposure.
  38665. */
  38666. /**
  38667. * The camera exposure used on this material.
  38668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38669. * This corresponds to a photographic exposure.
  38670. */
  38671. cameraExposure: number;
  38672. /**
  38673. * Gets The camera contrast used on this material.
  38674. */
  38675. /**
  38676. * Sets The camera contrast used on this material.
  38677. */
  38678. cameraContrast: number;
  38679. /**
  38680. * Gets the Color Grading 2D Lookup Texture.
  38681. */
  38682. /**
  38683. * Sets the Color Grading 2D Lookup Texture.
  38684. */
  38685. cameraColorGradingTexture: Nullable<BaseTexture>;
  38686. /**
  38687. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38688. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38689. * 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;
  38690. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38691. */
  38692. /**
  38693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38695. * 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;
  38696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38697. */
  38698. cameraColorCurves: Nullable<ColorCurves>;
  38699. /**
  38700. * Custom callback helping to override the default shader used in the material.
  38701. */
  38702. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38703. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38704. protected _worldViewProjectionMatrix: Matrix;
  38705. protected _globalAmbientColor: Color3;
  38706. protected _useLogarithmicDepth: boolean;
  38707. /**
  38708. * Instantiates a new standard material.
  38709. * This is the default material used in Babylon. It is the best trade off between quality
  38710. * and performances.
  38711. * @see http://doc.babylonjs.com/babylon101/materials
  38712. * @param name Define the name of the material in the scene
  38713. * @param scene Define the scene the material belong to
  38714. */
  38715. constructor(name: string, scene: Scene);
  38716. /**
  38717. * Gets a boolean indicating that current material needs to register RTT
  38718. */
  38719. readonly hasRenderTargetTextures: boolean;
  38720. /**
  38721. * Gets the current class name of the material e.g. "StandardMaterial"
  38722. * Mainly use in serialization.
  38723. * @returns the class name
  38724. */
  38725. getClassName(): string;
  38726. /**
  38727. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38728. * You can try switching to logarithmic depth.
  38729. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38730. */
  38731. useLogarithmicDepth: boolean;
  38732. /**
  38733. * Specifies if the material will require alpha blending
  38734. * @returns a boolean specifying if alpha blending is needed
  38735. */
  38736. needAlphaBlending(): boolean;
  38737. /**
  38738. * Specifies if this material should be rendered in alpha test mode
  38739. * @returns a boolean specifying if an alpha test is needed.
  38740. */
  38741. needAlphaTesting(): boolean;
  38742. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38743. /**
  38744. * Get the texture used for alpha test purpose.
  38745. * @returns the diffuse texture in case of the standard material.
  38746. */
  38747. getAlphaTestTexture(): Nullable<BaseTexture>;
  38748. /**
  38749. * Get if the submesh is ready to be used and all its information available.
  38750. * Child classes can use it to update shaders
  38751. * @param mesh defines the mesh to check
  38752. * @param subMesh defines which submesh to check
  38753. * @param useInstances specifies that instances should be used
  38754. * @returns a boolean indicating that the submesh is ready or not
  38755. */
  38756. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38757. /**
  38758. * Builds the material UBO layouts.
  38759. * Used internally during the effect preparation.
  38760. */
  38761. buildUniformLayout(): void;
  38762. /**
  38763. * Unbinds the material from the mesh
  38764. */
  38765. unbind(): void;
  38766. /**
  38767. * Binds the submesh to this material by preparing the effect and shader to draw
  38768. * @param world defines the world transformation matrix
  38769. * @param mesh defines the mesh containing the submesh
  38770. * @param subMesh defines the submesh to bind the material to
  38771. */
  38772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38773. /**
  38774. * Get the list of animatables in the material.
  38775. * @returns the list of animatables object used in the material
  38776. */
  38777. getAnimatables(): IAnimatable[];
  38778. /**
  38779. * Gets the active textures from the material
  38780. * @returns an array of textures
  38781. */
  38782. getActiveTextures(): BaseTexture[];
  38783. /**
  38784. * Specifies if the material uses a texture
  38785. * @param texture defines the texture to check against the material
  38786. * @returns a boolean specifying if the material uses the texture
  38787. */
  38788. hasTexture(texture: BaseTexture): boolean;
  38789. /**
  38790. * Disposes the material
  38791. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38792. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38793. */
  38794. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38795. /**
  38796. * Makes a duplicate of the material, and gives it a new name
  38797. * @param name defines the new name for the duplicated material
  38798. * @returns the cloned material
  38799. */
  38800. clone(name: string): StandardMaterial;
  38801. /**
  38802. * Serializes this material in a JSON representation
  38803. * @returns the serialized material object
  38804. */
  38805. serialize(): any;
  38806. /**
  38807. * Creates a standard material from parsed material data
  38808. * @param source defines the JSON representation of the material
  38809. * @param scene defines the hosting scene
  38810. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38811. * @returns a new standard material
  38812. */
  38813. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38814. /**
  38815. * Are diffuse textures enabled in the application.
  38816. */
  38817. static DiffuseTextureEnabled: boolean;
  38818. /**
  38819. * Are ambient textures enabled in the application.
  38820. */
  38821. static AmbientTextureEnabled: boolean;
  38822. /**
  38823. * Are opacity textures enabled in the application.
  38824. */
  38825. static OpacityTextureEnabled: boolean;
  38826. /**
  38827. * Are reflection textures enabled in the application.
  38828. */
  38829. static ReflectionTextureEnabled: boolean;
  38830. /**
  38831. * Are emissive textures enabled in the application.
  38832. */
  38833. static EmissiveTextureEnabled: boolean;
  38834. /**
  38835. * Are specular textures enabled in the application.
  38836. */
  38837. static SpecularTextureEnabled: boolean;
  38838. /**
  38839. * Are bump textures enabled in the application.
  38840. */
  38841. static BumpTextureEnabled: boolean;
  38842. /**
  38843. * Are lightmap textures enabled in the application.
  38844. */
  38845. static LightmapTextureEnabled: boolean;
  38846. /**
  38847. * Are refraction textures enabled in the application.
  38848. */
  38849. static RefractionTextureEnabled: boolean;
  38850. /**
  38851. * Are color grading textures enabled in the application.
  38852. */
  38853. static ColorGradingTextureEnabled: boolean;
  38854. /**
  38855. * Are fresnels enabled in the application.
  38856. */
  38857. static FresnelEnabled: boolean;
  38858. }
  38859. }
  38860. declare module BABYLON {
  38861. /**
  38862. * A class extending Texture allowing drawing on a texture
  38863. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38864. */
  38865. export class DynamicTexture extends Texture {
  38866. private _generateMipMaps;
  38867. private _canvas;
  38868. private _context;
  38869. private _engine;
  38870. /**
  38871. * Creates a DynamicTexture
  38872. * @param name defines the name of the texture
  38873. * @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
  38874. * @param scene defines the scene where you want the texture
  38875. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38876. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38877. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38878. */
  38879. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38880. /**
  38881. * Get the current class name of the texture useful for serialization or dynamic coding.
  38882. * @returns "DynamicTexture"
  38883. */
  38884. getClassName(): string;
  38885. /**
  38886. * Gets the current state of canRescale
  38887. */
  38888. readonly canRescale: boolean;
  38889. private _recreate;
  38890. /**
  38891. * Scales the texture
  38892. * @param ratio the scale factor to apply to both width and height
  38893. */
  38894. scale(ratio: number): void;
  38895. /**
  38896. * Resizes the texture
  38897. * @param width the new width
  38898. * @param height the new height
  38899. */
  38900. scaleTo(width: number, height: number): void;
  38901. /**
  38902. * Gets the context of the canvas used by the texture
  38903. * @returns the canvas context of the dynamic texture
  38904. */
  38905. getContext(): CanvasRenderingContext2D;
  38906. /**
  38907. * Clears the texture
  38908. */
  38909. clear(): void;
  38910. /**
  38911. * Updates the texture
  38912. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38913. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38914. */
  38915. update(invertY?: boolean, premulAlpha?: boolean): void;
  38916. /**
  38917. * Draws text onto the texture
  38918. * @param text defines the text to be drawn
  38919. * @param x defines the placement of the text from the left
  38920. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38921. * @param font defines the font to be used with font-style, font-size, font-name
  38922. * @param color defines the color used for the text
  38923. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38924. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38925. * @param update defines whether texture is immediately update (default is true)
  38926. */
  38927. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38928. /**
  38929. * Clones the texture
  38930. * @returns the clone of the texture.
  38931. */
  38932. clone(): DynamicTexture;
  38933. /**
  38934. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38935. * @returns a serialized dynamic texture object
  38936. */
  38937. serialize(): any;
  38938. /** @hidden */
  38939. _rebuild(): void;
  38940. }
  38941. }
  38942. declare module BABYLON {
  38943. /** @hidden */
  38944. export var imageProcessingPixelShader: {
  38945. name: string;
  38946. shader: string;
  38947. };
  38948. }
  38949. declare module BABYLON {
  38950. /**
  38951. * ImageProcessingPostProcess
  38952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38953. */
  38954. export class ImageProcessingPostProcess extends PostProcess {
  38955. /**
  38956. * Default configuration related to image processing available in the PBR Material.
  38957. */
  38958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38959. /**
  38960. * Gets the image processing configuration used either in this material.
  38961. */
  38962. /**
  38963. * Sets the Default image processing configuration used either in the this material.
  38964. *
  38965. * If sets to null, the scene one is in use.
  38966. */
  38967. imageProcessingConfiguration: ImageProcessingConfiguration;
  38968. /**
  38969. * Keep track of the image processing observer to allow dispose and replace.
  38970. */
  38971. private _imageProcessingObserver;
  38972. /**
  38973. * Attaches a new image processing configuration to the PBR Material.
  38974. * @param configuration
  38975. */
  38976. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38977. /**
  38978. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38979. */
  38980. /**
  38981. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38982. */
  38983. colorCurves: Nullable<ColorCurves>;
  38984. /**
  38985. * Gets wether the color curves effect is enabled.
  38986. */
  38987. /**
  38988. * Sets wether the color curves effect is enabled.
  38989. */
  38990. colorCurvesEnabled: boolean;
  38991. /**
  38992. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38993. */
  38994. /**
  38995. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38996. */
  38997. colorGradingTexture: Nullable<BaseTexture>;
  38998. /**
  38999. * Gets wether the color grading effect is enabled.
  39000. */
  39001. /**
  39002. * Gets wether the color grading effect is enabled.
  39003. */
  39004. colorGradingEnabled: boolean;
  39005. /**
  39006. * Gets exposure used in the effect.
  39007. */
  39008. /**
  39009. * Sets exposure used in the effect.
  39010. */
  39011. exposure: number;
  39012. /**
  39013. * Gets wether tonemapping is enabled or not.
  39014. */
  39015. /**
  39016. * Sets wether tonemapping is enabled or not
  39017. */
  39018. toneMappingEnabled: boolean;
  39019. /**
  39020. * Gets contrast used in the effect.
  39021. */
  39022. /**
  39023. * Sets contrast used in the effect.
  39024. */
  39025. contrast: number;
  39026. /**
  39027. * Gets Vignette stretch size.
  39028. */
  39029. /**
  39030. * Sets Vignette stretch size.
  39031. */
  39032. vignetteStretch: number;
  39033. /**
  39034. * Gets Vignette centre X Offset.
  39035. */
  39036. /**
  39037. * Sets Vignette centre X Offset.
  39038. */
  39039. vignetteCentreX: number;
  39040. /**
  39041. * Gets Vignette centre Y Offset.
  39042. */
  39043. /**
  39044. * Sets Vignette centre Y Offset.
  39045. */
  39046. vignetteCentreY: number;
  39047. /**
  39048. * Gets Vignette weight or intensity of the vignette effect.
  39049. */
  39050. /**
  39051. * Sets Vignette weight or intensity of the vignette effect.
  39052. */
  39053. vignetteWeight: number;
  39054. /**
  39055. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39056. * if vignetteEnabled is set to true.
  39057. */
  39058. /**
  39059. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39060. * if vignetteEnabled is set to true.
  39061. */
  39062. vignetteColor: Color4;
  39063. /**
  39064. * Gets Camera field of view used by the Vignette effect.
  39065. */
  39066. /**
  39067. * Sets Camera field of view used by the Vignette effect.
  39068. */
  39069. vignetteCameraFov: number;
  39070. /**
  39071. * Gets the vignette blend mode allowing different kind of effect.
  39072. */
  39073. /**
  39074. * Sets the vignette blend mode allowing different kind of effect.
  39075. */
  39076. vignetteBlendMode: number;
  39077. /**
  39078. * Gets wether the vignette effect is enabled.
  39079. */
  39080. /**
  39081. * Sets wether the vignette effect is enabled.
  39082. */
  39083. vignetteEnabled: boolean;
  39084. private _fromLinearSpace;
  39085. /**
  39086. * Gets wether the input of the processing is in Gamma or Linear Space.
  39087. */
  39088. /**
  39089. * Sets wether the input of the processing is in Gamma or Linear Space.
  39090. */
  39091. fromLinearSpace: boolean;
  39092. /**
  39093. * Defines cache preventing GC.
  39094. */
  39095. private _defines;
  39096. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39097. /**
  39098. * "ImageProcessingPostProcess"
  39099. * @returns "ImageProcessingPostProcess"
  39100. */
  39101. getClassName(): string;
  39102. protected _updateParameters(): void;
  39103. dispose(camera?: Camera): void;
  39104. }
  39105. }
  39106. declare module BABYLON {
  39107. /**
  39108. * Options to modify the vr teleportation behavior.
  39109. */
  39110. export interface VRTeleportationOptions {
  39111. /**
  39112. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39113. */
  39114. floorMeshName?: string;
  39115. /**
  39116. * A list of meshes to be used as the teleportation floor. (default: empty)
  39117. */
  39118. floorMeshes?: Mesh[];
  39119. }
  39120. /**
  39121. * Options to modify the vr experience helper's behavior.
  39122. */
  39123. export interface VRExperienceHelperOptions extends WebVROptions {
  39124. /**
  39125. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39126. */
  39127. createDeviceOrientationCamera?: boolean;
  39128. /**
  39129. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39130. */
  39131. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39132. /**
  39133. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39134. */
  39135. laserToggle?: boolean;
  39136. /**
  39137. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39138. */
  39139. floorMeshes?: Mesh[];
  39140. }
  39141. /**
  39142. * Helps to quickly add VR support to an existing scene.
  39143. * See http://doc.babylonjs.com/how_to/webvr_helper
  39144. */
  39145. export class VRExperienceHelper {
  39146. /** Options to modify the vr experience helper's behavior. */
  39147. webVROptions: VRExperienceHelperOptions;
  39148. private _scene;
  39149. private _position;
  39150. private _btnVR;
  39151. private _btnVRDisplayed;
  39152. private _webVRsupported;
  39153. private _webVRready;
  39154. private _webVRrequesting;
  39155. private _webVRpresenting;
  39156. private _hasEnteredVR;
  39157. private _fullscreenVRpresenting;
  39158. private _canvas;
  39159. private _webVRCamera;
  39160. private _vrDeviceOrientationCamera;
  39161. private _deviceOrientationCamera;
  39162. private _existingCamera;
  39163. private _onKeyDown;
  39164. private _onVrDisplayPresentChange;
  39165. private _onVRDisplayChanged;
  39166. private _onVRRequestPresentStart;
  39167. private _onVRRequestPresentComplete;
  39168. /**
  39169. * Observable raised when entering VR.
  39170. */
  39171. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39172. /**
  39173. * Observable raised when exiting VR.
  39174. */
  39175. onExitingVRObservable: Observable<VRExperienceHelper>;
  39176. /**
  39177. * Observable raised when controller mesh is loaded.
  39178. */
  39179. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39180. /** Return this.onEnteringVRObservable
  39181. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39182. */
  39183. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39184. /** Return this.onExitingVRObservable
  39185. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39186. */
  39187. readonly onExitingVR: Observable<VRExperienceHelper>;
  39188. /** Return this.onControllerMeshLoadedObservable
  39189. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39190. */
  39191. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39192. private _rayLength;
  39193. private _useCustomVRButton;
  39194. private _teleportationRequested;
  39195. private _teleportActive;
  39196. private _floorMeshName;
  39197. private _floorMeshesCollection;
  39198. private _rotationAllowed;
  39199. private _teleportBackwardsVector;
  39200. private _teleportationTarget;
  39201. private _isDefaultTeleportationTarget;
  39202. private _postProcessMove;
  39203. private _teleportationFillColor;
  39204. private _teleportationBorderColor;
  39205. private _rotationAngle;
  39206. private _haloCenter;
  39207. private _cameraGazer;
  39208. private _padSensibilityUp;
  39209. private _padSensibilityDown;
  39210. private _leftController;
  39211. private _rightController;
  39212. /**
  39213. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39214. */
  39215. onNewMeshSelected: Observable<AbstractMesh>;
  39216. /**
  39217. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39218. */
  39219. onNewMeshPicked: Observable<PickingInfo>;
  39220. private _circleEase;
  39221. /**
  39222. * Observable raised before camera teleportation
  39223. */
  39224. onBeforeCameraTeleport: Observable<Vector3>;
  39225. /**
  39226. * Observable raised after camera teleportation
  39227. */
  39228. onAfterCameraTeleport: Observable<Vector3>;
  39229. /**
  39230. * Observable raised when current selected mesh gets unselected
  39231. */
  39232. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39233. private _raySelectionPredicate;
  39234. /**
  39235. * To be optionaly changed by user to define custom ray selection
  39236. */
  39237. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39238. /**
  39239. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39240. */
  39241. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39242. /**
  39243. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39244. */
  39245. teleportationEnabled: boolean;
  39246. private _defaultHeight;
  39247. private _teleportationInitialized;
  39248. private _interactionsEnabled;
  39249. private _interactionsRequested;
  39250. private _displayGaze;
  39251. private _displayLaserPointer;
  39252. /**
  39253. * The mesh used to display where the user is going to teleport.
  39254. */
  39255. /**
  39256. * Sets the mesh to be used to display where the user is going to teleport.
  39257. */
  39258. teleportationTarget: Mesh;
  39259. /**
  39260. * 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
  39261. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39262. * See http://doc.babylonjs.com/resources/baking_transformations
  39263. */
  39264. gazeTrackerMesh: Mesh;
  39265. /**
  39266. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39267. */
  39268. updateGazeTrackerScale: boolean;
  39269. /**
  39270. * If the gaze trackers color should be updated when selecting meshes
  39271. */
  39272. updateGazeTrackerColor: boolean;
  39273. /**
  39274. * The gaze tracking mesh corresponding to the left controller
  39275. */
  39276. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39277. /**
  39278. * The gaze tracking mesh corresponding to the right controller
  39279. */
  39280. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39281. /**
  39282. * If the ray of the gaze should be displayed.
  39283. */
  39284. /**
  39285. * Sets if the ray of the gaze should be displayed.
  39286. */
  39287. displayGaze: boolean;
  39288. /**
  39289. * If the ray of the LaserPointer should be displayed.
  39290. */
  39291. /**
  39292. * Sets if the ray of the LaserPointer should be displayed.
  39293. */
  39294. displayLaserPointer: boolean;
  39295. /**
  39296. * The deviceOrientationCamera used as the camera when not in VR.
  39297. */
  39298. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39299. /**
  39300. * Based on the current WebVR support, returns the current VR camera used.
  39301. */
  39302. readonly currentVRCamera: Nullable<Camera>;
  39303. /**
  39304. * The webVRCamera which is used when in VR.
  39305. */
  39306. readonly webVRCamera: WebVRFreeCamera;
  39307. /**
  39308. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39309. */
  39310. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39311. private readonly _teleportationRequestInitiated;
  39312. /**
  39313. * Instantiates a VRExperienceHelper.
  39314. * Helps to quickly add VR support to an existing scene.
  39315. * @param scene The scene the VRExperienceHelper belongs to.
  39316. * @param webVROptions Options to modify the vr experience helper's behavior.
  39317. */
  39318. constructor(scene: Scene,
  39319. /** Options to modify the vr experience helper's behavior. */
  39320. webVROptions?: VRExperienceHelperOptions);
  39321. private _onDefaultMeshLoaded;
  39322. private _onResize;
  39323. private _onFullscreenChange;
  39324. /**
  39325. * Gets a value indicating if we are currently in VR mode.
  39326. */
  39327. readonly isInVRMode: boolean;
  39328. private onVrDisplayPresentChange;
  39329. private onVRDisplayChanged;
  39330. private moveButtonToBottomRight;
  39331. private displayVRButton;
  39332. private updateButtonVisibility;
  39333. private _cachedAngularSensibility;
  39334. /**
  39335. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39336. * Otherwise, will use the fullscreen API.
  39337. */
  39338. enterVR(): void;
  39339. /**
  39340. * Attempt to exit VR, or fullscreen.
  39341. */
  39342. exitVR(): void;
  39343. /**
  39344. * The position of the vr experience helper.
  39345. */
  39346. /**
  39347. * Sets the position of the vr experience helper.
  39348. */
  39349. position: Vector3;
  39350. /**
  39351. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39352. */
  39353. enableInteractions(): void;
  39354. private readonly _noControllerIsActive;
  39355. private beforeRender;
  39356. private _isTeleportationFloor;
  39357. /**
  39358. * Adds a floor mesh to be used for teleportation.
  39359. * @param floorMesh the mesh to be used for teleportation.
  39360. */
  39361. addFloorMesh(floorMesh: Mesh): void;
  39362. /**
  39363. * Removes a floor mesh from being used for teleportation.
  39364. * @param floorMesh the mesh to be removed.
  39365. */
  39366. removeFloorMesh(floorMesh: Mesh): void;
  39367. /**
  39368. * Enables interactions and teleportation using the VR controllers and gaze.
  39369. * @param vrTeleportationOptions options to modify teleportation behavior.
  39370. */
  39371. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39372. private _onNewGamepadConnected;
  39373. private _tryEnableInteractionOnController;
  39374. private _onNewGamepadDisconnected;
  39375. private _enableInteractionOnController;
  39376. private _checkTeleportWithRay;
  39377. private _checkRotate;
  39378. private _checkTeleportBackwards;
  39379. private _enableTeleportationOnController;
  39380. private _createTeleportationCircles;
  39381. private _displayTeleportationTarget;
  39382. private _hideTeleportationTarget;
  39383. private _rotateCamera;
  39384. private _moveTeleportationSelectorTo;
  39385. private _workingVector;
  39386. private _workingQuaternion;
  39387. private _workingMatrix;
  39388. /**
  39389. * Teleports the users feet to the desired location
  39390. * @param location The location where the user's feet should be placed
  39391. */
  39392. teleportCamera(location: Vector3): void;
  39393. private _convertNormalToDirectionOfRay;
  39394. private _castRayAndSelectObject;
  39395. private _notifySelectedMeshUnselected;
  39396. /**
  39397. * Sets the color of the laser ray from the vr controllers.
  39398. * @param color new color for the ray.
  39399. */
  39400. changeLaserColor(color: Color3): void;
  39401. /**
  39402. * Sets the color of the ray from the vr headsets gaze.
  39403. * @param color new color for the ray.
  39404. */
  39405. changeGazeColor(color: Color3): void;
  39406. /**
  39407. * Exits VR and disposes of the vr experience helper
  39408. */
  39409. dispose(): void;
  39410. /**
  39411. * Gets the name of the VRExperienceHelper class
  39412. * @returns "VRExperienceHelper"
  39413. */
  39414. getClassName(): string;
  39415. }
  39416. }
  39417. declare module BABYLON {
  39418. /**
  39419. * Manages an XRSession
  39420. * @see https://doc.babylonjs.com/how_to/webxr
  39421. */
  39422. export class WebXRSessionManager implements IDisposable {
  39423. private scene;
  39424. /**
  39425. * Fires every time a new xrFrame arrives which can be used to update the camera
  39426. */
  39427. onXRFrameObservable: Observable<any>;
  39428. /**
  39429. * Fires when the xr session is ended either by the device or manually done
  39430. */
  39431. onXRSessionEnded: Observable<any>;
  39432. /** @hidden */
  39433. _xrSession: XRSession;
  39434. /** @hidden */
  39435. _frameOfReference: XRFrameOfReference;
  39436. /** @hidden */
  39437. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39438. /** @hidden */
  39439. _currentXRFrame: Nullable<XRFrame>;
  39440. private _xrNavigator;
  39441. private _xrDevice;
  39442. private _tmpMatrix;
  39443. /**
  39444. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39445. * @param scene The scene which the session should be created for
  39446. */
  39447. constructor(scene: Scene);
  39448. /**
  39449. * Initializes the manager
  39450. * After initialization enterXR can be called to start an XR session
  39451. * @returns Promise which resolves after it is initialized
  39452. */
  39453. initializeAsync(): Promise<void>;
  39454. /**
  39455. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39456. * @param sessionCreationOptions xr options to create the session with
  39457. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39458. * @returns Promise which resolves after it enters XR
  39459. */
  39460. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39461. /**
  39462. * Stops the xrSession and restores the renderloop
  39463. * @returns Promise which resolves after it exits XR
  39464. */
  39465. exitXRAsync(): Promise<void>;
  39466. /**
  39467. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39468. * @param ray ray to cast into the environment
  39469. * @returns Promise which resolves with a collision point in the environment if it exists
  39470. */
  39471. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39472. /**
  39473. * Checks if a session would be supported for the creation options specified
  39474. * @param options creation options to check if they are supported
  39475. * @returns true if supported
  39476. */
  39477. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39478. /**
  39479. * @hidden
  39480. * Converts the render layer of xrSession to a render target
  39481. * @param session session to create render target for
  39482. * @param scene scene the new render target should be created for
  39483. */
  39484. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39485. /**
  39486. * Disposes of the session manager
  39487. */
  39488. dispose(): void;
  39489. }
  39490. }
  39491. declare module BABYLON {
  39492. /**
  39493. * WebXR Camera which holds the views for the xrSession
  39494. * @see https://doc.babylonjs.com/how_to/webxr
  39495. */
  39496. export class WebXRCamera extends FreeCamera {
  39497. private static _TmpMatrix;
  39498. /**
  39499. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39500. * @param name the name of the camera
  39501. * @param scene the scene to add the camera to
  39502. */
  39503. constructor(name: string, scene: Scene);
  39504. private _updateNumberOfRigCameras;
  39505. /** @hidden */
  39506. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39507. /**
  39508. * Updates the cameras position from the current pose information of the XR session
  39509. * @param xrSessionManager the session containing pose information
  39510. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39511. */
  39512. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39513. }
  39514. }
  39515. declare module BABYLON {
  39516. /**
  39517. * States of the webXR experience
  39518. */
  39519. export enum WebXRState {
  39520. /**
  39521. * Transitioning to being in XR mode
  39522. */
  39523. ENTERING_XR = 0,
  39524. /**
  39525. * Transitioning to non XR mode
  39526. */
  39527. EXITING_XR = 1,
  39528. /**
  39529. * In XR mode and presenting
  39530. */
  39531. IN_XR = 2,
  39532. /**
  39533. * Not entered XR mode
  39534. */
  39535. NOT_IN_XR = 3
  39536. }
  39537. /**
  39538. * Helper class used to enable XR
  39539. * @see https://doc.babylonjs.com/how_to/webxr
  39540. */
  39541. export class WebXRExperienceHelper implements IDisposable {
  39542. private scene;
  39543. /**
  39544. * 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
  39545. */
  39546. container: AbstractMesh;
  39547. /**
  39548. * Camera used to render xr content
  39549. */
  39550. camera: WebXRCamera;
  39551. /**
  39552. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39553. */
  39554. state: WebXRState;
  39555. private _setState;
  39556. private static _TmpVector;
  39557. /**
  39558. * Fires when the state of the experience helper has changed
  39559. */
  39560. onStateChangedObservable: Observable<WebXRState>;
  39561. /** @hidden */
  39562. _sessionManager: WebXRSessionManager;
  39563. private _nonVRCamera;
  39564. private _originalSceneAutoClear;
  39565. private _supported;
  39566. /**
  39567. * Creates the experience helper
  39568. * @param scene the scene to attach the experience helper to
  39569. * @returns a promise for the experience helper
  39570. */
  39571. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39572. /**
  39573. * Creates a WebXRExperienceHelper
  39574. * @param scene The scene the helper should be created in
  39575. */
  39576. private constructor();
  39577. /**
  39578. * Exits XR mode and returns the scene to its original state
  39579. * @returns promise that resolves after xr mode has exited
  39580. */
  39581. exitXRAsync(): Promise<void>;
  39582. /**
  39583. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39584. * @param sessionCreationOptions options for the XR session
  39585. * @param frameOfReference frame of reference of the XR session
  39586. * @returns promise that resolves after xr mode has entered
  39587. */
  39588. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39589. /**
  39590. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39591. * @param ray ray to cast into the environment
  39592. * @returns Promise which resolves with a collision point in the environment if it exists
  39593. */
  39594. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39595. /**
  39596. * Updates the global position of the camera by moving the camera's container
  39597. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39598. * @param position The desired global position of the camera
  39599. */
  39600. setPositionOfCameraUsingContainer(position: Vector3): void;
  39601. /**
  39602. * Rotates the xr camera by rotating the camera's container around the camera's position
  39603. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39604. * @param rotation the desired quaternion rotation to apply to the camera
  39605. */
  39606. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39607. /**
  39608. * Checks if the creation options are supported by the xr session
  39609. * @param options creation options
  39610. * @returns true if supported
  39611. */
  39612. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39613. /**
  39614. * Disposes of the experience helper
  39615. */
  39616. dispose(): void;
  39617. }
  39618. }
  39619. declare module BABYLON {
  39620. /**
  39621. * Button which can be used to enter a different mode of XR
  39622. */
  39623. export class WebXREnterExitUIButton {
  39624. /** button element */
  39625. element: HTMLElement;
  39626. /** XR initialization options for the button */
  39627. initializationOptions: XRSessionCreationOptions;
  39628. /**
  39629. * Creates a WebXREnterExitUIButton
  39630. * @param element button element
  39631. * @param initializationOptions XR initialization options for the button
  39632. */
  39633. constructor(
  39634. /** button element */
  39635. element: HTMLElement,
  39636. /** XR initialization options for the button */
  39637. initializationOptions: XRSessionCreationOptions);
  39638. /**
  39639. * Overwritable function which can be used to update the button's visuals when the state changes
  39640. * @param activeButton the current active button in the UI
  39641. */
  39642. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39643. }
  39644. /**
  39645. * Options to create the webXR UI
  39646. */
  39647. export class WebXREnterExitUIOptions {
  39648. /**
  39649. * Context to enter xr with
  39650. */
  39651. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39652. /**
  39653. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39654. */
  39655. customButtons?: Array<WebXREnterExitUIButton>;
  39656. }
  39657. /**
  39658. * UI to allow the user to enter/exit XR mode
  39659. */
  39660. export class WebXREnterExitUI implements IDisposable {
  39661. private scene;
  39662. private _overlay;
  39663. private _buttons;
  39664. private _activeButton;
  39665. /**
  39666. * Fired every time the active button is changed.
  39667. *
  39668. * When xr is entered via a button that launches xr that button will be the callback parameter
  39669. *
  39670. * When exiting xr the callback parameter will be null)
  39671. */
  39672. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39673. /**
  39674. * Creates UI to allow the user to enter/exit XR mode
  39675. * @param scene the scene to add the ui to
  39676. * @param helper the xr experience helper to enter/exit xr with
  39677. * @param options options to configure the UI
  39678. * @returns the created ui
  39679. */
  39680. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39681. private constructor();
  39682. private _updateButtons;
  39683. /**
  39684. * Disposes of the object
  39685. */
  39686. dispose(): void;
  39687. }
  39688. }
  39689. declare module BABYLON {
  39690. /**
  39691. * Represents an XR input
  39692. */
  39693. export class WebXRController {
  39694. /**
  39695. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  39696. */
  39697. grip?: AbstractMesh;
  39698. /**
  39699. * Pointer which can be used to select objects or attach a visible laser to
  39700. */
  39701. pointer: AbstractMesh;
  39702. /**
  39703. * Creates the controller
  39704. * @see https://doc.babylonjs.com/how_to/webxr
  39705. * @param scene the scene which the controller should be associated to
  39706. */
  39707. constructor(scene: Scene);
  39708. /**
  39709. * Disposes of the object
  39710. */
  39711. dispose(): void;
  39712. }
  39713. /**
  39714. * XR input used to track XR inputs such as controllers/rays
  39715. */
  39716. export class WebXRInput implements IDisposable {
  39717. private helper;
  39718. /**
  39719. * XR controllers being tracked
  39720. */
  39721. controllers: Array<WebXRController>;
  39722. private _tmpMatrix;
  39723. private _frameObserver;
  39724. /**
  39725. * Initializes the WebXRInput
  39726. * @param helper experience helper which the input should be created for
  39727. */
  39728. constructor(helper: WebXRExperienceHelper);
  39729. /**
  39730. * Disposes of the object
  39731. */
  39732. dispose(): void;
  39733. }
  39734. }
  39735. declare module BABYLON {
  39736. /**
  39737. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39738. */
  39739. export class WebXRManagedOutputCanvas implements IDisposable {
  39740. private _canvas;
  39741. /**
  39742. * xrpresent context of the canvas which can be used to display/mirror xr content
  39743. */
  39744. canvasContext: Nullable<WebGLRenderingContext>;
  39745. /**
  39746. * Initializes the canvas to be added/removed upon entering/exiting xr
  39747. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39748. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39749. */
  39750. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39751. /**
  39752. * Disposes of the object
  39753. */
  39754. dispose(): void;
  39755. private _setManagedOutputCanvas;
  39756. private _addCanvas;
  39757. private _removeCanvas;
  39758. }
  39759. }
  39760. declare module BABYLON {
  39761. /**
  39762. * Contains an array of blocks representing the octree
  39763. */
  39764. export interface IOctreeContainer<T> {
  39765. /**
  39766. * Blocks within the octree
  39767. */
  39768. blocks: Array<OctreeBlock<T>>;
  39769. }
  39770. /**
  39771. * Class used to store a cell in an octree
  39772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39773. */
  39774. export class OctreeBlock<T> {
  39775. /**
  39776. * Gets the content of the current block
  39777. */
  39778. entries: T[];
  39779. /**
  39780. * Gets the list of block children
  39781. */
  39782. blocks: Array<OctreeBlock<T>>;
  39783. private _depth;
  39784. private _maxDepth;
  39785. private _capacity;
  39786. private _minPoint;
  39787. private _maxPoint;
  39788. private _boundingVectors;
  39789. private _creationFunc;
  39790. /**
  39791. * Creates a new block
  39792. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39793. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39794. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39795. * @param depth defines the current depth of this block in the octree
  39796. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39797. * @param creationFunc defines a callback to call when an element is added to the block
  39798. */
  39799. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39800. /**
  39801. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39802. */
  39803. readonly capacity: number;
  39804. /**
  39805. * Gets the minimum vector (in world space) of the block's bounding box
  39806. */
  39807. readonly minPoint: Vector3;
  39808. /**
  39809. * Gets the maximum vector (in world space) of the block's bounding box
  39810. */
  39811. readonly maxPoint: Vector3;
  39812. /**
  39813. * Add a new element to this block
  39814. * @param entry defines the element to add
  39815. */
  39816. addEntry(entry: T): void;
  39817. /**
  39818. * Remove an element from this block
  39819. * @param entry defines the element to remove
  39820. */
  39821. removeEntry(entry: T): void;
  39822. /**
  39823. * Add an array of elements to this block
  39824. * @param entries defines the array of elements to add
  39825. */
  39826. addEntries(entries: T[]): void;
  39827. /**
  39828. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39829. * @param frustumPlanes defines the frustum planes to test
  39830. * @param selection defines the array to store current content if selection is positive
  39831. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39832. */
  39833. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39834. /**
  39835. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39836. * @param sphereCenter defines the bounding sphere center
  39837. * @param sphereRadius defines the bounding sphere radius
  39838. * @param selection defines the array to store current content if selection is positive
  39839. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39840. */
  39841. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39842. /**
  39843. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39844. * @param ray defines the ray to test with
  39845. * @param selection defines the array to store current content if selection is positive
  39846. */
  39847. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39848. /**
  39849. * Subdivide the content into child blocks (this block will then be empty)
  39850. */
  39851. createInnerBlocks(): void;
  39852. /**
  39853. * @hidden
  39854. */
  39855. 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;
  39856. }
  39857. }
  39858. declare module BABYLON {
  39859. /**
  39860. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39861. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39862. */
  39863. export class Octree<T> {
  39864. /** 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.) */
  39865. maxDepth: number;
  39866. /**
  39867. * Blocks within the octree containing objects
  39868. */
  39869. blocks: Array<OctreeBlock<T>>;
  39870. /**
  39871. * Content stored in the octree
  39872. */
  39873. dynamicContent: T[];
  39874. private _maxBlockCapacity;
  39875. private _selectionContent;
  39876. private _creationFunc;
  39877. /**
  39878. * Creates a octree
  39879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39880. * @param creationFunc function to be used to instatiate the octree
  39881. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39882. * @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.)
  39883. */
  39884. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39885. /** 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.) */
  39886. maxDepth?: number);
  39887. /**
  39888. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39889. * @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);
  39890. * @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);
  39891. * @param entries meshes to be added to the octree blocks
  39892. */
  39893. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39894. /**
  39895. * Adds a mesh to the octree
  39896. * @param entry Mesh to add to the octree
  39897. */
  39898. addMesh(entry: T): void;
  39899. /**
  39900. * Remove an element from the octree
  39901. * @param entry defines the element to remove
  39902. */
  39903. removeMesh(entry: T): void;
  39904. /**
  39905. * Selects an array of meshes within the frustum
  39906. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39907. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39908. * @returns array of meshes within the frustum
  39909. */
  39910. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39911. /**
  39912. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39913. * @param sphereCenter defines the bounding sphere center
  39914. * @param sphereRadius defines the bounding sphere radius
  39915. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39916. * @returns an array of objects that intersect the sphere
  39917. */
  39918. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39919. /**
  39920. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39921. * @param ray defines the ray to test with
  39922. * @returns array of intersected objects
  39923. */
  39924. intersectsRay(ray: Ray): SmartArray<T>;
  39925. /**
  39926. * Adds a mesh into the octree block if it intersects the block
  39927. */
  39928. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39929. /**
  39930. * Adds a submesh into the octree block if it intersects the block
  39931. */
  39932. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39933. }
  39934. }
  39935. declare module BABYLON {
  39936. interface Scene {
  39937. /**
  39938. * @hidden
  39939. * Backing Filed
  39940. */
  39941. _selectionOctree: Octree<AbstractMesh>;
  39942. /**
  39943. * Gets the octree used to boost mesh selection (picking)
  39944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39945. */
  39946. selectionOctree: Octree<AbstractMesh>;
  39947. /**
  39948. * Creates or updates the octree used to boost selection (picking)
  39949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39950. * @param maxCapacity defines the maximum capacity per leaf
  39951. * @param maxDepth defines the maximum depth of the octree
  39952. * @returns an octree of AbstractMesh
  39953. */
  39954. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39955. }
  39956. interface AbstractMesh {
  39957. /**
  39958. * @hidden
  39959. * Backing Field
  39960. */
  39961. _submeshesOctree: Octree<SubMesh>;
  39962. /**
  39963. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39964. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39965. * @param maxCapacity defines the maximum size of each block (64 by default)
  39966. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39967. * @returns the new octree
  39968. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39969. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39970. */
  39971. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39972. }
  39973. /**
  39974. * Defines the octree scene component responsible to manage any octrees
  39975. * in a given scene.
  39976. */
  39977. export class OctreeSceneComponent {
  39978. /**
  39979. * The component name helpfull to identify the component in the list of scene components.
  39980. */
  39981. readonly name: string;
  39982. /**
  39983. * The scene the component belongs to.
  39984. */
  39985. scene: Scene;
  39986. /**
  39987. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39988. */
  39989. readonly checksIsEnabled: boolean;
  39990. /**
  39991. * Creates a new instance of the component for the given scene
  39992. * @param scene Defines the scene to register the component in
  39993. */
  39994. constructor(scene: Scene);
  39995. /**
  39996. * Registers the component in a given scene
  39997. */
  39998. register(): void;
  39999. /**
  40000. * Return the list of active meshes
  40001. * @returns the list of active meshes
  40002. */
  40003. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40004. /**
  40005. * Return the list of active sub meshes
  40006. * @param mesh The mesh to get the candidates sub meshes from
  40007. * @returns the list of active sub meshes
  40008. */
  40009. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40010. private _tempRay;
  40011. /**
  40012. * Return the list of sub meshes intersecting with a given local ray
  40013. * @param mesh defines the mesh to find the submesh for
  40014. * @param localRay defines the ray in local space
  40015. * @returns the list of intersecting sub meshes
  40016. */
  40017. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40018. /**
  40019. * Return the list of sub meshes colliding with a collider
  40020. * @param mesh defines the mesh to find the submesh for
  40021. * @param collider defines the collider to evaluate the collision against
  40022. * @returns the list of colliding sub meshes
  40023. */
  40024. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40025. /**
  40026. * Rebuilds the elements related to this component in case of
  40027. * context lost for instance.
  40028. */
  40029. rebuild(): void;
  40030. /**
  40031. * Disposes the component and the associated ressources.
  40032. */
  40033. dispose(): void;
  40034. }
  40035. }
  40036. declare module BABYLON {
  40037. /**
  40038. * Renders a layer on top of an existing scene
  40039. */
  40040. export class UtilityLayerRenderer implements IDisposable {
  40041. /** the original scene that will be rendered on top of */
  40042. originalScene: Scene;
  40043. private _pointerCaptures;
  40044. private _lastPointerEvents;
  40045. private static _DefaultUtilityLayer;
  40046. private static _DefaultKeepDepthUtilityLayer;
  40047. /**
  40048. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40049. */
  40050. pickUtilitySceneFirst: boolean;
  40051. /**
  40052. * 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)
  40053. */
  40054. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40055. /**
  40056. * 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)
  40057. */
  40058. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40059. /**
  40060. * The scene that is rendered on top of the original scene
  40061. */
  40062. utilityLayerScene: Scene;
  40063. /**
  40064. * If the utility layer should automatically be rendered on top of existing scene
  40065. */
  40066. shouldRender: boolean;
  40067. /**
  40068. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40069. */
  40070. onlyCheckPointerDownEvents: boolean;
  40071. /**
  40072. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40073. */
  40074. processAllEvents: boolean;
  40075. /**
  40076. * Observable raised when the pointer move from the utility layer scene to the main scene
  40077. */
  40078. onPointerOutObservable: Observable<number>;
  40079. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40080. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40081. private _afterRenderObserver;
  40082. private _sceneDisposeObserver;
  40083. private _originalPointerObserver;
  40084. /**
  40085. * Instantiates a UtilityLayerRenderer
  40086. * @param originalScene the original scene that will be rendered on top of
  40087. * @param handleEvents boolean indicating if the utility layer should handle events
  40088. */
  40089. constructor(
  40090. /** the original scene that will be rendered on top of */
  40091. originalScene: Scene, handleEvents?: boolean);
  40092. private _notifyObservers;
  40093. /**
  40094. * Renders the utility layers scene on top of the original scene
  40095. */
  40096. render(): void;
  40097. /**
  40098. * Disposes of the renderer
  40099. */
  40100. dispose(): void;
  40101. private _updateCamera;
  40102. }
  40103. }
  40104. declare module BABYLON {
  40105. /**
  40106. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40107. */
  40108. export class Gizmo implements IDisposable {
  40109. /** The utility layer the gizmo will be added to */
  40110. gizmoLayer: UtilityLayerRenderer;
  40111. /**
  40112. * The root mesh of the gizmo
  40113. */
  40114. protected _rootMesh: Mesh;
  40115. private _attachedMesh;
  40116. /**
  40117. * Ratio for the scale of the gizmo (Default: 1)
  40118. */
  40119. scaleRatio: number;
  40120. private _tmpMatrix;
  40121. /**
  40122. * If a custom mesh has been set (Default: false)
  40123. */
  40124. protected _customMeshSet: boolean;
  40125. /**
  40126. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40127. * * When set, interactions will be enabled
  40128. */
  40129. attachedMesh: Nullable<AbstractMesh>;
  40130. /**
  40131. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40132. * @param mesh The mesh to replace the default mesh of the gizmo
  40133. */
  40134. setCustomMesh(mesh: Mesh): void;
  40135. /**
  40136. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40137. */
  40138. updateGizmoRotationToMatchAttachedMesh: boolean;
  40139. /**
  40140. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40141. */
  40142. updateGizmoPositionToMatchAttachedMesh: boolean;
  40143. /**
  40144. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40145. */
  40146. protected _updateScale: boolean;
  40147. protected _interactionsEnabled: boolean;
  40148. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40149. private _beforeRenderObserver;
  40150. /**
  40151. * Creates a gizmo
  40152. * @param gizmoLayer The utility layer the gizmo will be added to
  40153. */
  40154. constructor(
  40155. /** The utility layer the gizmo will be added to */
  40156. gizmoLayer?: UtilityLayerRenderer);
  40157. private _tempVector;
  40158. /**
  40159. * @hidden
  40160. * Updates the gizmo to match the attached mesh's position/rotation
  40161. */
  40162. protected _update(): void;
  40163. /**
  40164. * Disposes of the gizmo
  40165. */
  40166. dispose(): void;
  40167. }
  40168. }
  40169. declare module BABYLON {
  40170. /**
  40171. * Single axis drag gizmo
  40172. */
  40173. export class AxisDragGizmo extends Gizmo {
  40174. /**
  40175. * Drag behavior responsible for the gizmos dragging interactions
  40176. */
  40177. dragBehavior: PointerDragBehavior;
  40178. private _pointerObserver;
  40179. /**
  40180. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40181. */
  40182. snapDistance: number;
  40183. /**
  40184. * Event that fires each time the gizmo snaps to a new location.
  40185. * * snapDistance is the the change in distance
  40186. */
  40187. onSnapObservable: Observable<{
  40188. snapDistance: number;
  40189. }>;
  40190. /** @hidden */
  40191. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40192. /** @hidden */
  40193. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40194. /**
  40195. * Creates an AxisDragGizmo
  40196. * @param gizmoLayer The utility layer the gizmo will be added to
  40197. * @param dragAxis The axis which the gizmo will be able to drag on
  40198. * @param color The color of the gizmo
  40199. */
  40200. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40201. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40202. /**
  40203. * Disposes of the gizmo
  40204. */
  40205. dispose(): void;
  40206. }
  40207. }
  40208. declare module BABYLON.Debug {
  40209. /**
  40210. * The Axes viewer will show 3 axes in a specific point in space
  40211. */
  40212. export class AxesViewer {
  40213. private _xAxis;
  40214. private _yAxis;
  40215. private _zAxis;
  40216. private _scaleLinesFactor;
  40217. private _instanced;
  40218. /**
  40219. * Gets the hosting scene
  40220. */
  40221. scene: Scene;
  40222. /**
  40223. * Gets or sets a number used to scale line length
  40224. */
  40225. scaleLines: number;
  40226. /** Gets the node hierarchy used to render x-axis */
  40227. readonly xAxis: TransformNode;
  40228. /** Gets the node hierarchy used to render y-axis */
  40229. readonly yAxis: TransformNode;
  40230. /** Gets the node hierarchy used to render z-axis */
  40231. readonly zAxis: TransformNode;
  40232. /**
  40233. * Creates a new AxesViewer
  40234. * @param scene defines the hosting scene
  40235. * @param scaleLines defines a number used to scale line length (1 by default)
  40236. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40237. * @param xAxis defines the node hierarchy used to render the x-axis
  40238. * @param yAxis defines the node hierarchy used to render the y-axis
  40239. * @param zAxis defines the node hierarchy used to render the z-axis
  40240. */
  40241. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40242. /**
  40243. * Force the viewer to update
  40244. * @param position defines the position of the viewer
  40245. * @param xaxis defines the x axis of the viewer
  40246. * @param yaxis defines the y axis of the viewer
  40247. * @param zaxis defines the z axis of the viewer
  40248. */
  40249. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40250. /**
  40251. * Creates an instance of this axes viewer.
  40252. * @returns a new axes viewer with instanced meshes
  40253. */
  40254. createInstance(): AxesViewer;
  40255. /** Releases resources */
  40256. dispose(): void;
  40257. private static _SetRenderingGroupId;
  40258. }
  40259. }
  40260. declare module BABYLON.Debug {
  40261. /**
  40262. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40263. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40264. */
  40265. export class BoneAxesViewer extends AxesViewer {
  40266. /**
  40267. * Gets or sets the target mesh where to display the axes viewer
  40268. */
  40269. mesh: Nullable<Mesh>;
  40270. /**
  40271. * Gets or sets the target bone where to display the axes viewer
  40272. */
  40273. bone: Nullable<Bone>;
  40274. /** Gets current position */
  40275. pos: Vector3;
  40276. /** Gets direction of X axis */
  40277. xaxis: Vector3;
  40278. /** Gets direction of Y axis */
  40279. yaxis: Vector3;
  40280. /** Gets direction of Z axis */
  40281. zaxis: Vector3;
  40282. /**
  40283. * Creates a new BoneAxesViewer
  40284. * @param scene defines the hosting scene
  40285. * @param bone defines the target bone
  40286. * @param mesh defines the target mesh
  40287. * @param scaleLines defines a scaling factor for line length (1 by default)
  40288. */
  40289. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40290. /**
  40291. * Force the viewer to update
  40292. */
  40293. update(): void;
  40294. /** Releases resources */
  40295. dispose(): void;
  40296. }
  40297. }
  40298. declare module BABYLON {
  40299. /**
  40300. * Interface used to define scene explorer extensibility option
  40301. */
  40302. export interface IExplorerExtensibilityOption {
  40303. /**
  40304. * Define the option label
  40305. */
  40306. label: string;
  40307. /**
  40308. * Defines the action to execute on click
  40309. */
  40310. action: (entity: any) => void;
  40311. }
  40312. /**
  40313. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40314. */
  40315. export interface IExplorerExtensibilityGroup {
  40316. /**
  40317. * Defines a predicate to test if a given type mut be extended
  40318. */
  40319. predicate: (entity: any) => boolean;
  40320. /**
  40321. * Gets the list of options added to a type
  40322. */
  40323. entries: IExplorerExtensibilityOption[];
  40324. }
  40325. /**
  40326. * Interface used to define the options to use to create the Inspector
  40327. */
  40328. export interface IInspectorOptions {
  40329. /**
  40330. * Display in overlay mode (default: false)
  40331. */
  40332. overlay?: boolean;
  40333. /**
  40334. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40335. */
  40336. globalRoot?: HTMLElement;
  40337. /**
  40338. * Display the Scene explorer
  40339. */
  40340. showExplorer?: boolean;
  40341. /**
  40342. * Display the property inspector
  40343. */
  40344. showInspector?: boolean;
  40345. /**
  40346. * Display in embed mode (both panes on the right)
  40347. */
  40348. embedMode?: boolean;
  40349. /**
  40350. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40351. */
  40352. handleResize?: boolean;
  40353. /**
  40354. * Allow the panes to popup (default: true)
  40355. */
  40356. enablePopup?: boolean;
  40357. /**
  40358. * Allow the panes to be closed by users (default: true)
  40359. */
  40360. enableClose?: boolean;
  40361. /**
  40362. * Optional list of extensibility entries
  40363. */
  40364. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40365. }
  40366. interface Scene {
  40367. /**
  40368. * @hidden
  40369. * Backing field
  40370. */
  40371. _debugLayer: DebugLayer;
  40372. /**
  40373. * Gets the debug layer (aka Inspector) associated with the scene
  40374. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40375. */
  40376. debugLayer: DebugLayer;
  40377. }
  40378. /**
  40379. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40380. * what is happening in your scene
  40381. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40382. */
  40383. export class DebugLayer {
  40384. /**
  40385. * Define the url to get the inspector script from.
  40386. * By default it uses the babylonjs CDN.
  40387. * @ignoreNaming
  40388. */
  40389. static InspectorURL: string;
  40390. private _scene;
  40391. private BJSINSPECTOR;
  40392. /**
  40393. * Observable triggered when a property is changed through the inspector.
  40394. */
  40395. onPropertyChangedObservable: Observable<{
  40396. object: any;
  40397. property: string;
  40398. value: any;
  40399. initialValue: any;
  40400. }>;
  40401. /**
  40402. * Instantiates a new debug layer.
  40403. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40404. * what is happening in your scene
  40405. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40406. * @param scene Defines the scene to inspect
  40407. */
  40408. constructor(scene: Scene);
  40409. /** Creates the inspector window. */
  40410. private _createInspector;
  40411. /** Get the inspector from bundle or global */
  40412. private _getGlobalInspector;
  40413. /**
  40414. * Get if the inspector is visible or not.
  40415. * @returns true if visible otherwise, false
  40416. */
  40417. isVisible(): boolean;
  40418. /**
  40419. * Hide the inspector and close its window.
  40420. */
  40421. hide(): void;
  40422. /**
  40423. * Launch the debugLayer.
  40424. * @param config Define the configuration of the inspector
  40425. */
  40426. show(config?: IInspectorOptions): void;
  40427. }
  40428. }
  40429. declare module BABYLON.Debug {
  40430. /**
  40431. * Used to show the physics impostor around the specific mesh
  40432. */
  40433. export class PhysicsViewer {
  40434. /** @hidden */
  40435. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40436. /** @hidden */
  40437. protected _meshes: Array<Nullable<AbstractMesh>>;
  40438. /** @hidden */
  40439. protected _scene: Nullable<Scene>;
  40440. /** @hidden */
  40441. protected _numMeshes: number;
  40442. /** @hidden */
  40443. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40444. private _renderFunction;
  40445. private _utilityLayer;
  40446. private _debugBoxMesh;
  40447. private _debugSphereMesh;
  40448. private _debugMaterial;
  40449. /**
  40450. * Creates a new PhysicsViewer
  40451. * @param scene defines the hosting scene
  40452. */
  40453. constructor(scene: Scene);
  40454. /** @hidden */
  40455. protected _updateDebugMeshes(): void;
  40456. /**
  40457. * Renders a specified physic impostor
  40458. * @param impostor defines the impostor to render
  40459. * @returns the new debug mesh used to render the impostor
  40460. */
  40461. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  40462. /**
  40463. * Hides a specified physic impostor
  40464. * @param impostor defines the impostor to hide
  40465. */
  40466. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40467. private _getDebugMaterial;
  40468. private _getDebugBoxMesh;
  40469. private _getDebugSphereMesh;
  40470. private _getDebugMesh;
  40471. /** Releases all resources */
  40472. dispose(): void;
  40473. }
  40474. }
  40475. declare module BABYLON {
  40476. /**
  40477. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40478. * in order to better appreciate the issue one might have.
  40479. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40480. */
  40481. export class RayHelper {
  40482. /**
  40483. * Defines the ray we are currently tryin to visualize.
  40484. */
  40485. ray: Nullable<Ray>;
  40486. private _renderPoints;
  40487. private _renderLine;
  40488. private _renderFunction;
  40489. private _scene;
  40490. private _updateToMeshFunction;
  40491. private _attachedToMesh;
  40492. private _meshSpaceDirection;
  40493. private _meshSpaceOrigin;
  40494. /**
  40495. * Helper function to create a colored helper in a scene in one line.
  40496. * @param ray Defines the ray we are currently tryin to visualize
  40497. * @param scene Defines the scene the ray is used in
  40498. * @param color Defines the color we want to see the ray in
  40499. * @returns The newly created ray helper.
  40500. */
  40501. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40502. /**
  40503. * Instantiate a new ray helper.
  40504. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40505. * in order to better appreciate the issue one might have.
  40506. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40507. * @param ray Defines the ray we are currently tryin to visualize
  40508. */
  40509. constructor(ray: Ray);
  40510. /**
  40511. * Shows the ray we are willing to debug.
  40512. * @param scene Defines the scene the ray needs to be rendered in
  40513. * @param color Defines the color the ray needs to be rendered in
  40514. */
  40515. show(scene: Scene, color?: Color3): void;
  40516. /**
  40517. * Hides the ray we are debugging.
  40518. */
  40519. hide(): void;
  40520. private _render;
  40521. /**
  40522. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40523. * @param mesh Defines the mesh we want the helper attached to
  40524. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40525. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40526. * @param length Defines the length of the ray
  40527. */
  40528. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40529. /**
  40530. * Detach the ray helper from the mesh it has previously been attached to.
  40531. */
  40532. detachFromMesh(): void;
  40533. private _updateToMesh;
  40534. /**
  40535. * Dispose the helper and release its associated resources.
  40536. */
  40537. dispose(): void;
  40538. }
  40539. }
  40540. declare module BABYLON.Debug {
  40541. /**
  40542. * Class used to render a debug view of a given skeleton
  40543. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40544. */
  40545. export class SkeletonViewer {
  40546. /** defines the skeleton to render */
  40547. skeleton: Skeleton;
  40548. /** defines the mesh attached to the skeleton */
  40549. mesh: AbstractMesh;
  40550. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40551. autoUpdateBonesMatrices: boolean;
  40552. /** defines the rendering group id to use with the viewer */
  40553. renderingGroupId: number;
  40554. /** Gets or sets the color used to render the skeleton */
  40555. color: Color3;
  40556. private _scene;
  40557. private _debugLines;
  40558. private _debugMesh;
  40559. private _isEnabled;
  40560. private _renderFunction;
  40561. private _utilityLayer;
  40562. /**
  40563. * Returns the mesh used to render the bones
  40564. */
  40565. readonly debugMesh: Nullable<LinesMesh>;
  40566. /**
  40567. * Creates a new SkeletonViewer
  40568. * @param skeleton defines the skeleton to render
  40569. * @param mesh defines the mesh attached to the skeleton
  40570. * @param scene defines the hosting scene
  40571. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40572. * @param renderingGroupId defines the rendering group id to use with the viewer
  40573. */
  40574. constructor(
  40575. /** defines the skeleton to render */
  40576. skeleton: Skeleton,
  40577. /** defines the mesh attached to the skeleton */
  40578. mesh: AbstractMesh, scene: Scene,
  40579. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40580. autoUpdateBonesMatrices?: boolean,
  40581. /** defines the rendering group id to use with the viewer */
  40582. renderingGroupId?: number);
  40583. /** Gets or sets a boolean indicating if the viewer is enabled */
  40584. isEnabled: boolean;
  40585. private _getBonePosition;
  40586. private _getLinesForBonesWithLength;
  40587. private _getLinesForBonesNoLength;
  40588. /** Update the viewer to sync with current skeleton state */
  40589. update(): void;
  40590. /** Release associated resources */
  40591. dispose(): void;
  40592. }
  40593. }
  40594. declare module BABYLON {
  40595. /**
  40596. * Options to create the null engine
  40597. */
  40598. export class NullEngineOptions {
  40599. /**
  40600. * Render width (Default: 512)
  40601. */
  40602. renderWidth: number;
  40603. /**
  40604. * Render height (Default: 256)
  40605. */
  40606. renderHeight: number;
  40607. /**
  40608. * Texture size (Default: 512)
  40609. */
  40610. textureSize: number;
  40611. /**
  40612. * If delta time between frames should be constant
  40613. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40614. */
  40615. deterministicLockstep: boolean;
  40616. /**
  40617. * Maximum about of steps between frames (Default: 4)
  40618. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40619. */
  40620. lockstepMaxSteps: number;
  40621. }
  40622. /**
  40623. * The null engine class provides support for headless version of babylon.js.
  40624. * This can be used in server side scenario or for testing purposes
  40625. */
  40626. export class NullEngine extends Engine {
  40627. private _options;
  40628. /**
  40629. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40630. */
  40631. isDeterministicLockStep(): boolean;
  40632. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40633. getLockstepMaxSteps(): number;
  40634. /**
  40635. * Sets hardware scaling, used to save performance if needed
  40636. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40637. */
  40638. getHardwareScalingLevel(): number;
  40639. constructor(options?: NullEngineOptions);
  40640. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40641. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40642. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40643. getRenderWidth(useScreen?: boolean): number;
  40644. getRenderHeight(useScreen?: boolean): number;
  40645. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40646. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40647. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40648. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40649. bindSamplers(effect: Effect): void;
  40650. enableEffect(effect: Effect): void;
  40651. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40652. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40653. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40654. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40655. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40656. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40657. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40658. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40659. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40660. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40661. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40662. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40663. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40664. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40665. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40666. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40667. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40668. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40669. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40670. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40671. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40672. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40673. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40674. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40675. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40676. bindBuffers(vertexBuffers: {
  40677. [key: string]: VertexBuffer;
  40678. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40679. wipeCaches(bruteForce?: boolean): void;
  40680. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40681. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40682. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40683. /** @hidden */
  40684. _createTexture(): WebGLTexture;
  40685. /** @hidden */
  40686. _releaseTexture(texture: InternalTexture): void;
  40687. 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;
  40688. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40689. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40690. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40691. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40692. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40693. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40694. areAllEffectsReady(): boolean;
  40695. /**
  40696. * @hidden
  40697. * Get the current error code of the webGL context
  40698. * @returns the error code
  40699. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40700. */
  40701. getError(): number;
  40702. /** @hidden */
  40703. _getUnpackAlignement(): number;
  40704. /** @hidden */
  40705. _unpackFlipY(value: boolean): void;
  40706. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40707. /**
  40708. * Updates a dynamic vertex buffer.
  40709. * @param vertexBuffer the vertex buffer to update
  40710. * @param data the data used to update the vertex buffer
  40711. * @param byteOffset the byte offset of the data (optional)
  40712. * @param byteLength the byte length of the data (optional)
  40713. */
  40714. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40715. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40716. /** @hidden */
  40717. _bindTexture(channel: number, texture: InternalTexture): void;
  40718. /** @hidden */
  40719. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40720. releaseEffects(): void;
  40721. displayLoadingUI(): void;
  40722. hideLoadingUI(): void;
  40723. /** @hidden */
  40724. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40725. /** @hidden */
  40726. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40727. /** @hidden */
  40728. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40729. /** @hidden */
  40730. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40731. }
  40732. }
  40733. declare module BABYLON {
  40734. /** @hidden */
  40735. export class _OcclusionDataStorage {
  40736. /** @hidden */
  40737. occlusionInternalRetryCounter: number;
  40738. /** @hidden */
  40739. isOcclusionQueryInProgress: boolean;
  40740. /** @hidden */
  40741. isOccluded: boolean;
  40742. /** @hidden */
  40743. occlusionRetryCount: number;
  40744. /** @hidden */
  40745. occlusionType: number;
  40746. /** @hidden */
  40747. occlusionQueryAlgorithmType: number;
  40748. }
  40749. interface Engine {
  40750. /**
  40751. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40752. * @return the new query
  40753. */
  40754. createQuery(): WebGLQuery;
  40755. /**
  40756. * Delete and release a webGL query
  40757. * @param query defines the query to delete
  40758. * @return the current engine
  40759. */
  40760. deleteQuery(query: WebGLQuery): Engine;
  40761. /**
  40762. * Check if a given query has resolved and got its value
  40763. * @param query defines the query to check
  40764. * @returns true if the query got its value
  40765. */
  40766. isQueryResultAvailable(query: WebGLQuery): boolean;
  40767. /**
  40768. * Gets the value of a given query
  40769. * @param query defines the query to check
  40770. * @returns the value of the query
  40771. */
  40772. getQueryResult(query: WebGLQuery): number;
  40773. /**
  40774. * Initiates an occlusion query
  40775. * @param algorithmType defines the algorithm to use
  40776. * @param query defines the query to use
  40777. * @returns the current engine
  40778. * @see http://doc.babylonjs.com/features/occlusionquery
  40779. */
  40780. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40781. /**
  40782. * Ends an occlusion query
  40783. * @see http://doc.babylonjs.com/features/occlusionquery
  40784. * @param algorithmType defines the algorithm to use
  40785. * @returns the current engine
  40786. */
  40787. endOcclusionQuery(algorithmType: number): Engine;
  40788. /**
  40789. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40790. * Please note that only one query can be issued at a time
  40791. * @returns a time token used to track the time span
  40792. */
  40793. startTimeQuery(): Nullable<_TimeToken>;
  40794. /**
  40795. * Ends a time query
  40796. * @param token defines the token used to measure the time span
  40797. * @returns the time spent (in ns)
  40798. */
  40799. endTimeQuery(token: _TimeToken): int;
  40800. /** @hidden */
  40801. _currentNonTimestampToken: Nullable<_TimeToken>;
  40802. /** @hidden */
  40803. _createTimeQuery(): WebGLQuery;
  40804. /** @hidden */
  40805. _deleteTimeQuery(query: WebGLQuery): void;
  40806. /** @hidden */
  40807. _getGlAlgorithmType(algorithmType: number): number;
  40808. /** @hidden */
  40809. _getTimeQueryResult(query: WebGLQuery): any;
  40810. /** @hidden */
  40811. _getTimeQueryAvailability(query: WebGLQuery): any;
  40812. }
  40813. interface AbstractMesh {
  40814. /**
  40815. * Backing filed
  40816. * @hidden
  40817. */
  40818. __occlusionDataStorage: _OcclusionDataStorage;
  40819. /**
  40820. * Access property
  40821. * @hidden
  40822. */
  40823. _occlusionDataStorage: _OcclusionDataStorage;
  40824. /**
  40825. * 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.
  40826. * The default value is -1 which means don't break the query and wait till the result
  40827. * @see http://doc.babylonjs.com/features/occlusionquery
  40828. */
  40829. occlusionRetryCount: number;
  40830. /**
  40831. * 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:
  40832. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40833. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40834. * * 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.
  40835. * @see http://doc.babylonjs.com/features/occlusionquery
  40836. */
  40837. occlusionType: number;
  40838. /**
  40839. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40840. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40841. * * 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.
  40842. * @see http://doc.babylonjs.com/features/occlusionquery
  40843. */
  40844. occlusionQueryAlgorithmType: number;
  40845. /**
  40846. * 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
  40847. * @see http://doc.babylonjs.com/features/occlusionquery
  40848. */
  40849. isOccluded: boolean;
  40850. /**
  40851. * Flag to check the progress status of the query
  40852. * @see http://doc.babylonjs.com/features/occlusionquery
  40853. */
  40854. isOcclusionQueryInProgress: boolean;
  40855. }
  40856. }
  40857. declare module BABYLON {
  40858. /** @hidden */
  40859. export var _forceTransformFeedbackToBundle: boolean;
  40860. interface Engine {
  40861. /**
  40862. * Creates a webGL transform feedback object
  40863. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40864. * @returns the webGL transform feedback object
  40865. */
  40866. createTransformFeedback(): WebGLTransformFeedback;
  40867. /**
  40868. * Delete a webGL transform feedback object
  40869. * @param value defines the webGL transform feedback object to delete
  40870. */
  40871. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40872. /**
  40873. * Bind a webGL transform feedback object to the webgl context
  40874. * @param value defines the webGL transform feedback object to bind
  40875. */
  40876. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40877. /**
  40878. * Begins a transform feedback operation
  40879. * @param usePoints defines if points or triangles must be used
  40880. */
  40881. beginTransformFeedback(usePoints: boolean): void;
  40882. /**
  40883. * Ends a transform feedback operation
  40884. */
  40885. endTransformFeedback(): void;
  40886. /**
  40887. * Specify the varyings to use with transform feedback
  40888. * @param program defines the associated webGL program
  40889. * @param value defines the list of strings representing the varying names
  40890. */
  40891. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40892. /**
  40893. * Bind a webGL buffer for a transform feedback operation
  40894. * @param value defines the webGL buffer to bind
  40895. */
  40896. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40897. }
  40898. }
  40899. declare module BABYLON {
  40900. /**
  40901. * Gather the list of clipboard event types as constants.
  40902. */
  40903. export class ClipboardEventTypes {
  40904. /**
  40905. * The clipboard event is fired when a copy command is active (pressed).
  40906. */
  40907. static readonly COPY: number;
  40908. /**
  40909. * The clipboard event is fired when a cut command is active (pressed).
  40910. */
  40911. static readonly CUT: number;
  40912. /**
  40913. * The clipboard event is fired when a paste command is active (pressed).
  40914. */
  40915. static readonly PASTE: number;
  40916. }
  40917. /**
  40918. * This class is used to store clipboard related info for the onClipboardObservable event.
  40919. */
  40920. export class ClipboardInfo {
  40921. /**
  40922. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40923. */
  40924. type: number;
  40925. /**
  40926. * Defines the related dom event
  40927. */
  40928. event: ClipboardEvent;
  40929. /**
  40930. *Creates an instance of ClipboardInfo.
  40931. * @param {number} type
  40932. * @param {ClipboardEvent} event
  40933. */
  40934. constructor(
  40935. /**
  40936. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40937. */
  40938. type: number,
  40939. /**
  40940. * Defines the related dom event
  40941. */
  40942. event: ClipboardEvent);
  40943. /**
  40944. * Get the clipboard event's type from the keycode.
  40945. * @param keyCode Defines the keyCode for the current keyboard event.
  40946. * @return {number}
  40947. */
  40948. static GetTypeFromCharacter(keyCode: number): number;
  40949. }
  40950. }
  40951. declare module BABYLON {
  40952. /**
  40953. * Class used to represent data loading progression
  40954. */
  40955. export class SceneLoaderProgressEvent {
  40956. /** defines if data length to load can be evaluated */
  40957. readonly lengthComputable: boolean;
  40958. /** defines the loaded data length */
  40959. readonly loaded: number;
  40960. /** defines the data length to load */
  40961. readonly total: number;
  40962. /**
  40963. * Create a new progress event
  40964. * @param lengthComputable defines if data length to load can be evaluated
  40965. * @param loaded defines the loaded data length
  40966. * @param total defines the data length to load
  40967. */
  40968. constructor(
  40969. /** defines if data length to load can be evaluated */
  40970. lengthComputable: boolean,
  40971. /** defines the loaded data length */
  40972. loaded: number,
  40973. /** defines the data length to load */
  40974. total: number);
  40975. /**
  40976. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40977. * @param event defines the source event
  40978. * @returns a new SceneLoaderProgressEvent
  40979. */
  40980. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40981. }
  40982. /**
  40983. * Interface used by SceneLoader plugins to define supported file extensions
  40984. */
  40985. export interface ISceneLoaderPluginExtensions {
  40986. /**
  40987. * Defines the list of supported extensions
  40988. */
  40989. [extension: string]: {
  40990. isBinary: boolean;
  40991. };
  40992. }
  40993. /**
  40994. * Interface used by SceneLoader plugin factory
  40995. */
  40996. export interface ISceneLoaderPluginFactory {
  40997. /**
  40998. * Defines the name of the factory
  40999. */
  41000. name: string;
  41001. /**
  41002. * Function called to create a new plugin
  41003. * @return the new plugin
  41004. */
  41005. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41006. /**
  41007. * Boolean indicating if the plugin can direct load specific data
  41008. */
  41009. canDirectLoad?: (data: string) => boolean;
  41010. }
  41011. /**
  41012. * Interface used to define a SceneLoader plugin
  41013. */
  41014. export interface ISceneLoaderPlugin {
  41015. /**
  41016. * The friendly name of this plugin.
  41017. */
  41018. name: string;
  41019. /**
  41020. * The file extensions supported by this plugin.
  41021. */
  41022. extensions: string | ISceneLoaderPluginExtensions;
  41023. /**
  41024. * Import meshes into a scene.
  41025. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41026. * @param scene The scene to import into
  41027. * @param data The data to import
  41028. * @param rootUrl The root url for scene and resources
  41029. * @param meshes The meshes array to import into
  41030. * @param particleSystems The particle systems array to import into
  41031. * @param skeletons The skeletons array to import into
  41032. * @param onError The callback when import fails
  41033. * @returns True if successful or false otherwise
  41034. */
  41035. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41036. /**
  41037. * Load into a scene.
  41038. * @param scene The scene to load into
  41039. * @param data The data to import
  41040. * @param rootUrl The root url for scene and resources
  41041. * @param onError The callback when import fails
  41042. * @returns true if successful or false otherwise
  41043. */
  41044. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41045. /**
  41046. * The callback that returns true if the data can be directly loaded.
  41047. */
  41048. canDirectLoad?: (data: string) => boolean;
  41049. /**
  41050. * The callback that allows custom handling of the root url based on the response url.
  41051. */
  41052. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41053. /**
  41054. * Load into an asset container.
  41055. * @param scene The scene to load into
  41056. * @param data The data to import
  41057. * @param rootUrl The root url for scene and resources
  41058. * @param onError The callback when import fails
  41059. * @returns The loaded asset container
  41060. */
  41061. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41062. }
  41063. /**
  41064. * Interface used to define an async SceneLoader plugin
  41065. */
  41066. export interface ISceneLoaderPluginAsync {
  41067. /**
  41068. * The friendly name of this plugin.
  41069. */
  41070. name: string;
  41071. /**
  41072. * The file extensions supported by this plugin.
  41073. */
  41074. extensions: string | ISceneLoaderPluginExtensions;
  41075. /**
  41076. * Import meshes into a scene.
  41077. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41078. * @param scene The scene to import into
  41079. * @param data The data to import
  41080. * @param rootUrl The root url for scene and resources
  41081. * @param onProgress The callback when the load progresses
  41082. * @param fileName Defines the name of the file to load
  41083. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41084. */
  41085. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41086. meshes: AbstractMesh[];
  41087. particleSystems: IParticleSystem[];
  41088. skeletons: Skeleton[];
  41089. animationGroups: AnimationGroup[];
  41090. }>;
  41091. /**
  41092. * Load into a scene.
  41093. * @param scene The scene to load into
  41094. * @param data The data to import
  41095. * @param rootUrl The root url for scene and resources
  41096. * @param onProgress The callback when the load progresses
  41097. * @param fileName Defines the name of the file to load
  41098. * @returns Nothing
  41099. */
  41100. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41101. /**
  41102. * The callback that returns true if the data can be directly loaded.
  41103. */
  41104. canDirectLoad?: (data: string) => boolean;
  41105. /**
  41106. * The callback that allows custom handling of the root url based on the response url.
  41107. */
  41108. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41109. /**
  41110. * Load into an asset container.
  41111. * @param scene The scene to load into
  41112. * @param data The data to import
  41113. * @param rootUrl The root url for scene and resources
  41114. * @param onProgress The callback when the load progresses
  41115. * @param fileName Defines the name of the file to load
  41116. * @returns The loaded asset container
  41117. */
  41118. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41119. }
  41120. /**
  41121. * Class used to load scene from various file formats using registered plugins
  41122. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41123. */
  41124. export class SceneLoader {
  41125. /**
  41126. * No logging while loading
  41127. */
  41128. static readonly NO_LOGGING: number;
  41129. /**
  41130. * Minimal logging while loading
  41131. */
  41132. static readonly MINIMAL_LOGGING: number;
  41133. /**
  41134. * Summary logging while loading
  41135. */
  41136. static readonly SUMMARY_LOGGING: number;
  41137. /**
  41138. * Detailled logging while loading
  41139. */
  41140. static readonly DETAILED_LOGGING: number;
  41141. /**
  41142. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41143. */
  41144. static ForceFullSceneLoadingForIncremental: boolean;
  41145. /**
  41146. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41147. */
  41148. static ShowLoadingScreen: boolean;
  41149. /**
  41150. * Defines the current logging level (while loading the scene)
  41151. * @ignorenaming
  41152. */
  41153. static loggingLevel: number;
  41154. /**
  41155. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41156. */
  41157. static CleanBoneMatrixWeights: boolean;
  41158. /**
  41159. * Event raised when a plugin is used to load a scene
  41160. */
  41161. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41162. private static _registeredPlugins;
  41163. private static _getDefaultPlugin;
  41164. private static _getPluginForExtension;
  41165. private static _getPluginForDirectLoad;
  41166. private static _getPluginForFilename;
  41167. private static _getDirectLoad;
  41168. private static _loadData;
  41169. private static _getFileInfo;
  41170. /**
  41171. * Gets a plugin that can load the given extension
  41172. * @param extension defines the extension to load
  41173. * @returns a plugin or null if none works
  41174. */
  41175. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41176. /**
  41177. * Gets a boolean indicating that the given extension can be loaded
  41178. * @param extension defines the extension to load
  41179. * @returns true if the extension is supported
  41180. */
  41181. static IsPluginForExtensionAvailable(extension: string): boolean;
  41182. /**
  41183. * Adds a new plugin to the list of registered plugins
  41184. * @param plugin defines the plugin to add
  41185. */
  41186. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41187. /**
  41188. * Import meshes into a scene
  41189. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41190. * @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)
  41191. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41192. * @param scene the instance of BABYLON.Scene to append to
  41193. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41194. * @param onProgress a callback with a progress event for each file being loaded
  41195. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41196. * @param pluginExtension the extension used to determine the plugin
  41197. * @returns The loaded plugin
  41198. */
  41199. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, 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>;
  41200. /**
  41201. * Import meshes into a scene
  41202. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41203. * @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)
  41204. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41205. * @param scene the instance of BABYLON.Scene to append to
  41206. * @param onProgress a callback with a progress event for each file being loaded
  41207. * @param pluginExtension the extension used to determine the plugin
  41208. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41209. */
  41210. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41211. meshes: AbstractMesh[];
  41212. particleSystems: IParticleSystem[];
  41213. skeletons: Skeleton[];
  41214. animationGroups: AnimationGroup[];
  41215. }>;
  41216. /**
  41217. * Load a scene
  41218. * @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)
  41219. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41220. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41221. * @param onSuccess a callback with the scene when import succeeds
  41222. * @param onProgress a callback with a progress event for each file being loaded
  41223. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41224. * @param pluginExtension the extension used to determine the plugin
  41225. * @returns The loaded plugin
  41226. */
  41227. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<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>;
  41228. /**
  41229. * Load a scene
  41230. * @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)
  41231. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41232. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41233. * @param onProgress a callback with a progress event for each file being loaded
  41234. * @param pluginExtension the extension used to determine the plugin
  41235. * @returns The loaded scene
  41236. */
  41237. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41238. /**
  41239. * Append a scene
  41240. * @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)
  41241. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41242. * @param scene is the instance of BABYLON.Scene to append to
  41243. * @param onSuccess a callback with the scene when import succeeds
  41244. * @param onProgress a callback with a progress event for each file being loaded
  41245. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41246. * @param pluginExtension the extension used to determine the plugin
  41247. * @returns The loaded plugin
  41248. */
  41249. static Append(rootUrl: string, sceneFilename?: string | File, 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>;
  41250. /**
  41251. * Append a scene
  41252. * @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)
  41253. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41254. * @param scene is the instance of BABYLON.Scene to append to
  41255. * @param onProgress a callback with a progress event for each file being loaded
  41256. * @param pluginExtension the extension used to determine the plugin
  41257. * @returns The given scene
  41258. */
  41259. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41260. /**
  41261. * Load a scene into an asset container
  41262. * @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)
  41263. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41264. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41265. * @param onSuccess a callback with the scene when import succeeds
  41266. * @param onProgress a callback with a progress event for each file being loaded
  41267. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41268. * @param pluginExtension the extension used to determine the plugin
  41269. * @returns The loaded plugin
  41270. */
  41271. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, 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>;
  41272. /**
  41273. * Load a scene into an asset container
  41274. * @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)
  41275. * @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)
  41276. * @param scene is the instance of Scene to append to
  41277. * @param onProgress a callback with a progress event for each file being loaded
  41278. * @param pluginExtension the extension used to determine the plugin
  41279. * @returns The loaded asset container
  41280. */
  41281. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41282. }
  41283. }
  41284. declare module BABYLON {
  41285. /**
  41286. * Google Daydream controller
  41287. */
  41288. export class DaydreamController extends WebVRController {
  41289. /**
  41290. * Base Url for the controller model.
  41291. */
  41292. static MODEL_BASE_URL: string;
  41293. /**
  41294. * File name for the controller model.
  41295. */
  41296. static MODEL_FILENAME: string;
  41297. /**
  41298. * Gamepad Id prefix used to identify Daydream Controller.
  41299. */
  41300. static readonly GAMEPAD_ID_PREFIX: string;
  41301. /**
  41302. * Creates a new DaydreamController from a gamepad
  41303. * @param vrGamepad the gamepad that the controller should be created from
  41304. */
  41305. constructor(vrGamepad: any);
  41306. /**
  41307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41308. * @param scene scene in which to add meshes
  41309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41310. */
  41311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41312. /**
  41313. * Called once for each button that changed state since the last frame
  41314. * @param buttonIdx Which button index changed
  41315. * @param state New state of the button
  41316. * @param changes Which properties on the state changed since last frame
  41317. */
  41318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41319. }
  41320. }
  41321. declare module BABYLON {
  41322. /**
  41323. * Gear VR Controller
  41324. */
  41325. export class GearVRController extends WebVRController {
  41326. /**
  41327. * Base Url for the controller model.
  41328. */
  41329. static MODEL_BASE_URL: string;
  41330. /**
  41331. * File name for the controller model.
  41332. */
  41333. static MODEL_FILENAME: string;
  41334. /**
  41335. * Gamepad Id prefix used to identify this controller.
  41336. */
  41337. static readonly GAMEPAD_ID_PREFIX: string;
  41338. private readonly _buttonIndexToObservableNameMap;
  41339. /**
  41340. * Creates a new GearVRController from a gamepad
  41341. * @param vrGamepad the gamepad that the controller should be created from
  41342. */
  41343. constructor(vrGamepad: any);
  41344. /**
  41345. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41346. * @param scene scene in which to add meshes
  41347. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41348. */
  41349. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41350. /**
  41351. * Called once for each button that changed state since the last frame
  41352. * @param buttonIdx Which button index changed
  41353. * @param state New state of the button
  41354. * @param changes Which properties on the state changed since last frame
  41355. */
  41356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41357. }
  41358. }
  41359. declare module BABYLON {
  41360. /**
  41361. * Generic Controller
  41362. */
  41363. export class GenericController extends WebVRController {
  41364. /**
  41365. * Base Url for the controller model.
  41366. */
  41367. static readonly MODEL_BASE_URL: string;
  41368. /**
  41369. * File name for the controller model.
  41370. */
  41371. static readonly MODEL_FILENAME: string;
  41372. /**
  41373. * Creates a new GenericController from a gamepad
  41374. * @param vrGamepad the gamepad that the controller should be created from
  41375. */
  41376. constructor(vrGamepad: any);
  41377. /**
  41378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41379. * @param scene scene in which to add meshes
  41380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41381. */
  41382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41383. /**
  41384. * Called once for each button that changed state since the last frame
  41385. * @param buttonIdx Which button index changed
  41386. * @param state New state of the button
  41387. * @param changes Which properties on the state changed since last frame
  41388. */
  41389. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41390. }
  41391. }
  41392. declare module BABYLON {
  41393. /**
  41394. * Oculus Touch Controller
  41395. */
  41396. export class OculusTouchController extends WebVRController {
  41397. /**
  41398. * Base Url for the controller model.
  41399. */
  41400. static MODEL_BASE_URL: string;
  41401. /**
  41402. * File name for the left controller model.
  41403. */
  41404. static MODEL_LEFT_FILENAME: string;
  41405. /**
  41406. * File name for the right controller model.
  41407. */
  41408. static MODEL_RIGHT_FILENAME: string;
  41409. /**
  41410. * Fired when the secondary trigger on this controller is modified
  41411. */
  41412. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41413. /**
  41414. * Fired when the thumb rest on this controller is modified
  41415. */
  41416. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41417. /**
  41418. * Creates a new OculusTouchController from a gamepad
  41419. * @param vrGamepad the gamepad that the controller should be created from
  41420. */
  41421. constructor(vrGamepad: any);
  41422. /**
  41423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41424. * @param scene scene in which to add meshes
  41425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41426. */
  41427. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41428. /**
  41429. * Fired when the A button on this controller is modified
  41430. */
  41431. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41432. /**
  41433. * Fired when the B button on this controller is modified
  41434. */
  41435. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41436. /**
  41437. * Fired when the X button on this controller is modified
  41438. */
  41439. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41440. /**
  41441. * Fired when the Y button on this controller is modified
  41442. */
  41443. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41444. /**
  41445. * Called once for each button that changed state since the last frame
  41446. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41447. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41448. * 2) secondary trigger (same)
  41449. * 3) A (right) X (left), touch, pressed = value
  41450. * 4) B / Y
  41451. * 5) thumb rest
  41452. * @param buttonIdx Which button index changed
  41453. * @param state New state of the button
  41454. * @param changes Which properties on the state changed since last frame
  41455. */
  41456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41457. }
  41458. }
  41459. declare module BABYLON {
  41460. /**
  41461. * Vive Controller
  41462. */
  41463. export class ViveController extends WebVRController {
  41464. /**
  41465. * Base Url for the controller model.
  41466. */
  41467. static MODEL_BASE_URL: string;
  41468. /**
  41469. * File name for the controller model.
  41470. */
  41471. static MODEL_FILENAME: string;
  41472. /**
  41473. * Creates a new ViveController from a gamepad
  41474. * @param vrGamepad the gamepad that the controller should be created from
  41475. */
  41476. constructor(vrGamepad: any);
  41477. /**
  41478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41479. * @param scene scene in which to add meshes
  41480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41481. */
  41482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41483. /**
  41484. * Fired when the left button on this controller is modified
  41485. */
  41486. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41487. /**
  41488. * Fired when the right button on this controller is modified
  41489. */
  41490. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41491. /**
  41492. * Fired when the menu button on this controller is modified
  41493. */
  41494. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41495. /**
  41496. * Called once for each button that changed state since the last frame
  41497. * Vive mapping:
  41498. * 0: touchpad
  41499. * 1: trigger
  41500. * 2: left AND right buttons
  41501. * 3: menu button
  41502. * @param buttonIdx Which button index changed
  41503. * @param state New state of the button
  41504. * @param changes Which properties on the state changed since last frame
  41505. */
  41506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41507. }
  41508. }
  41509. declare module BABYLON {
  41510. /**
  41511. * Defines the WindowsMotionController object that the state of the windows motion controller
  41512. */
  41513. export class WindowsMotionController extends WebVRController {
  41514. /**
  41515. * The base url used to load the left and right controller models
  41516. */
  41517. static MODEL_BASE_URL: string;
  41518. /**
  41519. * The name of the left controller model file
  41520. */
  41521. static MODEL_LEFT_FILENAME: string;
  41522. /**
  41523. * The name of the right controller model file
  41524. */
  41525. static MODEL_RIGHT_FILENAME: string;
  41526. /**
  41527. * The controller name prefix for this controller type
  41528. */
  41529. static readonly GAMEPAD_ID_PREFIX: string;
  41530. /**
  41531. * The controller id pattern for this controller type
  41532. */
  41533. private static readonly GAMEPAD_ID_PATTERN;
  41534. private _loadedMeshInfo;
  41535. private readonly _mapping;
  41536. /**
  41537. * Fired when the trackpad on this controller is clicked
  41538. */
  41539. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41540. /**
  41541. * Fired when the trackpad on this controller is modified
  41542. */
  41543. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41544. /**
  41545. * The current x and y values of this controller's trackpad
  41546. */
  41547. trackpad: StickValues;
  41548. /**
  41549. * Creates a new WindowsMotionController from a gamepad
  41550. * @param vrGamepad the gamepad that the controller should be created from
  41551. */
  41552. constructor(vrGamepad: any);
  41553. /**
  41554. * Fired when the trigger on this controller is modified
  41555. */
  41556. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41557. /**
  41558. * Fired when the menu button on this controller is modified
  41559. */
  41560. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41561. /**
  41562. * Fired when the grip button on this controller is modified
  41563. */
  41564. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41565. /**
  41566. * Fired when the thumbstick button on this controller is modified
  41567. */
  41568. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41569. /**
  41570. * Fired when the touchpad button on this controller is modified
  41571. */
  41572. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41573. /**
  41574. * Fired when the touchpad values on this controller are modified
  41575. */
  41576. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41577. private _updateTrackpad;
  41578. /**
  41579. * Called once per frame by the engine.
  41580. */
  41581. update(): void;
  41582. /**
  41583. * Called once for each button that changed state since the last frame
  41584. * @param buttonIdx Which button index changed
  41585. * @param state New state of the button
  41586. * @param changes Which properties on the state changed since last frame
  41587. */
  41588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41589. /**
  41590. * Moves the buttons on the controller mesh based on their current state
  41591. * @param buttonName the name of the button to move
  41592. * @param buttonValue the value of the button which determines the buttons new position
  41593. */
  41594. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41595. /**
  41596. * Moves the axis on the controller mesh based on its current state
  41597. * @param axis the index of the axis
  41598. * @param axisValue the value of the axis which determines the meshes new position
  41599. * @hidden
  41600. */
  41601. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41602. /**
  41603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41604. * @param scene scene in which to add meshes
  41605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41606. */
  41607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41608. /**
  41609. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41610. * can be transformed by button presses and axes values, based on this._mapping.
  41611. *
  41612. * @param scene scene in which the meshes exist
  41613. * @param meshes list of meshes that make up the controller model to process
  41614. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41615. */
  41616. private processModel;
  41617. private createMeshInfo;
  41618. /**
  41619. * Gets the ray of the controller in the direction the controller is pointing
  41620. * @param length the length the resulting ray should be
  41621. * @returns a ray in the direction the controller is pointing
  41622. */
  41623. getForwardRay(length?: number): Ray;
  41624. /**
  41625. * Disposes of the controller
  41626. */
  41627. dispose(): void;
  41628. }
  41629. }
  41630. declare module BABYLON {
  41631. /**
  41632. * Manager for handling gamepads
  41633. */
  41634. export class GamepadManager {
  41635. private _scene?;
  41636. private _babylonGamepads;
  41637. private _oneGamepadConnected;
  41638. /** @hidden */
  41639. _isMonitoring: boolean;
  41640. private _gamepadEventSupported;
  41641. private _gamepadSupport;
  41642. /**
  41643. * observable to be triggered when the gamepad controller has been connected
  41644. */
  41645. onGamepadConnectedObservable: Observable<Gamepad>;
  41646. /**
  41647. * observable to be triggered when the gamepad controller has been disconnected
  41648. */
  41649. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41650. private _onGamepadConnectedEvent;
  41651. private _onGamepadDisconnectedEvent;
  41652. /**
  41653. * Initializes the gamepad manager
  41654. * @param _scene BabylonJS scene
  41655. */
  41656. constructor(_scene?: Scene | undefined);
  41657. /**
  41658. * The gamepads in the game pad manager
  41659. */
  41660. readonly gamepads: Gamepad[];
  41661. /**
  41662. * Get the gamepad controllers based on type
  41663. * @param type The type of gamepad controller
  41664. * @returns Nullable gamepad
  41665. */
  41666. getGamepadByType(type?: number): Nullable<Gamepad>;
  41667. /**
  41668. * Disposes the gamepad manager
  41669. */
  41670. dispose(): void;
  41671. private _addNewGamepad;
  41672. private _startMonitoringGamepads;
  41673. private _stopMonitoringGamepads;
  41674. /** @hidden */
  41675. _checkGamepadsStatus(): void;
  41676. private _updateGamepadObjects;
  41677. }
  41678. }
  41679. declare module BABYLON {
  41680. interface Scene {
  41681. /** @hidden */
  41682. _gamepadManager: Nullable<GamepadManager>;
  41683. /**
  41684. * Gets the gamepad manager associated with the scene
  41685. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41686. */
  41687. gamepadManager: GamepadManager;
  41688. }
  41689. /**
  41690. * Interface representing a free camera inputs manager
  41691. */
  41692. interface FreeCameraInputsManager {
  41693. /**
  41694. * Adds gamepad input support to the FreeCameraInputsManager.
  41695. * @returns the FreeCameraInputsManager
  41696. */
  41697. addGamepad(): FreeCameraInputsManager;
  41698. }
  41699. /**
  41700. * Interface representing an arc rotate camera inputs manager
  41701. */
  41702. interface ArcRotateCameraInputsManager {
  41703. /**
  41704. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41705. * @returns the camera inputs manager
  41706. */
  41707. addGamepad(): ArcRotateCameraInputsManager;
  41708. }
  41709. /**
  41710. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41711. */
  41712. export class GamepadSystemSceneComponent implements ISceneComponent {
  41713. /**
  41714. * The component name helpfull to identify the component in the list of scene components.
  41715. */
  41716. readonly name: string;
  41717. /**
  41718. * The scene the component belongs to.
  41719. */
  41720. scene: Scene;
  41721. /**
  41722. * Creates a new instance of the component for the given scene
  41723. * @param scene Defines the scene to register the component in
  41724. */
  41725. constructor(scene: Scene);
  41726. /**
  41727. * Registers the component in a given scene
  41728. */
  41729. register(): void;
  41730. /**
  41731. * Rebuilds the elements related to this component in case of
  41732. * context lost for instance.
  41733. */
  41734. rebuild(): void;
  41735. /**
  41736. * Disposes the component and the associated ressources
  41737. */
  41738. dispose(): void;
  41739. private _beforeCameraUpdate;
  41740. }
  41741. }
  41742. declare module BABYLON {
  41743. /**
  41744. * Single axis scale gizmo
  41745. */
  41746. export class AxisScaleGizmo extends Gizmo {
  41747. private _coloredMaterial;
  41748. /**
  41749. * Drag behavior responsible for the gizmos dragging interactions
  41750. */
  41751. dragBehavior: PointerDragBehavior;
  41752. private _pointerObserver;
  41753. /**
  41754. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41755. */
  41756. snapDistance: number;
  41757. /**
  41758. * Event that fires each time the gizmo snaps to a new location.
  41759. * * snapDistance is the the change in distance
  41760. */
  41761. onSnapObservable: Observable<{
  41762. snapDistance: number;
  41763. }>;
  41764. /**
  41765. * If the scaling operation should be done on all axis (default: false)
  41766. */
  41767. uniformScaling: boolean;
  41768. /**
  41769. * Creates an AxisScaleGizmo
  41770. * @param gizmoLayer The utility layer the gizmo will be added to
  41771. * @param dragAxis The axis which the gizmo will be able to scale on
  41772. * @param color The color of the gizmo
  41773. */
  41774. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41776. /**
  41777. * Disposes of the gizmo
  41778. */
  41779. dispose(): void;
  41780. /**
  41781. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41782. * @param mesh The mesh to replace the default mesh of the gizmo
  41783. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41784. */
  41785. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41786. }
  41787. }
  41788. declare module BABYLON {
  41789. /**
  41790. * Bounding box gizmo
  41791. */
  41792. export class BoundingBoxGizmo extends Gizmo {
  41793. private _lineBoundingBox;
  41794. private _rotateSpheresParent;
  41795. private _scaleBoxesParent;
  41796. private _boundingDimensions;
  41797. private _renderObserver;
  41798. private _pointerObserver;
  41799. private _scaleDragSpeed;
  41800. private _tmpQuaternion;
  41801. private _tmpVector;
  41802. private _tmpRotationMatrix;
  41803. /**
  41804. * 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)
  41805. */
  41806. ignoreChildren: boolean;
  41807. /**
  41808. * 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)
  41809. */
  41810. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41811. /**
  41812. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41813. */
  41814. rotationSphereSize: number;
  41815. /**
  41816. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41817. */
  41818. scaleBoxSize: number;
  41819. /**
  41820. * 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)
  41821. */
  41822. fixedDragMeshScreenSize: boolean;
  41823. /**
  41824. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41825. */
  41826. fixedDragMeshScreenSizeDistanceFactor: number;
  41827. /**
  41828. * Fired when a rotation sphere or scale box is dragged
  41829. */
  41830. onDragStartObservable: Observable<{}>;
  41831. /**
  41832. * Fired when a scale box is dragged
  41833. */
  41834. onScaleBoxDragObservable: Observable<{}>;
  41835. /**
  41836. * Fired when a scale box drag is ended
  41837. */
  41838. onScaleBoxDragEndObservable: Observable<{}>;
  41839. /**
  41840. * Fired when a rotation sphere is dragged
  41841. */
  41842. onRotationSphereDragObservable: Observable<{}>;
  41843. /**
  41844. * Fired when a rotation sphere drag is ended
  41845. */
  41846. onRotationSphereDragEndObservable: Observable<{}>;
  41847. /**
  41848. * 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)
  41849. */
  41850. scalePivot: Nullable<Vector3>;
  41851. private _anchorMesh;
  41852. private _existingMeshScale;
  41853. private _dragMesh;
  41854. private pointerDragBehavior;
  41855. /**
  41856. * Creates an BoundingBoxGizmo
  41857. * @param gizmoLayer The utility layer the gizmo will be added to
  41858. * @param color The color of the gizmo
  41859. */
  41860. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41862. private _selectNode;
  41863. /**
  41864. * Updates the bounding box information for the Gizmo
  41865. */
  41866. updateBoundingBox(): void;
  41867. private _updateRotationSpheres;
  41868. private _updateScaleBoxes;
  41869. /**
  41870. * Enables rotation on the specified axis and disables rotation on the others
  41871. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41872. */
  41873. setEnabledRotationAxis(axis: string): void;
  41874. /**
  41875. * Enables/disables scaling
  41876. * @param enable if scaling should be enabled
  41877. */
  41878. setEnabledScaling(enable: boolean): void;
  41879. private _updateDummy;
  41880. /**
  41881. * Enables a pointer drag behavior on the bounding box of the gizmo
  41882. */
  41883. enableDragBehavior(): void;
  41884. /**
  41885. * Disposes of the gizmo
  41886. */
  41887. dispose(): void;
  41888. /**
  41889. * 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)
  41890. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41891. * @returns the bounding box mesh with the passed in mesh as a child
  41892. */
  41893. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41894. /**
  41895. * CustomMeshes are not supported by this gizmo
  41896. * @param mesh The mesh to replace the default mesh of the gizmo
  41897. */
  41898. setCustomMesh(mesh: Mesh): void;
  41899. }
  41900. }
  41901. declare module BABYLON {
  41902. /**
  41903. * Single plane rotation gizmo
  41904. */
  41905. export class PlaneRotationGizmo extends Gizmo {
  41906. /**
  41907. * Drag behavior responsible for the gizmos dragging interactions
  41908. */
  41909. dragBehavior: PointerDragBehavior;
  41910. private _pointerObserver;
  41911. /**
  41912. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41913. */
  41914. snapDistance: number;
  41915. /**
  41916. * Event that fires each time the gizmo snaps to a new location.
  41917. * * snapDistance is the the change in distance
  41918. */
  41919. onSnapObservable: Observable<{
  41920. snapDistance: number;
  41921. }>;
  41922. /**
  41923. * Creates a PlaneRotationGizmo
  41924. * @param gizmoLayer The utility layer the gizmo will be added to
  41925. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41926. * @param color The color of the gizmo
  41927. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41928. */
  41929. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41930. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41931. /**
  41932. * Disposes of the gizmo
  41933. */
  41934. dispose(): void;
  41935. }
  41936. }
  41937. declare module BABYLON {
  41938. /**
  41939. * Gizmo that enables rotating a mesh along 3 axis
  41940. */
  41941. export class RotationGizmo extends Gizmo {
  41942. /**
  41943. * Internal gizmo used for interactions on the x axis
  41944. */
  41945. xGizmo: PlaneRotationGizmo;
  41946. /**
  41947. * Internal gizmo used for interactions on the y axis
  41948. */
  41949. yGizmo: PlaneRotationGizmo;
  41950. /**
  41951. * Internal gizmo used for interactions on the z axis
  41952. */
  41953. zGizmo: PlaneRotationGizmo;
  41954. /** Fires an event when any of it's sub gizmos are dragged */
  41955. onDragStartObservable: Observable<{}>;
  41956. /** Fires an event when any of it's sub gizmos are released from dragging */
  41957. onDragEndObservable: Observable<{}>;
  41958. attachedMesh: Nullable<AbstractMesh>;
  41959. /**
  41960. * Creates a RotationGizmo
  41961. * @param gizmoLayer The utility layer the gizmo will be added to
  41962. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41963. */
  41964. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41965. updateGizmoRotationToMatchAttachedMesh: boolean;
  41966. /**
  41967. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41968. */
  41969. snapDistance: number;
  41970. /**
  41971. * Ratio for the scale of the gizmo (Default: 1)
  41972. */
  41973. scaleRatio: number;
  41974. /**
  41975. * Disposes of the gizmo
  41976. */
  41977. dispose(): void;
  41978. /**
  41979. * CustomMeshes are not supported by this gizmo
  41980. * @param mesh The mesh to replace the default mesh of the gizmo
  41981. */
  41982. setCustomMesh(mesh: Mesh): void;
  41983. }
  41984. }
  41985. declare module BABYLON {
  41986. /**
  41987. * Gizmo that enables dragging a mesh along 3 axis
  41988. */
  41989. export class PositionGizmo extends Gizmo {
  41990. /**
  41991. * Internal gizmo used for interactions on the x axis
  41992. */
  41993. xGizmo: AxisDragGizmo;
  41994. /**
  41995. * Internal gizmo used for interactions on the y axis
  41996. */
  41997. yGizmo: AxisDragGizmo;
  41998. /**
  41999. * Internal gizmo used for interactions on the z axis
  42000. */
  42001. zGizmo: AxisDragGizmo;
  42002. /** Fires an event when any of it's sub gizmos are dragged */
  42003. onDragStartObservable: Observable<{}>;
  42004. /** Fires an event when any of it's sub gizmos are released from dragging */
  42005. onDragEndObservable: Observable<{}>;
  42006. attachedMesh: Nullable<AbstractMesh>;
  42007. /**
  42008. * Creates a PositionGizmo
  42009. * @param gizmoLayer The utility layer the gizmo will be added to
  42010. */
  42011. constructor(gizmoLayer?: UtilityLayerRenderer);
  42012. updateGizmoRotationToMatchAttachedMesh: boolean;
  42013. /**
  42014. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42015. */
  42016. snapDistance: number;
  42017. /**
  42018. * Ratio for the scale of the gizmo (Default: 1)
  42019. */
  42020. scaleRatio: number;
  42021. /**
  42022. * Disposes of the gizmo
  42023. */
  42024. dispose(): void;
  42025. /**
  42026. * CustomMeshes are not supported by this gizmo
  42027. * @param mesh The mesh to replace the default mesh of the gizmo
  42028. */
  42029. setCustomMesh(mesh: Mesh): void;
  42030. }
  42031. }
  42032. declare module BABYLON {
  42033. /**
  42034. * Gizmo that enables scaling a mesh along 3 axis
  42035. */
  42036. export class ScaleGizmo extends Gizmo {
  42037. /**
  42038. * Internal gizmo used for interactions on the x axis
  42039. */
  42040. xGizmo: AxisScaleGizmo;
  42041. /**
  42042. * Internal gizmo used for interactions on the y axis
  42043. */
  42044. yGizmo: AxisScaleGizmo;
  42045. /**
  42046. * Internal gizmo used for interactions on the z axis
  42047. */
  42048. zGizmo: AxisScaleGizmo;
  42049. /**
  42050. * Internal gizmo used to scale all axis equally
  42051. */
  42052. uniformScaleGizmo: AxisScaleGizmo;
  42053. /** Fires an event when any of it's sub gizmos are dragged */
  42054. onDragStartObservable: Observable<{}>;
  42055. /** Fires an event when any of it's sub gizmos are released from dragging */
  42056. onDragEndObservable: Observable<{}>;
  42057. attachedMesh: Nullable<AbstractMesh>;
  42058. /**
  42059. * Creates a ScaleGizmo
  42060. * @param gizmoLayer The utility layer the gizmo will be added to
  42061. */
  42062. constructor(gizmoLayer?: UtilityLayerRenderer);
  42063. updateGizmoRotationToMatchAttachedMesh: boolean;
  42064. /**
  42065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42066. */
  42067. snapDistance: number;
  42068. /**
  42069. * Ratio for the scale of the gizmo (Default: 1)
  42070. */
  42071. scaleRatio: number;
  42072. /**
  42073. * Disposes of the gizmo
  42074. */
  42075. dispose(): void;
  42076. }
  42077. }
  42078. declare module BABYLON {
  42079. /**
  42080. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42081. */
  42082. export class GizmoManager implements IDisposable {
  42083. private scene;
  42084. /**
  42085. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42086. */
  42087. gizmos: {
  42088. positionGizmo: Nullable<PositionGizmo>;
  42089. rotationGizmo: Nullable<RotationGizmo>;
  42090. scaleGizmo: Nullable<ScaleGizmo>;
  42091. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42092. };
  42093. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42094. clearGizmoOnEmptyPointerEvent: boolean;
  42095. /** Fires an event when the manager is attached to a mesh */
  42096. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42097. private _gizmosEnabled;
  42098. private _pointerObserver;
  42099. private _attachedMesh;
  42100. private _boundingBoxColor;
  42101. private _defaultUtilityLayer;
  42102. private _defaultKeepDepthUtilityLayer;
  42103. /**
  42104. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42105. */
  42106. boundingBoxDragBehavior: SixDofDragBehavior;
  42107. /**
  42108. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42109. */
  42110. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42111. /**
  42112. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42113. */
  42114. usePointerToAttachGizmos: boolean;
  42115. /**
  42116. * Instatiates a gizmo manager
  42117. * @param scene the scene to overlay the gizmos on top of
  42118. */
  42119. constructor(scene: Scene);
  42120. /**
  42121. * Attaches a set of gizmos to the specified mesh
  42122. * @param mesh The mesh the gizmo's should be attached to
  42123. */
  42124. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42125. /**
  42126. * If the position gizmo is enabled
  42127. */
  42128. positionGizmoEnabled: boolean;
  42129. /**
  42130. * If the rotation gizmo is enabled
  42131. */
  42132. rotationGizmoEnabled: boolean;
  42133. /**
  42134. * If the scale gizmo is enabled
  42135. */
  42136. scaleGizmoEnabled: boolean;
  42137. /**
  42138. * If the boundingBox gizmo is enabled
  42139. */
  42140. boundingBoxGizmoEnabled: boolean;
  42141. /**
  42142. * Disposes of the gizmo manager
  42143. */
  42144. dispose(): void;
  42145. }
  42146. }
  42147. declare module BABYLON {
  42148. /** @hidden */
  42149. export var backgroundFragmentDeclaration: {
  42150. name: string;
  42151. shader: string;
  42152. };
  42153. }
  42154. declare module BABYLON {
  42155. /** @hidden */
  42156. export var backgroundUboDeclaration: {
  42157. name: string;
  42158. shader: string;
  42159. };
  42160. }
  42161. declare module BABYLON {
  42162. /** @hidden */
  42163. export var backgroundPixelShader: {
  42164. name: string;
  42165. shader: string;
  42166. };
  42167. }
  42168. declare module BABYLON {
  42169. /** @hidden */
  42170. export var backgroundVertexDeclaration: {
  42171. name: string;
  42172. shader: string;
  42173. };
  42174. }
  42175. declare module BABYLON {
  42176. /** @hidden */
  42177. export var backgroundVertexShader: {
  42178. name: string;
  42179. shader: string;
  42180. };
  42181. }
  42182. declare module BABYLON {
  42183. /**
  42184. * Background material used to create an efficient environement around your scene.
  42185. */
  42186. export class BackgroundMaterial extends PushMaterial {
  42187. /**
  42188. * Standard reflectance value at parallel view angle.
  42189. */
  42190. static StandardReflectance0: number;
  42191. /**
  42192. * Standard reflectance value at grazing angle.
  42193. */
  42194. static StandardReflectance90: number;
  42195. protected _primaryColor: Color3;
  42196. /**
  42197. * Key light Color (multiply against the environement texture)
  42198. */
  42199. primaryColor: Color3;
  42200. protected __perceptualColor: Nullable<Color3>;
  42201. /**
  42202. * Experimental Internal Use Only.
  42203. *
  42204. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42205. * This acts as a helper to set the primary color to a more "human friendly" value.
  42206. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42207. * output color as close as possible from the chosen value.
  42208. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42209. * part of lighting setup.)
  42210. */
  42211. _perceptualColor: Nullable<Color3>;
  42212. protected _primaryColorShadowLevel: float;
  42213. /**
  42214. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42215. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42216. */
  42217. primaryColorShadowLevel: float;
  42218. protected _primaryColorHighlightLevel: float;
  42219. /**
  42220. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42221. * The primary color is used at the level chosen to define what the white area would look.
  42222. */
  42223. primaryColorHighlightLevel: float;
  42224. protected _reflectionTexture: Nullable<BaseTexture>;
  42225. /**
  42226. * Reflection Texture used in the material.
  42227. * Should be author in a specific way for the best result (refer to the documentation).
  42228. */
  42229. reflectionTexture: Nullable<BaseTexture>;
  42230. protected _reflectionBlur: float;
  42231. /**
  42232. * Reflection Texture level of blur.
  42233. *
  42234. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42235. * texture twice.
  42236. */
  42237. reflectionBlur: float;
  42238. protected _diffuseTexture: Nullable<BaseTexture>;
  42239. /**
  42240. * Diffuse Texture used in the material.
  42241. * Should be author in a specific way for the best result (refer to the documentation).
  42242. */
  42243. diffuseTexture: Nullable<BaseTexture>;
  42244. protected _shadowLights: Nullable<IShadowLight[]>;
  42245. /**
  42246. * Specify the list of lights casting shadow on the material.
  42247. * All scene shadow lights will be included if null.
  42248. */
  42249. shadowLights: Nullable<IShadowLight[]>;
  42250. protected _shadowLevel: float;
  42251. /**
  42252. * Helps adjusting the shadow to a softer level if required.
  42253. * 0 means black shadows and 1 means no shadows.
  42254. */
  42255. shadowLevel: float;
  42256. protected _sceneCenter: Vector3;
  42257. /**
  42258. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42259. * It is usually zero but might be interesting to modify according to your setup.
  42260. */
  42261. sceneCenter: Vector3;
  42262. protected _opacityFresnel: boolean;
  42263. /**
  42264. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42265. * This helps ensuring a nice transition when the camera goes under the ground.
  42266. */
  42267. opacityFresnel: boolean;
  42268. protected _reflectionFresnel: boolean;
  42269. /**
  42270. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42271. * This helps adding a mirror texture on the ground.
  42272. */
  42273. reflectionFresnel: boolean;
  42274. protected _reflectionFalloffDistance: number;
  42275. /**
  42276. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42277. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42278. */
  42279. reflectionFalloffDistance: number;
  42280. protected _reflectionAmount: number;
  42281. /**
  42282. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42283. */
  42284. reflectionAmount: number;
  42285. protected _reflectionReflectance0: number;
  42286. /**
  42287. * This specifies the weight of the reflection at grazing angle.
  42288. */
  42289. reflectionReflectance0: number;
  42290. protected _reflectionReflectance90: number;
  42291. /**
  42292. * This specifies the weight of the reflection at a perpendicular point of view.
  42293. */
  42294. reflectionReflectance90: number;
  42295. /**
  42296. * Sets the reflection reflectance fresnel values according to the default standard
  42297. * empirically know to work well :-)
  42298. */
  42299. reflectionStandardFresnelWeight: number;
  42300. protected _useRGBColor: boolean;
  42301. /**
  42302. * Helps to directly use the maps channels instead of their level.
  42303. */
  42304. useRGBColor: boolean;
  42305. protected _enableNoise: boolean;
  42306. /**
  42307. * This helps reducing the banding effect that could occur on the background.
  42308. */
  42309. enableNoise: boolean;
  42310. /**
  42311. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42312. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42313. * Recommended to be keep at 1.0 except for special cases.
  42314. */
  42315. fovMultiplier: number;
  42316. private _fovMultiplier;
  42317. /**
  42318. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42319. */
  42320. useEquirectangularFOV: boolean;
  42321. private _maxSimultaneousLights;
  42322. /**
  42323. * Number of Simultaneous lights allowed on the material.
  42324. */
  42325. maxSimultaneousLights: int;
  42326. /**
  42327. * Default configuration related to image processing available in the Background Material.
  42328. */
  42329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42330. /**
  42331. * Keep track of the image processing observer to allow dispose and replace.
  42332. */
  42333. private _imageProcessingObserver;
  42334. /**
  42335. * Attaches a new image processing configuration to the PBR Material.
  42336. * @param configuration (if null the scene configuration will be use)
  42337. */
  42338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42339. /**
  42340. * Gets the image processing configuration used either in this material.
  42341. */
  42342. /**
  42343. * Sets the Default image processing configuration used either in the this material.
  42344. *
  42345. * If sets to null, the scene one is in use.
  42346. */
  42347. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42348. /**
  42349. * Gets wether the color curves effect is enabled.
  42350. */
  42351. /**
  42352. * Sets wether the color curves effect is enabled.
  42353. */
  42354. cameraColorCurvesEnabled: boolean;
  42355. /**
  42356. * Gets wether the color grading effect is enabled.
  42357. */
  42358. /**
  42359. * Gets wether the color grading effect is enabled.
  42360. */
  42361. cameraColorGradingEnabled: boolean;
  42362. /**
  42363. * Gets wether tonemapping is enabled or not.
  42364. */
  42365. /**
  42366. * Sets wether tonemapping is enabled or not
  42367. */
  42368. cameraToneMappingEnabled: boolean;
  42369. /**
  42370. * The camera exposure used on this material.
  42371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42372. * This corresponds to a photographic exposure.
  42373. */
  42374. /**
  42375. * The camera exposure used on this material.
  42376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42377. * This corresponds to a photographic exposure.
  42378. */
  42379. cameraExposure: float;
  42380. /**
  42381. * Gets The camera contrast used on this material.
  42382. */
  42383. /**
  42384. * Sets The camera contrast used on this material.
  42385. */
  42386. cameraContrast: float;
  42387. /**
  42388. * Gets the Color Grading 2D Lookup Texture.
  42389. */
  42390. /**
  42391. * Sets the Color Grading 2D Lookup Texture.
  42392. */
  42393. cameraColorGradingTexture: Nullable<BaseTexture>;
  42394. /**
  42395. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42396. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42397. * 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;
  42398. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42399. */
  42400. /**
  42401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42403. * 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;
  42404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42405. */
  42406. cameraColorCurves: Nullable<ColorCurves>;
  42407. /**
  42408. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42409. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42410. */
  42411. switchToBGR: boolean;
  42412. private _renderTargets;
  42413. private _reflectionControls;
  42414. private _white;
  42415. private _primaryShadowColor;
  42416. private _primaryHighlightColor;
  42417. /**
  42418. * Instantiates a Background Material in the given scene
  42419. * @param name The friendly name of the material
  42420. * @param scene The scene to add the material to
  42421. */
  42422. constructor(name: string, scene: Scene);
  42423. /**
  42424. * Gets a boolean indicating that current material needs to register RTT
  42425. */
  42426. readonly hasRenderTargetTextures: boolean;
  42427. /**
  42428. * The entire material has been created in order to prevent overdraw.
  42429. * @returns false
  42430. */
  42431. needAlphaTesting(): boolean;
  42432. /**
  42433. * The entire material has been created in order to prevent overdraw.
  42434. * @returns true if blending is enable
  42435. */
  42436. needAlphaBlending(): boolean;
  42437. /**
  42438. * Checks wether the material is ready to be rendered for a given mesh.
  42439. * @param mesh The mesh to render
  42440. * @param subMesh The submesh to check against
  42441. * @param useInstances Specify wether or not the material is used with instances
  42442. * @returns true if all the dependencies are ready (Textures, Effects...)
  42443. */
  42444. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42445. /**
  42446. * Compute the primary color according to the chosen perceptual color.
  42447. */
  42448. private _computePrimaryColorFromPerceptualColor;
  42449. /**
  42450. * Compute the highlights and shadow colors according to their chosen levels.
  42451. */
  42452. private _computePrimaryColors;
  42453. /**
  42454. * Build the uniform buffer used in the material.
  42455. */
  42456. buildUniformLayout(): void;
  42457. /**
  42458. * Unbind the material.
  42459. */
  42460. unbind(): void;
  42461. /**
  42462. * Bind only the world matrix to the material.
  42463. * @param world The world matrix to bind.
  42464. */
  42465. bindOnlyWorldMatrix(world: Matrix): void;
  42466. /**
  42467. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42468. * @param world The world matrix to bind.
  42469. * @param subMesh The submesh to bind for.
  42470. */
  42471. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42472. /**
  42473. * Dispose the material.
  42474. * @param forceDisposeEffect Force disposal of the associated effect.
  42475. * @param forceDisposeTextures Force disposal of the associated textures.
  42476. */
  42477. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42478. /**
  42479. * Clones the material.
  42480. * @param name The cloned name.
  42481. * @returns The cloned material.
  42482. */
  42483. clone(name: string): BackgroundMaterial;
  42484. /**
  42485. * Serializes the current material to its JSON representation.
  42486. * @returns The JSON representation.
  42487. */
  42488. serialize(): any;
  42489. /**
  42490. * Gets the class name of the material
  42491. * @returns "BackgroundMaterial"
  42492. */
  42493. getClassName(): string;
  42494. /**
  42495. * Parse a JSON input to create back a background material.
  42496. * @param source The JSON data to parse
  42497. * @param scene The scene to create the parsed material in
  42498. * @param rootUrl The root url of the assets the material depends upon
  42499. * @returns the instantiated BackgroundMaterial.
  42500. */
  42501. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42502. }
  42503. }
  42504. declare module BABYLON {
  42505. /**
  42506. * Represents the different options available during the creation of
  42507. * a Environment helper.
  42508. *
  42509. * This can control the default ground, skybox and image processing setup of your scene.
  42510. */
  42511. export interface IEnvironmentHelperOptions {
  42512. /**
  42513. * Specifies wether or not to create a ground.
  42514. * True by default.
  42515. */
  42516. createGround: boolean;
  42517. /**
  42518. * Specifies the ground size.
  42519. * 15 by default.
  42520. */
  42521. groundSize: number;
  42522. /**
  42523. * The texture used on the ground for the main color.
  42524. * Comes from the BabylonJS CDN by default.
  42525. *
  42526. * Remarks: Can be either a texture or a url.
  42527. */
  42528. groundTexture: string | BaseTexture;
  42529. /**
  42530. * The color mixed in the ground texture by default.
  42531. * BabylonJS clearColor by default.
  42532. */
  42533. groundColor: Color3;
  42534. /**
  42535. * Specifies the ground opacity.
  42536. * 1 by default.
  42537. */
  42538. groundOpacity: number;
  42539. /**
  42540. * Enables the ground to receive shadows.
  42541. * True by default.
  42542. */
  42543. enableGroundShadow: boolean;
  42544. /**
  42545. * Helps preventing the shadow to be fully black on the ground.
  42546. * 0.5 by default.
  42547. */
  42548. groundShadowLevel: number;
  42549. /**
  42550. * Creates a mirror texture attach to the ground.
  42551. * false by default.
  42552. */
  42553. enableGroundMirror: boolean;
  42554. /**
  42555. * Specifies the ground mirror size ratio.
  42556. * 0.3 by default as the default kernel is 64.
  42557. */
  42558. groundMirrorSizeRatio: number;
  42559. /**
  42560. * Specifies the ground mirror blur kernel size.
  42561. * 64 by default.
  42562. */
  42563. groundMirrorBlurKernel: number;
  42564. /**
  42565. * Specifies the ground mirror visibility amount.
  42566. * 1 by default
  42567. */
  42568. groundMirrorAmount: number;
  42569. /**
  42570. * Specifies the ground mirror reflectance weight.
  42571. * This uses the standard weight of the background material to setup the fresnel effect
  42572. * of the mirror.
  42573. * 1 by default.
  42574. */
  42575. groundMirrorFresnelWeight: number;
  42576. /**
  42577. * Specifies the ground mirror Falloff distance.
  42578. * This can helps reducing the size of the reflection.
  42579. * 0 by Default.
  42580. */
  42581. groundMirrorFallOffDistance: number;
  42582. /**
  42583. * Specifies the ground mirror texture type.
  42584. * Unsigned Int by Default.
  42585. */
  42586. groundMirrorTextureType: number;
  42587. /**
  42588. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42589. * the shown objects.
  42590. */
  42591. groundYBias: number;
  42592. /**
  42593. * Specifies wether or not to create a skybox.
  42594. * True by default.
  42595. */
  42596. createSkybox: boolean;
  42597. /**
  42598. * Specifies the skybox size.
  42599. * 20 by default.
  42600. */
  42601. skyboxSize: number;
  42602. /**
  42603. * The texture used on the skybox for the main color.
  42604. * Comes from the BabylonJS CDN by default.
  42605. *
  42606. * Remarks: Can be either a texture or a url.
  42607. */
  42608. skyboxTexture: string | BaseTexture;
  42609. /**
  42610. * The color mixed in the skybox texture by default.
  42611. * BabylonJS clearColor by default.
  42612. */
  42613. skyboxColor: Color3;
  42614. /**
  42615. * The background rotation around the Y axis of the scene.
  42616. * This helps aligning the key lights of your scene with the background.
  42617. * 0 by default.
  42618. */
  42619. backgroundYRotation: number;
  42620. /**
  42621. * Compute automatically the size of the elements to best fit with the scene.
  42622. */
  42623. sizeAuto: boolean;
  42624. /**
  42625. * Default position of the rootMesh if autoSize is not true.
  42626. */
  42627. rootPosition: Vector3;
  42628. /**
  42629. * Sets up the image processing in the scene.
  42630. * true by default.
  42631. */
  42632. setupImageProcessing: boolean;
  42633. /**
  42634. * The texture used as your environment texture in the scene.
  42635. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42636. *
  42637. * Remarks: Can be either a texture or a url.
  42638. */
  42639. environmentTexture: string | BaseTexture;
  42640. /**
  42641. * The value of the exposure to apply to the scene.
  42642. * 0.6 by default if setupImageProcessing is true.
  42643. */
  42644. cameraExposure: number;
  42645. /**
  42646. * The value of the contrast to apply to the scene.
  42647. * 1.6 by default if setupImageProcessing is true.
  42648. */
  42649. cameraContrast: number;
  42650. /**
  42651. * Specifies wether or not tonemapping should be enabled in the scene.
  42652. * true by default if setupImageProcessing is true.
  42653. */
  42654. toneMappingEnabled: boolean;
  42655. }
  42656. /**
  42657. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42658. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42659. * It also helps with the default setup of your imageProcessing configuration.
  42660. */
  42661. export class EnvironmentHelper {
  42662. /**
  42663. * Default ground texture URL.
  42664. */
  42665. private static _groundTextureCDNUrl;
  42666. /**
  42667. * Default skybox texture URL.
  42668. */
  42669. private static _skyboxTextureCDNUrl;
  42670. /**
  42671. * Default environment texture URL.
  42672. */
  42673. private static _environmentTextureCDNUrl;
  42674. /**
  42675. * Creates the default options for the helper.
  42676. */
  42677. private static _getDefaultOptions;
  42678. private _rootMesh;
  42679. /**
  42680. * Gets the root mesh created by the helper.
  42681. */
  42682. readonly rootMesh: Mesh;
  42683. private _skybox;
  42684. /**
  42685. * Gets the skybox created by the helper.
  42686. */
  42687. readonly skybox: Nullable<Mesh>;
  42688. private _skyboxTexture;
  42689. /**
  42690. * Gets the skybox texture created by the helper.
  42691. */
  42692. readonly skyboxTexture: Nullable<BaseTexture>;
  42693. private _skyboxMaterial;
  42694. /**
  42695. * Gets the skybox material created by the helper.
  42696. */
  42697. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42698. private _ground;
  42699. /**
  42700. * Gets the ground mesh created by the helper.
  42701. */
  42702. readonly ground: Nullable<Mesh>;
  42703. private _groundTexture;
  42704. /**
  42705. * Gets the ground texture created by the helper.
  42706. */
  42707. readonly groundTexture: Nullable<BaseTexture>;
  42708. private _groundMirror;
  42709. /**
  42710. * Gets the ground mirror created by the helper.
  42711. */
  42712. readonly groundMirror: Nullable<MirrorTexture>;
  42713. /**
  42714. * Gets the ground mirror render list to helps pushing the meshes
  42715. * you wish in the ground reflection.
  42716. */
  42717. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42718. private _groundMaterial;
  42719. /**
  42720. * Gets the ground material created by the helper.
  42721. */
  42722. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42723. /**
  42724. * Stores the creation options.
  42725. */
  42726. private readonly _scene;
  42727. private _options;
  42728. /**
  42729. * This observable will be notified with any error during the creation of the environment,
  42730. * mainly texture creation errors.
  42731. */
  42732. onErrorObservable: Observable<{
  42733. message?: string;
  42734. exception?: any;
  42735. }>;
  42736. /**
  42737. * constructor
  42738. * @param options
  42739. * @param scene The scene to add the material to
  42740. */
  42741. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42742. /**
  42743. * Updates the background according to the new options
  42744. * @param options
  42745. */
  42746. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42747. /**
  42748. * Sets the primary color of all the available elements.
  42749. * @param color the main color to affect to the ground and the background
  42750. */
  42751. setMainColor(color: Color3): void;
  42752. /**
  42753. * Setup the image processing according to the specified options.
  42754. */
  42755. private _setupImageProcessing;
  42756. /**
  42757. * Setup the environment texture according to the specified options.
  42758. */
  42759. private _setupEnvironmentTexture;
  42760. /**
  42761. * Setup the background according to the specified options.
  42762. */
  42763. private _setupBackground;
  42764. /**
  42765. * Get the scene sizes according to the setup.
  42766. */
  42767. private _getSceneSize;
  42768. /**
  42769. * Setup the ground according to the specified options.
  42770. */
  42771. private _setupGround;
  42772. /**
  42773. * Setup the ground material according to the specified options.
  42774. */
  42775. private _setupGroundMaterial;
  42776. /**
  42777. * Setup the ground diffuse texture according to the specified options.
  42778. */
  42779. private _setupGroundDiffuseTexture;
  42780. /**
  42781. * Setup the ground mirror texture according to the specified options.
  42782. */
  42783. private _setupGroundMirrorTexture;
  42784. /**
  42785. * Setup the ground to receive the mirror texture.
  42786. */
  42787. private _setupMirrorInGroundMaterial;
  42788. /**
  42789. * Setup the skybox according to the specified options.
  42790. */
  42791. private _setupSkybox;
  42792. /**
  42793. * Setup the skybox material according to the specified options.
  42794. */
  42795. private _setupSkyboxMaterial;
  42796. /**
  42797. * Setup the skybox reflection texture according to the specified options.
  42798. */
  42799. private _setupSkyboxReflectionTexture;
  42800. private _errorHandler;
  42801. /**
  42802. * Dispose all the elements created by the Helper.
  42803. */
  42804. dispose(): void;
  42805. }
  42806. }
  42807. declare module BABYLON {
  42808. /**
  42809. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42810. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42811. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42812. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42813. */
  42814. export class PhotoDome extends TransformNode {
  42815. private _useDirectMapping;
  42816. /**
  42817. * The texture being displayed on the sphere
  42818. */
  42819. protected _photoTexture: Texture;
  42820. /**
  42821. * Gets or sets the texture being displayed on the sphere
  42822. */
  42823. photoTexture: Texture;
  42824. /**
  42825. * Observable raised when an error occured while loading the 360 image
  42826. */
  42827. onLoadErrorObservable: Observable<string>;
  42828. /**
  42829. * The skybox material
  42830. */
  42831. protected _material: BackgroundMaterial;
  42832. /**
  42833. * The surface used for the skybox
  42834. */
  42835. protected _mesh: Mesh;
  42836. /**
  42837. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42838. * Also see the options.resolution property.
  42839. */
  42840. fovMultiplier: number;
  42841. /**
  42842. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42843. * @param name Element's name, child elements will append suffixes for their own names.
  42844. * @param urlsOfPhoto defines the url of the photo to display
  42845. * @param options defines an object containing optional or exposed sub element properties
  42846. * @param onError defines a callback called when an error occured while loading the texture
  42847. */
  42848. constructor(name: string, urlOfPhoto: string, options: {
  42849. resolution?: number;
  42850. size?: number;
  42851. useDirectMapping?: boolean;
  42852. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42853. /**
  42854. * Releases resources associated with this node.
  42855. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42856. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42857. */
  42858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42859. }
  42860. }
  42861. declare module BABYLON {
  42862. /**
  42863. * Class used to host texture specific utilities
  42864. */
  42865. export class TextureTools {
  42866. /**
  42867. * Uses the GPU to create a copy texture rescaled at a given size
  42868. * @param texture Texture to copy from
  42869. * @param width defines the desired width
  42870. * @param height defines the desired height
  42871. * @param useBilinearMode defines if bilinear mode has to be used
  42872. * @return the generated texture
  42873. */
  42874. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42875. /**
  42876. * Gets an environment BRDF texture for a given scene
  42877. * @param scene defines the hosting scene
  42878. * @returns the environment BRDF texture
  42879. */
  42880. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42881. private static _environmentBRDFBase64Texture;
  42882. }
  42883. }
  42884. declare module BABYLON {
  42885. /** @hidden */
  42886. export var pbrFragmentDeclaration: {
  42887. name: string;
  42888. shader: string;
  42889. };
  42890. }
  42891. declare module BABYLON {
  42892. /** @hidden */
  42893. export var pbrUboDeclaration: {
  42894. name: string;
  42895. shader: string;
  42896. };
  42897. }
  42898. declare module BABYLON {
  42899. /** @hidden */
  42900. export var pbrFunctions: {
  42901. name: string;
  42902. shader: string;
  42903. };
  42904. }
  42905. declare module BABYLON {
  42906. /** @hidden */
  42907. export var harmonicsFunctions: {
  42908. name: string;
  42909. shader: string;
  42910. };
  42911. }
  42912. declare module BABYLON {
  42913. /** @hidden */
  42914. export var pbrLightFunctions: {
  42915. name: string;
  42916. shader: string;
  42917. };
  42918. }
  42919. declare module BABYLON {
  42920. /** @hidden */
  42921. export var pbrPixelShader: {
  42922. name: string;
  42923. shader: string;
  42924. };
  42925. }
  42926. declare module BABYLON {
  42927. /** @hidden */
  42928. export var pbrVertexDeclaration: {
  42929. name: string;
  42930. shader: string;
  42931. };
  42932. }
  42933. declare module BABYLON {
  42934. /** @hidden */
  42935. export var pbrVertexShader: {
  42936. name: string;
  42937. shader: string;
  42938. };
  42939. }
  42940. declare module BABYLON {
  42941. /**
  42942. * The Physically based material base class of BJS.
  42943. *
  42944. * This offers the main features of a standard PBR material.
  42945. * For more information, please refer to the documentation :
  42946. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42947. */
  42948. export abstract class PBRBaseMaterial extends PushMaterial {
  42949. /**
  42950. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42951. */
  42952. static readonly PBRMATERIAL_OPAQUE: number;
  42953. /**
  42954. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42955. */
  42956. static readonly PBRMATERIAL_ALPHATEST: number;
  42957. /**
  42958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42959. */
  42960. static readonly PBRMATERIAL_ALPHABLEND: number;
  42961. /**
  42962. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42963. * They are also discarded below the alpha cutoff threshold to improve performances.
  42964. */
  42965. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42966. /**
  42967. * Defines the default value of how much AO map is occluding the analytical lights
  42968. * (point spot...).
  42969. */
  42970. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42971. /**
  42972. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42973. */
  42974. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42975. /**
  42976. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42977. * to enhance interoperability with other engines.
  42978. */
  42979. static readonly LIGHTFALLOFF_GLTF: number;
  42980. /**
  42981. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42982. * to enhance interoperability with other materials.
  42983. */
  42984. static readonly LIGHTFALLOFF_STANDARD: number;
  42985. /**
  42986. * Intensity of the direct lights e.g. the four lights available in your scene.
  42987. * This impacts both the direct diffuse and specular highlights.
  42988. */
  42989. protected _directIntensity: number;
  42990. /**
  42991. * Intensity of the emissive part of the material.
  42992. * This helps controlling the emissive effect without modifying the emissive color.
  42993. */
  42994. protected _emissiveIntensity: number;
  42995. /**
  42996. * Intensity of the environment e.g. how much the environment will light the object
  42997. * either through harmonics for rough material or through the refelction for shiny ones.
  42998. */
  42999. protected _environmentIntensity: number;
  43000. /**
  43001. * This is a special control allowing the reduction of the specular highlights coming from the
  43002. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43003. */
  43004. protected _specularIntensity: number;
  43005. /**
  43006. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43007. */
  43008. private _lightingInfos;
  43009. /**
  43010. * Debug Control allowing disabling the bump map on this material.
  43011. */
  43012. protected _disableBumpMap: boolean;
  43013. /**
  43014. * AKA Diffuse Texture in standard nomenclature.
  43015. */
  43016. protected _albedoTexture: BaseTexture;
  43017. /**
  43018. * AKA Occlusion Texture in other nomenclature.
  43019. */
  43020. protected _ambientTexture: BaseTexture;
  43021. /**
  43022. * AKA Occlusion Texture Intensity in other nomenclature.
  43023. */
  43024. protected _ambientTextureStrength: number;
  43025. /**
  43026. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43027. * 1 means it completely occludes it
  43028. * 0 mean it has no impact
  43029. */
  43030. protected _ambientTextureImpactOnAnalyticalLights: number;
  43031. /**
  43032. * Stores the alpha values in a texture.
  43033. */
  43034. protected _opacityTexture: BaseTexture;
  43035. /**
  43036. * Stores the reflection values in a texture.
  43037. */
  43038. protected _reflectionTexture: BaseTexture;
  43039. /**
  43040. * Stores the refraction values in a texture.
  43041. */
  43042. protected _refractionTexture: BaseTexture;
  43043. /**
  43044. * Stores the emissive values in a texture.
  43045. */
  43046. protected _emissiveTexture: BaseTexture;
  43047. /**
  43048. * AKA Specular texture in other nomenclature.
  43049. */
  43050. protected _reflectivityTexture: BaseTexture;
  43051. /**
  43052. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43053. */
  43054. protected _metallicTexture: BaseTexture;
  43055. /**
  43056. * Specifies the metallic scalar of the metallic/roughness workflow.
  43057. * Can also be used to scale the metalness values of the metallic texture.
  43058. */
  43059. protected _metallic: Nullable<number>;
  43060. /**
  43061. * Specifies the roughness scalar of the metallic/roughness workflow.
  43062. * Can also be used to scale the roughness values of the metallic texture.
  43063. */
  43064. protected _roughness: Nullable<number>;
  43065. /**
  43066. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43067. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43068. */
  43069. protected _microSurfaceTexture: BaseTexture;
  43070. /**
  43071. * Stores surface normal data used to displace a mesh in a texture.
  43072. */
  43073. protected _bumpTexture: BaseTexture;
  43074. /**
  43075. * Stores the pre-calculated light information of a mesh in a texture.
  43076. */
  43077. protected _lightmapTexture: BaseTexture;
  43078. /**
  43079. * The color of a material in ambient lighting.
  43080. */
  43081. protected _ambientColor: Color3;
  43082. /**
  43083. * AKA Diffuse Color in other nomenclature.
  43084. */
  43085. protected _albedoColor: Color3;
  43086. /**
  43087. * AKA Specular Color in other nomenclature.
  43088. */
  43089. protected _reflectivityColor: Color3;
  43090. /**
  43091. * The color applied when light is reflected from a material.
  43092. */
  43093. protected _reflectionColor: Color3;
  43094. /**
  43095. * The color applied when light is emitted from a material.
  43096. */
  43097. protected _emissiveColor: Color3;
  43098. /**
  43099. * AKA Glossiness in other nomenclature.
  43100. */
  43101. protected _microSurface: number;
  43102. /**
  43103. * source material index of refraction (IOR)' / 'destination material IOR.
  43104. */
  43105. protected _indexOfRefraction: number;
  43106. /**
  43107. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43108. */
  43109. protected _invertRefractionY: boolean;
  43110. /**
  43111. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43112. * Materials half opaque for instance using refraction could benefit from this control.
  43113. */
  43114. protected _linkRefractionWithTransparency: boolean;
  43115. /**
  43116. * Specifies that the material will use the light map as a show map.
  43117. */
  43118. protected _useLightmapAsShadowmap: boolean;
  43119. /**
  43120. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43121. * makes the reflect vector face the model (under horizon).
  43122. */
  43123. protected _useHorizonOcclusion: boolean;
  43124. /**
  43125. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43126. * too much the area relying on ambient texture to define their ambient occlusion.
  43127. */
  43128. protected _useRadianceOcclusion: boolean;
  43129. /**
  43130. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43131. */
  43132. protected _useAlphaFromAlbedoTexture: boolean;
  43133. /**
  43134. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43135. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43136. */
  43137. protected _useSpecularOverAlpha: boolean;
  43138. /**
  43139. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43140. */
  43141. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43142. /**
  43143. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43144. */
  43145. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43146. /**
  43147. * Specifies if the metallic texture contains the roughness information in its green channel.
  43148. */
  43149. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43150. /**
  43151. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43152. */
  43153. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43154. /**
  43155. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43156. */
  43157. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43158. /**
  43159. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43160. */
  43161. protected _useAmbientInGrayScale: boolean;
  43162. /**
  43163. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43164. * The material will try to infer what glossiness each pixel should be.
  43165. */
  43166. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43167. /**
  43168. * Defines the falloff type used in this material.
  43169. * It by default is Physical.
  43170. */
  43171. protected _lightFalloff: number;
  43172. /**
  43173. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43174. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43175. */
  43176. protected _useRadianceOverAlpha: boolean;
  43177. /**
  43178. * Allows using an object space normal map (instead of tangent space).
  43179. */
  43180. protected _useObjectSpaceNormalMap: boolean;
  43181. /**
  43182. * Allows using the bump map in parallax mode.
  43183. */
  43184. protected _useParallax: boolean;
  43185. /**
  43186. * Allows using the bump map in parallax occlusion mode.
  43187. */
  43188. protected _useParallaxOcclusion: boolean;
  43189. /**
  43190. * Controls the scale bias of the parallax mode.
  43191. */
  43192. protected _parallaxScaleBias: number;
  43193. /**
  43194. * If sets to true, disables all the lights affecting the material.
  43195. */
  43196. protected _disableLighting: boolean;
  43197. /**
  43198. * Number of Simultaneous lights allowed on the material.
  43199. */
  43200. protected _maxSimultaneousLights: number;
  43201. /**
  43202. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43203. */
  43204. protected _invertNormalMapX: boolean;
  43205. /**
  43206. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43207. */
  43208. protected _invertNormalMapY: boolean;
  43209. /**
  43210. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43211. */
  43212. protected _twoSidedLighting: boolean;
  43213. /**
  43214. * Defines the alpha limits in alpha test mode.
  43215. */
  43216. protected _alphaCutOff: number;
  43217. /**
  43218. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43219. */
  43220. protected _forceAlphaTest: boolean;
  43221. /**
  43222. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43223. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43224. */
  43225. protected _useAlphaFresnel: boolean;
  43226. /**
  43227. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43228. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43229. */
  43230. protected _useLinearAlphaFresnel: boolean;
  43231. /**
  43232. * The transparency mode of the material.
  43233. */
  43234. protected _transparencyMode: Nullable<number>;
  43235. /**
  43236. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  43237. * from cos thetav and roughness:
  43238. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  43239. */
  43240. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  43241. /**
  43242. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43243. */
  43244. protected _forceIrradianceInFragment: boolean;
  43245. /**
  43246. * Force normal to face away from face.
  43247. */
  43248. protected _forceNormalForward: boolean;
  43249. /**
  43250. * Enables specular anti aliasing in the PBR shader.
  43251. * It will both interacts on the Geometry for analytical and IBL lighting.
  43252. * It also prefilter the roughness map based on the bump values.
  43253. */
  43254. protected _enableSpecularAntiAliasing: boolean;
  43255. /**
  43256. * Default configuration related to image processing available in the PBR Material.
  43257. */
  43258. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43259. /**
  43260. * Keep track of the image processing observer to allow dispose and replace.
  43261. */
  43262. private _imageProcessingObserver;
  43263. /**
  43264. * Attaches a new image processing configuration to the PBR Material.
  43265. * @param configuration
  43266. */
  43267. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43268. /**
  43269. * Stores the available render targets.
  43270. */
  43271. private _renderTargets;
  43272. /**
  43273. * Sets the global ambient color for the material used in lighting calculations.
  43274. */
  43275. private _globalAmbientColor;
  43276. /**
  43277. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  43278. */
  43279. private _useLogarithmicDepth;
  43280. /**
  43281. * If set to true, no lighting calculations will be applied.
  43282. */
  43283. private _unlit;
  43284. /**
  43285. * Instantiates a new PBRMaterial instance.
  43286. *
  43287. * @param name The material name
  43288. * @param scene The scene the material will be use in.
  43289. */
  43290. constructor(name: string, scene: Scene);
  43291. /**
  43292. * Gets a boolean indicating that current material needs to register RTT
  43293. */
  43294. readonly hasRenderTargetTextures: boolean;
  43295. /**
  43296. * Gets the name of the material class.
  43297. */
  43298. getClassName(): string;
  43299. /**
  43300. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43301. */
  43302. /**
  43303. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43304. */
  43305. useLogarithmicDepth: boolean;
  43306. /**
  43307. * Gets the current transparency mode.
  43308. */
  43309. /**
  43310. * Sets the transparency mode of the material.
  43311. *
  43312. * | Value | Type | Description |
  43313. * | ----- | ----------------------------------- | ----------- |
  43314. * | 0 | OPAQUE | |
  43315. * | 1 | ALPHATEST | |
  43316. * | 2 | ALPHABLEND | |
  43317. * | 3 | ALPHATESTANDBLEND | |
  43318. *
  43319. */
  43320. transparencyMode: Nullable<number>;
  43321. /**
  43322. * Returns true if alpha blending should be disabled.
  43323. */
  43324. private readonly _disableAlphaBlending;
  43325. /**
  43326. * Specifies whether or not this material should be rendered in alpha blend mode.
  43327. */
  43328. needAlphaBlending(): boolean;
  43329. /**
  43330. * Specifies if the mesh will require alpha blending.
  43331. * @param mesh - BJS mesh.
  43332. */
  43333. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  43334. /**
  43335. * Specifies whether or not this material should be rendered in alpha test mode.
  43336. */
  43337. needAlphaTesting(): boolean;
  43338. /**
  43339. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  43340. */
  43341. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  43342. /**
  43343. * Gets the texture used for the alpha test.
  43344. */
  43345. getAlphaTestTexture(): BaseTexture;
  43346. /**
  43347. * Specifies that the submesh is ready to be used.
  43348. * @param mesh - BJS mesh.
  43349. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  43350. * @param useInstances - Specifies that instances should be used.
  43351. * @returns - boolean indicating that the submesh is ready or not.
  43352. */
  43353. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43354. /**
  43355. * Specifies if the material uses metallic roughness workflow.
  43356. * @returns boolean specifiying if the material uses metallic roughness workflow.
  43357. */
  43358. isMetallicWorkflow(): boolean;
  43359. private _prepareEffect;
  43360. private _prepareDefines;
  43361. /**
  43362. * Force shader compilation
  43363. */
  43364. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  43365. clipPlane: boolean;
  43366. }>): void;
  43367. /**
  43368. * Initializes the uniform buffer layout for the shader.
  43369. */
  43370. buildUniformLayout(): void;
  43371. /**
  43372. * Unbinds the textures.
  43373. */
  43374. unbind(): void;
  43375. /**
  43376. * Binds the submesh data.
  43377. * @param world - The world matrix.
  43378. * @param mesh - The BJS mesh.
  43379. * @param subMesh - A submesh of the BJS mesh.
  43380. */
  43381. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43382. /**
  43383. * Returns the animatable textures.
  43384. * @returns - Array of animatable textures.
  43385. */
  43386. getAnimatables(): IAnimatable[];
  43387. /**
  43388. * Returns the texture used for reflections.
  43389. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  43390. */
  43391. private _getReflectionTexture;
  43392. /**
  43393. * Returns the texture used for refraction or null if none is used.
  43394. * @returns - Refection texture if present. If no refraction texture and refraction
  43395. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43396. */
  43397. private _getRefractionTexture;
  43398. /**
  43399. * Disposes the resources of the material.
  43400. * @param forceDisposeEffect - Forces the disposal of effects.
  43401. * @param forceDisposeTextures - Forces the disposal of all textures.
  43402. */
  43403. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * The Physically based material of BJS.
  43409. *
  43410. * This offers the main features of a standard PBR material.
  43411. * For more information, please refer to the documentation :
  43412. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43413. */
  43414. export class PBRMaterial extends PBRBaseMaterial {
  43415. /**
  43416. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43417. */
  43418. static readonly PBRMATERIAL_OPAQUE: number;
  43419. /**
  43420. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43421. */
  43422. static readonly PBRMATERIAL_ALPHATEST: number;
  43423. /**
  43424. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43425. */
  43426. static readonly PBRMATERIAL_ALPHABLEND: number;
  43427. /**
  43428. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43429. * They are also discarded below the alpha cutoff threshold to improve performances.
  43430. */
  43431. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43432. /**
  43433. * Defines the default value of how much AO map is occluding the analytical lights
  43434. * (point spot...).
  43435. */
  43436. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43437. /**
  43438. * Intensity of the direct lights e.g. the four lights available in your scene.
  43439. * This impacts both the direct diffuse and specular highlights.
  43440. */
  43441. directIntensity: number;
  43442. /**
  43443. * Intensity of the emissive part of the material.
  43444. * This helps controlling the emissive effect without modifying the emissive color.
  43445. */
  43446. emissiveIntensity: number;
  43447. /**
  43448. * Intensity of the environment e.g. how much the environment will light the object
  43449. * either through harmonics for rough material or through the refelction for shiny ones.
  43450. */
  43451. environmentIntensity: number;
  43452. /**
  43453. * This is a special control allowing the reduction of the specular highlights coming from the
  43454. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43455. */
  43456. specularIntensity: number;
  43457. /**
  43458. * Debug Control allowing disabling the bump map on this material.
  43459. */
  43460. disableBumpMap: boolean;
  43461. /**
  43462. * AKA Diffuse Texture in standard nomenclature.
  43463. */
  43464. albedoTexture: BaseTexture;
  43465. /**
  43466. * AKA Occlusion Texture in other nomenclature.
  43467. */
  43468. ambientTexture: BaseTexture;
  43469. /**
  43470. * AKA Occlusion Texture Intensity in other nomenclature.
  43471. */
  43472. ambientTextureStrength: number;
  43473. /**
  43474. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43475. * 1 means it completely occludes it
  43476. * 0 mean it has no impact
  43477. */
  43478. ambientTextureImpactOnAnalyticalLights: number;
  43479. /**
  43480. * Stores the alpha values in a texture.
  43481. */
  43482. opacityTexture: BaseTexture;
  43483. /**
  43484. * Stores the reflection values in a texture.
  43485. */
  43486. reflectionTexture: Nullable<BaseTexture>;
  43487. /**
  43488. * Stores the emissive values in a texture.
  43489. */
  43490. emissiveTexture: BaseTexture;
  43491. /**
  43492. * AKA Specular texture in other nomenclature.
  43493. */
  43494. reflectivityTexture: BaseTexture;
  43495. /**
  43496. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43497. */
  43498. metallicTexture: BaseTexture;
  43499. /**
  43500. * Specifies the metallic scalar of the metallic/roughness workflow.
  43501. * Can also be used to scale the metalness values of the metallic texture.
  43502. */
  43503. metallic: Nullable<number>;
  43504. /**
  43505. * Specifies the roughness scalar of the metallic/roughness workflow.
  43506. * Can also be used to scale the roughness values of the metallic texture.
  43507. */
  43508. roughness: Nullable<number>;
  43509. /**
  43510. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43511. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43512. */
  43513. microSurfaceTexture: BaseTexture;
  43514. /**
  43515. * Stores surface normal data used to displace a mesh in a texture.
  43516. */
  43517. bumpTexture: BaseTexture;
  43518. /**
  43519. * Stores the pre-calculated light information of a mesh in a texture.
  43520. */
  43521. lightmapTexture: BaseTexture;
  43522. /**
  43523. * Stores the refracted light information in a texture.
  43524. */
  43525. refractionTexture: BaseTexture;
  43526. /**
  43527. * The color of a material in ambient lighting.
  43528. */
  43529. ambientColor: Color3;
  43530. /**
  43531. * AKA Diffuse Color in other nomenclature.
  43532. */
  43533. albedoColor: Color3;
  43534. /**
  43535. * AKA Specular Color in other nomenclature.
  43536. */
  43537. reflectivityColor: Color3;
  43538. /**
  43539. * The color reflected from the material.
  43540. */
  43541. reflectionColor: Color3;
  43542. /**
  43543. * The color emitted from the material.
  43544. */
  43545. emissiveColor: Color3;
  43546. /**
  43547. * AKA Glossiness in other nomenclature.
  43548. */
  43549. microSurface: number;
  43550. /**
  43551. * source material index of refraction (IOR)' / 'destination material IOR.
  43552. */
  43553. indexOfRefraction: number;
  43554. /**
  43555. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43556. */
  43557. invertRefractionY: boolean;
  43558. /**
  43559. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43560. * Materials half opaque for instance using refraction could benefit from this control.
  43561. */
  43562. linkRefractionWithTransparency: boolean;
  43563. /**
  43564. * If true, the light map contains occlusion information instead of lighting info.
  43565. */
  43566. useLightmapAsShadowmap: boolean;
  43567. /**
  43568. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43569. */
  43570. useAlphaFromAlbedoTexture: boolean;
  43571. /**
  43572. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43573. */
  43574. forceAlphaTest: boolean;
  43575. /**
  43576. * Defines the alpha limits in alpha test mode.
  43577. */
  43578. alphaCutOff: number;
  43579. /**
  43580. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  43581. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43582. */
  43583. useSpecularOverAlpha: boolean;
  43584. /**
  43585. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43586. */
  43587. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43588. /**
  43589. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43590. */
  43591. useRoughnessFromMetallicTextureAlpha: boolean;
  43592. /**
  43593. * Specifies if the metallic texture contains the roughness information in its green channel.
  43594. */
  43595. useRoughnessFromMetallicTextureGreen: boolean;
  43596. /**
  43597. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43598. */
  43599. useMetallnessFromMetallicTextureBlue: boolean;
  43600. /**
  43601. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43602. */
  43603. useAmbientOcclusionFromMetallicTextureRed: boolean;
  43604. /**
  43605. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43606. */
  43607. useAmbientInGrayScale: boolean;
  43608. /**
  43609. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43610. * The material will try to infer what glossiness each pixel should be.
  43611. */
  43612. useAutoMicroSurfaceFromReflectivityMap: boolean;
  43613. /**
  43614. * BJS is using an harcoded light falloff based on a manually sets up range.
  43615. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43616. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43617. */
  43618. /**
  43619. * BJS is using an harcoded light falloff based on a manually sets up range.
  43620. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43621. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43622. */
  43623. usePhysicalLightFalloff: boolean;
  43624. /**
  43625. * In order to support the falloff compatibility with gltf, a special mode has been added
  43626. * to reproduce the gltf light falloff.
  43627. */
  43628. /**
  43629. * In order to support the falloff compatibility with gltf, a special mode has been added
  43630. * to reproduce the gltf light falloff.
  43631. */
  43632. useGLTFLightFalloff: boolean;
  43633. /**
  43634. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43635. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43636. */
  43637. useRadianceOverAlpha: boolean;
  43638. /**
  43639. * Allows using an object space normal map (instead of tangent space).
  43640. */
  43641. useObjectSpaceNormalMap: boolean;
  43642. /**
  43643. * Allows using the bump map in parallax mode.
  43644. */
  43645. useParallax: boolean;
  43646. /**
  43647. * Allows using the bump map in parallax occlusion mode.
  43648. */
  43649. useParallaxOcclusion: boolean;
  43650. /**
  43651. * Controls the scale bias of the parallax mode.
  43652. */
  43653. parallaxScaleBias: number;
  43654. /**
  43655. * If sets to true, disables all the lights affecting the material.
  43656. */
  43657. disableLighting: boolean;
  43658. /**
  43659. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43660. */
  43661. forceIrradianceInFragment: boolean;
  43662. /**
  43663. * Number of Simultaneous lights allowed on the material.
  43664. */
  43665. maxSimultaneousLights: number;
  43666. /**
  43667. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43668. */
  43669. invertNormalMapX: boolean;
  43670. /**
  43671. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43672. */
  43673. invertNormalMapY: boolean;
  43674. /**
  43675. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43676. */
  43677. twoSidedLighting: boolean;
  43678. /**
  43679. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43680. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43681. */
  43682. useAlphaFresnel: boolean;
  43683. /**
  43684. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43685. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43686. */
  43687. useLinearAlphaFresnel: boolean;
  43688. /**
  43689. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43690. * And/Or occlude the blended part.
  43691. */
  43692. environmentBRDFTexture: Nullable<BaseTexture>;
  43693. /**
  43694. * Force normal to face away from face.
  43695. */
  43696. forceNormalForward: boolean;
  43697. /**
  43698. * Enables specular anti aliasing in the PBR shader.
  43699. * It will both interacts on the Geometry for analytical and IBL lighting.
  43700. * It also prefilter the roughness map based on the bump values.
  43701. */
  43702. enableSpecularAntiAliasing: boolean;
  43703. /**
  43704. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43705. * makes the reflect vector face the model (under horizon).
  43706. */
  43707. useHorizonOcclusion: boolean;
  43708. /**
  43709. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43710. * too much the area relying on ambient texture to define their ambient occlusion.
  43711. */
  43712. useRadianceOcclusion: boolean;
  43713. /**
  43714. * If set to true, no lighting calculations will be applied.
  43715. */
  43716. unlit: boolean;
  43717. /**
  43718. * Gets the image processing configuration used either in this material.
  43719. */
  43720. /**
  43721. * Sets the Default image processing configuration used either in the this material.
  43722. *
  43723. * If sets to null, the scene one is in use.
  43724. */
  43725. imageProcessingConfiguration: ImageProcessingConfiguration;
  43726. /**
  43727. * Gets wether the color curves effect is enabled.
  43728. */
  43729. /**
  43730. * Sets wether the color curves effect is enabled.
  43731. */
  43732. cameraColorCurvesEnabled: boolean;
  43733. /**
  43734. * Gets wether the color grading effect is enabled.
  43735. */
  43736. /**
  43737. * Gets wether the color grading effect is enabled.
  43738. */
  43739. cameraColorGradingEnabled: boolean;
  43740. /**
  43741. * Gets wether tonemapping is enabled or not.
  43742. */
  43743. /**
  43744. * Sets wether tonemapping is enabled or not
  43745. */
  43746. cameraToneMappingEnabled: boolean;
  43747. /**
  43748. * The camera exposure used on this material.
  43749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43750. * This corresponds to a photographic exposure.
  43751. */
  43752. /**
  43753. * The camera exposure used on this material.
  43754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43755. * This corresponds to a photographic exposure.
  43756. */
  43757. cameraExposure: number;
  43758. /**
  43759. * Gets The camera contrast used on this material.
  43760. */
  43761. /**
  43762. * Sets The camera contrast used on this material.
  43763. */
  43764. cameraContrast: number;
  43765. /**
  43766. * Gets the Color Grading 2D Lookup Texture.
  43767. */
  43768. /**
  43769. * Sets the Color Grading 2D Lookup Texture.
  43770. */
  43771. cameraColorGradingTexture: Nullable<BaseTexture>;
  43772. /**
  43773. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43774. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43775. * 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;
  43776. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43777. */
  43778. /**
  43779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43781. * 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;
  43782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43783. */
  43784. cameraColorCurves: Nullable<ColorCurves>;
  43785. /**
  43786. * Instantiates a new PBRMaterial instance.
  43787. *
  43788. * @param name The material name
  43789. * @param scene The scene the material will be use in.
  43790. */
  43791. constructor(name: string, scene: Scene);
  43792. /**
  43793. * Returns the name of this material class.
  43794. */
  43795. getClassName(): string;
  43796. /**
  43797. * Returns an array of the actively used textures.
  43798. * @returns - Array of BaseTextures
  43799. */
  43800. getActiveTextures(): BaseTexture[];
  43801. /**
  43802. * Checks to see if a texture is used in the material.
  43803. * @param texture - Base texture to use.
  43804. * @returns - Boolean specifying if a texture is used in the material.
  43805. */
  43806. hasTexture(texture: BaseTexture): boolean;
  43807. /**
  43808. * Makes a duplicate of the current material.
  43809. * @param name - name to use for the new material.
  43810. */
  43811. clone(name: string): PBRMaterial;
  43812. /**
  43813. * Serializes this PBR Material.
  43814. * @returns - An object with the serialized material.
  43815. */
  43816. serialize(): any;
  43817. /**
  43818. * Parses a PBR Material from a serialized object.
  43819. * @param source - Serialized object.
  43820. * @param scene - BJS scene instance.
  43821. * @param rootUrl - url for the scene object
  43822. * @returns - PBRMaterial
  43823. */
  43824. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43825. }
  43826. }
  43827. declare module BABYLON {
  43828. /** @hidden */
  43829. export var _forceSceneHelpersToBundle: boolean;
  43830. interface Scene {
  43831. /**
  43832. * Creates a default light for the scene.
  43833. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43834. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43835. */
  43836. createDefaultLight(replace?: boolean): void;
  43837. /**
  43838. * Creates a default camera for the scene.
  43839. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43840. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43841. * @param replace has default false, when true replaces the active camera in the scene
  43842. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43843. */
  43844. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43845. /**
  43846. * Creates a default camera and a default light.
  43847. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43848. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43849. * @param replace has the default false, when true replaces the active camera/light in the scene
  43850. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43851. */
  43852. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43853. /**
  43854. * Creates a new sky box
  43855. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43856. * @param environmentTexture defines the texture to use as environment texture
  43857. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43858. * @param scale defines the overall scale of the skybox
  43859. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43860. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43861. * @returns a new mesh holding the sky box
  43862. */
  43863. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43864. /**
  43865. * Creates a new environment
  43866. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43867. * @param options defines the options you can use to configure the environment
  43868. * @returns the new EnvironmentHelper
  43869. */
  43870. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43871. /**
  43872. * Creates a new VREXperienceHelper
  43873. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43874. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43875. * @returns a new VREXperienceHelper
  43876. */
  43877. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43878. /**
  43879. * Creates a new XREXperienceHelper
  43880. * @see http://doc.babylonjs.com/how_to/webxr
  43881. * @returns a promise for a new XREXperienceHelper
  43882. */
  43883. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43884. }
  43885. }
  43886. declare module BABYLON {
  43887. /**
  43888. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43889. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43890. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43891. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43892. */
  43893. export class VideoDome extends TransformNode {
  43894. private _useDirectMapping;
  43895. /**
  43896. * The video texture being displayed on the sphere
  43897. */
  43898. protected _videoTexture: VideoTexture;
  43899. /**
  43900. * Gets the video texture being displayed on the sphere
  43901. */
  43902. readonly videoTexture: VideoTexture;
  43903. /**
  43904. * The skybox material
  43905. */
  43906. protected _material: BackgroundMaterial;
  43907. /**
  43908. * The surface used for the skybox
  43909. */
  43910. protected _mesh: Mesh;
  43911. /**
  43912. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43913. * Also see the options.resolution property.
  43914. */
  43915. fovMultiplier: number;
  43916. /**
  43917. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43918. * @param name Element's name, child elements will append suffixes for their own names.
  43919. * @param urlsOrVideo defines the url(s) or the video element to use
  43920. * @param options An object containing optional or exposed sub element properties
  43921. */
  43922. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43923. resolution?: number;
  43924. clickToPlay?: boolean;
  43925. autoPlay?: boolean;
  43926. loop?: boolean;
  43927. size?: number;
  43928. poster?: string;
  43929. useDirectMapping?: boolean;
  43930. }, scene: Scene);
  43931. /**
  43932. * Releases resources associated with this node.
  43933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43935. */
  43936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43937. }
  43938. }
  43939. declare module BABYLON {
  43940. /**
  43941. * This class can be used to get instrumentation data from a Babylon engine
  43942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43943. */
  43944. export class EngineInstrumentation implements IDisposable {
  43945. /**
  43946. * Define the instrumented engine.
  43947. */
  43948. engine: Engine;
  43949. private _captureGPUFrameTime;
  43950. private _gpuFrameTimeToken;
  43951. private _gpuFrameTime;
  43952. private _captureShaderCompilationTime;
  43953. private _shaderCompilationTime;
  43954. private _onBeginFrameObserver;
  43955. private _onEndFrameObserver;
  43956. private _onBeforeShaderCompilationObserver;
  43957. private _onAfterShaderCompilationObserver;
  43958. /**
  43959. * Gets the perf counter used for GPU frame time
  43960. */
  43961. readonly gpuFrameTimeCounter: PerfCounter;
  43962. /**
  43963. * Gets the GPU frame time capture status
  43964. */
  43965. /**
  43966. * Enable or disable the GPU frame time capture
  43967. */
  43968. captureGPUFrameTime: boolean;
  43969. /**
  43970. * Gets the perf counter used for shader compilation time
  43971. */
  43972. readonly shaderCompilationTimeCounter: PerfCounter;
  43973. /**
  43974. * Gets the shader compilation time capture status
  43975. */
  43976. /**
  43977. * Enable or disable the shader compilation time capture
  43978. */
  43979. captureShaderCompilationTime: boolean;
  43980. /**
  43981. * Instantiates a new engine instrumentation.
  43982. * This class can be used to get instrumentation data from a Babylon engine
  43983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43984. * @param engine Defines the engine to instrument
  43985. */
  43986. constructor(
  43987. /**
  43988. * Define the instrumented engine.
  43989. */
  43990. engine: Engine);
  43991. /**
  43992. * Dispose and release associated resources.
  43993. */
  43994. dispose(): void;
  43995. }
  43996. }
  43997. declare module BABYLON {
  43998. /**
  43999. * This class can be used to get instrumentation data from a Babylon engine
  44000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44001. */
  44002. export class SceneInstrumentation implements IDisposable {
  44003. /**
  44004. * Defines the scene to instrument
  44005. */
  44006. scene: Scene;
  44007. private _captureActiveMeshesEvaluationTime;
  44008. private _activeMeshesEvaluationTime;
  44009. private _captureRenderTargetsRenderTime;
  44010. private _renderTargetsRenderTime;
  44011. private _captureFrameTime;
  44012. private _frameTime;
  44013. private _captureRenderTime;
  44014. private _renderTime;
  44015. private _captureInterFrameTime;
  44016. private _interFrameTime;
  44017. private _captureParticlesRenderTime;
  44018. private _particlesRenderTime;
  44019. private _captureSpritesRenderTime;
  44020. private _spritesRenderTime;
  44021. private _capturePhysicsTime;
  44022. private _physicsTime;
  44023. private _captureAnimationsTime;
  44024. private _animationsTime;
  44025. private _captureCameraRenderTime;
  44026. private _cameraRenderTime;
  44027. private _onBeforeActiveMeshesEvaluationObserver;
  44028. private _onAfterActiveMeshesEvaluationObserver;
  44029. private _onBeforeRenderTargetsRenderObserver;
  44030. private _onAfterRenderTargetsRenderObserver;
  44031. private _onAfterRenderObserver;
  44032. private _onBeforeDrawPhaseObserver;
  44033. private _onAfterDrawPhaseObserver;
  44034. private _onBeforeAnimationsObserver;
  44035. private _onBeforeParticlesRenderingObserver;
  44036. private _onAfterParticlesRenderingObserver;
  44037. private _onBeforeSpritesRenderingObserver;
  44038. private _onAfterSpritesRenderingObserver;
  44039. private _onBeforePhysicsObserver;
  44040. private _onAfterPhysicsObserver;
  44041. private _onAfterAnimationsObserver;
  44042. private _onBeforeCameraRenderObserver;
  44043. private _onAfterCameraRenderObserver;
  44044. /**
  44045. * Gets the perf counter used for active meshes evaluation time
  44046. */
  44047. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  44048. /**
  44049. * Gets the active meshes evaluation time capture status
  44050. */
  44051. /**
  44052. * Enable or disable the active meshes evaluation time capture
  44053. */
  44054. captureActiveMeshesEvaluationTime: boolean;
  44055. /**
  44056. * Gets the perf counter used for render targets render time
  44057. */
  44058. readonly renderTargetsRenderTimeCounter: PerfCounter;
  44059. /**
  44060. * Gets the render targets render time capture status
  44061. */
  44062. /**
  44063. * Enable or disable the render targets render time capture
  44064. */
  44065. captureRenderTargetsRenderTime: boolean;
  44066. /**
  44067. * Gets the perf counter used for particles render time
  44068. */
  44069. readonly particlesRenderTimeCounter: PerfCounter;
  44070. /**
  44071. * Gets the particles render time capture status
  44072. */
  44073. /**
  44074. * Enable or disable the particles render time capture
  44075. */
  44076. captureParticlesRenderTime: boolean;
  44077. /**
  44078. * Gets the perf counter used for sprites render time
  44079. */
  44080. readonly spritesRenderTimeCounter: PerfCounter;
  44081. /**
  44082. * Gets the sprites render time capture status
  44083. */
  44084. /**
  44085. * Enable or disable the sprites render time capture
  44086. */
  44087. captureSpritesRenderTime: boolean;
  44088. /**
  44089. * Gets the perf counter used for physics time
  44090. */
  44091. readonly physicsTimeCounter: PerfCounter;
  44092. /**
  44093. * Gets the physics time capture status
  44094. */
  44095. /**
  44096. * Enable or disable the physics time capture
  44097. */
  44098. capturePhysicsTime: boolean;
  44099. /**
  44100. * Gets the perf counter used for animations time
  44101. */
  44102. readonly animationsTimeCounter: PerfCounter;
  44103. /**
  44104. * Gets the animations time capture status
  44105. */
  44106. /**
  44107. * Enable or disable the animations time capture
  44108. */
  44109. captureAnimationsTime: boolean;
  44110. /**
  44111. * Gets the perf counter used for frame time capture
  44112. */
  44113. readonly frameTimeCounter: PerfCounter;
  44114. /**
  44115. * Gets the frame time capture status
  44116. */
  44117. /**
  44118. * Enable or disable the frame time capture
  44119. */
  44120. captureFrameTime: boolean;
  44121. /**
  44122. * Gets the perf counter used for inter-frames time capture
  44123. */
  44124. readonly interFrameTimeCounter: PerfCounter;
  44125. /**
  44126. * Gets the inter-frames time capture status
  44127. */
  44128. /**
  44129. * Enable or disable the inter-frames time capture
  44130. */
  44131. captureInterFrameTime: boolean;
  44132. /**
  44133. * Gets the perf counter used for render time capture
  44134. */
  44135. readonly renderTimeCounter: PerfCounter;
  44136. /**
  44137. * Gets the render time capture status
  44138. */
  44139. /**
  44140. * Enable or disable the render time capture
  44141. */
  44142. captureRenderTime: boolean;
  44143. /**
  44144. * Gets the perf counter used for camera render time capture
  44145. */
  44146. readonly cameraRenderTimeCounter: PerfCounter;
  44147. /**
  44148. * Gets the camera render time capture status
  44149. */
  44150. /**
  44151. * Enable or disable the camera render time capture
  44152. */
  44153. captureCameraRenderTime: boolean;
  44154. /**
  44155. * Gets the perf counter used for draw calls
  44156. */
  44157. readonly drawCallsCounter: PerfCounter;
  44158. /**
  44159. * Gets the perf counter used for texture collisions
  44160. */
  44161. readonly textureCollisionsCounter: PerfCounter;
  44162. /**
  44163. * Instantiates a new scene instrumentation.
  44164. * This class can be used to get instrumentation data from a Babylon engine
  44165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44166. * @param scene Defines the scene to instrument
  44167. */
  44168. constructor(
  44169. /**
  44170. * Defines the scene to instrument
  44171. */
  44172. scene: Scene);
  44173. /**
  44174. * Dispose and release associated resources.
  44175. */
  44176. dispose(): void;
  44177. }
  44178. }
  44179. declare module BABYLON {
  44180. /** @hidden */
  44181. export var glowMapGenerationPixelShader: {
  44182. name: string;
  44183. shader: string;
  44184. };
  44185. }
  44186. declare module BABYLON {
  44187. /** @hidden */
  44188. export var glowMapGenerationVertexShader: {
  44189. name: string;
  44190. shader: string;
  44191. };
  44192. }
  44193. declare module BABYLON {
  44194. /**
  44195. * Effect layer options. This helps customizing the behaviour
  44196. * of the effect layer.
  44197. */
  44198. export interface IEffectLayerOptions {
  44199. /**
  44200. * Multiplication factor apply to the canvas size to compute the render target size
  44201. * used to generated the objects (the smaller the faster).
  44202. */
  44203. mainTextureRatio: number;
  44204. /**
  44205. * Enforces a fixed size texture to ensure effect stability across devices.
  44206. */
  44207. mainTextureFixedSize?: number;
  44208. /**
  44209. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  44210. */
  44211. alphaBlendingMode: number;
  44212. /**
  44213. * The camera attached to the layer.
  44214. */
  44215. camera: Nullable<Camera>;
  44216. /**
  44217. * The rendering group to draw the layer in.
  44218. */
  44219. renderingGroupId: number;
  44220. }
  44221. /**
  44222. * The effect layer Helps adding post process effect blended with the main pass.
  44223. *
  44224. * This can be for instance use to generate glow or higlight effects on the scene.
  44225. *
  44226. * The effect layer class can not be used directly and is intented to inherited from to be
  44227. * customized per effects.
  44228. */
  44229. export abstract class EffectLayer {
  44230. private _vertexBuffers;
  44231. private _indexBuffer;
  44232. private _cachedDefines;
  44233. private _effectLayerMapGenerationEffect;
  44234. private _effectLayerOptions;
  44235. private _mergeEffect;
  44236. protected _scene: Scene;
  44237. protected _engine: Engine;
  44238. protected _maxSize: number;
  44239. protected _mainTextureDesiredSize: ISize;
  44240. protected _mainTexture: RenderTargetTexture;
  44241. protected _shouldRender: boolean;
  44242. protected _postProcesses: PostProcess[];
  44243. protected _textures: BaseTexture[];
  44244. protected _emissiveTextureAndColor: {
  44245. texture: Nullable<BaseTexture>;
  44246. color: Color4;
  44247. };
  44248. /**
  44249. * The name of the layer
  44250. */
  44251. name: string;
  44252. /**
  44253. * The clear color of the texture used to generate the glow map.
  44254. */
  44255. neutralColor: Color4;
  44256. /**
  44257. * Specifies wether the highlight layer is enabled or not.
  44258. */
  44259. isEnabled: boolean;
  44260. /**
  44261. * Gets the camera attached to the layer.
  44262. */
  44263. readonly camera: Nullable<Camera>;
  44264. /**
  44265. * Gets the rendering group id the layer should render in.
  44266. */
  44267. readonly renderingGroupId: number;
  44268. /**
  44269. * An event triggered when the effect layer has been disposed.
  44270. */
  44271. onDisposeObservable: Observable<EffectLayer>;
  44272. /**
  44273. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  44274. */
  44275. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  44276. /**
  44277. * An event triggered when the generated texture is being merged in the scene.
  44278. */
  44279. onBeforeComposeObservable: Observable<EffectLayer>;
  44280. /**
  44281. * An event triggered when the generated texture has been merged in the scene.
  44282. */
  44283. onAfterComposeObservable: Observable<EffectLayer>;
  44284. /**
  44285. * An event triggered when the efffect layer changes its size.
  44286. */
  44287. onSizeChangedObservable: Observable<EffectLayer>;
  44288. /** @hidden */
  44289. static _SceneComponentInitialization: (scene: Scene) => void;
  44290. /**
  44291. * Instantiates a new effect Layer and references it in the scene.
  44292. * @param name The name of the layer
  44293. * @param scene The scene to use the layer in
  44294. */
  44295. constructor(
  44296. /** The Friendly of the effect in the scene */
  44297. name: string, scene: Scene);
  44298. /**
  44299. * Get the effect name of the layer.
  44300. * @return The effect name
  44301. */
  44302. abstract getEffectName(): string;
  44303. /**
  44304. * Checks for the readiness of the element composing the layer.
  44305. * @param subMesh the mesh to check for
  44306. * @param useInstances specify wether or not to use instances to render the mesh
  44307. * @return true if ready otherwise, false
  44308. */
  44309. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44310. /**
  44311. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44312. * @returns true if the effect requires stencil during the main canvas render pass.
  44313. */
  44314. abstract needStencil(): boolean;
  44315. /**
  44316. * Create the merge effect. This is the shader use to blit the information back
  44317. * to the main canvas at the end of the scene rendering.
  44318. * @returns The effect containing the shader used to merge the effect on the main canvas
  44319. */
  44320. protected abstract _createMergeEffect(): Effect;
  44321. /**
  44322. * Creates the render target textures and post processes used in the effect layer.
  44323. */
  44324. protected abstract _createTextureAndPostProcesses(): void;
  44325. /**
  44326. * Implementation specific of rendering the generating effect on the main canvas.
  44327. * @param effect The effect used to render through
  44328. */
  44329. protected abstract _internalRender(effect: Effect): void;
  44330. /**
  44331. * Sets the required values for both the emissive texture and and the main color.
  44332. */
  44333. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44334. /**
  44335. * Free any resources and references associated to a mesh.
  44336. * Internal use
  44337. * @param mesh The mesh to free.
  44338. */
  44339. abstract _disposeMesh(mesh: Mesh): void;
  44340. /**
  44341. * Serializes this layer (Glow or Highlight for example)
  44342. * @returns a serialized layer object
  44343. */
  44344. abstract serialize?(): any;
  44345. /**
  44346. * Initializes the effect layer with the required options.
  44347. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  44348. */
  44349. protected _init(options: Partial<IEffectLayerOptions>): void;
  44350. /**
  44351. * Generates the index buffer of the full screen quad blending to the main canvas.
  44352. */
  44353. private _generateIndexBuffer;
  44354. /**
  44355. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  44356. */
  44357. private _genrateVertexBuffer;
  44358. /**
  44359. * Sets the main texture desired size which is the closest power of two
  44360. * of the engine canvas size.
  44361. */
  44362. private _setMainTextureSize;
  44363. /**
  44364. * Creates the main texture for the effect layer.
  44365. */
  44366. protected _createMainTexture(): void;
  44367. /**
  44368. * Adds specific effects defines.
  44369. * @param defines The defines to add specifics to.
  44370. */
  44371. protected _addCustomEffectDefines(defines: string[]): void;
  44372. /**
  44373. * Checks for the readiness of the element composing the layer.
  44374. * @param subMesh the mesh to check for
  44375. * @param useInstances specify wether or not to use instances to render the mesh
  44376. * @param emissiveTexture the associated emissive texture used to generate the glow
  44377. * @return true if ready otherwise, false
  44378. */
  44379. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  44380. /**
  44381. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  44382. */
  44383. render(): void;
  44384. /**
  44385. * Determine if a given mesh will be used in the current effect.
  44386. * @param mesh mesh to test
  44387. * @returns true if the mesh will be used
  44388. */
  44389. hasMesh(mesh: AbstractMesh): boolean;
  44390. /**
  44391. * Returns true if the layer contains information to display, otherwise false.
  44392. * @returns true if the glow layer should be rendered
  44393. */
  44394. shouldRender(): boolean;
  44395. /**
  44396. * Returns true if the mesh should render, otherwise false.
  44397. * @param mesh The mesh to render
  44398. * @returns true if it should render otherwise false
  44399. */
  44400. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  44401. /**
  44402. * Returns true if the mesh can be rendered, otherwise false.
  44403. * @param mesh The mesh to render
  44404. * @param material The material used on the mesh
  44405. * @returns true if it can be rendered otherwise false
  44406. */
  44407. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44408. /**
  44409. * Returns true if the mesh should render, otherwise false.
  44410. * @param mesh The mesh to render
  44411. * @returns true if it should render otherwise false
  44412. */
  44413. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  44414. /**
  44415. * Renders the submesh passed in parameter to the generation map.
  44416. */
  44417. protected _renderSubMesh(subMesh: SubMesh): void;
  44418. /**
  44419. * Rebuild the required buffers.
  44420. * @hidden Internal use only.
  44421. */
  44422. _rebuild(): void;
  44423. /**
  44424. * Dispose only the render target textures and post process.
  44425. */
  44426. private _disposeTextureAndPostProcesses;
  44427. /**
  44428. * Dispose the highlight layer and free resources.
  44429. */
  44430. dispose(): void;
  44431. /**
  44432. * Gets the class name of the effect layer
  44433. * @returns the string with the class name of the effect layer
  44434. */
  44435. getClassName(): string;
  44436. /**
  44437. * Creates an effect layer from parsed effect layer data
  44438. * @param parsedEffectLayer defines effect layer data
  44439. * @param scene defines the current scene
  44440. * @param rootUrl defines the root URL containing the effect layer information
  44441. * @returns a parsed effect Layer
  44442. */
  44443. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  44444. }
  44445. }
  44446. declare module BABYLON {
  44447. interface AbstractScene {
  44448. /**
  44449. * The list of effect layers (highlights/glow) added to the scene
  44450. * @see http://doc.babylonjs.com/how_to/highlight_layer
  44451. * @see http://doc.babylonjs.com/how_to/glow_layer
  44452. */
  44453. effectLayers: Array<EffectLayer>;
  44454. /**
  44455. * Removes the given effect layer from this scene.
  44456. * @param toRemove defines the effect layer to remove
  44457. * @returns the index of the removed effect layer
  44458. */
  44459. removeEffectLayer(toRemove: EffectLayer): number;
  44460. /**
  44461. * Adds the given effect layer to this scene
  44462. * @param newEffectLayer defines the effect layer to add
  44463. */
  44464. addEffectLayer(newEffectLayer: EffectLayer): void;
  44465. }
  44466. /**
  44467. * Defines the layer scene component responsible to manage any effect layers
  44468. * in a given scene.
  44469. */
  44470. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  44471. /**
  44472. * The component name helpfull to identify the component in the list of scene components.
  44473. */
  44474. readonly name: string;
  44475. /**
  44476. * The scene the component belongs to.
  44477. */
  44478. scene: Scene;
  44479. private _engine;
  44480. private _renderEffects;
  44481. private _needStencil;
  44482. private _previousStencilState;
  44483. /**
  44484. * Creates a new instance of the component for the given scene
  44485. * @param scene Defines the scene to register the component in
  44486. */
  44487. constructor(scene: Scene);
  44488. /**
  44489. * Registers the component in a given scene
  44490. */
  44491. register(): void;
  44492. /**
  44493. * Rebuilds the elements related to this component in case of
  44494. * context lost for instance.
  44495. */
  44496. rebuild(): void;
  44497. /**
  44498. * Serializes the component data to the specified json object
  44499. * @param serializationObject The object to serialize to
  44500. */
  44501. serialize(serializationObject: any): void;
  44502. /**
  44503. * Adds all the element from the container to the scene
  44504. * @param container the container holding the elements
  44505. */
  44506. addFromContainer(container: AbstractScene): void;
  44507. /**
  44508. * Removes all the elements in the container from the scene
  44509. * @param container contains the elements to remove
  44510. */
  44511. removeFromContainer(container: AbstractScene): void;
  44512. /**
  44513. * Disposes the component and the associated ressources.
  44514. */
  44515. dispose(): void;
  44516. private _isReadyForMesh;
  44517. private _renderMainTexture;
  44518. private _setStencil;
  44519. private _setStencilBack;
  44520. private _draw;
  44521. private _drawCamera;
  44522. private _drawRenderingGroup;
  44523. }
  44524. }
  44525. declare module BABYLON {
  44526. /** @hidden */
  44527. export var glowMapMergePixelShader: {
  44528. name: string;
  44529. shader: string;
  44530. };
  44531. }
  44532. declare module BABYLON {
  44533. /** @hidden */
  44534. export var glowMapMergeVertexShader: {
  44535. name: string;
  44536. shader: string;
  44537. };
  44538. }
  44539. declare module BABYLON {
  44540. interface AbstractScene {
  44541. /**
  44542. * Return a the first highlight layer of the scene with a given name.
  44543. * @param name The name of the highlight layer to look for.
  44544. * @return The highlight layer if found otherwise null.
  44545. */
  44546. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  44547. }
  44548. /**
  44549. * Glow layer options. This helps customizing the behaviour
  44550. * of the glow layer.
  44551. */
  44552. export interface IGlowLayerOptions {
  44553. /**
  44554. * Multiplication factor apply to the canvas size to compute the render target size
  44555. * used to generated the glowing objects (the smaller the faster).
  44556. */
  44557. mainTextureRatio: number;
  44558. /**
  44559. * Enforces a fixed size texture to ensure resize independant blur.
  44560. */
  44561. mainTextureFixedSize?: number;
  44562. /**
  44563. * How big is the kernel of the blur texture.
  44564. */
  44565. blurKernelSize: number;
  44566. /**
  44567. * The camera attached to the layer.
  44568. */
  44569. camera: Nullable<Camera>;
  44570. /**
  44571. * Enable MSAA by chosing the number of samples.
  44572. */
  44573. mainTextureSamples?: number;
  44574. /**
  44575. * The rendering group to draw the layer in.
  44576. */
  44577. renderingGroupId: number;
  44578. }
  44579. /**
  44580. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  44581. *
  44582. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44583. * glowy meshes to your scene.
  44584. *
  44585. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  44586. */
  44587. export class GlowLayer extends EffectLayer {
  44588. /**
  44589. * Effect Name of the layer.
  44590. */
  44591. static readonly EffectName: string;
  44592. /**
  44593. * The default blur kernel size used for the glow.
  44594. */
  44595. static DefaultBlurKernelSize: number;
  44596. /**
  44597. * The default texture size ratio used for the glow.
  44598. */
  44599. static DefaultTextureRatio: number;
  44600. /**
  44601. * Sets the kernel size of the blur.
  44602. */
  44603. /**
  44604. * Gets the kernel size of the blur.
  44605. */
  44606. blurKernelSize: number;
  44607. /**
  44608. * Sets the glow intensity.
  44609. */
  44610. /**
  44611. * Gets the glow intensity.
  44612. */
  44613. intensity: number;
  44614. private _options;
  44615. private _intensity;
  44616. private _horizontalBlurPostprocess1;
  44617. private _verticalBlurPostprocess1;
  44618. private _horizontalBlurPostprocess2;
  44619. private _verticalBlurPostprocess2;
  44620. private _blurTexture1;
  44621. private _blurTexture2;
  44622. private _postProcesses1;
  44623. private _postProcesses2;
  44624. private _includedOnlyMeshes;
  44625. private _excludedMeshes;
  44626. /**
  44627. * Callback used to let the user override the color selection on a per mesh basis
  44628. */
  44629. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  44630. /**
  44631. * Callback used to let the user override the texture selection on a per mesh basis
  44632. */
  44633. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  44634. /**
  44635. * Instantiates a new glow Layer and references it to the scene.
  44636. * @param name The name of the layer
  44637. * @param scene The scene to use the layer in
  44638. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  44639. */
  44640. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  44641. /**
  44642. * Get the effect name of the layer.
  44643. * @return The effect name
  44644. */
  44645. getEffectName(): string;
  44646. /**
  44647. * Create the merge effect. This is the shader use to blit the information back
  44648. * to the main canvas at the end of the scene rendering.
  44649. */
  44650. protected _createMergeEffect(): Effect;
  44651. /**
  44652. * Creates the render target textures and post processes used in the glow layer.
  44653. */
  44654. protected _createTextureAndPostProcesses(): void;
  44655. /**
  44656. * Checks for the readiness of the element composing the layer.
  44657. * @param subMesh the mesh to check for
  44658. * @param useInstances specify wether or not to use instances to render the mesh
  44659. * @param emissiveTexture the associated emissive texture used to generate the glow
  44660. * @return true if ready otherwise, false
  44661. */
  44662. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44663. /**
  44664. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44665. */
  44666. needStencil(): boolean;
  44667. /**
  44668. * Returns true if the mesh can be rendered, otherwise false.
  44669. * @param mesh The mesh to render
  44670. * @param material The material used on the mesh
  44671. * @returns true if it can be rendered otherwise false
  44672. */
  44673. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44674. /**
  44675. * Implementation specific of rendering the generating effect on the main canvas.
  44676. * @param effect The effect used to render through
  44677. */
  44678. protected _internalRender(effect: Effect): void;
  44679. /**
  44680. * Sets the required values for both the emissive texture and and the main color.
  44681. */
  44682. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44683. /**
  44684. * Returns true if the mesh should render, otherwise false.
  44685. * @param mesh The mesh to render
  44686. * @returns true if it should render otherwise false
  44687. */
  44688. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44689. /**
  44690. * Adds specific effects defines.
  44691. * @param defines The defines to add specifics to.
  44692. */
  44693. protected _addCustomEffectDefines(defines: string[]): void;
  44694. /**
  44695. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44696. * @param mesh The mesh to exclude from the glow layer
  44697. */
  44698. addExcludedMesh(mesh: Mesh): void;
  44699. /**
  44700. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44701. * @param mesh The mesh to remove
  44702. */
  44703. removeExcludedMesh(mesh: Mesh): void;
  44704. /**
  44705. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44706. * @param mesh The mesh to include in the glow layer
  44707. */
  44708. addIncludedOnlyMesh(mesh: Mesh): void;
  44709. /**
  44710. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44711. * @param mesh The mesh to remove
  44712. */
  44713. removeIncludedOnlyMesh(mesh: Mesh): void;
  44714. /**
  44715. * Determine if a given mesh will be used in the glow layer
  44716. * @param mesh The mesh to test
  44717. * @returns true if the mesh will be highlighted by the current glow layer
  44718. */
  44719. hasMesh(mesh: AbstractMesh): boolean;
  44720. /**
  44721. * Free any resources and references associated to a mesh.
  44722. * Internal use
  44723. * @param mesh The mesh to free.
  44724. * @hidden
  44725. */
  44726. _disposeMesh(mesh: Mesh): void;
  44727. /**
  44728. * Gets the class name of the effect layer
  44729. * @returns the string with the class name of the effect layer
  44730. */
  44731. getClassName(): string;
  44732. /**
  44733. * Serializes this glow layer
  44734. * @returns a serialized glow layer object
  44735. */
  44736. serialize(): any;
  44737. /**
  44738. * Creates a Glow Layer from parsed glow layer data
  44739. * @param parsedGlowLayer defines glow layer data
  44740. * @param scene defines the current scene
  44741. * @param rootUrl defines the root URL containing the glow layer information
  44742. * @returns a parsed Glow Layer
  44743. */
  44744. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44745. }
  44746. }
  44747. declare module BABYLON {
  44748. /** @hidden */
  44749. export var glowBlurPostProcessPixelShader: {
  44750. name: string;
  44751. shader: string;
  44752. };
  44753. }
  44754. declare module BABYLON {
  44755. interface AbstractScene {
  44756. /**
  44757. * Return a the first highlight layer of the scene with a given name.
  44758. * @param name The name of the highlight layer to look for.
  44759. * @return The highlight layer if found otherwise null.
  44760. */
  44761. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44762. }
  44763. /**
  44764. * Highlight layer options. This helps customizing the behaviour
  44765. * of the highlight layer.
  44766. */
  44767. export interface IHighlightLayerOptions {
  44768. /**
  44769. * Multiplication factor apply to the canvas size to compute the render target size
  44770. * used to generated the glowing objects (the smaller the faster).
  44771. */
  44772. mainTextureRatio: number;
  44773. /**
  44774. * Enforces a fixed size texture to ensure resize independant blur.
  44775. */
  44776. mainTextureFixedSize?: number;
  44777. /**
  44778. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44779. * of the picture to blur (the smaller the faster).
  44780. */
  44781. blurTextureSizeRatio: number;
  44782. /**
  44783. * How big in texel of the blur texture is the vertical blur.
  44784. */
  44785. blurVerticalSize: number;
  44786. /**
  44787. * How big in texel of the blur texture is the horizontal blur.
  44788. */
  44789. blurHorizontalSize: number;
  44790. /**
  44791. * Alpha blending mode used to apply the blur. Default is combine.
  44792. */
  44793. alphaBlendingMode: number;
  44794. /**
  44795. * The camera attached to the layer.
  44796. */
  44797. camera: Nullable<Camera>;
  44798. /**
  44799. * Should we display highlight as a solid stroke?
  44800. */
  44801. isStroke?: boolean;
  44802. /**
  44803. * The rendering group to draw the layer in.
  44804. */
  44805. renderingGroupId: number;
  44806. }
  44807. /**
  44808. * The highlight layer Helps adding a glow effect around a mesh.
  44809. *
  44810. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44811. * glowy meshes to your scene.
  44812. *
  44813. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44814. */
  44815. export class HighlightLayer extends EffectLayer {
  44816. name: string;
  44817. /**
  44818. * Effect Name of the highlight layer.
  44819. */
  44820. static readonly EffectName: string;
  44821. /**
  44822. * The neutral color used during the preparation of the glow effect.
  44823. * This is black by default as the blend operation is a blend operation.
  44824. */
  44825. static NeutralColor: Color4;
  44826. /**
  44827. * Stencil value used for glowing meshes.
  44828. */
  44829. static GlowingMeshStencilReference: number;
  44830. /**
  44831. * Stencil value used for the other meshes in the scene.
  44832. */
  44833. static NormalMeshStencilReference: number;
  44834. /**
  44835. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44836. */
  44837. innerGlow: boolean;
  44838. /**
  44839. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44840. */
  44841. outerGlow: boolean;
  44842. /**
  44843. * Specifies the horizontal size of the blur.
  44844. */
  44845. /**
  44846. * Gets the horizontal size of the blur.
  44847. */
  44848. blurHorizontalSize: number;
  44849. /**
  44850. * Specifies the vertical size of the blur.
  44851. */
  44852. /**
  44853. * Gets the vertical size of the blur.
  44854. */
  44855. blurVerticalSize: number;
  44856. /**
  44857. * An event triggered when the highlight layer is being blurred.
  44858. */
  44859. onBeforeBlurObservable: Observable<HighlightLayer>;
  44860. /**
  44861. * An event triggered when the highlight layer has been blurred.
  44862. */
  44863. onAfterBlurObservable: Observable<HighlightLayer>;
  44864. private _instanceGlowingMeshStencilReference;
  44865. private _options;
  44866. private _downSamplePostprocess;
  44867. private _horizontalBlurPostprocess;
  44868. private _verticalBlurPostprocess;
  44869. private _blurTexture;
  44870. private _meshes;
  44871. private _excludedMeshes;
  44872. /**
  44873. * Instantiates a new highlight Layer and references it to the scene..
  44874. * @param name The name of the layer
  44875. * @param scene The scene to use the layer in
  44876. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44877. */
  44878. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44879. /**
  44880. * Get the effect name of the layer.
  44881. * @return The effect name
  44882. */
  44883. getEffectName(): string;
  44884. /**
  44885. * Create the merge effect. This is the shader use to blit the information back
  44886. * to the main canvas at the end of the scene rendering.
  44887. */
  44888. protected _createMergeEffect(): Effect;
  44889. /**
  44890. * Creates the render target textures and post processes used in the highlight layer.
  44891. */
  44892. protected _createTextureAndPostProcesses(): void;
  44893. /**
  44894. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44895. */
  44896. needStencil(): boolean;
  44897. /**
  44898. * Checks for the readiness of the element composing the layer.
  44899. * @param subMesh the mesh to check for
  44900. * @param useInstances specify wether or not to use instances to render the mesh
  44901. * @param emissiveTexture the associated emissive texture used to generate the glow
  44902. * @return true if ready otherwise, false
  44903. */
  44904. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44905. /**
  44906. * Implementation specific of rendering the generating effect on the main canvas.
  44907. * @param effect The effect used to render through
  44908. */
  44909. protected _internalRender(effect: Effect): void;
  44910. /**
  44911. * Returns true if the layer contains information to display, otherwise false.
  44912. */
  44913. shouldRender(): boolean;
  44914. /**
  44915. * Returns true if the mesh should render, otherwise false.
  44916. * @param mesh The mesh to render
  44917. * @returns true if it should render otherwise false
  44918. */
  44919. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44920. /**
  44921. * Sets the required values for both the emissive texture and and the main color.
  44922. */
  44923. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44924. /**
  44925. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44926. * @param mesh The mesh to exclude from the highlight layer
  44927. */
  44928. addExcludedMesh(mesh: Mesh): void;
  44929. /**
  44930. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44931. * @param mesh The mesh to highlight
  44932. */
  44933. removeExcludedMesh(mesh: Mesh): void;
  44934. /**
  44935. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44936. * @param mesh mesh to test
  44937. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44938. */
  44939. hasMesh(mesh: AbstractMesh): boolean;
  44940. /**
  44941. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44942. * @param mesh The mesh to highlight
  44943. * @param color The color of the highlight
  44944. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44945. */
  44946. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  44947. /**
  44948. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44949. * @param mesh The mesh to highlight
  44950. */
  44951. removeMesh(mesh: Mesh): void;
  44952. /**
  44953. * Force the stencil to the normal expected value for none glowing parts
  44954. */
  44955. private _defaultStencilReference;
  44956. /**
  44957. * Free any resources and references associated to a mesh.
  44958. * Internal use
  44959. * @param mesh The mesh to free.
  44960. * @hidden
  44961. */
  44962. _disposeMesh(mesh: Mesh): void;
  44963. /**
  44964. * Dispose the highlight layer and free resources.
  44965. */
  44966. dispose(): void;
  44967. /**
  44968. * Gets the class name of the effect layer
  44969. * @returns the string with the class name of the effect layer
  44970. */
  44971. getClassName(): string;
  44972. /**
  44973. * Serializes this Highlight layer
  44974. * @returns a serialized Highlight layer object
  44975. */
  44976. serialize(): any;
  44977. /**
  44978. * Creates a Highlight layer from parsed Highlight layer data
  44979. * @param parsedHightlightLayer defines the Highlight layer data
  44980. * @param scene defines the current scene
  44981. * @param rootUrl defines the root URL containing the Highlight layer information
  44982. * @returns a parsed Highlight layer
  44983. */
  44984. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  44985. }
  44986. }
  44987. declare module BABYLON {
  44988. /** @hidden */
  44989. export var lensFlarePixelShader: {
  44990. name: string;
  44991. shader: string;
  44992. };
  44993. }
  44994. declare module BABYLON {
  44995. /** @hidden */
  44996. export var lensFlareVertexShader: {
  44997. name: string;
  44998. shader: string;
  44999. };
  45000. }
  45001. declare module BABYLON {
  45002. /**
  45003. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  45004. * It is usually composed of several `lensFlare`.
  45005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45006. */
  45007. export class LensFlareSystem {
  45008. /**
  45009. * Define the name of the lens flare system
  45010. */
  45011. name: string;
  45012. /**
  45013. * List of lens flares used in this system.
  45014. */
  45015. lensFlares: LensFlare[];
  45016. /**
  45017. * Define a limit from the border the lens flare can be visible.
  45018. */
  45019. borderLimit: number;
  45020. /**
  45021. * Define a viewport border we do not want to see the lens flare in.
  45022. */
  45023. viewportBorder: number;
  45024. /**
  45025. * Define a predicate which could limit the list of meshes able to occlude the effect.
  45026. */
  45027. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45028. /**
  45029. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  45030. */
  45031. layerMask: number;
  45032. /**
  45033. * Define the id of the lens flare system in the scene.
  45034. * (equal to name by default)
  45035. */
  45036. id: string;
  45037. private _scene;
  45038. private _emitter;
  45039. private _vertexBuffers;
  45040. private _indexBuffer;
  45041. private _effect;
  45042. private _positionX;
  45043. private _positionY;
  45044. private _isEnabled;
  45045. /** @hidden */
  45046. static _SceneComponentInitialization: (scene: Scene) => void;
  45047. /**
  45048. * Instantiates a lens flare system.
  45049. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  45050. * It is usually composed of several `lensFlare`.
  45051. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45052. * @param name Define the name of the lens flare system in the scene
  45053. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  45054. * @param scene Define the scene the lens flare system belongs to
  45055. */
  45056. constructor(
  45057. /**
  45058. * Define the name of the lens flare system
  45059. */
  45060. name: string, emitter: any, scene: Scene);
  45061. /**
  45062. * Define if the lens flare system is enabled.
  45063. */
  45064. isEnabled: boolean;
  45065. /**
  45066. * Get the scene the effects belongs to.
  45067. * @returns the scene holding the lens flare system
  45068. */
  45069. getScene(): Scene;
  45070. /**
  45071. * Get the emitter of the lens flare system.
  45072. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45073. * @returns the emitter of the lens flare system
  45074. */
  45075. getEmitter(): any;
  45076. /**
  45077. * Set the emitter of the lens flare system.
  45078. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45079. * @param newEmitter Define the new emitter of the system
  45080. */
  45081. setEmitter(newEmitter: any): void;
  45082. /**
  45083. * Get the lens flare system emitter position.
  45084. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45085. * @returns the position
  45086. */
  45087. getEmitterPosition(): Vector3;
  45088. /**
  45089. * @hidden
  45090. */
  45091. computeEffectivePosition(globalViewport: Viewport): boolean;
  45092. /** @hidden */
  45093. _isVisible(): boolean;
  45094. /**
  45095. * @hidden
  45096. */
  45097. render(): boolean;
  45098. /**
  45099. * Dispose and release the lens flare with its associated resources.
  45100. */
  45101. dispose(): void;
  45102. /**
  45103. * Parse a lens flare system from a JSON repressentation
  45104. * @param parsedLensFlareSystem Define the JSON to parse
  45105. * @param scene Define the scene the parsed system should be instantiated in
  45106. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45107. * @returns the parsed system
  45108. */
  45109. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  45110. /**
  45111. * Serialize the current Lens Flare System into a JSON representation.
  45112. * @returns the serialized JSON
  45113. */
  45114. serialize(): any;
  45115. }
  45116. }
  45117. declare module BABYLON {
  45118. /**
  45119. * This represents one of the lens effect in a `lensFlareSystem`.
  45120. * It controls one of the indiviual texture used in the effect.
  45121. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45122. */
  45123. export class LensFlare {
  45124. /**
  45125. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45126. */
  45127. size: number;
  45128. /**
  45129. * 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.
  45130. */
  45131. position: number;
  45132. /**
  45133. * Define the lens color.
  45134. */
  45135. color: Color3;
  45136. /**
  45137. * Define the lens texture.
  45138. */
  45139. texture: Nullable<Texture>;
  45140. /**
  45141. * Define the alpha mode to render this particular lens.
  45142. */
  45143. alphaMode: number;
  45144. private _system;
  45145. /**
  45146. * Creates a new Lens Flare.
  45147. * This represents one of the lens effect in a `lensFlareSystem`.
  45148. * It controls one of the indiviual texture used in the effect.
  45149. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45150. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  45151. * @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.
  45152. * @param color Define the lens color
  45153. * @param imgUrl Define the lens texture url
  45154. * @param system Define the `lensFlareSystem` this flare is part of
  45155. * @returns The newly created Lens Flare
  45156. */
  45157. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  45158. /**
  45159. * Instantiates a new Lens Flare.
  45160. * This represents one of the lens effect in a `lensFlareSystem`.
  45161. * It controls one of the indiviual texture used in the effect.
  45162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45163. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  45164. * @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.
  45165. * @param color Define the lens color
  45166. * @param imgUrl Define the lens texture url
  45167. * @param system Define the `lensFlareSystem` this flare is part of
  45168. */
  45169. constructor(
  45170. /**
  45171. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45172. */
  45173. size: number,
  45174. /**
  45175. * 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.
  45176. */
  45177. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  45178. /**
  45179. * Dispose and release the lens flare with its associated resources.
  45180. */
  45181. dispose(): void;
  45182. }
  45183. }
  45184. declare module BABYLON {
  45185. interface AbstractScene {
  45186. /**
  45187. * The list of lens flare system added to the scene
  45188. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45189. */
  45190. lensFlareSystems: Array<LensFlareSystem>;
  45191. /**
  45192. * Removes the given lens flare system from this scene.
  45193. * @param toRemove The lens flare system to remove
  45194. * @returns The index of the removed lens flare system
  45195. */
  45196. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  45197. /**
  45198. * Adds the given lens flare system to this scene
  45199. * @param newLensFlareSystem The lens flare system to add
  45200. */
  45201. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  45202. /**
  45203. * Gets a lens flare system using its name
  45204. * @param name defines the name to look for
  45205. * @returns the lens flare system or null if not found
  45206. */
  45207. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  45208. /**
  45209. * Gets a lens flare system using its id
  45210. * @param id defines the id to look for
  45211. * @returns the lens flare system or null if not found
  45212. */
  45213. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  45214. }
  45215. /**
  45216. * Defines the lens flare scene component responsible to manage any lens flares
  45217. * in a given scene.
  45218. */
  45219. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  45220. /**
  45221. * The component name helpfull to identify the component in the list of scene components.
  45222. */
  45223. readonly name: string;
  45224. /**
  45225. * The scene the component belongs to.
  45226. */
  45227. scene: Scene;
  45228. /**
  45229. * Creates a new instance of the component for the given scene
  45230. * @param scene Defines the scene to register the component in
  45231. */
  45232. constructor(scene: Scene);
  45233. /**
  45234. * Registers the component in a given scene
  45235. */
  45236. register(): void;
  45237. /**
  45238. * Rebuilds the elements related to this component in case of
  45239. * context lost for instance.
  45240. */
  45241. rebuild(): void;
  45242. /**
  45243. * Adds all the element from the container to the scene
  45244. * @param container the container holding the elements
  45245. */
  45246. addFromContainer(container: AbstractScene): void;
  45247. /**
  45248. * Removes all the elements in the container from the scene
  45249. * @param container contains the elements to remove
  45250. */
  45251. removeFromContainer(container: AbstractScene): void;
  45252. /**
  45253. * Serializes the component data to the specified json object
  45254. * @param serializationObject The object to serialize to
  45255. */
  45256. serialize(serializationObject: any): void;
  45257. /**
  45258. * Disposes the component and the associated ressources.
  45259. */
  45260. dispose(): void;
  45261. private _draw;
  45262. }
  45263. }
  45264. declare module BABYLON {
  45265. /**
  45266. * Defines the shadow generator component responsible to manage any shadow generators
  45267. * in a given scene.
  45268. */
  45269. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  45270. /**
  45271. * The component name helpfull to identify the component in the list of scene components.
  45272. */
  45273. readonly name: string;
  45274. /**
  45275. * The scene the component belongs to.
  45276. */
  45277. scene: Scene;
  45278. /**
  45279. * Creates a new instance of the component for the given scene
  45280. * @param scene Defines the scene to register the component in
  45281. */
  45282. constructor(scene: Scene);
  45283. /**
  45284. * Registers the component in a given scene
  45285. */
  45286. register(): void;
  45287. /**
  45288. * Rebuilds the elements related to this component in case of
  45289. * context lost for instance.
  45290. */
  45291. rebuild(): void;
  45292. /**
  45293. * Serializes the component data to the specified json object
  45294. * @param serializationObject The object to serialize to
  45295. */
  45296. serialize(serializationObject: any): void;
  45297. /**
  45298. * Adds all the element from the container to the scene
  45299. * @param container the container holding the elements
  45300. */
  45301. addFromContainer(container: AbstractScene): void;
  45302. /**
  45303. * Removes all the elements in the container from the scene
  45304. * @param container contains the elements to remove
  45305. */
  45306. removeFromContainer(container: AbstractScene): void;
  45307. /**
  45308. * Rebuilds the elements related to this component in case of
  45309. * context lost for instance.
  45310. */
  45311. dispose(): void;
  45312. private _gatherRenderTargets;
  45313. }
  45314. }
  45315. declare module BABYLON {
  45316. /**
  45317. * A directional light is defined by a direction (what a surprise!).
  45318. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45319. * 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.
  45320. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45321. */
  45322. export class DirectionalLight extends ShadowLight {
  45323. private _shadowFrustumSize;
  45324. /**
  45325. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45326. */
  45327. /**
  45328. * Specifies a fix frustum size for the shadow generation.
  45329. */
  45330. shadowFrustumSize: number;
  45331. private _shadowOrthoScale;
  45332. /**
  45333. * Gets the shadow projection scale against the optimal computed one.
  45334. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45335. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45336. */
  45337. /**
  45338. * Sets the shadow projection scale against the optimal computed one.
  45339. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45340. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45341. */
  45342. shadowOrthoScale: number;
  45343. /**
  45344. * Automatically compute the projection matrix to best fit (including all the casters)
  45345. * on each frame.
  45346. */
  45347. autoUpdateExtends: boolean;
  45348. private _orthoLeft;
  45349. private _orthoRight;
  45350. private _orthoTop;
  45351. private _orthoBottom;
  45352. /**
  45353. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45354. * The directional light is emitted from everywhere in the given direction.
  45355. * It can cast shadows.
  45356. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45357. * @param name The friendly name of the light
  45358. * @param direction The direction of the light
  45359. * @param scene The scene the light belongs to
  45360. */
  45361. constructor(name: string, direction: Vector3, scene: Scene);
  45362. /**
  45363. * Returns the string "DirectionalLight".
  45364. * @return The class name
  45365. */
  45366. getClassName(): string;
  45367. /**
  45368. * Returns the integer 1.
  45369. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45370. */
  45371. getTypeID(): number;
  45372. /**
  45373. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45374. * Returns the DirectionalLight Shadow projection matrix.
  45375. */
  45376. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45377. /**
  45378. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45379. * Returns the DirectionalLight Shadow projection matrix.
  45380. */
  45381. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45382. /**
  45383. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45384. * Returns the DirectionalLight Shadow projection matrix.
  45385. */
  45386. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45387. protected _buildUniformLayout(): void;
  45388. /**
  45389. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45390. * @param effect The effect to update
  45391. * @param lightIndex The index of the light in the effect to update
  45392. * @returns The directional light
  45393. */
  45394. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45395. /**
  45396. * Gets the minZ used for shadow according to both the scene and the light.
  45397. *
  45398. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45399. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45400. * @param activeCamera The camera we are returning the min for
  45401. * @returns the depth min z
  45402. */
  45403. getDepthMinZ(activeCamera: Camera): number;
  45404. /**
  45405. * Gets the maxZ used for shadow according to both the scene and the light.
  45406. *
  45407. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45408. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45409. * @param activeCamera The camera we are returning the max for
  45410. * @returns the depth max z
  45411. */
  45412. getDepthMaxZ(activeCamera: Camera): number;
  45413. /**
  45414. * Prepares the list of defines specific to the light type.
  45415. * @param defines the list of defines
  45416. * @param lightIndex defines the index of the light for the effect
  45417. */
  45418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45419. }
  45420. }
  45421. declare module BABYLON {
  45422. /**
  45423. * A point light is a light defined by an unique point in world space.
  45424. * The light is emitted in every direction from this point.
  45425. * A good example of a point light is a standard light bulb.
  45426. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45427. */
  45428. export class PointLight extends ShadowLight {
  45429. private _shadowAngle;
  45430. /**
  45431. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45432. * This specifies what angle the shadow will use to be created.
  45433. *
  45434. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45435. */
  45436. /**
  45437. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45438. * This specifies what angle the shadow will use to be created.
  45439. *
  45440. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45441. */
  45442. shadowAngle: number;
  45443. /**
  45444. * Gets the direction if it has been set.
  45445. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45446. */
  45447. /**
  45448. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45449. */
  45450. direction: Vector3;
  45451. /**
  45452. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  45453. * A PointLight emits the light in every direction.
  45454. * It can cast shadows.
  45455. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  45456. * ```javascript
  45457. * var pointLight = new PointLight("pl", camera.position, scene);
  45458. * ```
  45459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45460. * @param name The light friendly name
  45461. * @param position The position of the point light in the scene
  45462. * @param scene The scene the lights belongs to
  45463. */
  45464. constructor(name: string, position: Vector3, scene: Scene);
  45465. /**
  45466. * Returns the string "PointLight"
  45467. * @returns the class name
  45468. */
  45469. getClassName(): string;
  45470. /**
  45471. * Returns the integer 0.
  45472. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45473. */
  45474. getTypeID(): number;
  45475. /**
  45476. * Specifies wether or not the shadowmap should be a cube texture.
  45477. * @returns true if the shadowmap needs to be a cube texture.
  45478. */
  45479. needCube(): boolean;
  45480. /**
  45481. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  45482. * @param faceIndex The index of the face we are computed the direction to generate shadow
  45483. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  45484. */
  45485. getShadowDirection(faceIndex?: number): Vector3;
  45486. /**
  45487. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  45488. * - fov = PI / 2
  45489. * - aspect ratio : 1.0
  45490. * - z-near and far equal to the active camera minZ and maxZ.
  45491. * Returns the PointLight.
  45492. */
  45493. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45494. protected _buildUniformLayout(): void;
  45495. /**
  45496. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  45497. * @param effect The effect to update
  45498. * @param lightIndex The index of the light in the effect to update
  45499. * @returns The point light
  45500. */
  45501. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  45502. /**
  45503. * Prepares the list of defines specific to the light type.
  45504. * @param defines the list of defines
  45505. * @param lightIndex defines the index of the light for the effect
  45506. */
  45507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45508. }
  45509. }
  45510. declare module BABYLON {
  45511. /**
  45512. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45513. * These values define a cone of light starting from the position, emitting toward the direction.
  45514. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45515. * and the exponent defines the speed of the decay of the light with distance (reach).
  45516. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45517. */
  45518. export class SpotLight extends ShadowLight {
  45519. private _angle;
  45520. private _innerAngle;
  45521. private _cosHalfAngle;
  45522. private _lightAngleScale;
  45523. private _lightAngleOffset;
  45524. /**
  45525. * Gets the cone angle of the spot light in Radians.
  45526. */
  45527. /**
  45528. * Sets the cone angle of the spot light in Radians.
  45529. */
  45530. angle: number;
  45531. /**
  45532. * Only used in gltf falloff mode, this defines the angle where
  45533. * the directional falloff will start before cutting at angle which could be seen
  45534. * as outer angle.
  45535. */
  45536. /**
  45537. * Only used in gltf falloff mode, this defines the angle where
  45538. * the directional falloff will start before cutting at angle which could be seen
  45539. * as outer angle.
  45540. */
  45541. innerAngle: number;
  45542. private _shadowAngleScale;
  45543. /**
  45544. * Allows scaling the angle of the light for shadow generation only.
  45545. */
  45546. /**
  45547. * Allows scaling the angle of the light for shadow generation only.
  45548. */
  45549. shadowAngleScale: number;
  45550. /**
  45551. * The light decay speed with the distance from the emission spot.
  45552. */
  45553. exponent: number;
  45554. private _projectionTextureMatrix;
  45555. /**
  45556. * Allows reading the projecton texture
  45557. */
  45558. readonly projectionTextureMatrix: Matrix;
  45559. protected _projectionTextureLightNear: number;
  45560. /**
  45561. * Gets the near clip of the Spotlight for texture projection.
  45562. */
  45563. /**
  45564. * Sets the near clip of the Spotlight for texture projection.
  45565. */
  45566. projectionTextureLightNear: number;
  45567. protected _projectionTextureLightFar: number;
  45568. /**
  45569. * Gets the far clip of the Spotlight for texture projection.
  45570. */
  45571. /**
  45572. * Sets the far clip of the Spotlight for texture projection.
  45573. */
  45574. projectionTextureLightFar: number;
  45575. protected _projectionTextureUpDirection: Vector3;
  45576. /**
  45577. * Gets the Up vector of the Spotlight for texture projection.
  45578. */
  45579. /**
  45580. * Sets the Up vector of the Spotlight for texture projection.
  45581. */
  45582. projectionTextureUpDirection: Vector3;
  45583. private _projectionTexture;
  45584. /**
  45585. * Gets the projection texture of the light.
  45586. */
  45587. /**
  45588. * Sets the projection texture of the light.
  45589. */
  45590. projectionTexture: Nullable<BaseTexture>;
  45591. private _projectionTextureViewLightDirty;
  45592. private _projectionTextureProjectionLightDirty;
  45593. private _projectionTextureDirty;
  45594. private _projectionTextureViewTargetVector;
  45595. private _projectionTextureViewLightMatrix;
  45596. private _projectionTextureProjectionLightMatrix;
  45597. private _projectionTextureScalingMatrix;
  45598. /**
  45599. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45600. * It can cast shadows.
  45601. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45602. * @param name The light friendly name
  45603. * @param position The position of the spot light in the scene
  45604. * @param direction The direction of the light in the scene
  45605. * @param angle The cone angle of the light in Radians
  45606. * @param exponent The light decay speed with the distance from the emission spot
  45607. * @param scene The scene the lights belongs to
  45608. */
  45609. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45610. /**
  45611. * Returns the string "SpotLight".
  45612. * @returns the class name
  45613. */
  45614. getClassName(): string;
  45615. /**
  45616. * Returns the integer 2.
  45617. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45618. */
  45619. getTypeID(): number;
  45620. /**
  45621. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45622. */
  45623. protected _setDirection(value: Vector3): void;
  45624. /**
  45625. * Overrides the position setter to recompute the projection texture view light Matrix.
  45626. */
  45627. protected _setPosition(value: Vector3): void;
  45628. /**
  45629. * 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.
  45630. * Returns the SpotLight.
  45631. */
  45632. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45633. protected _computeProjectionTextureViewLightMatrix(): void;
  45634. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45635. /**
  45636. * Main function for light texture projection matrix computing.
  45637. */
  45638. protected _computeProjectionTextureMatrix(): void;
  45639. protected _buildUniformLayout(): void;
  45640. private _computeAngleValues;
  45641. /**
  45642. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45643. * @param effect The effect to update
  45644. * @param lightIndex The index of the light in the effect to update
  45645. * @returns The spot light
  45646. */
  45647. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45648. /**
  45649. * Disposes the light and the associated resources.
  45650. */
  45651. dispose(): void;
  45652. /**
  45653. * Prepares the list of defines specific to the light type.
  45654. * @param defines the list of defines
  45655. * @param lightIndex defines the index of the light for the effect
  45656. */
  45657. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45658. }
  45659. }
  45660. declare module BABYLON {
  45661. /**
  45662. * Header information of HDR texture files.
  45663. */
  45664. export interface HDRInfo {
  45665. /**
  45666. * The height of the texture in pixels.
  45667. */
  45668. height: number;
  45669. /**
  45670. * The width of the texture in pixels.
  45671. */
  45672. width: number;
  45673. /**
  45674. * The index of the beginning of the data in the binary file.
  45675. */
  45676. dataPosition: number;
  45677. }
  45678. /**
  45679. * This groups tools to convert HDR texture to native colors array.
  45680. */
  45681. export class HDRTools {
  45682. private static Ldexp;
  45683. private static Rgbe2float;
  45684. private static readStringLine;
  45685. /**
  45686. * Reads header information from an RGBE texture stored in a native array.
  45687. * More information on this format are available here:
  45688. * https://en.wikipedia.org/wiki/RGBE_image_format
  45689. *
  45690. * @param uint8array The binary file stored in native array.
  45691. * @return The header information.
  45692. */
  45693. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  45694. /**
  45695. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  45696. * This RGBE texture needs to store the information as a panorama.
  45697. *
  45698. * More information on this format are available here:
  45699. * https://en.wikipedia.org/wiki/RGBE_image_format
  45700. *
  45701. * @param buffer The binary file stored in an array buffer.
  45702. * @param size The expected size of the extracted cubemap.
  45703. * @return The Cube Map information.
  45704. */
  45705. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  45706. /**
  45707. * Returns the pixels data extracted from an RGBE texture.
  45708. * This pixels will be stored left to right up to down in the R G B order in one array.
  45709. *
  45710. * More information on this format are available here:
  45711. * https://en.wikipedia.org/wiki/RGBE_image_format
  45712. *
  45713. * @param uint8array The binary file stored in an array buffer.
  45714. * @param hdrInfo The header information of the file.
  45715. * @return The pixels data in RGB right to left up to down order.
  45716. */
  45717. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  45718. private static RGBE_ReadPixels_RLE;
  45719. }
  45720. }
  45721. declare module BABYLON {
  45722. /**
  45723. * This represents a texture coming from an HDR input.
  45724. *
  45725. * The only supported format is currently panorama picture stored in RGBE format.
  45726. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45727. */
  45728. export class HDRCubeTexture extends BaseTexture {
  45729. private static _facesMapping;
  45730. private _generateHarmonics;
  45731. private _noMipmap;
  45732. private _textureMatrix;
  45733. private _size;
  45734. private _onLoad;
  45735. private _onError;
  45736. /**
  45737. * The texture URL.
  45738. */
  45739. url: string;
  45740. /**
  45741. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45742. */
  45743. coordinatesMode: number;
  45744. protected _isBlocking: boolean;
  45745. /**
  45746. * Sets wether or not the texture is blocking during loading.
  45747. */
  45748. /**
  45749. * Gets wether or not the texture is blocking during loading.
  45750. */
  45751. isBlocking: boolean;
  45752. protected _rotationY: number;
  45753. /**
  45754. * Sets texture matrix rotation angle around Y axis in radians.
  45755. */
  45756. /**
  45757. * Gets texture matrix rotation angle around Y axis radians.
  45758. */
  45759. rotationY: number;
  45760. /**
  45761. * Gets or sets the center of the bounding box associated with the cube texture
  45762. * It must define where the camera used to render the texture was set
  45763. */
  45764. boundingBoxPosition: Vector3;
  45765. private _boundingBoxSize;
  45766. /**
  45767. * Gets or sets the size of the bounding box associated with the cube texture
  45768. * When defined, the cubemap will switch to local mode
  45769. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45770. * @example https://www.babylonjs-playground.com/#RNASML
  45771. */
  45772. boundingBoxSize: Vector3;
  45773. /**
  45774. * Instantiates an HDRTexture from the following parameters.
  45775. *
  45776. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45777. * @param scene The scene the texture will be used in
  45778. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45779. * @param noMipmap Forces to not generate the mipmap if true
  45780. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45781. * @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)
  45782. * @param reserved Reserved flag for internal use.
  45783. */
  45784. 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>);
  45785. /**
  45786. * Get the current class name of the texture useful for serialization or dynamic coding.
  45787. * @returns "HDRCubeTexture"
  45788. */
  45789. getClassName(): string;
  45790. /**
  45791. * Occurs when the file is raw .hdr file.
  45792. */
  45793. private loadTexture;
  45794. clone(): HDRCubeTexture;
  45795. delayLoad(): void;
  45796. /**
  45797. * Get the texture reflection matrix used to rotate/transform the reflection.
  45798. * @returns the reflection matrix
  45799. */
  45800. getReflectionTextureMatrix(): Matrix;
  45801. /**
  45802. * Set the texture reflection matrix used to rotate/transform the reflection.
  45803. * @param value Define the reflection matrix to set
  45804. */
  45805. setReflectionTextureMatrix(value: Matrix): void;
  45806. /**
  45807. * Parses a JSON representation of an HDR Texture in order to create the texture
  45808. * @param parsedTexture Define the JSON representation
  45809. * @param scene Define the scene the texture should be created in
  45810. * @param rootUrl Define the root url in case we need to load relative dependencies
  45811. * @returns the newly created texture after parsing
  45812. */
  45813. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45814. serialize(): any;
  45815. }
  45816. }
  45817. declare module BABYLON {
  45818. /**
  45819. * Class used to control physics engine
  45820. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45821. */
  45822. export class PhysicsEngine implements IPhysicsEngine {
  45823. private _physicsPlugin;
  45824. /**
  45825. * Global value used to control the smallest number supported by the simulation
  45826. */
  45827. static Epsilon: number;
  45828. private _impostors;
  45829. private _joints;
  45830. /**
  45831. * Gets the gravity vector used by the simulation
  45832. */
  45833. gravity: Vector3;
  45834. /**
  45835. * Factory used to create the default physics plugin.
  45836. * @returns The default physics plugin
  45837. */
  45838. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45839. /**
  45840. * Creates a new Physics Engine
  45841. * @param gravity defines the gravity vector used by the simulation
  45842. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45843. */
  45844. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45845. /**
  45846. * Sets the gravity vector used by the simulation
  45847. * @param gravity defines the gravity vector to use
  45848. */
  45849. setGravity(gravity: Vector3): void;
  45850. /**
  45851. * Set the time step of the physics engine.
  45852. * Default is 1/60.
  45853. * To slow it down, enter 1/600 for example.
  45854. * To speed it up, 1/30
  45855. * @param newTimeStep defines the new timestep to apply to this world.
  45856. */
  45857. setTimeStep(newTimeStep?: number): void;
  45858. /**
  45859. * Get the time step of the physics engine.
  45860. * @returns the current time step
  45861. */
  45862. getTimeStep(): number;
  45863. /**
  45864. * Release all resources
  45865. */
  45866. dispose(): void;
  45867. /**
  45868. * Gets the name of the current physics plugin
  45869. * @returns the name of the plugin
  45870. */
  45871. getPhysicsPluginName(): string;
  45872. /**
  45873. * Adding a new impostor for the impostor tracking.
  45874. * This will be done by the impostor itself.
  45875. * @param impostor the impostor to add
  45876. */
  45877. addImpostor(impostor: PhysicsImpostor): void;
  45878. /**
  45879. * Remove an impostor from the engine.
  45880. * This impostor and its mesh will not longer be updated by the physics engine.
  45881. * @param impostor the impostor to remove
  45882. */
  45883. removeImpostor(impostor: PhysicsImpostor): void;
  45884. /**
  45885. * Add a joint to the physics engine
  45886. * @param mainImpostor defines the main impostor to which the joint is added.
  45887. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45888. * @param joint defines the joint that will connect both impostors.
  45889. */
  45890. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45891. /**
  45892. * Removes a joint from the simulation
  45893. * @param mainImpostor defines the impostor used with the joint
  45894. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45895. * @param joint defines the joint to remove
  45896. */
  45897. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45898. /**
  45899. * Called by the scene. No need to call it.
  45900. * @param delta defines the timespam between frames
  45901. */
  45902. _step(delta: number): void;
  45903. /**
  45904. * Gets the current plugin used to run the simulation
  45905. * @returns current plugin
  45906. */
  45907. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45908. /**
  45909. * Gets the list of physic impostors
  45910. * @returns an array of PhysicsImpostor
  45911. */
  45912. getImpostors(): Array<PhysicsImpostor>;
  45913. /**
  45914. * Gets the impostor for a physics enabled object
  45915. * @param object defines the object impersonated by the impostor
  45916. * @returns the PhysicsImpostor or null if not found
  45917. */
  45918. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45919. /**
  45920. * Gets the impostor for a physics body object
  45921. * @param body defines physics body used by the impostor
  45922. * @returns the PhysicsImpostor or null if not found
  45923. */
  45924. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45925. }
  45926. }
  45927. declare module BABYLON {
  45928. /** @hidden */
  45929. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45930. private _useDeltaForWorldStep;
  45931. world: any;
  45932. name: string;
  45933. private _physicsMaterials;
  45934. private _fixedTimeStep;
  45935. BJSCANNON: any;
  45936. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45937. setGravity(gravity: Vector3): void;
  45938. setTimeStep(timeStep: number): void;
  45939. getTimeStep(): number;
  45940. executeStep(delta: number): void;
  45941. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45942. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45943. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45944. private _processChildMeshes;
  45945. removePhysicsBody(impostor: PhysicsImpostor): void;
  45946. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45947. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45948. private _addMaterial;
  45949. private _checkWithEpsilon;
  45950. private _createShape;
  45951. private _createHeightmap;
  45952. private _minus90X;
  45953. private _plus90X;
  45954. private _tmpPosition;
  45955. private _tmpDeltaPosition;
  45956. private _tmpUnityRotation;
  45957. private _updatePhysicsBodyTransformation;
  45958. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45959. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45960. isSupported(): boolean;
  45961. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45962. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45963. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45964. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45966. getBodyMass(impostor: PhysicsImpostor): number;
  45967. getBodyFriction(impostor: PhysicsImpostor): number;
  45968. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45969. getBodyRestitution(impostor: PhysicsImpostor): number;
  45970. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45971. sleepBody(impostor: PhysicsImpostor): void;
  45972. wakeUpBody(impostor: PhysicsImpostor): void;
  45973. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  45974. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  45975. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  45976. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45977. getRadius(impostor: PhysicsImpostor): number;
  45978. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45979. dispose(): void;
  45980. private _extendNamespace;
  45981. }
  45982. }
  45983. declare module BABYLON {
  45984. /** @hidden */
  45985. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  45986. world: any;
  45987. name: string;
  45988. BJSOIMO: any;
  45989. constructor(iterations?: number, oimoInjection?: any);
  45990. setGravity(gravity: Vector3): void;
  45991. setTimeStep(timeStep: number): void;
  45992. getTimeStep(): number;
  45993. private _tmpImpostorsArray;
  45994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  45995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45998. private _tmpPositionVector;
  45999. removePhysicsBody(impostor: PhysicsImpostor): void;
  46000. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  46001. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  46002. isSupported(): boolean;
  46003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  46004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  46005. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46006. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  46010. getBodyMass(impostor: PhysicsImpostor): number;
  46011. getBodyFriction(impostor: PhysicsImpostor): number;
  46012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  46013. getBodyRestitution(impostor: PhysicsImpostor): number;
  46014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  46015. sleepBody(impostor: PhysicsImpostor): void;
  46016. wakeUpBody(impostor: PhysicsImpostor): void;
  46017. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  46018. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  46019. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  46020. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  46021. getRadius(impostor: PhysicsImpostor): number;
  46022. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  46023. dispose(): void;
  46024. }
  46025. }
  46026. declare module BABYLON {
  46027. interface AbstractScene {
  46028. /**
  46029. * The list of reflection probes added to the scene
  46030. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  46031. */
  46032. reflectionProbes: Array<ReflectionProbe>;
  46033. /**
  46034. * Removes the given reflection probe from this scene.
  46035. * @param toRemove The reflection probe to remove
  46036. * @returns The index of the removed reflection probe
  46037. */
  46038. removeReflectionProbe(toRemove: ReflectionProbe): number;
  46039. /**
  46040. * Adds the given reflection probe to this scene.
  46041. * @param newReflectionProbe The reflection probe to add
  46042. */
  46043. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  46044. }
  46045. /**
  46046. * Class used to generate realtime reflection / refraction cube textures
  46047. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  46048. */
  46049. export class ReflectionProbe {
  46050. /** defines the name of the probe */
  46051. name: string;
  46052. private _scene;
  46053. private _renderTargetTexture;
  46054. private _projectionMatrix;
  46055. private _viewMatrix;
  46056. private _target;
  46057. private _add;
  46058. private _attachedMesh;
  46059. private _invertYAxis;
  46060. /** Gets or sets probe position (center of the cube map) */
  46061. position: Vector3;
  46062. /**
  46063. * Creates a new reflection probe
  46064. * @param name defines the name of the probe
  46065. * @param size defines the texture resolution (for each face)
  46066. * @param scene defines the hosting scene
  46067. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  46068. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  46069. */
  46070. constructor(
  46071. /** defines the name of the probe */
  46072. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  46073. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  46074. samples: number;
  46075. /** Gets or sets the refresh rate to use (on every frame by default) */
  46076. refreshRate: number;
  46077. /**
  46078. * Gets the hosting scene
  46079. * @returns a Scene
  46080. */
  46081. getScene(): Scene;
  46082. /** Gets the internal CubeTexture used to render to */
  46083. readonly cubeTexture: RenderTargetTexture;
  46084. /** Gets the list of meshes to render */
  46085. readonly renderList: Nullable<AbstractMesh[]>;
  46086. /**
  46087. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  46088. * @param mesh defines the mesh to attach to
  46089. */
  46090. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46091. /**
  46092. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  46093. * @param renderingGroupId The rendering group id corresponding to its index
  46094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46095. */
  46096. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  46097. /**
  46098. * Clean all associated resources
  46099. */
  46100. dispose(): void;
  46101. /**
  46102. * Converts the reflection probe information to a readable string for debug purpose.
  46103. * @param fullDetails Supports for multiple levels of logging within scene loading
  46104. * @returns the human readable reflection probe info
  46105. */
  46106. toString(fullDetails?: boolean): string;
  46107. /**
  46108. * Get the class name of the relfection probe.
  46109. * @returns "ReflectionProbe"
  46110. */
  46111. getClassName(): string;
  46112. /**
  46113. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  46114. * @returns The JSON representation of the texture
  46115. */
  46116. serialize(): any;
  46117. /**
  46118. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  46119. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  46120. * @param scene Define the scene the parsed reflection probe should be instantiated in
  46121. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  46122. * @returns The parsed reflection probe if successful
  46123. */
  46124. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  46125. }
  46126. }
  46127. declare module BABYLON {
  46128. /** @hidden */
  46129. export var _BabylonLoaderRegistered: boolean;
  46130. }
  46131. declare module BABYLON {
  46132. /**
  46133. * The Physically based simple base material of BJS.
  46134. *
  46135. * This enables better naming and convention enforcements on top of the pbrMaterial.
  46136. * It is used as the base class for both the specGloss and metalRough conventions.
  46137. */
  46138. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  46139. /**
  46140. * Number of Simultaneous lights allowed on the material.
  46141. */
  46142. maxSimultaneousLights: number;
  46143. /**
  46144. * If sets to true, disables all the lights affecting the material.
  46145. */
  46146. disableLighting: boolean;
  46147. /**
  46148. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  46149. */
  46150. environmentTexture: BaseTexture;
  46151. /**
  46152. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46153. */
  46154. invertNormalMapX: boolean;
  46155. /**
  46156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46157. */
  46158. invertNormalMapY: boolean;
  46159. /**
  46160. * Normal map used in the model.
  46161. */
  46162. normalTexture: BaseTexture;
  46163. /**
  46164. * Emissivie color used to self-illuminate the model.
  46165. */
  46166. emissiveColor: Color3;
  46167. /**
  46168. * Emissivie texture used to self-illuminate the model.
  46169. */
  46170. emissiveTexture: BaseTexture;
  46171. /**
  46172. * Occlusion Channel Strenght.
  46173. */
  46174. occlusionStrength: number;
  46175. /**
  46176. * Occlusion Texture of the material (adding extra occlusion effects).
  46177. */
  46178. occlusionTexture: BaseTexture;
  46179. /**
  46180. * Defines the alpha limits in alpha test mode.
  46181. */
  46182. alphaCutOff: number;
  46183. /**
  46184. * Gets the current double sided mode.
  46185. */
  46186. /**
  46187. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46188. */
  46189. doubleSided: boolean;
  46190. /**
  46191. * Stores the pre-calculated light information of a mesh in a texture.
  46192. */
  46193. lightmapTexture: BaseTexture;
  46194. /**
  46195. * If true, the light map contains occlusion information instead of lighting info.
  46196. */
  46197. useLightmapAsShadowmap: boolean;
  46198. /**
  46199. * Return the active textures of the material.
  46200. */
  46201. getActiveTextures(): BaseTexture[];
  46202. hasTexture(texture: BaseTexture): boolean;
  46203. /**
  46204. * Instantiates a new PBRMaterial instance.
  46205. *
  46206. * @param name The material name
  46207. * @param scene The scene the material will be use in.
  46208. */
  46209. constructor(name: string, scene: Scene);
  46210. getClassName(): string;
  46211. }
  46212. }
  46213. declare module BABYLON {
  46214. /**
  46215. * The PBR material of BJS following the metal roughness convention.
  46216. *
  46217. * This fits to the PBR convention in the GLTF definition:
  46218. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46219. */
  46220. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46221. /**
  46222. * The base color has two different interpretations depending on the value of metalness.
  46223. * When the material is a metal, the base color is the specific measured reflectance value
  46224. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46225. * of the material.
  46226. */
  46227. baseColor: Color3;
  46228. /**
  46229. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46230. * well as opacity information in the alpha channel.
  46231. */
  46232. baseTexture: BaseTexture;
  46233. /**
  46234. * Specifies the metallic scalar value of the material.
  46235. * Can also be used to scale the metalness values of the metallic texture.
  46236. */
  46237. metallic: number;
  46238. /**
  46239. * Specifies the roughness scalar value of the material.
  46240. * Can also be used to scale the roughness values of the metallic texture.
  46241. */
  46242. roughness: number;
  46243. /**
  46244. * Texture containing both the metallic value in the B channel and the
  46245. * roughness value in the G channel to keep better precision.
  46246. */
  46247. metallicRoughnessTexture: BaseTexture;
  46248. /**
  46249. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46250. *
  46251. * @param name The material name
  46252. * @param scene The scene the material will be use in.
  46253. */
  46254. constructor(name: string, scene: Scene);
  46255. /**
  46256. * Return the currrent class name of the material.
  46257. */
  46258. getClassName(): string;
  46259. /**
  46260. * Return the active textures of the material.
  46261. */
  46262. getActiveTextures(): BaseTexture[];
  46263. /**
  46264. * Checks to see if a texture is used in the material.
  46265. * @param texture - Base texture to use.
  46266. * @returns - Boolean specifying if a texture is used in the material.
  46267. */
  46268. hasTexture(texture: BaseTexture): boolean;
  46269. /**
  46270. * Makes a duplicate of the current material.
  46271. * @param name - name to use for the new material.
  46272. */
  46273. clone(name: string): PBRMetallicRoughnessMaterial;
  46274. /**
  46275. * Serialize the material to a parsable JSON object.
  46276. */
  46277. serialize(): any;
  46278. /**
  46279. * Parses a JSON object correponding to the serialize function.
  46280. */
  46281. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * The PBR material of BJS following the specular glossiness convention.
  46287. *
  46288. * This fits to the PBR convention in the GLTF definition:
  46289. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46290. */
  46291. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46292. /**
  46293. * Specifies the diffuse color of the material.
  46294. */
  46295. diffuseColor: Color3;
  46296. /**
  46297. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46298. * channel.
  46299. */
  46300. diffuseTexture: BaseTexture;
  46301. /**
  46302. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46303. */
  46304. specularColor: Color3;
  46305. /**
  46306. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46307. */
  46308. glossiness: number;
  46309. /**
  46310. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46311. */
  46312. specularGlossinessTexture: BaseTexture;
  46313. /**
  46314. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46315. *
  46316. * @param name The material name
  46317. * @param scene The scene the material will be use in.
  46318. */
  46319. constructor(name: string, scene: Scene);
  46320. /**
  46321. * Return the currrent class name of the material.
  46322. */
  46323. getClassName(): string;
  46324. /**
  46325. * Return the active textures of the material.
  46326. */
  46327. getActiveTextures(): BaseTexture[];
  46328. /**
  46329. * Checks to see if a texture is used in the material.
  46330. * @param texture - Base texture to use.
  46331. * @returns - Boolean specifying if a texture is used in the material.
  46332. */
  46333. hasTexture(texture: BaseTexture): boolean;
  46334. /**
  46335. * Makes a duplicate of the current material.
  46336. * @param name - name to use for the new material.
  46337. */
  46338. clone(name: string): PBRSpecularGlossinessMaterial;
  46339. /**
  46340. * Serialize the material to a parsable JSON object.
  46341. */
  46342. serialize(): any;
  46343. /**
  46344. * Parses a JSON object correponding to the serialize function.
  46345. */
  46346. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. /**
  46351. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46352. * It can help converting any input color in a desired output one. This can then be used to create effects
  46353. * from sepia, black and white to sixties or futuristic rendering...
  46354. *
  46355. * The only supported format is currently 3dl.
  46356. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46357. */
  46358. export class ColorGradingTexture extends BaseTexture {
  46359. /**
  46360. * The current texture matrix. (will always be identity in color grading texture)
  46361. */
  46362. private _textureMatrix;
  46363. /**
  46364. * The texture URL.
  46365. */
  46366. url: string;
  46367. /**
  46368. * Empty line regex stored for GC.
  46369. */
  46370. private static _noneEmptyLineRegex;
  46371. private _engine;
  46372. /**
  46373. * Instantiates a ColorGradingTexture from the following parameters.
  46374. *
  46375. * @param url The location of the color gradind data (currently only supporting 3dl)
  46376. * @param scene The scene the texture will be used in
  46377. */
  46378. constructor(url: string, scene: Scene);
  46379. /**
  46380. * Returns the texture matrix used in most of the material.
  46381. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46382. */
  46383. getTextureMatrix(): Matrix;
  46384. /**
  46385. * Occurs when the file being loaded is a .3dl LUT file.
  46386. */
  46387. private load3dlTexture;
  46388. /**
  46389. * Starts the loading process of the texture.
  46390. */
  46391. private loadTexture;
  46392. /**
  46393. * Clones the color gradind texture.
  46394. */
  46395. clone(): ColorGradingTexture;
  46396. /**
  46397. * Called during delayed load for textures.
  46398. */
  46399. delayLoad(): void;
  46400. /**
  46401. * Parses a color grading texture serialized by Babylon.
  46402. * @param parsedTexture The texture information being parsedTexture
  46403. * @param scene The scene to load the texture in
  46404. * @param rootUrl The root url of the data assets to load
  46405. * @return A color gradind texture
  46406. */
  46407. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  46408. /**
  46409. * Serializes the LUT texture to json format.
  46410. */
  46411. serialize(): any;
  46412. }
  46413. }
  46414. declare module BABYLON {
  46415. /**
  46416. * Direct draw surface info
  46417. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46418. */
  46419. export interface DDSInfo {
  46420. /**
  46421. * Width of the texture
  46422. */
  46423. width: number;
  46424. /**
  46425. * Width of the texture
  46426. */
  46427. height: number;
  46428. /**
  46429. * Number of Mipmaps for the texture
  46430. * @see https://en.wikipedia.org/wiki/Mipmap
  46431. */
  46432. mipmapCount: number;
  46433. /**
  46434. * If the textures format is a known fourCC format
  46435. * @see https://www.fourcc.org/
  46436. */
  46437. isFourCC: boolean;
  46438. /**
  46439. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46440. */
  46441. isRGB: boolean;
  46442. /**
  46443. * If the texture is a lumincance format
  46444. */
  46445. isLuminance: boolean;
  46446. /**
  46447. * If this is a cube texture
  46448. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46449. */
  46450. isCube: boolean;
  46451. /**
  46452. * If the texture is a compressed format eg. FOURCC_DXT1
  46453. */
  46454. isCompressed: boolean;
  46455. /**
  46456. * The dxgiFormat of the texture
  46457. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46458. */
  46459. dxgiFormat: number;
  46460. /**
  46461. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46462. */
  46463. textureType: number;
  46464. /**
  46465. * Sphericle polynomial created for the dds texture
  46466. */
  46467. sphericalPolynomial?: SphericalPolynomial;
  46468. }
  46469. /**
  46470. * Class used to provide DDS decompression tools
  46471. */
  46472. export class DDSTools {
  46473. /**
  46474. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46475. */
  46476. static StoreLODInAlphaChannel: boolean;
  46477. /**
  46478. * Gets DDS information from an array buffer
  46479. * @param arrayBuffer defines the array buffer to read data from
  46480. * @returns the DDS information
  46481. */
  46482. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46483. private static _FloatView;
  46484. private static _Int32View;
  46485. private static _ToHalfFloat;
  46486. private static _FromHalfFloat;
  46487. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46488. private static _GetHalfFloatRGBAArrayBuffer;
  46489. private static _GetFloatRGBAArrayBuffer;
  46490. private static _GetFloatAsUIntRGBAArrayBuffer;
  46491. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46492. private static _GetRGBAArrayBuffer;
  46493. private static _ExtractLongWordOrder;
  46494. private static _GetRGBArrayBuffer;
  46495. private static _GetLuminanceArrayBuffer;
  46496. /**
  46497. * Uploads DDS Levels to a Babylon Texture
  46498. * @hidden
  46499. */
  46500. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46501. }
  46502. interface Engine {
  46503. /**
  46504. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46505. * @param rootUrl defines the url where the file to load is located
  46506. * @param scene defines the current scene
  46507. * @param lodScale defines scale to apply to the mip map selection
  46508. * @param lodOffset defines offset to apply to the mip map selection
  46509. * @param onLoad defines an optional callback raised when the texture is loaded
  46510. * @param onError defines an optional callback raised if there is an issue to load the texture
  46511. * @param format defines the format of the data
  46512. * @param forcedExtension defines the extension to use to pick the right loader
  46513. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46514. * @returns the cube texture as an InternalTexture
  46515. */
  46516. 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;
  46517. }
  46518. }
  46519. declare module BABYLON {
  46520. /**
  46521. * Implementation of the DDS Texture Loader.
  46522. * @hidden
  46523. */
  46524. export class _DDSTextureLoader implements IInternalTextureLoader {
  46525. /**
  46526. * Defines wether the loader supports cascade loading the different faces.
  46527. */
  46528. readonly supportCascades: boolean;
  46529. /**
  46530. * This returns if the loader support the current file information.
  46531. * @param extension defines the file extension of the file being loaded
  46532. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46533. * @param fallback defines the fallback internal texture if any
  46534. * @param isBase64 defines whether the texture is encoded as a base64
  46535. * @param isBuffer defines whether the texture data are stored as a buffer
  46536. * @returns true if the loader can load the specified file
  46537. */
  46538. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46539. /**
  46540. * Transform the url before loading if required.
  46541. * @param rootUrl the url of the texture
  46542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46543. * @returns the transformed texture
  46544. */
  46545. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46546. /**
  46547. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46548. * @param rootUrl the url of the texture
  46549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46550. * @returns the fallback texture
  46551. */
  46552. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46553. /**
  46554. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46555. * @param data contains the texture data
  46556. * @param texture defines the BabylonJS internal texture
  46557. * @param createPolynomials will be true if polynomials have been requested
  46558. * @param onLoad defines the callback to trigger once the texture is ready
  46559. * @param onError defines the callback to trigger in case of error
  46560. */
  46561. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46562. /**
  46563. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46564. * @param data contains the texture data
  46565. * @param texture defines the BabylonJS internal texture
  46566. * @param callback defines the method to call once ready to upload
  46567. */
  46568. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46569. }
  46570. }
  46571. declare module BABYLON {
  46572. /** @hidden */
  46573. export var rgbdEncodePixelShader: {
  46574. name: string;
  46575. shader: string;
  46576. };
  46577. }
  46578. declare module BABYLON {
  46579. /** @hidden */
  46580. export var rgbdDecodePixelShader: {
  46581. name: string;
  46582. shader: string;
  46583. };
  46584. }
  46585. declare module BABYLON {
  46586. /**
  46587. * Raw texture data and descriptor sufficient for WebGL texture upload
  46588. */
  46589. export interface EnvironmentTextureInfo {
  46590. /**
  46591. * Version of the environment map
  46592. */
  46593. version: number;
  46594. /**
  46595. * Width of image
  46596. */
  46597. width: number;
  46598. /**
  46599. * Irradiance information stored in the file.
  46600. */
  46601. irradiance: any;
  46602. /**
  46603. * Specular information stored in the file.
  46604. */
  46605. specular: any;
  46606. }
  46607. /**
  46608. * Sets of helpers addressing the serialization and deserialization of environment texture
  46609. * stored in a BabylonJS env file.
  46610. * Those files are usually stored as .env files.
  46611. */
  46612. export class EnvironmentTextureTools {
  46613. /**
  46614. * Magic number identifying the env file.
  46615. */
  46616. private static _MagicBytes;
  46617. /**
  46618. * Gets the environment info from an env file.
  46619. * @param data The array buffer containing the .env bytes.
  46620. * @returns the environment file info (the json header) if successfully parsed.
  46621. */
  46622. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46623. /**
  46624. * Creates an environment texture from a loaded cube texture.
  46625. * @param texture defines the cube texture to convert in env file
  46626. * @return a promise containing the environment data if succesfull.
  46627. */
  46628. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46629. /**
  46630. * Creates a JSON representation of the spherical data.
  46631. * @param texture defines the texture containing the polynomials
  46632. * @return the JSON representation of the spherical info
  46633. */
  46634. private static _CreateEnvTextureIrradiance;
  46635. /**
  46636. * Uploads the texture info contained in the env file to the GPU.
  46637. * @param texture defines the internal texture to upload to
  46638. * @param arrayBuffer defines the buffer cotaining the data to load
  46639. * @param info defines the texture info retrieved through the GetEnvInfo method
  46640. * @returns a promise
  46641. */
  46642. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46643. /**
  46644. * Uploads the levels of image data to the GPU.
  46645. * @param texture defines the internal texture to upload to
  46646. * @param imageData defines the array buffer views of image data [mipmap][face]
  46647. * @returns a promise
  46648. */
  46649. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46650. /**
  46651. * Uploads spherical polynomials information to the texture.
  46652. * @param texture defines the texture we are trying to upload the information to
  46653. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46654. */
  46655. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46656. /** @hidden */
  46657. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46658. }
  46659. }
  46660. declare module BABYLON {
  46661. /**
  46662. * Implementation of the ENV Texture Loader.
  46663. * @hidden
  46664. */
  46665. export class _ENVTextureLoader implements IInternalTextureLoader {
  46666. /**
  46667. * Defines wether the loader supports cascade loading the different faces.
  46668. */
  46669. readonly supportCascades: boolean;
  46670. /**
  46671. * This returns if the loader support the current file information.
  46672. * @param extension defines the file extension of the file being loaded
  46673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46674. * @param fallback defines the fallback internal texture if any
  46675. * @param isBase64 defines whether the texture is encoded as a base64
  46676. * @param isBuffer defines whether the texture data are stored as a buffer
  46677. * @returns true if the loader can load the specified file
  46678. */
  46679. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46680. /**
  46681. * Transform the url before loading if required.
  46682. * @param rootUrl the url of the texture
  46683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46684. * @returns the transformed texture
  46685. */
  46686. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46687. /**
  46688. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46689. * @param rootUrl the url of the texture
  46690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46691. * @returns the fallback texture
  46692. */
  46693. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46694. /**
  46695. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46696. * @param data contains the texture data
  46697. * @param texture defines the BabylonJS internal texture
  46698. * @param createPolynomials will be true if polynomials have been requested
  46699. * @param onLoad defines the callback to trigger once the texture is ready
  46700. * @param onError defines the callback to trigger in case of error
  46701. */
  46702. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46703. /**
  46704. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46705. * @param data contains the texture data
  46706. * @param texture defines the BabylonJS internal texture
  46707. * @param callback defines the method to call once ready to upload
  46708. */
  46709. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46710. }
  46711. }
  46712. declare module BABYLON {
  46713. /**
  46714. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46715. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46716. */
  46717. export class KhronosTextureContainer {
  46718. /** contents of the KTX container file */
  46719. arrayBuffer: any;
  46720. private static HEADER_LEN;
  46721. private static COMPRESSED_2D;
  46722. private static COMPRESSED_3D;
  46723. private static TEX_2D;
  46724. private static TEX_3D;
  46725. /**
  46726. * Gets the openGL type
  46727. */
  46728. glType: number;
  46729. /**
  46730. * Gets the openGL type size
  46731. */
  46732. glTypeSize: number;
  46733. /**
  46734. * Gets the openGL format
  46735. */
  46736. glFormat: number;
  46737. /**
  46738. * Gets the openGL internal format
  46739. */
  46740. glInternalFormat: number;
  46741. /**
  46742. * Gets the base internal format
  46743. */
  46744. glBaseInternalFormat: number;
  46745. /**
  46746. * Gets image width in pixel
  46747. */
  46748. pixelWidth: number;
  46749. /**
  46750. * Gets image height in pixel
  46751. */
  46752. pixelHeight: number;
  46753. /**
  46754. * Gets image depth in pixels
  46755. */
  46756. pixelDepth: number;
  46757. /**
  46758. * Gets the number of array elements
  46759. */
  46760. numberOfArrayElements: number;
  46761. /**
  46762. * Gets the number of faces
  46763. */
  46764. numberOfFaces: number;
  46765. /**
  46766. * Gets the number of mipmap levels
  46767. */
  46768. numberOfMipmapLevels: number;
  46769. /**
  46770. * Gets the bytes of key value data
  46771. */
  46772. bytesOfKeyValueData: number;
  46773. /**
  46774. * Gets the load type
  46775. */
  46776. loadType: number;
  46777. /**
  46778. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46779. */
  46780. isInvalid: boolean;
  46781. /**
  46782. * Creates a new KhronosTextureContainer
  46783. * @param arrayBuffer contents of the KTX container file
  46784. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46785. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46786. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46787. */
  46788. constructor(
  46789. /** contents of the KTX container file */
  46790. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46791. /**
  46792. * Uploads KTX content to a Babylon Texture.
  46793. * It is assumed that the texture has already been created & is currently bound
  46794. * @hidden
  46795. */
  46796. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46797. private _upload2DCompressedLevels;
  46798. }
  46799. }
  46800. declare module BABYLON {
  46801. /**
  46802. * Implementation of the KTX Texture Loader.
  46803. * @hidden
  46804. */
  46805. export class _KTXTextureLoader implements IInternalTextureLoader {
  46806. /**
  46807. * Defines wether the loader supports cascade loading the different faces.
  46808. */
  46809. readonly supportCascades: boolean;
  46810. /**
  46811. * This returns if the loader support the current file information.
  46812. * @param extension defines the file extension of the file being loaded
  46813. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46814. * @param fallback defines the fallback internal texture if any
  46815. * @param isBase64 defines whether the texture is encoded as a base64
  46816. * @param isBuffer defines whether the texture data are stored as a buffer
  46817. * @returns true if the loader can load the specified file
  46818. */
  46819. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46820. /**
  46821. * Transform the url before loading if required.
  46822. * @param rootUrl the url of the texture
  46823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46824. * @returns the transformed texture
  46825. */
  46826. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46827. /**
  46828. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46829. * @param rootUrl the url of the texture
  46830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46831. * @returns the fallback texture
  46832. */
  46833. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46834. /**
  46835. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46836. * @param data contains the texture data
  46837. * @param texture defines the BabylonJS internal texture
  46838. * @param createPolynomials will be true if polynomials have been requested
  46839. * @param onLoad defines the callback to trigger once the texture is ready
  46840. * @param onError defines the callback to trigger in case of error
  46841. */
  46842. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46843. /**
  46844. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46845. * @param data contains the texture data
  46846. * @param texture defines the BabylonJS internal texture
  46847. * @param callback defines the method to call once ready to upload
  46848. */
  46849. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46850. }
  46851. }
  46852. declare module BABYLON {
  46853. /**
  46854. * Based on jsTGALoader - Javascript loader for TGA file
  46855. * By Vincent Thibault
  46856. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46857. */
  46858. export class TGATools {
  46859. private static _TYPE_INDEXED;
  46860. private static _TYPE_RGB;
  46861. private static _TYPE_GREY;
  46862. private static _TYPE_RLE_INDEXED;
  46863. private static _TYPE_RLE_RGB;
  46864. private static _TYPE_RLE_GREY;
  46865. private static _ORIGIN_MASK;
  46866. private static _ORIGIN_SHIFT;
  46867. private static _ORIGIN_BL;
  46868. private static _ORIGIN_BR;
  46869. private static _ORIGIN_UL;
  46870. private static _ORIGIN_UR;
  46871. /**
  46872. * Gets the header of a TGA file
  46873. * @param data defines the TGA data
  46874. * @returns the header
  46875. */
  46876. static GetTGAHeader(data: Uint8Array): any;
  46877. /**
  46878. * Uploads TGA content to a Babylon Texture
  46879. * @hidden
  46880. */
  46881. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46882. /** @hidden */
  46883. 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;
  46884. /** @hidden */
  46885. 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;
  46886. /** @hidden */
  46887. 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;
  46888. /** @hidden */
  46889. 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;
  46890. /** @hidden */
  46891. 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;
  46892. /** @hidden */
  46893. 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;
  46894. }
  46895. }
  46896. declare module BABYLON {
  46897. /**
  46898. * Implementation of the TGA Texture Loader.
  46899. * @hidden
  46900. */
  46901. export class _TGATextureLoader implements IInternalTextureLoader {
  46902. /**
  46903. * Defines wether the loader supports cascade loading the different faces.
  46904. */
  46905. readonly supportCascades: boolean;
  46906. /**
  46907. * This returns if the loader support the current file information.
  46908. * @param extension defines the file extension of the file being loaded
  46909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46910. * @param fallback defines the fallback internal texture if any
  46911. * @param isBase64 defines whether the texture is encoded as a base64
  46912. * @param isBuffer defines whether the texture data are stored as a buffer
  46913. * @returns true if the loader can load the specified file
  46914. */
  46915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46916. /**
  46917. * Transform the url before loading if required.
  46918. * @param rootUrl the url of the texture
  46919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46920. * @returns the transformed texture
  46921. */
  46922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46923. /**
  46924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46925. * @param rootUrl the url of the texture
  46926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46927. * @returns the fallback texture
  46928. */
  46929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46930. /**
  46931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46932. * @param data contains the texture data
  46933. * @param texture defines the BabylonJS internal texture
  46934. * @param createPolynomials will be true if polynomials have been requested
  46935. * @param onLoad defines the callback to trigger once the texture is ready
  46936. * @param onError defines the callback to trigger in case of error
  46937. */
  46938. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46939. /**
  46940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46941. * @param data contains the texture data
  46942. * @param texture defines the BabylonJS internal texture
  46943. * @param callback defines the method to call once ready to upload
  46944. */
  46945. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46946. }
  46947. }
  46948. declare module BABYLON {
  46949. /**
  46950. * 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.
  46951. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46952. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46953. */
  46954. export class CustomProceduralTexture extends ProceduralTexture {
  46955. private _animate;
  46956. private _time;
  46957. private _config;
  46958. private _texturePath;
  46959. /**
  46960. * Instantiates a new Custom Procedural Texture.
  46961. * 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.
  46962. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46963. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46964. * @param name Define the name of the texture
  46965. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46966. * @param size Define the size of the texture to create
  46967. * @param scene Define the scene the texture belongs to
  46968. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46969. * @param generateMipMaps Define if the texture should creates mip maps or not
  46970. */
  46971. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46972. private _loadJson;
  46973. /**
  46974. * Is the texture ready to be used ? (rendered at least once)
  46975. * @returns true if ready, otherwise, false.
  46976. */
  46977. isReady(): boolean;
  46978. /**
  46979. * Render the texture to its associated render target.
  46980. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46981. */
  46982. render(useCameraPostProcess?: boolean): void;
  46983. /**
  46984. * Update the list of dependant textures samplers in the shader.
  46985. */
  46986. updateTextures(): void;
  46987. /**
  46988. * Update the uniform values of the procedural texture in the shader.
  46989. */
  46990. updateShaderUniforms(): void;
  46991. /**
  46992. * Define if the texture animates or not.
  46993. */
  46994. animate: boolean;
  46995. }
  46996. }
  46997. declare module BABYLON {
  46998. /** @hidden */
  46999. export var noisePixelShader: {
  47000. name: string;
  47001. shader: string;
  47002. };
  47003. }
  47004. declare module BABYLON {
  47005. /**
  47006. * Class used to generate noise procedural textures
  47007. */
  47008. export class NoiseProceduralTexture extends ProceduralTexture {
  47009. private _time;
  47010. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  47011. brightness: number;
  47012. /** Defines the number of octaves to process */
  47013. octaves: number;
  47014. /** Defines the level of persistence (0.8 by default) */
  47015. persistence: number;
  47016. /** Gets or sets animation speed factor (default is 1) */
  47017. animationSpeedFactor: number;
  47018. /**
  47019. * Creates a new NoiseProceduralTexture
  47020. * @param name defines the name fo the texture
  47021. * @param size defines the size of the texture (default is 256)
  47022. * @param scene defines the hosting scene
  47023. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  47024. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  47025. */
  47026. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47027. private _updateShaderUniforms;
  47028. protected _getDefines(): string;
  47029. /** Generate the current state of the procedural texture */
  47030. render(useCameraPostProcess?: boolean): void;
  47031. /**
  47032. * Serializes this noise procedural texture
  47033. * @returns a serialized noise procedural texture object
  47034. */
  47035. serialize(): any;
  47036. /**
  47037. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  47038. * @param parsedTexture defines parsed texture data
  47039. * @param scene defines the current scene
  47040. * @param rootUrl defines the root URL containing noise procedural texture information
  47041. * @returns a parsed NoiseProceduralTexture
  47042. */
  47043. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  47044. }
  47045. }
  47046. declare module BABYLON {
  47047. /**
  47048. * Raw cube texture where the raw buffers are passed in
  47049. */
  47050. export class RawCubeTexture extends CubeTexture {
  47051. /**
  47052. * Creates a cube texture where the raw buffers are passed in.
  47053. * @param scene defines the scene the texture is attached to
  47054. * @param data defines the array of data to use to create each face
  47055. * @param size defines the size of the textures
  47056. * @param format defines the format of the data
  47057. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47058. * @param generateMipMaps defines if the engine should generate the mip levels
  47059. * @param invertY defines if data must be stored with Y axis inverted
  47060. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47061. * @param compression defines the compression used (null by default)
  47062. */
  47063. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47064. /**
  47065. * Updates the raw cube texture.
  47066. * @param data defines the data to store
  47067. * @param format defines the data format
  47068. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47069. * @param invertY defines if data must be stored with Y axis inverted
  47070. * @param compression defines the compression used (null by default)
  47071. * @param level defines which level of the texture to update
  47072. */
  47073. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  47074. /**
  47075. * Updates a raw cube texture with RGBD encoded data.
  47076. * @param data defines the array of data [mipmap][face] to use to create each face
  47077. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47078. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47079. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47080. * @returns a promsie that resolves when the operation is complete
  47081. */
  47082. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47083. /**
  47084. * Clones the raw cube texture.
  47085. * @return a new cube texture
  47086. */
  47087. clone(): CubeTexture;
  47088. /** @hidden */
  47089. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47090. }
  47091. }
  47092. declare module BABYLON {
  47093. /**
  47094. * Class used to store 3D textures containing user data
  47095. */
  47096. export class RawTexture3D extends Texture {
  47097. /** Gets or sets the texture format to use */
  47098. format: number;
  47099. private _engine;
  47100. /**
  47101. * Create a new RawTexture3D
  47102. * @param data defines the data of the texture
  47103. * @param width defines the width of the texture
  47104. * @param height defines the height of the texture
  47105. * @param depth defines the depth of the texture
  47106. * @param format defines the texture format to use
  47107. * @param scene defines the hosting scene
  47108. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47109. * @param invertY defines if texture must be stored with Y axis inverted
  47110. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  47111. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47112. */
  47113. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47114. /** Gets or sets the texture format to use */
  47115. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47116. /**
  47117. * Update the texture with new data
  47118. * @param data defines the data to store in the texture
  47119. */
  47120. update(data: ArrayBufferView): void;
  47121. }
  47122. }
  47123. declare module BABYLON {
  47124. /**
  47125. * Creates a refraction texture used by refraction channel of the standard material.
  47126. * It is like a mirror but to see through a material.
  47127. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47128. */
  47129. export class RefractionTexture extends RenderTargetTexture {
  47130. /**
  47131. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47132. * It is possible to directly set the refractionPlane by directly using a 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.
  47133. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47134. */
  47135. refractionPlane: Plane;
  47136. /**
  47137. * Define how deep under the surface we should see.
  47138. */
  47139. depth: number;
  47140. /**
  47141. * Creates a refraction texture used by refraction channel of the standard material.
  47142. * It is like a mirror but to see through a material.
  47143. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47144. * @param name Define the texture name
  47145. * @param size Define the size of the underlying texture
  47146. * @param scene Define the scene the refraction belongs to
  47147. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47148. */
  47149. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47150. /**
  47151. * Clone the refraction texture.
  47152. * @returns the cloned texture
  47153. */
  47154. clone(): RefractionTexture;
  47155. /**
  47156. * Serialize the texture to a JSON representation you could use in Parse later on
  47157. * @returns the serialized JSON representation
  47158. */
  47159. serialize(): any;
  47160. }
  47161. }
  47162. declare module BABYLON {
  47163. /**
  47164. * Configuration for Draco compression
  47165. */
  47166. export interface IDracoCompressionConfiguration {
  47167. /**
  47168. * Configuration for the decoder.
  47169. */
  47170. decoder?: {
  47171. /**
  47172. * The url to the WebAssembly module.
  47173. */
  47174. wasmUrl?: string;
  47175. /**
  47176. * The url to the WebAssembly binary.
  47177. */
  47178. wasmBinaryUrl?: string;
  47179. /**
  47180. * The url to the fallback JavaScript module.
  47181. */
  47182. fallbackUrl?: string;
  47183. };
  47184. }
  47185. /**
  47186. * Draco compression (https://google.github.io/draco/)
  47187. *
  47188. * This class wraps the Draco module.
  47189. *
  47190. * **Encoder**
  47191. *
  47192. * The encoder is not currently implemented.
  47193. *
  47194. * **Decoder**
  47195. *
  47196. * 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.
  47197. *
  47198. * To update the configuration, use the following code:
  47199. * ```javascript
  47200. * DracoCompression.Configuration = {
  47201. * decoder: {
  47202. * wasmUrl: "<url to the WebAssembly library>",
  47203. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47204. * fallbackUrl: "<url to the fallback JavaScript library>",
  47205. * }
  47206. * };
  47207. * ```
  47208. *
  47209. * 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.
  47210. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47211. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47212. *
  47213. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47214. * ```javascript
  47215. * var dracoCompression = new DracoCompression();
  47216. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47217. * [VertexBuffer.PositionKind]: 0
  47218. * });
  47219. * ```
  47220. *
  47221. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47222. */
  47223. export class DracoCompression implements IDisposable {
  47224. private static _DecoderModulePromise;
  47225. /**
  47226. * The configuration. Defaults to the following urls:
  47227. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47228. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47229. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47230. */
  47231. static Configuration: IDracoCompressionConfiguration;
  47232. /**
  47233. * Returns true if the decoder is available.
  47234. */
  47235. static readonly DecoderAvailable: boolean;
  47236. /**
  47237. * Constructor
  47238. */
  47239. constructor();
  47240. /**
  47241. * Stop all async operations and release resources.
  47242. */
  47243. dispose(): void;
  47244. /**
  47245. * Decode Draco compressed mesh data to vertex data.
  47246. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47247. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47248. * @returns A promise that resolves with the decoded vertex data
  47249. */
  47250. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47251. [kind: string]: number;
  47252. }): Promise<VertexData>;
  47253. private static _GetDecoderModule;
  47254. private static _LoadScriptAsync;
  47255. private static _LoadFileAsync;
  47256. }
  47257. }
  47258. declare module BABYLON {
  47259. /**
  47260. * Class for building Constructive Solid Geometry
  47261. */
  47262. export class CSG {
  47263. private polygons;
  47264. /**
  47265. * The world matrix
  47266. */
  47267. matrix: Matrix;
  47268. /**
  47269. * Stores the position
  47270. */
  47271. position: Vector3;
  47272. /**
  47273. * Stores the rotation
  47274. */
  47275. rotation: Vector3;
  47276. /**
  47277. * Stores the rotation quaternion
  47278. */
  47279. rotationQuaternion: Nullable<Quaternion>;
  47280. /**
  47281. * Stores the scaling vector
  47282. */
  47283. scaling: Vector3;
  47284. /**
  47285. * Convert the Mesh to CSG
  47286. * @param mesh The Mesh to convert to CSG
  47287. * @returns A new CSG from the Mesh
  47288. */
  47289. static FromMesh(mesh: Mesh): CSG;
  47290. /**
  47291. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  47292. * @param polygons Polygons used to construct a CSG solid
  47293. */
  47294. private static FromPolygons;
  47295. /**
  47296. * Clones, or makes a deep copy, of the CSG
  47297. * @returns A new CSG
  47298. */
  47299. clone(): CSG;
  47300. /**
  47301. * Unions this CSG with another CSG
  47302. * @param csg The CSG to union against this CSG
  47303. * @returns The unioned CSG
  47304. */
  47305. union(csg: CSG): CSG;
  47306. /**
  47307. * Unions this CSG with another CSG in place
  47308. * @param csg The CSG to union against this CSG
  47309. */
  47310. unionInPlace(csg: CSG): void;
  47311. /**
  47312. * Subtracts this CSG with another CSG
  47313. * @param csg The CSG to subtract against this CSG
  47314. * @returns A new CSG
  47315. */
  47316. subtract(csg: CSG): CSG;
  47317. /**
  47318. * Subtracts this CSG with another CSG in place
  47319. * @param csg The CSG to subtact against this CSG
  47320. */
  47321. subtractInPlace(csg: CSG): void;
  47322. /**
  47323. * Intersect this CSG with another CSG
  47324. * @param csg The CSG to intersect against this CSG
  47325. * @returns A new CSG
  47326. */
  47327. intersect(csg: CSG): CSG;
  47328. /**
  47329. * Intersects this CSG with another CSG in place
  47330. * @param csg The CSG to intersect against this CSG
  47331. */
  47332. intersectInPlace(csg: CSG): void;
  47333. /**
  47334. * Return a new CSG solid with solid and empty space switched. This solid is
  47335. * not modified.
  47336. * @returns A new CSG solid with solid and empty space switched
  47337. */
  47338. inverse(): CSG;
  47339. /**
  47340. * Inverses the CSG in place
  47341. */
  47342. inverseInPlace(): void;
  47343. /**
  47344. * This is used to keep meshes transformations so they can be restored
  47345. * when we build back a Babylon Mesh
  47346. * NB : All CSG operations are performed in world coordinates
  47347. * @param csg The CSG to copy the transform attributes from
  47348. * @returns This CSG
  47349. */
  47350. copyTransformAttributes(csg: CSG): CSG;
  47351. /**
  47352. * Build Raw mesh from CSG
  47353. * Coordinates here are in world space
  47354. * @param name The name of the mesh geometry
  47355. * @param scene The Scene
  47356. * @param keepSubMeshes Specifies if the submeshes should be kept
  47357. * @returns A new Mesh
  47358. */
  47359. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  47360. /**
  47361. * Build Mesh from CSG taking material and transforms into account
  47362. * @param name The name of the Mesh
  47363. * @param material The material of the Mesh
  47364. * @param scene The Scene
  47365. * @param keepSubMeshes Specifies if submeshes should be kept
  47366. * @returns The new Mesh
  47367. */
  47368. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  47369. }
  47370. }
  47371. declare module BABYLON {
  47372. /**
  47373. * A simplifier interface for future simplification implementations
  47374. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47375. */
  47376. export interface ISimplifier {
  47377. /**
  47378. * Simplification of a given mesh according to the given settings.
  47379. * Since this requires computation, it is assumed that the function runs async.
  47380. * @param settings The settings of the simplification, including quality and distance
  47381. * @param successCallback A callback that will be called after the mesh was simplified.
  47382. * @param errorCallback in case of an error, this callback will be called. optional.
  47383. */
  47384. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47385. }
  47386. /**
  47387. * Expected simplification settings.
  47388. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47389. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47390. */
  47391. export interface ISimplificationSettings {
  47392. /**
  47393. * Gets or sets the expected quality
  47394. */
  47395. quality: number;
  47396. /**
  47397. * Gets or sets the distance when this optimized version should be used
  47398. */
  47399. distance: number;
  47400. /**
  47401. * Gets an already optimized mesh
  47402. */
  47403. optimizeMesh?: boolean;
  47404. }
  47405. /**
  47406. * Class used to specify simplification options
  47407. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47408. */
  47409. export class SimplificationSettings implements ISimplificationSettings {
  47410. /** expected quality */
  47411. quality: number;
  47412. /** distance when this optimized version should be used */
  47413. distance: number;
  47414. /** already optimized mesh */
  47415. optimizeMesh?: boolean | undefined;
  47416. /**
  47417. * Creates a SimplificationSettings
  47418. * @param quality expected quality
  47419. * @param distance distance when this optimized version should be used
  47420. * @param optimizeMesh already optimized mesh
  47421. */
  47422. constructor(
  47423. /** expected quality */
  47424. quality: number,
  47425. /** distance when this optimized version should be used */
  47426. distance: number,
  47427. /** already optimized mesh */
  47428. optimizeMesh?: boolean | undefined);
  47429. }
  47430. /**
  47431. * Interface used to define a simplification task
  47432. */
  47433. export interface ISimplificationTask {
  47434. /**
  47435. * Array of settings
  47436. */
  47437. settings: Array<ISimplificationSettings>;
  47438. /**
  47439. * Simplification type
  47440. */
  47441. simplificationType: SimplificationType;
  47442. /**
  47443. * Mesh to simplify
  47444. */
  47445. mesh: Mesh;
  47446. /**
  47447. * Callback called on success
  47448. */
  47449. successCallback?: () => void;
  47450. /**
  47451. * Defines if parallel processing can be used
  47452. */
  47453. parallelProcessing: boolean;
  47454. }
  47455. /**
  47456. * Queue used to order the simplification tasks
  47457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47458. */
  47459. export class SimplificationQueue {
  47460. private _simplificationArray;
  47461. /**
  47462. * Gets a boolean indicating that the process is still running
  47463. */
  47464. running: boolean;
  47465. /**
  47466. * Creates a new queue
  47467. */
  47468. constructor();
  47469. /**
  47470. * Adds a new simplification task
  47471. * @param task defines a task to add
  47472. */
  47473. addTask(task: ISimplificationTask): void;
  47474. /**
  47475. * Execute next task
  47476. */
  47477. executeNext(): void;
  47478. /**
  47479. * Execute a simplification task
  47480. * @param task defines the task to run
  47481. */
  47482. runSimplification(task: ISimplificationTask): void;
  47483. private getSimplifier;
  47484. }
  47485. /**
  47486. * The implemented types of simplification
  47487. * At the moment only Quadratic Error Decimation is implemented
  47488. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47489. */
  47490. export enum SimplificationType {
  47491. /** Quadratic error decimation */
  47492. QUADRATIC = 0
  47493. }
  47494. }
  47495. declare module BABYLON {
  47496. interface Scene {
  47497. /** @hidden (Backing field) */
  47498. _simplificationQueue: SimplificationQueue;
  47499. /**
  47500. * Gets or sets the simplification queue attached to the scene
  47501. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47502. */
  47503. simplificationQueue: SimplificationQueue;
  47504. }
  47505. interface Mesh {
  47506. /**
  47507. * Simplify the mesh according to the given array of settings.
  47508. * Function will return immediately and will simplify async
  47509. * @param settings a collection of simplification settings
  47510. * @param parallelProcessing should all levels calculate parallel or one after the other
  47511. * @param simplificationType the type of simplification to run
  47512. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47513. * @returns the current mesh
  47514. */
  47515. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47516. }
  47517. /**
  47518. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47519. * created in a scene
  47520. */
  47521. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47522. /**
  47523. * The component name helpfull to identify the component in the list of scene components.
  47524. */
  47525. readonly name: string;
  47526. /**
  47527. * The scene the component belongs to.
  47528. */
  47529. scene: Scene;
  47530. /**
  47531. * Creates a new instance of the component for the given scene
  47532. * @param scene Defines the scene to register the component in
  47533. */
  47534. constructor(scene: Scene);
  47535. /**
  47536. * Registers the component in a given scene
  47537. */
  47538. register(): void;
  47539. /**
  47540. * Rebuilds the elements related to this component in case of
  47541. * context lost for instance.
  47542. */
  47543. rebuild(): void;
  47544. /**
  47545. * Disposes the component and the associated ressources
  47546. */
  47547. dispose(): void;
  47548. private _beforeCameraUpdate;
  47549. }
  47550. }
  47551. declare module BABYLON {
  47552. /**
  47553. * Class used to enable access to IndexedDB
  47554. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47555. */
  47556. export class Database implements IOfflineProvider {
  47557. private _callbackManifestChecked;
  47558. private _currentSceneUrl;
  47559. private _db;
  47560. private _enableSceneOffline;
  47561. private _enableTexturesOffline;
  47562. private _manifestVersionFound;
  47563. private _mustUpdateRessources;
  47564. private _hasReachedQuota;
  47565. private _isSupported;
  47566. private _idbFactory;
  47567. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47568. private static IsUASupportingBlobStorage;
  47569. /**
  47570. * Gets a boolean indicating if Database storate is enabled (off by default)
  47571. */
  47572. static IDBStorageEnabled: boolean;
  47573. /**
  47574. * Gets a boolean indicating if scene must be saved in the database
  47575. */
  47576. readonly enableSceneOffline: boolean;
  47577. /**
  47578. * Gets a boolean indicating if textures must be saved in the database
  47579. */
  47580. readonly enableTexturesOffline: boolean;
  47581. /**
  47582. * Creates a new Database
  47583. * @param urlToScene defines the url to load the scene
  47584. * @param callbackManifestChecked defines the callback to use when manifest is checked
  47585. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  47586. */
  47587. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  47588. private static _ParseURL;
  47589. private static _ReturnFullUrlLocation;
  47590. private _checkManifestFile;
  47591. /**
  47592. * Open the database and make it available
  47593. * @param successCallback defines the callback to call on success
  47594. * @param errorCallback defines the callback to call on error
  47595. */
  47596. open(successCallback: () => void, errorCallback: () => void): void;
  47597. /**
  47598. * Loads an image from the database
  47599. * @param url defines the url to load from
  47600. * @param image defines the target DOM image
  47601. */
  47602. loadImage(url: string, image: HTMLImageElement): void;
  47603. private _loadImageFromDBAsync;
  47604. private _saveImageIntoDBAsync;
  47605. private _checkVersionFromDB;
  47606. private _loadVersionFromDBAsync;
  47607. private _saveVersionIntoDBAsync;
  47608. /**
  47609. * Loads a file from database
  47610. * @param url defines the URL to load from
  47611. * @param sceneLoaded defines a callback to call on success
  47612. * @param progressCallBack defines a callback to call when progress changed
  47613. * @param errorCallback defines a callback to call on error
  47614. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  47615. */
  47616. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  47617. private _loadFileAsync;
  47618. private _saveFileAsync;
  47619. /**
  47620. * Validates if xhr data is correct
  47621. * @param xhr defines the request to validate
  47622. * @param dataType defines the expected data type
  47623. * @returns true if data is correct
  47624. */
  47625. private static _ValidateXHRData;
  47626. }
  47627. }
  47628. declare module BABYLON {
  47629. /** @hidden */
  47630. export var gpuUpdateParticlesPixelShader: {
  47631. name: string;
  47632. shader: string;
  47633. };
  47634. }
  47635. declare module BABYLON {
  47636. /** @hidden */
  47637. export var gpuUpdateParticlesVertexShader: {
  47638. name: string;
  47639. shader: string;
  47640. };
  47641. }
  47642. declare module BABYLON {
  47643. /** @hidden */
  47644. export var clipPlaneFragmentDeclaration2: {
  47645. name: string;
  47646. shader: string;
  47647. };
  47648. }
  47649. declare module BABYLON {
  47650. /** @hidden */
  47651. export var gpuRenderParticlesPixelShader: {
  47652. name: string;
  47653. shader: string;
  47654. };
  47655. }
  47656. declare module BABYLON {
  47657. /** @hidden */
  47658. export var clipPlaneVertexDeclaration2: {
  47659. name: string;
  47660. shader: string;
  47661. };
  47662. }
  47663. declare module BABYLON {
  47664. /** @hidden */
  47665. export var gpuRenderParticlesVertexShader: {
  47666. name: string;
  47667. shader: string;
  47668. };
  47669. }
  47670. declare module BABYLON {
  47671. /**
  47672. * This represents a GPU particle system in Babylon
  47673. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  47674. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  47675. */
  47676. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  47677. /**
  47678. * The layer mask we are rendering the particles through.
  47679. */
  47680. layerMask: number;
  47681. private _capacity;
  47682. private _activeCount;
  47683. private _currentActiveCount;
  47684. private _accumulatedCount;
  47685. private _renderEffect;
  47686. private _updateEffect;
  47687. private _buffer0;
  47688. private _buffer1;
  47689. private _spriteBuffer;
  47690. private _updateVAO;
  47691. private _renderVAO;
  47692. private _targetIndex;
  47693. private _sourceBuffer;
  47694. private _targetBuffer;
  47695. private _engine;
  47696. private _currentRenderId;
  47697. private _started;
  47698. private _stopped;
  47699. private _timeDelta;
  47700. private _randomTexture;
  47701. private _randomTexture2;
  47702. private _attributesStrideSize;
  47703. private _updateEffectOptions;
  47704. private _randomTextureSize;
  47705. private _actualFrame;
  47706. private readonly _rawTextureWidth;
  47707. /**
  47708. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  47709. */
  47710. static readonly IsSupported: boolean;
  47711. /**
  47712. * An event triggered when the system is disposed.
  47713. */
  47714. onDisposeObservable: Observable<GPUParticleSystem>;
  47715. /**
  47716. * Gets the maximum number of particles active at the same time.
  47717. * @returns The max number of active particles.
  47718. */
  47719. getCapacity(): number;
  47720. /**
  47721. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  47722. * to override the particles.
  47723. */
  47724. forceDepthWrite: boolean;
  47725. /**
  47726. * Gets or set the number of active particles
  47727. */
  47728. activeParticleCount: number;
  47729. private _preWarmDone;
  47730. /**
  47731. * Is this system ready to be used/rendered
  47732. * @return true if the system is ready
  47733. */
  47734. isReady(): boolean;
  47735. /**
  47736. * Gets if the system has been started. (Note: this will still be true after stop is called)
  47737. * @returns True if it has been started, otherwise false.
  47738. */
  47739. isStarted(): boolean;
  47740. /**
  47741. * Starts the particle system and begins to emit
  47742. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  47743. */
  47744. start(delay?: number): void;
  47745. /**
  47746. * Stops the particle system.
  47747. */
  47748. stop(): void;
  47749. /**
  47750. * Remove all active particles
  47751. */
  47752. reset(): void;
  47753. /**
  47754. * Returns the string "GPUParticleSystem"
  47755. * @returns a string containing the class name
  47756. */
  47757. getClassName(): string;
  47758. private _colorGradientsTexture;
  47759. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  47760. /**
  47761. * Adds a new color gradient
  47762. * @param gradient defines the gradient to use (between 0 and 1)
  47763. * @param color1 defines the color to affect to the specified gradient
  47764. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  47765. * @returns the current particle system
  47766. */
  47767. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  47768. /**
  47769. * Remove a specific color gradient
  47770. * @param gradient defines the gradient to remove
  47771. * @returns the current particle system
  47772. */
  47773. removeColorGradient(gradient: number): GPUParticleSystem;
  47774. private _angularSpeedGradientsTexture;
  47775. private _sizeGradientsTexture;
  47776. private _velocityGradientsTexture;
  47777. private _limitVelocityGradientsTexture;
  47778. private _dragGradientsTexture;
  47779. private _addFactorGradient;
  47780. /**
  47781. * Adds a new size gradient
  47782. * @param gradient defines the gradient to use (between 0 and 1)
  47783. * @param factor defines the size factor to affect to the specified gradient
  47784. * @returns the current particle system
  47785. */
  47786. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  47787. /**
  47788. * Remove a specific size gradient
  47789. * @param gradient defines the gradient to remove
  47790. * @returns the current particle system
  47791. */
  47792. removeSizeGradient(gradient: number): GPUParticleSystem;
  47793. /**
  47794. * Adds a new angular speed gradient
  47795. * @param gradient defines the gradient to use (between 0 and 1)
  47796. * @param factor defines the angular speed to affect to the specified gradient
  47797. * @returns the current particle system
  47798. */
  47799. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  47800. /**
  47801. * Remove a specific angular speed gradient
  47802. * @param gradient defines the gradient to remove
  47803. * @returns the current particle system
  47804. */
  47805. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  47806. /**
  47807. * Adds a new velocity gradient
  47808. * @param gradient defines the gradient to use (between 0 and 1)
  47809. * @param factor defines the velocity to affect to the specified gradient
  47810. * @returns the current particle system
  47811. */
  47812. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47813. /**
  47814. * Remove a specific velocity gradient
  47815. * @param gradient defines the gradient to remove
  47816. * @returns the current particle system
  47817. */
  47818. removeVelocityGradient(gradient: number): GPUParticleSystem;
  47819. /**
  47820. * Adds a new limit velocity gradient
  47821. * @param gradient defines the gradient to use (between 0 and 1)
  47822. * @param factor defines the limit velocity value to affect to the specified gradient
  47823. * @returns the current particle system
  47824. */
  47825. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47826. /**
  47827. * Remove a specific limit velocity gradient
  47828. * @param gradient defines the gradient to remove
  47829. * @returns the current particle system
  47830. */
  47831. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  47832. /**
  47833. * Adds a new drag gradient
  47834. * @param gradient defines the gradient to use (between 0 and 1)
  47835. * @param factor defines the drag value to affect to the specified gradient
  47836. * @returns the current particle system
  47837. */
  47838. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  47839. /**
  47840. * Remove a specific drag gradient
  47841. * @param gradient defines the gradient to remove
  47842. * @returns the current particle system
  47843. */
  47844. removeDragGradient(gradient: number): GPUParticleSystem;
  47845. /**
  47846. * Not supported by GPUParticleSystem
  47847. * @param gradient defines the gradient to use (between 0 and 1)
  47848. * @param factor defines the emit rate value to affect to the specified gradient
  47849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47850. * @returns the current particle system
  47851. */
  47852. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47853. /**
  47854. * Not supported by GPUParticleSystem
  47855. * @param gradient defines the gradient to remove
  47856. * @returns the current particle system
  47857. */
  47858. removeEmitRateGradient(gradient: number): IParticleSystem;
  47859. /**
  47860. * Not supported by GPUParticleSystem
  47861. * @param gradient defines the gradient to use (between 0 and 1)
  47862. * @param factor defines the start size value to affect to the specified gradient
  47863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47864. * @returns the current particle system
  47865. */
  47866. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47867. /**
  47868. * Not supported by GPUParticleSystem
  47869. * @param gradient defines the gradient to remove
  47870. * @returns the current particle system
  47871. */
  47872. removeStartSizeGradient(gradient: number): IParticleSystem;
  47873. /**
  47874. * Not supported by GPUParticleSystem
  47875. * @param gradient defines the gradient to use (between 0 and 1)
  47876. * @param min defines the color remap minimal range
  47877. * @param max defines the color remap maximal range
  47878. * @returns the current particle system
  47879. */
  47880. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47881. /**
  47882. * Not supported by GPUParticleSystem
  47883. * @param gradient defines the gradient to remove
  47884. * @returns the current particle system
  47885. */
  47886. removeColorRemapGradient(): IParticleSystem;
  47887. /**
  47888. * Not supported by GPUParticleSystem
  47889. * @param gradient defines the gradient to use (between 0 and 1)
  47890. * @param min defines the alpha remap minimal range
  47891. * @param max defines the alpha remap maximal range
  47892. * @returns the current particle system
  47893. */
  47894. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47895. /**
  47896. * Not supported by GPUParticleSystem
  47897. * @param gradient defines the gradient to remove
  47898. * @returns the current particle system
  47899. */
  47900. removeAlphaRemapGradient(): IParticleSystem;
  47901. /**
  47902. * Not supported by GPUParticleSystem
  47903. * @param gradient defines the gradient to use (between 0 and 1)
  47904. * @param color defines the color to affect to the specified gradient
  47905. * @returns the current particle system
  47906. */
  47907. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  47908. /**
  47909. * Not supported by GPUParticleSystem
  47910. * @param gradient defines the gradient to remove
  47911. * @returns the current particle system
  47912. */
  47913. removeRampGradient(): IParticleSystem;
  47914. /**
  47915. * Not supported by GPUParticleSystem
  47916. * @returns the list of ramp gradients
  47917. */
  47918. getRampGradients(): Nullable<Array<Color3Gradient>>;
  47919. /**
  47920. * Not supported by GPUParticleSystem
  47921. * Gets or sets a boolean indicating that ramp gradients must be used
  47922. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  47923. */
  47924. useRampGradients: boolean;
  47925. /**
  47926. * Not supported by GPUParticleSystem
  47927. * @param gradient defines the gradient to use (between 0 and 1)
  47928. * @param factor defines the life time factor to affect to the specified gradient
  47929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47930. * @returns the current particle system
  47931. */
  47932. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47933. /**
  47934. * Not supported by GPUParticleSystem
  47935. * @param gradient defines the gradient to remove
  47936. * @returns the current particle system
  47937. */
  47938. removeLifeTimeGradient(gradient: number): IParticleSystem;
  47939. /**
  47940. * Instantiates a GPU particle system.
  47941. * 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.
  47942. * @param name The name of the particle system
  47943. * @param options The options used to create the system
  47944. * @param scene The scene the particle system belongs to
  47945. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  47946. */
  47947. constructor(name: string, options: Partial<{
  47948. capacity: number;
  47949. randomTextureSize: number;
  47950. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  47951. protected _reset(): void;
  47952. private _createUpdateVAO;
  47953. private _createRenderVAO;
  47954. private _initialize;
  47955. /** @hidden */
  47956. _recreateUpdateEffect(): void;
  47957. /** @hidden */
  47958. _recreateRenderEffect(): void;
  47959. /**
  47960. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  47961. * @param preWarm defines if we are in the pre-warmimg phase
  47962. */
  47963. animate(preWarm?: boolean): void;
  47964. private _createFactorGradientTexture;
  47965. private _createSizeGradientTexture;
  47966. private _createAngularSpeedGradientTexture;
  47967. private _createVelocityGradientTexture;
  47968. private _createLimitVelocityGradientTexture;
  47969. private _createDragGradientTexture;
  47970. private _createColorGradientTexture;
  47971. /**
  47972. * Renders the particle system in its current state
  47973. * @param preWarm defines if the system should only update the particles but not render them
  47974. * @returns the current number of particles
  47975. */
  47976. render(preWarm?: boolean): number;
  47977. /**
  47978. * Rebuilds the particle system
  47979. */
  47980. rebuild(): void;
  47981. private _releaseBuffers;
  47982. private _releaseVAOs;
  47983. /**
  47984. * Disposes the particle system and free the associated resources
  47985. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  47986. */
  47987. dispose(disposeTexture?: boolean): void;
  47988. /**
  47989. * Clones the particle system.
  47990. * @param name The name of the cloned object
  47991. * @param newEmitter The new emitter to use
  47992. * @returns the cloned particle system
  47993. */
  47994. clone(name: string, newEmitter: any): GPUParticleSystem;
  47995. /**
  47996. * Serializes the particle system to a JSON object.
  47997. * @returns the JSON object
  47998. */
  47999. serialize(): any;
  48000. /**
  48001. * Parses a JSON object to create a GPU particle system.
  48002. * @param parsedParticleSystem The JSON object to parse
  48003. * @param scene The scene to create the particle system in
  48004. * @param rootUrl The root url to use to load external dependencies like texture
  48005. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  48006. * @returns the parsed GPU particle system
  48007. */
  48008. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  48009. }
  48010. }
  48011. declare module BABYLON {
  48012. /**
  48013. * Represents a set of particle systems working together to create a specific effect
  48014. */
  48015. export class ParticleSystemSet implements IDisposable {
  48016. private _emitterCreationOptions;
  48017. private _emitterNode;
  48018. /**
  48019. * Gets the particle system list
  48020. */
  48021. systems: IParticleSystem[];
  48022. /**
  48023. * Gets the emitter node used with this set
  48024. */
  48025. readonly emitterNode: Nullable<TransformNode>;
  48026. /**
  48027. * Creates a new emitter mesh as a sphere
  48028. * @param options defines the options used to create the sphere
  48029. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  48030. * @param scene defines the hosting scene
  48031. */
  48032. setEmitterAsSphere(options: {
  48033. diameter: number;
  48034. segments: number;
  48035. color: Color3;
  48036. }, renderingGroupId: number, scene: Scene): void;
  48037. /**
  48038. * Starts all particle systems of the set
  48039. * @param emitter defines an optional mesh to use as emitter for the particle systems
  48040. */
  48041. start(emitter?: AbstractMesh): void;
  48042. /**
  48043. * Release all associated resources
  48044. */
  48045. dispose(): void;
  48046. /**
  48047. * Serialize the set into a JSON compatible object
  48048. * @returns a JSON compatible representation of the set
  48049. */
  48050. serialize(): any;
  48051. /**
  48052. * Parse a new ParticleSystemSet from a serialized source
  48053. * @param data defines a JSON compatible representation of the set
  48054. * @param scene defines the hosting scene
  48055. * @param gpu defines if we want GPU particles or CPU particles
  48056. * @returns a new ParticleSystemSet
  48057. */
  48058. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  48059. }
  48060. }
  48061. declare module BABYLON {
  48062. /**
  48063. * This class is made for on one-liner static method to help creating particle system set.
  48064. */
  48065. export class ParticleHelper {
  48066. /**
  48067. * Gets or sets base Assets URL
  48068. */
  48069. static BaseAssetsUrl: string;
  48070. /**
  48071. * Create a default particle system that you can tweak
  48072. * @param emitter defines the emitter to use
  48073. * @param capacity defines the system capacity (default is 500 particles)
  48074. * @param scene defines the hosting scene
  48075. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  48076. * @returns the new Particle system
  48077. */
  48078. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  48079. /**
  48080. * This is the main static method (one-liner) of this helper to create different particle systems
  48081. * @param type This string represents the type to the particle system to create
  48082. * @param scene The scene where the particle system should live
  48083. * @param gpu If the system will use gpu
  48084. * @returns the ParticleSystemSet created
  48085. */
  48086. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  48087. /**
  48088. * Static function used to export a particle system to a ParticleSystemSet variable.
  48089. * Please note that the emitter shape is not exported
  48090. * @param systems defines the particle systems to export
  48091. * @returns the created particle system set
  48092. */
  48093. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  48094. }
  48095. }
  48096. declare module BABYLON {
  48097. interface Engine {
  48098. /**
  48099. * Create an effect to use with particle systems.
  48100. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  48101. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  48102. * @param uniformsNames defines a list of attribute names
  48103. * @param samplers defines an array of string used to represent textures
  48104. * @param defines defines the string containing the defines to use to compile the shaders
  48105. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  48106. * @param onCompiled defines a function to call when the effect creation is successful
  48107. * @param onError defines a function to call when the effect creation has failed
  48108. * @returns the new Effect
  48109. */
  48110. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  48111. }
  48112. interface Mesh {
  48113. /**
  48114. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  48115. * @returns an array of IParticleSystem
  48116. */
  48117. getEmittedParticleSystems(): IParticleSystem[];
  48118. /**
  48119. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  48120. * @returns an array of IParticleSystem
  48121. */
  48122. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  48123. }
  48124. /**
  48125. * @hidden
  48126. */
  48127. export var _IDoNeedToBeInTheBuild: number;
  48128. }
  48129. declare module BABYLON {
  48130. interface Scene {
  48131. /** @hidden (Backing field) */
  48132. _physicsEngine: Nullable<IPhysicsEngine>;
  48133. /**
  48134. * Gets the current physics engine
  48135. * @returns a IPhysicsEngine or null if none attached
  48136. */
  48137. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  48138. /**
  48139. * Enables physics to the current scene
  48140. * @param gravity defines the scene's gravity for the physics engine
  48141. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  48142. * @return a boolean indicating if the physics engine was initialized
  48143. */
  48144. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  48145. /**
  48146. * Disables and disposes the physics engine associated with the scene
  48147. */
  48148. disablePhysicsEngine(): void;
  48149. /**
  48150. * Gets a boolean indicating if there is an active physics engine
  48151. * @returns a boolean indicating if there is an active physics engine
  48152. */
  48153. isPhysicsEnabled(): boolean;
  48154. /**
  48155. * Deletes a physics compound impostor
  48156. * @param compound defines the compound to delete
  48157. */
  48158. deleteCompoundImpostor(compound: any): void;
  48159. /**
  48160. * An event triggered when physic simulation is about to be run
  48161. */
  48162. onBeforePhysicsObservable: Observable<Scene>;
  48163. /**
  48164. * An event triggered when physic simulation has been done
  48165. */
  48166. onAfterPhysicsObservable: Observable<Scene>;
  48167. }
  48168. interface AbstractMesh {
  48169. /** @hidden */
  48170. _physicsImpostor: Nullable<PhysicsImpostor>;
  48171. /**
  48172. * Gets or sets impostor used for physic simulation
  48173. * @see http://doc.babylonjs.com/features/physics_engine
  48174. */
  48175. physicsImpostor: Nullable<PhysicsImpostor>;
  48176. /**
  48177. * Gets the current physics impostor
  48178. * @see http://doc.babylonjs.com/features/physics_engine
  48179. * @returns a physics impostor or null
  48180. */
  48181. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  48182. /** Apply a physic impulse to the mesh
  48183. * @param force defines the force to apply
  48184. * @param contactPoint defines where to apply the force
  48185. * @returns the current mesh
  48186. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48187. */
  48188. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  48189. /**
  48190. * Creates a physic joint between two meshes
  48191. * @param otherMesh defines the other mesh to use
  48192. * @param pivot1 defines the pivot to use on this mesh
  48193. * @param pivot2 defines the pivot to use on the other mesh
  48194. * @param options defines additional options (can be plugin dependent)
  48195. * @returns the current mesh
  48196. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  48197. */
  48198. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  48199. /** @hidden */
  48200. _disposePhysicsObserver: Nullable<Observer<Node>>;
  48201. }
  48202. /**
  48203. * Defines the physics engine scene component responsible to manage a physics engine
  48204. */
  48205. export class PhysicsEngineSceneComponent implements ISceneComponent {
  48206. /**
  48207. * The component name helpful to identify the component in the list of scene components.
  48208. */
  48209. readonly name: string;
  48210. /**
  48211. * The scene the component belongs to.
  48212. */
  48213. scene: Scene;
  48214. /**
  48215. * Creates a new instance of the component for the given scene
  48216. * @param scene Defines the scene to register the component in
  48217. */
  48218. constructor(scene: Scene);
  48219. /**
  48220. * Registers the component in a given scene
  48221. */
  48222. register(): void;
  48223. /**
  48224. * Rebuilds the elements related to this component in case of
  48225. * context lost for instance.
  48226. */
  48227. rebuild(): void;
  48228. /**
  48229. * Disposes the component and the associated ressources
  48230. */
  48231. dispose(): void;
  48232. }
  48233. }
  48234. declare module BABYLON {
  48235. /**
  48236. * A helper for physics simulations
  48237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48238. */
  48239. export class PhysicsHelper {
  48240. private _scene;
  48241. private _physicsEngine;
  48242. /**
  48243. * Initializes the Physics helper
  48244. * @param scene Babylon.js scene
  48245. */
  48246. constructor(scene: Scene);
  48247. /**
  48248. * Applies a radial explosion impulse
  48249. * @param origin the origin of the explosion
  48250. * @param radius the explosion radius
  48251. * @param strength the explosion strength
  48252. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48253. * @returns A physics radial explosion event, or null
  48254. */
  48255. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48256. /**
  48257. * Applies a radial explosion force
  48258. * @param origin the origin of the explosion
  48259. * @param radius the explosion radius
  48260. * @param strength the explosion strength
  48261. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48262. * @returns A physics radial explosion event, or null
  48263. */
  48264. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48265. /**
  48266. * Creates a gravitational field
  48267. * @param origin the origin of the explosion
  48268. * @param radius the explosion radius
  48269. * @param strength the explosion strength
  48270. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48271. * @returns A physics gravitational field event, or null
  48272. */
  48273. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48274. /**
  48275. * Creates a physics updraft event
  48276. * @param origin the origin of the updraft
  48277. * @param radius the radius of the updraft
  48278. * @param strength the strength of the updraft
  48279. * @param height the height of the updraft
  48280. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48281. * @returns A physics updraft event, or null
  48282. */
  48283. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48284. /**
  48285. * Creates a physics vortex event
  48286. * @param origin the of the vortex
  48287. * @param radius the radius of the vortex
  48288. * @param strength the strength of the vortex
  48289. * @param height the height of the vortex
  48290. * @returns a Physics vortex event, or null
  48291. * A physics vortex event or null
  48292. */
  48293. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48294. }
  48295. /**
  48296. * Represents a physics radial explosion event
  48297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48298. */
  48299. export class PhysicsRadialExplosionEvent {
  48300. private _scene;
  48301. private _sphere;
  48302. private _sphereOptions;
  48303. private _rays;
  48304. private _dataFetched;
  48305. /**
  48306. * Initializes a radial explosioin event
  48307. * @param scene BabylonJS scene
  48308. */
  48309. constructor(scene: Scene);
  48310. /**
  48311. * Returns the data related to the radial explosion event (sphere & rays).
  48312. * @returns The radial explosion event data
  48313. */
  48314. getData(): PhysicsRadialExplosionEventData;
  48315. /**
  48316. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48317. * @param impostor A physics imposter
  48318. * @param origin the origin of the explosion
  48319. * @param radius the explosion radius
  48320. * @param strength the explosion strength
  48321. * @param falloff possible options: Constant & Linear
  48322. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48323. */
  48324. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48325. /**
  48326. * Disposes the sphere.
  48327. * @param force Specifies if the sphere should be disposed by force
  48328. */
  48329. dispose(force?: boolean): void;
  48330. /*** Helpers ***/
  48331. private _prepareSphere;
  48332. private _intersectsWithSphere;
  48333. }
  48334. /**
  48335. * Represents a gravitational field event
  48336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48337. */
  48338. export class PhysicsGravitationalFieldEvent {
  48339. private _physicsHelper;
  48340. private _scene;
  48341. private _origin;
  48342. private _radius;
  48343. private _strength;
  48344. private _falloff;
  48345. private _tickCallback;
  48346. private _sphere;
  48347. private _dataFetched;
  48348. /**
  48349. * Initializes the physics gravitational field event
  48350. * @param physicsHelper A physics helper
  48351. * @param scene BabylonJS scene
  48352. * @param origin The origin position of the gravitational field event
  48353. * @param radius The radius of the gravitational field event
  48354. * @param strength The strength of the gravitational field event
  48355. * @param falloff The falloff for the gravitational field event
  48356. */
  48357. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48358. /**
  48359. * Returns the data related to the gravitational field event (sphere).
  48360. * @returns A gravitational field event
  48361. */
  48362. getData(): PhysicsGravitationalFieldEventData;
  48363. /**
  48364. * Enables the gravitational field.
  48365. */
  48366. enable(): void;
  48367. /**
  48368. * Disables the gravitational field.
  48369. */
  48370. disable(): void;
  48371. /**
  48372. * Disposes the sphere.
  48373. * @param force The force to dispose from the gravitational field event
  48374. */
  48375. dispose(force?: boolean): void;
  48376. private _tick;
  48377. }
  48378. /**
  48379. * Represents a physics updraft event
  48380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48381. */
  48382. export class PhysicsUpdraftEvent {
  48383. private _scene;
  48384. private _origin;
  48385. private _radius;
  48386. private _strength;
  48387. private _height;
  48388. private _updraftMode;
  48389. private _physicsEngine;
  48390. private _originTop;
  48391. private _originDirection;
  48392. private _tickCallback;
  48393. private _cylinder;
  48394. private _cylinderPosition;
  48395. private _dataFetched;
  48396. /**
  48397. * Initializes the physics updraft event
  48398. * @param _scene BabylonJS scene
  48399. * @param _origin The origin position of the updraft
  48400. * @param _radius The radius of the updraft
  48401. * @param _strength The strength of the updraft
  48402. * @param _height The height of the updraft
  48403. * @param _updraftMode The mode of the updraft
  48404. */
  48405. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48406. /**
  48407. * Returns the data related to the updraft event (cylinder).
  48408. * @returns A physics updraft event
  48409. */
  48410. getData(): PhysicsUpdraftEventData;
  48411. /**
  48412. * Enables the updraft.
  48413. */
  48414. enable(): void;
  48415. /**
  48416. * Disables the cortex.
  48417. */
  48418. disable(): void;
  48419. /**
  48420. * Disposes the sphere.
  48421. * @param force Specifies if the updraft should be disposed by force
  48422. */
  48423. dispose(force?: boolean): void;
  48424. private getImpostorForceAndContactPoint;
  48425. private _tick;
  48426. /*** Helpers ***/
  48427. private _prepareCylinder;
  48428. private _intersectsWithCylinder;
  48429. }
  48430. /**
  48431. * Represents a physics vortex event
  48432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48433. */
  48434. export class PhysicsVortexEvent {
  48435. private _scene;
  48436. private _origin;
  48437. private _radius;
  48438. private _strength;
  48439. private _height;
  48440. private _physicsEngine;
  48441. private _originTop;
  48442. private _centripetalForceThreshold;
  48443. private _updraftMultiplier;
  48444. private _tickCallback;
  48445. private _cylinder;
  48446. private _cylinderPosition;
  48447. private _dataFetched;
  48448. /**
  48449. * Initializes the physics vortex event
  48450. * @param _scene The BabylonJS scene
  48451. * @param _origin The origin position of the vortex
  48452. * @param _radius The radius of the vortex
  48453. * @param _strength The strength of the vortex
  48454. * @param _height The height of the vortex
  48455. */
  48456. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48457. /**
  48458. * Returns the data related to the vortex event (cylinder).
  48459. * @returns The physics vortex event data
  48460. */
  48461. getData(): PhysicsVortexEventData;
  48462. /**
  48463. * Enables the vortex.
  48464. */
  48465. enable(): void;
  48466. /**
  48467. * Disables the cortex.
  48468. */
  48469. disable(): void;
  48470. /**
  48471. * Disposes the sphere.
  48472. * @param force
  48473. */
  48474. dispose(force?: boolean): void;
  48475. private getImpostorForceAndContactPoint;
  48476. private _tick;
  48477. /*** Helpers ***/
  48478. private _prepareCylinder;
  48479. private _intersectsWithCylinder;
  48480. }
  48481. /**
  48482. * The strenght of the force in correspondence to the distance of the affected object
  48483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48484. */
  48485. export enum PhysicsRadialImpulseFalloff {
  48486. /** Defines that impulse is constant in strength across it's whole radius */
  48487. Constant = 0,
  48488. /** DEfines that impulse gets weaker if it's further from the origin */
  48489. Linear = 1
  48490. }
  48491. /**
  48492. * The strength of the force in correspondence to the distance of the affected object
  48493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48494. */
  48495. export enum PhysicsUpdraftMode {
  48496. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48497. Center = 0,
  48498. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48499. Perpendicular = 1
  48500. }
  48501. /**
  48502. * Interface for a physics force and contact point
  48503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48504. */
  48505. export interface PhysicsForceAndContactPoint {
  48506. /**
  48507. * The force applied at the contact point
  48508. */
  48509. force: Vector3;
  48510. /**
  48511. * The contact point
  48512. */
  48513. contactPoint: Vector3;
  48514. }
  48515. /**
  48516. * Interface for radial explosion event data
  48517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48518. */
  48519. export interface PhysicsRadialExplosionEventData {
  48520. /**
  48521. * A sphere used for the radial explosion event
  48522. */
  48523. sphere: Mesh;
  48524. /**
  48525. * An array of rays for the radial explosion event
  48526. */
  48527. rays: Array<Ray>;
  48528. }
  48529. /**
  48530. * Interface for gravitational field event data
  48531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48532. */
  48533. export interface PhysicsGravitationalFieldEventData {
  48534. /**
  48535. * A sphere mesh used for the gravitational field event
  48536. */
  48537. sphere: Mesh;
  48538. }
  48539. /**
  48540. * Interface for updraft event data
  48541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48542. */
  48543. export interface PhysicsUpdraftEventData {
  48544. /**
  48545. * A cylinder used for the updraft event
  48546. */
  48547. cylinder: Mesh;
  48548. }
  48549. /**
  48550. * Interface for vortex event data
  48551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48552. */
  48553. export interface PhysicsVortexEventData {
  48554. /**
  48555. * A cylinder used for the vortex event
  48556. */
  48557. cylinder: Mesh;
  48558. }
  48559. }
  48560. declare module BABYLON {
  48561. /**
  48562. * AmmoJS Physics plugin
  48563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48564. * @see https://github.com/kripken/ammo.js/
  48565. */
  48566. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48567. private _useDeltaForWorldStep;
  48568. /**
  48569. * Reference to the Ammo library
  48570. */
  48571. bjsAMMO: any;
  48572. /**
  48573. * Created ammoJS world which physics bodies are added to
  48574. */
  48575. world: any;
  48576. /**
  48577. * Name of the plugin
  48578. */
  48579. name: string;
  48580. private _timeStep;
  48581. private _fixedTimeStep;
  48582. private _maxSteps;
  48583. private _tmpQuaternion;
  48584. private _tmpAmmoTransform;
  48585. private _tmpAmmoQuaternion;
  48586. private _tmpAmmoConcreteContactResultCallback;
  48587. private _collisionConfiguration;
  48588. private _dispatcher;
  48589. private _overlappingPairCache;
  48590. private _solver;
  48591. private _tmpAmmoVectorA;
  48592. private _tmpAmmoVectorB;
  48593. private _tmpAmmoVectorC;
  48594. private _tmpContactCallbackResult;
  48595. private static readonly DISABLE_COLLISION_FLAG;
  48596. private static readonly KINEMATIC_FLAG;
  48597. private static readonly DISABLE_DEACTIVATION_FLAG;
  48598. /**
  48599. * Initializes the ammoJS plugin
  48600. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48601. * @param ammoInjection can be used to inject your own ammo reference
  48602. */
  48603. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48604. /**
  48605. * Sets the gravity of the physics world (m/(s^2))
  48606. * @param gravity Gravity to set
  48607. */
  48608. setGravity(gravity: Vector3): void;
  48609. /**
  48610. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48611. * @param timeStep timestep to use in seconds
  48612. */
  48613. setTimeStep(timeStep: number): void;
  48614. /**
  48615. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  48616. * @param fixedTimeStep fixedTimeStep to use in seconds
  48617. */
  48618. setFixedTimeStep(fixedTimeStep: number): void;
  48619. /**
  48620. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48621. * @param maxSteps the maximum number of steps by the physics engine per frame
  48622. */
  48623. setMaxSteps(maxSteps: number): void;
  48624. /**
  48625. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48626. * @returns the current timestep in seconds
  48627. */
  48628. getTimeStep(): number;
  48629. private _isImpostorInContact;
  48630. private _isImpostorPairInContact;
  48631. private _stepSimulation;
  48632. /**
  48633. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48634. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48635. * After the step the babylon meshes are set to the position of the physics imposters
  48636. * @param delta amount of time to step forward
  48637. * @param impostors array of imposters to update before/after the step
  48638. */
  48639. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48640. private _tmpVector;
  48641. private _tmpMatrix;
  48642. /**
  48643. * Applies an implulse on the imposter
  48644. * @param impostor imposter to apply impulse
  48645. * @param force amount of force to be applied to the imposter
  48646. * @param contactPoint the location to apply the impulse on the imposter
  48647. */
  48648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48649. /**
  48650. * Applies a force on the imposter
  48651. * @param impostor imposter to apply force
  48652. * @param force amount of force to be applied to the imposter
  48653. * @param contactPoint the location to apply the force on the imposter
  48654. */
  48655. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48656. /**
  48657. * Creates a physics body using the plugin
  48658. * @param impostor the imposter to create the physics body on
  48659. */
  48660. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48661. /**
  48662. * Removes the physics body from the imposter and disposes of the body's memory
  48663. * @param impostor imposter to remove the physics body from
  48664. */
  48665. removePhysicsBody(impostor: PhysicsImpostor): void;
  48666. /**
  48667. * Generates a joint
  48668. * @param impostorJoint the imposter joint to create the joint with
  48669. */
  48670. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48671. /**
  48672. * Removes a joint
  48673. * @param impostorJoint the imposter joint to remove the joint from
  48674. */
  48675. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48676. private _addMeshVerts;
  48677. private _createShape;
  48678. /**
  48679. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48680. * @param impostor imposter containing the physics body and babylon object
  48681. */
  48682. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48683. /**
  48684. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48685. * @param impostor imposter containing the physics body and babylon object
  48686. * @param newPosition new position
  48687. * @param newRotation new rotation
  48688. */
  48689. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48690. /**
  48691. * If this plugin is supported
  48692. * @returns true if its supported
  48693. */
  48694. isSupported(): boolean;
  48695. /**
  48696. * Sets the linear velocity of the physics body
  48697. * @param impostor imposter to set the velocity on
  48698. * @param velocity velocity to set
  48699. */
  48700. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48701. /**
  48702. * Sets the angular velocity of the physics body
  48703. * @param impostor imposter to set the velocity on
  48704. * @param velocity velocity to set
  48705. */
  48706. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48707. /**
  48708. * gets the linear velocity
  48709. * @param impostor imposter to get linear velocity from
  48710. * @returns linear velocity
  48711. */
  48712. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48713. /**
  48714. * gets the angular velocity
  48715. * @param impostor imposter to get angular velocity from
  48716. * @returns angular velocity
  48717. */
  48718. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48719. /**
  48720. * Sets the mass of physics body
  48721. * @param impostor imposter to set the mass on
  48722. * @param mass mass to set
  48723. */
  48724. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48725. /**
  48726. * Gets the mass of the physics body
  48727. * @param impostor imposter to get the mass from
  48728. * @returns mass
  48729. */
  48730. getBodyMass(impostor: PhysicsImpostor): number;
  48731. /**
  48732. * Gets friction of the impostor
  48733. * @param impostor impostor to get friction from
  48734. * @returns friction value
  48735. */
  48736. getBodyFriction(impostor: PhysicsImpostor): number;
  48737. /**
  48738. * Sets friction of the impostor
  48739. * @param impostor impostor to set friction on
  48740. * @param friction friction value
  48741. */
  48742. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48743. /**
  48744. * Gets restitution of the impostor
  48745. * @param impostor impostor to get restitution from
  48746. * @returns restitution value
  48747. */
  48748. getBodyRestitution(impostor: PhysicsImpostor): number;
  48749. /**
  48750. * Sets resitution of the impostor
  48751. * @param impostor impostor to set resitution on
  48752. * @param restitution resitution value
  48753. */
  48754. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48755. /**
  48756. * Sleeps the physics body and stops it from being active
  48757. * @param impostor impostor to sleep
  48758. */
  48759. sleepBody(impostor: PhysicsImpostor): void;
  48760. /**
  48761. * Activates the physics body
  48762. * @param impostor impostor to activate
  48763. */
  48764. wakeUpBody(impostor: PhysicsImpostor): void;
  48765. /**
  48766. * Updates the distance parameters of the joint
  48767. * @param joint joint to update
  48768. * @param maxDistance maximum distance of the joint
  48769. * @param minDistance minimum distance of the joint
  48770. */
  48771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48772. /**
  48773. * Sets a motor on the joint
  48774. * @param joint joint to set motor on
  48775. * @param speed speed of the motor
  48776. * @param maxForce maximum force of the motor
  48777. * @param motorIndex index of the motor
  48778. */
  48779. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48780. /**
  48781. * Sets the motors limit
  48782. * @param joint joint to set limit on
  48783. * @param upperLimit upper limit
  48784. * @param lowerLimit lower limit
  48785. */
  48786. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48787. /**
  48788. * Syncs the position and rotation of a mesh with the impostor
  48789. * @param mesh mesh to sync
  48790. * @param impostor impostor to update the mesh with
  48791. */
  48792. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48793. /**
  48794. * Gets the radius of the impostor
  48795. * @param impostor impostor to get radius from
  48796. * @returns the radius
  48797. */
  48798. getRadius(impostor: PhysicsImpostor): number;
  48799. /**
  48800. * Gets the box size of the impostor
  48801. * @param impostor impostor to get box size from
  48802. * @param result the resulting box size
  48803. */
  48804. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48805. /**
  48806. * Disposes of the impostor
  48807. */
  48808. dispose(): void;
  48809. }
  48810. }
  48811. declare module BABYLON {
  48812. /** @hidden */
  48813. export var blackAndWhitePixelShader: {
  48814. name: string;
  48815. shader: string;
  48816. };
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * Post process used to render in black and white
  48821. */
  48822. export class BlackAndWhitePostProcess extends PostProcess {
  48823. /**
  48824. * Linear about to convert he result to black and white (default: 1)
  48825. */
  48826. degree: number;
  48827. /**
  48828. * Creates a black and white post process
  48829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  48830. * @param name The name of the effect.
  48831. * @param options The required width/height ratio to downsize to before computing the render pass.
  48832. * @param camera The camera to apply the render pass to.
  48833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48834. * @param engine The engine which the post process will be applied. (default: current engine)
  48835. * @param reusable If the post process can be reused on the same frame. (default: false)
  48836. */
  48837. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * This represents a set of one or more post processes in Babylon.
  48843. * A post process can be used to apply a shader to a texture after it is rendered.
  48844. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48845. */
  48846. export class PostProcessRenderEffect {
  48847. private _postProcesses;
  48848. private _getPostProcesses;
  48849. private _singleInstance;
  48850. private _cameras;
  48851. private _indicesForCamera;
  48852. /**
  48853. * Name of the effect
  48854. * @hidden
  48855. */
  48856. _name: string;
  48857. /**
  48858. * Instantiates a post process render effect.
  48859. * A post process can be used to apply a shader to a texture after it is rendered.
  48860. * @param engine The engine the effect is tied to
  48861. * @param name The name of the effect
  48862. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48863. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48864. */
  48865. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48866. /**
  48867. * Checks if all the post processes in the effect are supported.
  48868. */
  48869. readonly isSupported: boolean;
  48870. /**
  48871. * Updates the current state of the effect
  48872. * @hidden
  48873. */
  48874. _update(): void;
  48875. /**
  48876. * Attaches the effect on cameras
  48877. * @param cameras The camera to attach to.
  48878. * @hidden
  48879. */
  48880. _attachCameras(cameras: Camera): void;
  48881. /**
  48882. * Attaches the effect on cameras
  48883. * @param cameras The camera to attach to.
  48884. * @hidden
  48885. */
  48886. _attachCameras(cameras: Camera[]): void;
  48887. /**
  48888. * Detatches the effect on cameras
  48889. * @param cameras The camera to detatch from.
  48890. * @hidden
  48891. */
  48892. _detachCameras(cameras: Camera): void;
  48893. /**
  48894. * Detatches the effect on cameras
  48895. * @param cameras The camera to detatch from.
  48896. * @hidden
  48897. */
  48898. _detachCameras(cameras: Camera[]): void;
  48899. /**
  48900. * Enables the effect on given cameras
  48901. * @param cameras The camera to enable.
  48902. * @hidden
  48903. */
  48904. _enable(cameras: Camera): void;
  48905. /**
  48906. * Enables the effect on given cameras
  48907. * @param cameras The camera to enable.
  48908. * @hidden
  48909. */
  48910. _enable(cameras: Nullable<Camera[]>): void;
  48911. /**
  48912. * Disables the effect on the given cameras
  48913. * @param cameras The camera to disable.
  48914. * @hidden
  48915. */
  48916. _disable(cameras: Camera): void;
  48917. /**
  48918. * Disables the effect on the given cameras
  48919. * @param cameras The camera to disable.
  48920. * @hidden
  48921. */
  48922. _disable(cameras: Nullable<Camera[]>): void;
  48923. /**
  48924. * Gets a list of the post processes contained in the effect.
  48925. * @param camera The camera to get the post processes on.
  48926. * @returns The list of the post processes in the effect.
  48927. */
  48928. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48929. }
  48930. }
  48931. declare module BABYLON {
  48932. /** @hidden */
  48933. export var extractHighlightsPixelShader: {
  48934. name: string;
  48935. shader: string;
  48936. };
  48937. }
  48938. declare module BABYLON {
  48939. /**
  48940. * 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.
  48941. */
  48942. export class ExtractHighlightsPostProcess extends PostProcess {
  48943. /**
  48944. * The luminance threshold, pixels below this value will be set to black.
  48945. */
  48946. threshold: number;
  48947. /** @hidden */
  48948. _exposure: number;
  48949. /**
  48950. * Post process which has the input texture to be used when performing highlight extraction
  48951. * @hidden
  48952. */
  48953. _inputPostProcess: Nullable<PostProcess>;
  48954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48955. }
  48956. }
  48957. declare module BABYLON {
  48958. /** @hidden */
  48959. export var bloomMergePixelShader: {
  48960. name: string;
  48961. shader: string;
  48962. };
  48963. }
  48964. declare module BABYLON {
  48965. /**
  48966. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  48967. */
  48968. export class BloomMergePostProcess extends PostProcess {
  48969. /** Weight of the bloom to be added to the original input. */
  48970. weight: number;
  48971. /**
  48972. * Creates a new instance of @see BloomMergePostProcess
  48973. * @param name The name of the effect.
  48974. * @param originalFromInput Post process which's input will be used for the merge.
  48975. * @param blurred Blurred highlights post process which's output will be used.
  48976. * @param weight Weight of the bloom to be added to the original input.
  48977. * @param options The required width/height ratio to downsize to before computing the render pass.
  48978. * @param camera The camera to apply the render pass to.
  48979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48980. * @param engine The engine which the post process will be applied. (default: current engine)
  48981. * @param reusable If the post process can be reused on the same frame. (default: false)
  48982. * @param textureType Type of textures used when performing the post process. (default: 0)
  48983. * @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)
  48984. */
  48985. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  48986. /** Weight of the bloom to be added to the original input. */
  48987. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48988. }
  48989. }
  48990. declare module BABYLON {
  48991. /**
  48992. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  48993. */
  48994. export class BloomEffect extends PostProcessRenderEffect {
  48995. private bloomScale;
  48996. /**
  48997. * @hidden Internal
  48998. */
  48999. _effects: Array<PostProcess>;
  49000. /**
  49001. * @hidden Internal
  49002. */
  49003. _downscale: ExtractHighlightsPostProcess;
  49004. private _blurX;
  49005. private _blurY;
  49006. private _merge;
  49007. /**
  49008. * The luminance threshold to find bright areas of the image to bloom.
  49009. */
  49010. threshold: number;
  49011. /**
  49012. * The strength of the bloom.
  49013. */
  49014. weight: number;
  49015. /**
  49016. * Specifies the size of the bloom blur kernel, relative to the final output size
  49017. */
  49018. kernel: number;
  49019. /**
  49020. * Creates a new instance of @see BloomEffect
  49021. * @param scene The scene the effect belongs to.
  49022. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  49023. * @param bloomKernel The size of the kernel to be used when applying the blur.
  49024. * @param bloomWeight The the strength of bloom.
  49025. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49026. * @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)
  49027. */
  49028. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  49029. /**
  49030. * Disposes each of the internal effects for a given camera.
  49031. * @param camera The camera to dispose the effect on.
  49032. */
  49033. disposeEffects(camera: Camera): void;
  49034. /**
  49035. * @hidden Internal
  49036. */
  49037. _updateEffects(): void;
  49038. /**
  49039. * Internal
  49040. * @returns if all the contained post processes are ready.
  49041. * @hidden
  49042. */
  49043. _isReady(): boolean;
  49044. }
  49045. }
  49046. declare module BABYLON {
  49047. /** @hidden */
  49048. export var chromaticAberrationPixelShader: {
  49049. name: string;
  49050. shader: string;
  49051. };
  49052. }
  49053. declare module BABYLON {
  49054. /**
  49055. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  49056. */
  49057. export class ChromaticAberrationPostProcess extends PostProcess {
  49058. /**
  49059. * The amount of seperation of rgb channels (default: 30)
  49060. */
  49061. aberrationAmount: number;
  49062. /**
  49063. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  49064. */
  49065. radialIntensity: number;
  49066. /**
  49067. * 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))
  49068. */
  49069. direction: Vector2;
  49070. /**
  49071. * 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))
  49072. */
  49073. centerPosition: Vector2;
  49074. /**
  49075. * Creates a new instance ChromaticAberrationPostProcess
  49076. * @param name The name of the effect.
  49077. * @param screenWidth The width of the screen to apply the effect on.
  49078. * @param screenHeight The height of the screen to apply the effect on.
  49079. * @param options The required width/height ratio to downsize to before computing the render pass.
  49080. * @param camera The camera to apply the render pass to.
  49081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49082. * @param engine The engine which the post process will be applied. (default: current engine)
  49083. * @param reusable If the post process can be reused on the same frame. (default: false)
  49084. * @param textureType Type of textures used when performing the post process. (default: 0)
  49085. * @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)
  49086. */
  49087. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49088. }
  49089. }
  49090. declare module BABYLON {
  49091. /** @hidden */
  49092. export var circleOfConfusionPixelShader: {
  49093. name: string;
  49094. shader: string;
  49095. };
  49096. }
  49097. declare module BABYLON {
  49098. /**
  49099. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  49100. */
  49101. export class CircleOfConfusionPostProcess extends PostProcess {
  49102. /**
  49103. * 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.
  49104. */
  49105. lensSize: number;
  49106. /**
  49107. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49108. */
  49109. fStop: number;
  49110. /**
  49111. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49112. */
  49113. focusDistance: number;
  49114. /**
  49115. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  49116. */
  49117. focalLength: number;
  49118. private _depthTexture;
  49119. /**
  49120. * Creates a new instance CircleOfConfusionPostProcess
  49121. * @param name The name of the effect.
  49122. * @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.
  49123. * @param options The required width/height ratio to downsize to before computing the render pass.
  49124. * @param camera The camera to apply the render pass to.
  49125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49126. * @param engine The engine which the post process will be applied. (default: current engine)
  49127. * @param reusable If the post process can be reused on the same frame. (default: false)
  49128. * @param textureType Type of textures used when performing the post process. (default: 0)
  49129. * @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)
  49130. */
  49131. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49132. /**
  49133. * 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.
  49134. */
  49135. depthTexture: RenderTargetTexture;
  49136. }
  49137. }
  49138. declare module BABYLON {
  49139. /** @hidden */
  49140. export var colorCorrectionPixelShader: {
  49141. name: string;
  49142. shader: string;
  49143. };
  49144. }
  49145. declare module BABYLON {
  49146. /**
  49147. *
  49148. * This post-process allows the modification of rendered colors by using
  49149. * a 'look-up table' (LUT). This effect is also called Color Grading.
  49150. *
  49151. * The object needs to be provided an url to a texture containing the color
  49152. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  49153. * Use an image editing software to tweak the LUT to match your needs.
  49154. *
  49155. * For an example of a color LUT, see here:
  49156. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  49157. * For explanations on color grading, see here:
  49158. * @see http://udn.epicgames.com/Three/ColorGrading.html
  49159. *
  49160. */
  49161. export class ColorCorrectionPostProcess extends PostProcess {
  49162. private _colorTableTexture;
  49163. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49164. }
  49165. }
  49166. declare module BABYLON {
  49167. /** @hidden */
  49168. export var convolutionPixelShader: {
  49169. name: string;
  49170. shader: string;
  49171. };
  49172. }
  49173. declare module BABYLON {
  49174. /**
  49175. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  49176. * input texture to perform effects such as edge detection or sharpening
  49177. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49178. */
  49179. export class ConvolutionPostProcess extends PostProcess {
  49180. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49181. kernel: number[];
  49182. /**
  49183. * Creates a new instance ConvolutionPostProcess
  49184. * @param name The name of the effect.
  49185. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  49186. * @param options The required width/height ratio to downsize to before computing the render pass.
  49187. * @param camera The camera to apply the render pass to.
  49188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49189. * @param engine The engine which the post process will be applied. (default: current engine)
  49190. * @param reusable If the post process can be reused on the same frame. (default: false)
  49191. * @param textureType Type of textures used when performing the post process. (default: 0)
  49192. */
  49193. constructor(name: string,
  49194. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49195. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49196. /**
  49197. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49198. */
  49199. static EdgeDetect0Kernel: number[];
  49200. /**
  49201. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49202. */
  49203. static EdgeDetect1Kernel: number[];
  49204. /**
  49205. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49206. */
  49207. static EdgeDetect2Kernel: number[];
  49208. /**
  49209. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49210. */
  49211. static SharpenKernel: number[];
  49212. /**
  49213. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49214. */
  49215. static EmbossKernel: number[];
  49216. /**
  49217. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49218. */
  49219. static GaussianKernel: number[];
  49220. }
  49221. }
  49222. declare module BABYLON {
  49223. /**
  49224. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  49225. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  49226. * based on samples that have a large difference in distance than the center pixel.
  49227. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  49228. */
  49229. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  49230. direction: Vector2;
  49231. /**
  49232. * Creates a new instance CircleOfConfusionPostProcess
  49233. * @param name The name of the effect.
  49234. * @param scene The scene the effect belongs to.
  49235. * @param direction The direction the blur should be applied.
  49236. * @param kernel The size of the kernel used to blur.
  49237. * @param options The required width/height ratio to downsize to before computing the render pass.
  49238. * @param camera The camera to apply the render pass to.
  49239. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49240. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49242. * @param engine The engine which the post process will be applied. (default: current engine)
  49243. * @param reusable If the post process can be reused on the same frame. (default: false)
  49244. * @param textureType Type of textures used when performing the post process. (default: 0)
  49245. * @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)
  49246. */
  49247. 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);
  49248. }
  49249. }
  49250. declare module BABYLON {
  49251. /** @hidden */
  49252. export var depthOfFieldMergePixelShader: {
  49253. name: string;
  49254. shader: string;
  49255. };
  49256. }
  49257. declare module BABYLON {
  49258. /**
  49259. * Options to be set when merging outputs from the default pipeline.
  49260. */
  49261. export class DepthOfFieldMergePostProcessOptions {
  49262. /**
  49263. * The original image to merge on top of
  49264. */
  49265. originalFromInput: PostProcess;
  49266. /**
  49267. * Parameters to perform the merge of the depth of field effect
  49268. */
  49269. depthOfField?: {
  49270. circleOfConfusion: PostProcess;
  49271. blurSteps: Array<PostProcess>;
  49272. };
  49273. /**
  49274. * Parameters to perform the merge of bloom effect
  49275. */
  49276. bloom?: {
  49277. blurred: PostProcess;
  49278. weight: number;
  49279. };
  49280. }
  49281. /**
  49282. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49283. */
  49284. export class DepthOfFieldMergePostProcess extends PostProcess {
  49285. private blurSteps;
  49286. /**
  49287. * Creates a new instance of DepthOfFieldMergePostProcess
  49288. * @param name The name of the effect.
  49289. * @param originalFromInput Post process which's input will be used for the merge.
  49290. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49291. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49292. * @param options The required width/height ratio to downsize to before computing the render pass.
  49293. * @param camera The camera to apply the render pass to.
  49294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49295. * @param engine The engine which the post process will be applied. (default: current engine)
  49296. * @param reusable If the post process can be reused on the same frame. (default: false)
  49297. * @param textureType Type of textures used when performing the post process. (default: 0)
  49298. * @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)
  49299. */
  49300. 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);
  49301. /**
  49302. * Updates the effect with the current post process compile time values and recompiles the shader.
  49303. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49304. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49305. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49306. * @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
  49307. * @param onCompiled Called when the shader has been compiled.
  49308. * @param onError Called if there is an error when compiling a shader.
  49309. */
  49310. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49311. }
  49312. }
  49313. declare module BABYLON {
  49314. /**
  49315. * Specifies the level of max blur that should be applied when using the depth of field effect
  49316. */
  49317. export enum DepthOfFieldEffectBlurLevel {
  49318. /**
  49319. * Subtle blur
  49320. */
  49321. Low = 0,
  49322. /**
  49323. * Medium blur
  49324. */
  49325. Medium = 1,
  49326. /**
  49327. * Large blur
  49328. */
  49329. High = 2
  49330. }
  49331. /**
  49332. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49333. */
  49334. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49335. private _circleOfConfusion;
  49336. /**
  49337. * @hidden Internal, blurs from high to low
  49338. */
  49339. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49340. private _depthOfFieldBlurY;
  49341. private _dofMerge;
  49342. /**
  49343. * @hidden Internal post processes in depth of field effect
  49344. */
  49345. _effects: Array<PostProcess>;
  49346. /**
  49347. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49348. */
  49349. focalLength: number;
  49350. /**
  49351. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49352. */
  49353. fStop: number;
  49354. /**
  49355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49356. */
  49357. focusDistance: number;
  49358. /**
  49359. * 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.
  49360. */
  49361. lensSize: number;
  49362. /**
  49363. * Creates a new instance DepthOfFieldEffect
  49364. * @param scene The scene the effect belongs to.
  49365. * @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.
  49366. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49367. * @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)
  49368. */
  49369. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49370. /**
  49371. * 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.
  49372. */
  49373. depthTexture: RenderTargetTexture;
  49374. /**
  49375. * Disposes each of the internal effects for a given camera.
  49376. * @param camera The camera to dispose the effect on.
  49377. */
  49378. disposeEffects(camera: Camera): void;
  49379. /**
  49380. * @hidden Internal
  49381. */
  49382. _updateEffects(): void;
  49383. /**
  49384. * Internal
  49385. * @returns if all the contained post processes are ready.
  49386. * @hidden
  49387. */
  49388. _isReady(): boolean;
  49389. }
  49390. }
  49391. declare module BABYLON {
  49392. /** @hidden */
  49393. export var displayPassPixelShader: {
  49394. name: string;
  49395. shader: string;
  49396. };
  49397. }
  49398. declare module BABYLON {
  49399. /**
  49400. * DisplayPassPostProcess which produces an output the same as it's input
  49401. */
  49402. export class DisplayPassPostProcess extends PostProcess {
  49403. /**
  49404. * Creates the DisplayPassPostProcess
  49405. * @param name The name of the effect.
  49406. * @param options The required width/height ratio to downsize to before computing the render pass.
  49407. * @param camera The camera to apply the render pass to.
  49408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49409. * @param engine The engine which the post process will be applied. (default: current engine)
  49410. * @param reusable If the post process can be reused on the same frame. (default: false)
  49411. */
  49412. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49413. }
  49414. }
  49415. declare module BABYLON {
  49416. /** @hidden */
  49417. export var filterPixelShader: {
  49418. name: string;
  49419. shader: string;
  49420. };
  49421. }
  49422. declare module BABYLON {
  49423. /**
  49424. * Applies a kernel filter to the image
  49425. */
  49426. export class FilterPostProcess extends PostProcess {
  49427. /** The matrix to be applied to the image */
  49428. kernelMatrix: Matrix;
  49429. /**
  49430. *
  49431. * @param name The name of the effect.
  49432. * @param kernelMatrix The matrix to be applied to the image
  49433. * @param options The required width/height ratio to downsize to before computing the render pass.
  49434. * @param camera The camera to apply the render pass to.
  49435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49436. * @param engine The engine which the post process will be applied. (default: current engine)
  49437. * @param reusable If the post process can be reused on the same frame. (default: false)
  49438. */
  49439. constructor(name: string,
  49440. /** The matrix to be applied to the image */
  49441. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49442. }
  49443. }
  49444. declare module BABYLON {
  49445. /** @hidden */
  49446. export var fxaaPixelShader: {
  49447. name: string;
  49448. shader: string;
  49449. };
  49450. }
  49451. declare module BABYLON {
  49452. /** @hidden */
  49453. export var fxaaVertexShader: {
  49454. name: string;
  49455. shader: string;
  49456. };
  49457. }
  49458. declare module BABYLON {
  49459. /**
  49460. * Fxaa post process
  49461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49462. */
  49463. export class FxaaPostProcess extends PostProcess {
  49464. /** @hidden */
  49465. texelWidth: number;
  49466. /** @hidden */
  49467. texelHeight: number;
  49468. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49469. private _getDefines;
  49470. }
  49471. }
  49472. declare module BABYLON {
  49473. /** @hidden */
  49474. export var grainPixelShader: {
  49475. name: string;
  49476. shader: string;
  49477. };
  49478. }
  49479. declare module BABYLON {
  49480. /**
  49481. * The GrainPostProcess adds noise to the image at mid luminance levels
  49482. */
  49483. export class GrainPostProcess extends PostProcess {
  49484. /**
  49485. * The intensity of the grain added (default: 30)
  49486. */
  49487. intensity: number;
  49488. /**
  49489. * If the grain should be randomized on every frame
  49490. */
  49491. animated: boolean;
  49492. /**
  49493. * Creates a new instance of @see GrainPostProcess
  49494. * @param name The name of the effect.
  49495. * @param options The required width/height ratio to downsize to before computing the render pass.
  49496. * @param camera The camera to apply the render pass to.
  49497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49498. * @param engine The engine which the post process will be applied. (default: current engine)
  49499. * @param reusable If the post process can be reused on the same frame. (default: false)
  49500. * @param textureType Type of textures used when performing the post process. (default: 0)
  49501. * @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)
  49502. */
  49503. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49504. }
  49505. }
  49506. declare module BABYLON {
  49507. /** @hidden */
  49508. export var highlightsPixelShader: {
  49509. name: string;
  49510. shader: string;
  49511. };
  49512. }
  49513. declare module BABYLON {
  49514. /**
  49515. * Extracts highlights from the image
  49516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49517. */
  49518. export class HighlightsPostProcess extends PostProcess {
  49519. /**
  49520. * Extracts highlights from the image
  49521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49522. * @param name The name of the effect.
  49523. * @param options The required width/height ratio to downsize to before computing the render pass.
  49524. * @param camera The camera to apply the render pass to.
  49525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49526. * @param engine The engine which the post process will be applied. (default: current engine)
  49527. * @param reusable If the post process can be reused on the same frame. (default: false)
  49528. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49529. */
  49530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49531. }
  49532. }
  49533. declare module BABYLON {
  49534. /** @hidden */
  49535. export var mrtFragmentDeclaration: {
  49536. name: string;
  49537. shader: string;
  49538. };
  49539. }
  49540. declare module BABYLON {
  49541. /** @hidden */
  49542. export var geometryPixelShader: {
  49543. name: string;
  49544. shader: string;
  49545. };
  49546. }
  49547. declare module BABYLON {
  49548. /** @hidden */
  49549. export var geometryVertexShader: {
  49550. name: string;
  49551. shader: string;
  49552. };
  49553. }
  49554. declare module BABYLON {
  49555. /**
  49556. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49557. */
  49558. export class GeometryBufferRenderer {
  49559. /**
  49560. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49561. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49562. */
  49563. static readonly POSITION_TEXTURE_TYPE: number;
  49564. /**
  49565. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49566. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49567. */
  49568. static readonly VELOCITY_TEXTURE_TYPE: number;
  49569. /**
  49570. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49571. * in order to compute objects velocities when enableVelocity is set to "true"
  49572. * @hidden
  49573. */
  49574. _previousTransformationMatrices: {
  49575. [index: number]: Matrix;
  49576. };
  49577. private _scene;
  49578. private _multiRenderTarget;
  49579. private _ratio;
  49580. private _enablePosition;
  49581. private _enableVelocity;
  49582. private _positionIndex;
  49583. private _velocityIndex;
  49584. protected _effect: Effect;
  49585. protected _cachedDefines: string;
  49586. /**
  49587. * Set the render list (meshes to be rendered) used in the G buffer.
  49588. */
  49589. renderList: Mesh[];
  49590. /**
  49591. * Gets wether or not G buffer are supported by the running hardware.
  49592. * This requires draw buffer supports
  49593. */
  49594. readonly isSupported: boolean;
  49595. /**
  49596. * Returns the index of the given texture type in the G-Buffer textures array
  49597. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  49598. * @returns the index of the given texture type in the G-Buffer textures array
  49599. */
  49600. getTextureIndex(textureType: number): number;
  49601. /**
  49602. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  49603. */
  49604. /**
  49605. * Sets whether or not objects positions are enabled for the G buffer.
  49606. */
  49607. enablePosition: boolean;
  49608. /**
  49609. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  49610. */
  49611. /**
  49612. * Sets wether or not objects velocities are enabled for the G buffer.
  49613. */
  49614. enableVelocity: boolean;
  49615. /**
  49616. * Gets the scene associated with the buffer.
  49617. */
  49618. readonly scene: Scene;
  49619. /**
  49620. * Gets the ratio used by the buffer during its creation.
  49621. * How big is the buffer related to the main canvas.
  49622. */
  49623. readonly ratio: number;
  49624. /** @hidden */
  49625. static _SceneComponentInitialization: (scene: Scene) => void;
  49626. /**
  49627. * Creates a new G Buffer for the scene
  49628. * @param scene The scene the buffer belongs to
  49629. * @param ratio How big is the buffer related to the main canvas.
  49630. */
  49631. constructor(scene: Scene, ratio?: number);
  49632. /**
  49633. * Checks wether everything is ready to render a submesh to the G buffer.
  49634. * @param subMesh the submesh to check readiness for
  49635. * @param useInstances is the mesh drawn using instance or not
  49636. * @returns true if ready otherwise false
  49637. */
  49638. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49639. /**
  49640. * Gets the current underlying G Buffer.
  49641. * @returns the buffer
  49642. */
  49643. getGBuffer(): MultiRenderTarget;
  49644. /**
  49645. * Gets the number of samples used to render the buffer (anti aliasing).
  49646. */
  49647. /**
  49648. * Sets the number of samples used to render the buffer (anti aliasing).
  49649. */
  49650. samples: number;
  49651. /**
  49652. * Disposes the renderer and frees up associated resources.
  49653. */
  49654. dispose(): void;
  49655. protected _createRenderTargets(): void;
  49656. }
  49657. }
  49658. declare module BABYLON {
  49659. /** @hidden */
  49660. export var motionBlurPixelShader: {
  49661. name: string;
  49662. shader: string;
  49663. };
  49664. }
  49665. declare module BABYLON {
  49666. /**
  49667. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  49668. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  49669. * As an example, all you have to do is to create the post-process:
  49670. * var mb = new BABYLON.MotionBlurPostProcess(
  49671. * 'mb', // The name of the effect.
  49672. * scene, // The scene containing the objects to blur according to their velocity.
  49673. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  49674. * camera // The camera to apply the render pass to.
  49675. * );
  49676. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  49677. */
  49678. export class MotionBlurPostProcess extends PostProcess {
  49679. /**
  49680. * Defines how much the image is blurred by the movement. Default value is equal to 1
  49681. */
  49682. motionStrength: number;
  49683. /**
  49684. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  49685. */
  49686. /**
  49687. * Sets the number of iterations to be used for motion blur quality
  49688. */
  49689. motionBlurSamples: number;
  49690. private _motionBlurSamples;
  49691. private _geometryBufferRenderer;
  49692. /**
  49693. * Creates a new instance MotionBlurPostProcess
  49694. * @param name The name of the effect.
  49695. * @param scene The scene containing the objects to blur according to their velocity.
  49696. * @param options The required width/height ratio to downsize to before computing the render pass.
  49697. * @param camera The camera to apply the render pass to.
  49698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49699. * @param engine The engine which the post process will be applied. (default: current engine)
  49700. * @param reusable If the post process can be reused on the same frame. (default: false)
  49701. * @param textureType Type of textures used when performing the post process. (default: 0)
  49702. * @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)
  49703. */
  49704. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49705. /**
  49706. * Disposes the post process.
  49707. * @param camera The camera to dispose the post process on.
  49708. */
  49709. dispose(camera?: Camera): void;
  49710. }
  49711. }
  49712. declare module BABYLON {
  49713. /** @hidden */
  49714. export var refractionPixelShader: {
  49715. name: string;
  49716. shader: string;
  49717. };
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * Post process which applies a refractin texture
  49722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49723. */
  49724. export class RefractionPostProcess extends PostProcess {
  49725. /** the base color of the refraction (used to taint the rendering) */
  49726. color: Color3;
  49727. /** simulated refraction depth */
  49728. depth: number;
  49729. /** the coefficient of the base color (0 to remove base color tainting) */
  49730. colorLevel: number;
  49731. private _refTexture;
  49732. private _ownRefractionTexture;
  49733. /**
  49734. * Gets or sets the refraction texture
  49735. * Please note that you are responsible for disposing the texture if you set it manually
  49736. */
  49737. refractionTexture: Texture;
  49738. /**
  49739. * Initializes the RefractionPostProcess
  49740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49741. * @param name The name of the effect.
  49742. * @param refractionTextureUrl Url of the refraction texture to use
  49743. * @param color the base color of the refraction (used to taint the rendering)
  49744. * @param depth simulated refraction depth
  49745. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  49746. * @param camera The camera to apply the render pass to.
  49747. * @param options The required width/height ratio to downsize to before computing the render pass.
  49748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49749. * @param engine The engine which the post process will be applied. (default: current engine)
  49750. * @param reusable If the post process can be reused on the same frame. (default: false)
  49751. */
  49752. constructor(name: string, refractionTextureUrl: string,
  49753. /** the base color of the refraction (used to taint the rendering) */
  49754. color: Color3,
  49755. /** simulated refraction depth */
  49756. depth: number,
  49757. /** the coefficient of the base color (0 to remove base color tainting) */
  49758. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49759. /**
  49760. * Disposes of the post process
  49761. * @param camera Camera to dispose post process on
  49762. */
  49763. dispose(camera: Camera): void;
  49764. }
  49765. }
  49766. declare module BABYLON {
  49767. /** @hidden */
  49768. export var sharpenPixelShader: {
  49769. name: string;
  49770. shader: string;
  49771. };
  49772. }
  49773. declare module BABYLON {
  49774. /**
  49775. * The SharpenPostProcess applies a sharpen kernel to every pixel
  49776. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49777. */
  49778. export class SharpenPostProcess extends PostProcess {
  49779. /**
  49780. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  49781. */
  49782. colorAmount: number;
  49783. /**
  49784. * How much sharpness should be applied (default: 0.3)
  49785. */
  49786. edgeAmount: number;
  49787. /**
  49788. * Creates a new instance ConvolutionPostProcess
  49789. * @param name The name of the effect.
  49790. * @param options The required width/height ratio to downsize to before computing the render pass.
  49791. * @param camera The camera to apply the render pass to.
  49792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49793. * @param engine The engine which the post process will be applied. (default: current engine)
  49794. * @param reusable If the post process can be reused on the same frame. (default: false)
  49795. * @param textureType Type of textures used when performing the post process. (default: 0)
  49796. * @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)
  49797. */
  49798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49799. }
  49800. }
  49801. declare module BABYLON {
  49802. /**
  49803. * PostProcessRenderPipeline
  49804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49805. */
  49806. export class PostProcessRenderPipeline {
  49807. private engine;
  49808. private _renderEffects;
  49809. private _renderEffectsForIsolatedPass;
  49810. /**
  49811. * @hidden
  49812. */
  49813. protected _cameras: Camera[];
  49814. /** @hidden */
  49815. _name: string;
  49816. /**
  49817. * Initializes a PostProcessRenderPipeline
  49818. * @param engine engine to add the pipeline to
  49819. * @param name name of the pipeline
  49820. */
  49821. constructor(engine: Engine, name: string);
  49822. /**
  49823. * "PostProcessRenderPipeline"
  49824. * @returns "PostProcessRenderPipeline"
  49825. */
  49826. getClassName(): string;
  49827. /**
  49828. * If all the render effects in the pipeline are support
  49829. */
  49830. readonly isSupported: boolean;
  49831. /**
  49832. * Adds an effect to the pipeline
  49833. * @param renderEffect the effect to add
  49834. */
  49835. addEffect(renderEffect: PostProcessRenderEffect): void;
  49836. /** @hidden */
  49837. _rebuild(): void;
  49838. /** @hidden */
  49839. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49840. /** @hidden */
  49841. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49842. /** @hidden */
  49843. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49844. /** @hidden */
  49845. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49846. /** @hidden */
  49847. _attachCameras(cameras: Camera, unique: boolean): void;
  49848. /** @hidden */
  49849. _attachCameras(cameras: Camera[], unique: boolean): void;
  49850. /** @hidden */
  49851. _detachCameras(cameras: Camera): void;
  49852. /** @hidden */
  49853. _detachCameras(cameras: Nullable<Camera[]>): void;
  49854. /** @hidden */
  49855. _update(): void;
  49856. /** @hidden */
  49857. _reset(): void;
  49858. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49859. /**
  49860. * Disposes of the pipeline
  49861. */
  49862. dispose(): void;
  49863. }
  49864. }
  49865. declare module BABYLON {
  49866. /**
  49867. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49868. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49869. */
  49870. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49871. private _scene;
  49872. private _camerasToBeAttached;
  49873. /**
  49874. * ID of the sharpen post process,
  49875. */
  49876. private readonly SharpenPostProcessId;
  49877. /**
  49878. * @ignore
  49879. * ID of the image processing post process;
  49880. */
  49881. readonly ImageProcessingPostProcessId: string;
  49882. /**
  49883. * @ignore
  49884. * ID of the Fast Approximate Anti-Aliasing post process;
  49885. */
  49886. readonly FxaaPostProcessId: string;
  49887. /**
  49888. * ID of the chromatic aberration post process,
  49889. */
  49890. private readonly ChromaticAberrationPostProcessId;
  49891. /**
  49892. * ID of the grain post process
  49893. */
  49894. private readonly GrainPostProcessId;
  49895. /**
  49896. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49897. */
  49898. sharpen: SharpenPostProcess;
  49899. private _sharpenEffect;
  49900. private bloom;
  49901. /**
  49902. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49903. */
  49904. depthOfField: DepthOfFieldEffect;
  49905. /**
  49906. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49907. */
  49908. fxaa: FxaaPostProcess;
  49909. /**
  49910. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49911. */
  49912. imageProcessing: ImageProcessingPostProcess;
  49913. /**
  49914. * Chromatic aberration post process which will shift rgb colors in the image
  49915. */
  49916. chromaticAberration: ChromaticAberrationPostProcess;
  49917. private _chromaticAberrationEffect;
  49918. /**
  49919. * Grain post process which add noise to the image
  49920. */
  49921. grain: GrainPostProcess;
  49922. private _grainEffect;
  49923. /**
  49924. * Glow post process which adds a glow to emmisive areas of the image
  49925. */
  49926. private _glowLayer;
  49927. /**
  49928. * Animations which can be used to tweak settings over a period of time
  49929. */
  49930. animations: Animation[];
  49931. private _imageProcessingConfigurationObserver;
  49932. private _sharpenEnabled;
  49933. private _bloomEnabled;
  49934. private _depthOfFieldEnabled;
  49935. private _depthOfFieldBlurLevel;
  49936. private _fxaaEnabled;
  49937. private _imageProcessingEnabled;
  49938. private _defaultPipelineTextureType;
  49939. private _bloomScale;
  49940. private _chromaticAberrationEnabled;
  49941. private _grainEnabled;
  49942. private _buildAllowed;
  49943. /**
  49944. * Enable or disable the sharpen process from the pipeline
  49945. */
  49946. sharpenEnabled: boolean;
  49947. private _resizeObserver;
  49948. private _hardwareScaleLevel;
  49949. private _bloomKernel;
  49950. /**
  49951. * Specifies the size of the bloom blur kernel, relative to the final output size
  49952. */
  49953. bloomKernel: number;
  49954. /**
  49955. * Specifies the weight of the bloom in the final rendering
  49956. */
  49957. private _bloomWeight;
  49958. /**
  49959. * Specifies the luma threshold for the area that will be blurred by the bloom
  49960. */
  49961. private _bloomThreshold;
  49962. private _hdr;
  49963. /**
  49964. * The strength of the bloom.
  49965. */
  49966. bloomWeight: number;
  49967. /**
  49968. * The strength of the bloom.
  49969. */
  49970. bloomThreshold: number;
  49971. /**
  49972. * The scale of the bloom, lower value will provide better performance.
  49973. */
  49974. bloomScale: number;
  49975. /**
  49976. * Enable or disable the bloom from the pipeline
  49977. */
  49978. bloomEnabled: boolean;
  49979. private _rebuildBloom;
  49980. /**
  49981. * If the depth of field is enabled.
  49982. */
  49983. depthOfFieldEnabled: boolean;
  49984. /**
  49985. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49986. */
  49987. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49988. /**
  49989. * If the anti aliasing is enabled.
  49990. */
  49991. fxaaEnabled: boolean;
  49992. private _samples;
  49993. /**
  49994. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49995. */
  49996. samples: number;
  49997. /**
  49998. * If image processing is enabled.
  49999. */
  50000. imageProcessingEnabled: boolean;
  50001. /**
  50002. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50003. */
  50004. glowLayerEnabled: boolean;
  50005. /**
  50006. * Enable or disable the chromaticAberration process from the pipeline
  50007. */
  50008. chromaticAberrationEnabled: boolean;
  50009. /**
  50010. * Enable or disable the grain process from the pipeline
  50011. */
  50012. grainEnabled: boolean;
  50013. /**
  50014. * @constructor
  50015. * @param name - The rendering pipeline name (default: "")
  50016. * @param hdr - If high dynamic range textures should be used (default: true)
  50017. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50018. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50019. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50020. */
  50021. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50022. /**
  50023. * Force the compilation of the entire pipeline.
  50024. */
  50025. prepare(): void;
  50026. private _hasCleared;
  50027. private _prevPostProcess;
  50028. private _prevPrevPostProcess;
  50029. private _setAutoClearAndTextureSharing;
  50030. private _depthOfFieldSceneObserver;
  50031. private _buildPipeline;
  50032. private _disposePostProcesses;
  50033. /**
  50034. * Adds a camera to the pipeline
  50035. * @param camera the camera to be added
  50036. */
  50037. addCamera(camera: Camera): void;
  50038. /**
  50039. * Removes a camera from the pipeline
  50040. * @param camera the camera to remove
  50041. */
  50042. removeCamera(camera: Camera): void;
  50043. /**
  50044. * Dispose of the pipeline and stop all post processes
  50045. */
  50046. dispose(): void;
  50047. /**
  50048. * Serialize the rendering pipeline (Used when exporting)
  50049. * @returns the serialized object
  50050. */
  50051. serialize(): any;
  50052. /**
  50053. * Parse the serialized pipeline
  50054. * @param source Source pipeline.
  50055. * @param scene The scene to load the pipeline to.
  50056. * @param rootUrl The URL of the serialized pipeline.
  50057. * @returns An instantiated pipeline from the serialized object.
  50058. */
  50059. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50060. }
  50061. }
  50062. declare module BABYLON {
  50063. /** @hidden */
  50064. export var lensHighlightsPixelShader: {
  50065. name: string;
  50066. shader: string;
  50067. };
  50068. }
  50069. declare module BABYLON {
  50070. /** @hidden */
  50071. export var depthOfFieldPixelShader: {
  50072. name: string;
  50073. shader: string;
  50074. };
  50075. }
  50076. declare module BABYLON {
  50077. /**
  50078. * BABYLON.JS Chromatic Aberration GLSL Shader
  50079. * Author: Olivier Guyot
  50080. * Separates very slightly R, G and B colors on the edges of the screen
  50081. * Inspired by Francois Tarlier & Martins Upitis
  50082. */
  50083. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  50084. /**
  50085. * @ignore
  50086. * The chromatic aberration PostProcess id in the pipeline
  50087. */
  50088. LensChromaticAberrationEffect: string;
  50089. /**
  50090. * @ignore
  50091. * The highlights enhancing PostProcess id in the pipeline
  50092. */
  50093. HighlightsEnhancingEffect: string;
  50094. /**
  50095. * @ignore
  50096. * The depth-of-field PostProcess id in the pipeline
  50097. */
  50098. LensDepthOfFieldEffect: string;
  50099. private _scene;
  50100. private _depthTexture;
  50101. private _grainTexture;
  50102. private _chromaticAberrationPostProcess;
  50103. private _highlightsPostProcess;
  50104. private _depthOfFieldPostProcess;
  50105. private _edgeBlur;
  50106. private _grainAmount;
  50107. private _chromaticAberration;
  50108. private _distortion;
  50109. private _highlightsGain;
  50110. private _highlightsThreshold;
  50111. private _dofDistance;
  50112. private _dofAperture;
  50113. private _dofDarken;
  50114. private _dofPentagon;
  50115. private _blurNoise;
  50116. /**
  50117. * @constructor
  50118. *
  50119. * Effect parameters are as follow:
  50120. * {
  50121. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50122. * edge_blur: number; // from 0 to x (1 for realism)
  50123. * distortion: number; // from 0 to x (1 for realism)
  50124. * grain_amount: number; // from 0 to 1
  50125. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50126. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50127. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50128. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50129. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50130. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50131. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50132. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50133. * }
  50134. * Note: if an effect parameter is unset, effect is disabled
  50135. *
  50136. * @param name The rendering pipeline name
  50137. * @param parameters - An object containing all parameters (see above)
  50138. * @param scene The scene linked to this pipeline
  50139. * @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)
  50140. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50141. */
  50142. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50143. /**
  50144. * Sets the amount of blur at the edges
  50145. * @param amount blur amount
  50146. */
  50147. setEdgeBlur(amount: number): void;
  50148. /**
  50149. * Sets edge blur to 0
  50150. */
  50151. disableEdgeBlur(): void;
  50152. /**
  50153. * Sets the amout of grain
  50154. * @param amount Amount of grain
  50155. */
  50156. setGrainAmount(amount: number): void;
  50157. /**
  50158. * Set grain amount to 0
  50159. */
  50160. disableGrain(): void;
  50161. /**
  50162. * Sets the chromatic aberration amount
  50163. * @param amount amount of chromatic aberration
  50164. */
  50165. setChromaticAberration(amount: number): void;
  50166. /**
  50167. * Sets chromatic aberration amount to 0
  50168. */
  50169. disableChromaticAberration(): void;
  50170. /**
  50171. * Sets the EdgeDistortion amount
  50172. * @param amount amount of EdgeDistortion
  50173. */
  50174. setEdgeDistortion(amount: number): void;
  50175. /**
  50176. * Sets edge distortion to 0
  50177. */
  50178. disableEdgeDistortion(): void;
  50179. /**
  50180. * Sets the FocusDistance amount
  50181. * @param amount amount of FocusDistance
  50182. */
  50183. setFocusDistance(amount: number): void;
  50184. /**
  50185. * Disables depth of field
  50186. */
  50187. disableDepthOfField(): void;
  50188. /**
  50189. * Sets the Aperture amount
  50190. * @param amount amount of Aperture
  50191. */
  50192. setAperture(amount: number): void;
  50193. /**
  50194. * Sets the DarkenOutOfFocus amount
  50195. * @param amount amount of DarkenOutOfFocus
  50196. */
  50197. setDarkenOutOfFocus(amount: number): void;
  50198. /**
  50199. * Creates a pentagon bokeh effect
  50200. */
  50201. enablePentagonBokeh(): void;
  50202. /**
  50203. * Disables the pentagon bokeh effect
  50204. */
  50205. disablePentagonBokeh(): void;
  50206. /**
  50207. * Enables noise blur
  50208. */
  50209. enableNoiseBlur(): void;
  50210. /**
  50211. * Disables noise blur
  50212. */
  50213. disableNoiseBlur(): void;
  50214. /**
  50215. * Sets the HighlightsGain amount
  50216. * @param amount amount of HighlightsGain
  50217. */
  50218. setHighlightsGain(amount: number): void;
  50219. /**
  50220. * Sets the HighlightsThreshold amount
  50221. * @param amount amount of HighlightsThreshold
  50222. */
  50223. setHighlightsThreshold(amount: number): void;
  50224. /**
  50225. * Disables highlights
  50226. */
  50227. disableHighlights(): void;
  50228. /**
  50229. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50230. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50231. */
  50232. dispose(disableDepthRender?: boolean): void;
  50233. private _createChromaticAberrationPostProcess;
  50234. private _createHighlightsPostProcess;
  50235. private _createDepthOfFieldPostProcess;
  50236. private _createGrainTexture;
  50237. }
  50238. }
  50239. declare module BABYLON {
  50240. /** @hidden */
  50241. export var ssao2PixelShader: {
  50242. name: string;
  50243. shader: string;
  50244. };
  50245. }
  50246. declare module BABYLON {
  50247. /** @hidden */
  50248. export var ssaoCombinePixelShader: {
  50249. name: string;
  50250. shader: string;
  50251. };
  50252. }
  50253. declare module BABYLON {
  50254. /**
  50255. * Render pipeline to produce ssao effect
  50256. */
  50257. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50258. /**
  50259. * @ignore
  50260. * The PassPostProcess id in the pipeline that contains the original scene color
  50261. */
  50262. SSAOOriginalSceneColorEffect: string;
  50263. /**
  50264. * @ignore
  50265. * The SSAO PostProcess id in the pipeline
  50266. */
  50267. SSAORenderEffect: string;
  50268. /**
  50269. * @ignore
  50270. * The horizontal blur PostProcess id in the pipeline
  50271. */
  50272. SSAOBlurHRenderEffect: string;
  50273. /**
  50274. * @ignore
  50275. * The vertical blur PostProcess id in the pipeline
  50276. */
  50277. SSAOBlurVRenderEffect: string;
  50278. /**
  50279. * @ignore
  50280. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50281. */
  50282. SSAOCombineRenderEffect: string;
  50283. /**
  50284. * The output strength of the SSAO post-process. Default value is 1.0.
  50285. */
  50286. totalStrength: number;
  50287. /**
  50288. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50289. */
  50290. maxZ: number;
  50291. /**
  50292. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50293. */
  50294. minZAspect: number;
  50295. private _samples;
  50296. /**
  50297. * Number of samples used for the SSAO calculations. Default value is 8
  50298. */
  50299. samples: number;
  50300. private _textureSamples;
  50301. /**
  50302. * Number of samples to use for antialiasing
  50303. */
  50304. textureSamples: number;
  50305. /**
  50306. * Ratio object used for SSAO ratio and blur ratio
  50307. */
  50308. private _ratio;
  50309. /**
  50310. * Dynamically generated sphere sampler.
  50311. */
  50312. private _sampleSphere;
  50313. /**
  50314. * Blur filter offsets
  50315. */
  50316. private _samplerOffsets;
  50317. private _expensiveBlur;
  50318. /**
  50319. * If bilateral blur should be used
  50320. */
  50321. expensiveBlur: boolean;
  50322. /**
  50323. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50324. */
  50325. radius: number;
  50326. /**
  50327. * The base color of the SSAO post-process
  50328. * The final result is "base + ssao" between [0, 1]
  50329. */
  50330. base: number;
  50331. /**
  50332. * Support test.
  50333. */
  50334. static readonly IsSupported: boolean;
  50335. private _scene;
  50336. private _depthTexture;
  50337. private _normalTexture;
  50338. private _randomTexture;
  50339. private _originalColorPostProcess;
  50340. private _ssaoPostProcess;
  50341. private _blurHPostProcess;
  50342. private _blurVPostProcess;
  50343. private _ssaoCombinePostProcess;
  50344. private _firstUpdate;
  50345. /**
  50346. * @constructor
  50347. * @param name The rendering pipeline name
  50348. * @param scene The scene linked to this pipeline
  50349. * @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 }
  50350. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50351. */
  50352. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50353. /**
  50354. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50355. */
  50356. dispose(disableGeometryBufferRenderer?: boolean): void;
  50357. private _createBlurPostProcess;
  50358. /** @hidden */
  50359. _rebuild(): void;
  50360. private _bits;
  50361. private _radicalInverse_VdC;
  50362. private _hammersley;
  50363. private _hemisphereSample_uniform;
  50364. private _generateHemisphere;
  50365. private _createSSAOPostProcess;
  50366. private _createSSAOCombinePostProcess;
  50367. private _createRandomTexture;
  50368. /**
  50369. * Serialize the rendering pipeline (Used when exporting)
  50370. * @returns the serialized object
  50371. */
  50372. serialize(): any;
  50373. /**
  50374. * Parse the serialized pipeline
  50375. * @param source Source pipeline.
  50376. * @param scene The scene to load the pipeline to.
  50377. * @param rootUrl The URL of the serialized pipeline.
  50378. * @returns An instantiated pipeline from the serialized object.
  50379. */
  50380. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50381. }
  50382. }
  50383. declare module BABYLON {
  50384. /** @hidden */
  50385. export var ssaoPixelShader: {
  50386. name: string;
  50387. shader: string;
  50388. };
  50389. }
  50390. declare module BABYLON {
  50391. /**
  50392. * Render pipeline to produce ssao effect
  50393. */
  50394. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50395. /**
  50396. * @ignore
  50397. * The PassPostProcess id in the pipeline that contains the original scene color
  50398. */
  50399. SSAOOriginalSceneColorEffect: string;
  50400. /**
  50401. * @ignore
  50402. * The SSAO PostProcess id in the pipeline
  50403. */
  50404. SSAORenderEffect: string;
  50405. /**
  50406. * @ignore
  50407. * The horizontal blur PostProcess id in the pipeline
  50408. */
  50409. SSAOBlurHRenderEffect: string;
  50410. /**
  50411. * @ignore
  50412. * The vertical blur PostProcess id in the pipeline
  50413. */
  50414. SSAOBlurVRenderEffect: string;
  50415. /**
  50416. * @ignore
  50417. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50418. */
  50419. SSAOCombineRenderEffect: string;
  50420. /**
  50421. * The output strength of the SSAO post-process. Default value is 1.0.
  50422. */
  50423. totalStrength: number;
  50424. /**
  50425. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50426. */
  50427. radius: number;
  50428. /**
  50429. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50430. * Must not be equal to fallOff and superior to fallOff.
  50431. * Default value is 0.975
  50432. */
  50433. area: number;
  50434. /**
  50435. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50436. * Must not be equal to area and inferior to area.
  50437. * Default value is 0.0
  50438. */
  50439. fallOff: number;
  50440. /**
  50441. * The base color of the SSAO post-process
  50442. * The final result is "base + ssao" between [0, 1]
  50443. */
  50444. base: number;
  50445. private _scene;
  50446. private _depthTexture;
  50447. private _randomTexture;
  50448. private _originalColorPostProcess;
  50449. private _ssaoPostProcess;
  50450. private _blurHPostProcess;
  50451. private _blurVPostProcess;
  50452. private _ssaoCombinePostProcess;
  50453. private _firstUpdate;
  50454. /**
  50455. * @constructor
  50456. * @param name - The rendering pipeline name
  50457. * @param scene - The scene linked to this pipeline
  50458. * @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 }
  50459. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50460. */
  50461. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50462. /**
  50463. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50464. */
  50465. dispose(disableDepthRender?: boolean): void;
  50466. private _createBlurPostProcess;
  50467. /** @hidden */
  50468. _rebuild(): void;
  50469. private _createSSAOPostProcess;
  50470. private _createSSAOCombinePostProcess;
  50471. private _createRandomTexture;
  50472. }
  50473. }
  50474. declare module BABYLON {
  50475. /** @hidden */
  50476. export var standardPixelShader: {
  50477. name: string;
  50478. shader: string;
  50479. };
  50480. }
  50481. declare module BABYLON {
  50482. /**
  50483. * Standard rendering pipeline
  50484. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50485. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50486. */
  50487. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50488. /**
  50489. * Public members
  50490. */
  50491. /**
  50492. * Post-process which contains the original scene color before the pipeline applies all the effects
  50493. */
  50494. originalPostProcess: Nullable<PostProcess>;
  50495. /**
  50496. * Post-process used to down scale an image x4
  50497. */
  50498. downSampleX4PostProcess: Nullable<PostProcess>;
  50499. /**
  50500. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50501. */
  50502. brightPassPostProcess: Nullable<PostProcess>;
  50503. /**
  50504. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50505. */
  50506. blurHPostProcesses: PostProcess[];
  50507. /**
  50508. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50509. */
  50510. blurVPostProcesses: PostProcess[];
  50511. /**
  50512. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50513. */
  50514. textureAdderPostProcess: Nullable<PostProcess>;
  50515. /**
  50516. * Post-process used to create volumetric lighting effect
  50517. */
  50518. volumetricLightPostProcess: Nullable<PostProcess>;
  50519. /**
  50520. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50521. */
  50522. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50523. /**
  50524. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50525. */
  50526. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50527. /**
  50528. * Post-process used to merge the volumetric light effect and the real scene color
  50529. */
  50530. volumetricLightMergePostProces: Nullable<PostProcess>;
  50531. /**
  50532. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50533. */
  50534. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50535. /**
  50536. * Base post-process used to calculate the average luminance of the final image for HDR
  50537. */
  50538. luminancePostProcess: Nullable<PostProcess>;
  50539. /**
  50540. * Post-processes used to create down sample post-processes in order to get
  50541. * the average luminance of the final image for HDR
  50542. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50543. */
  50544. luminanceDownSamplePostProcesses: PostProcess[];
  50545. /**
  50546. * Post-process used to create a HDR effect (light adaptation)
  50547. */
  50548. hdrPostProcess: Nullable<PostProcess>;
  50549. /**
  50550. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50551. */
  50552. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50553. /**
  50554. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50555. */
  50556. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50557. /**
  50558. * Post-process used to merge the final HDR post-process and the real scene color
  50559. */
  50560. hdrFinalPostProcess: Nullable<PostProcess>;
  50561. /**
  50562. * Post-process used to create a lens flare effect
  50563. */
  50564. lensFlarePostProcess: Nullable<PostProcess>;
  50565. /**
  50566. * Post-process that merges the result of the lens flare post-process and the real scene color
  50567. */
  50568. lensFlareComposePostProcess: Nullable<PostProcess>;
  50569. /**
  50570. * Post-process used to create a motion blur effect
  50571. */
  50572. motionBlurPostProcess: Nullable<PostProcess>;
  50573. /**
  50574. * Post-process used to create a depth of field effect
  50575. */
  50576. depthOfFieldPostProcess: Nullable<PostProcess>;
  50577. /**
  50578. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50579. */
  50580. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50581. /**
  50582. * Represents the brightness threshold in order to configure the illuminated surfaces
  50583. */
  50584. brightThreshold: number;
  50585. /**
  50586. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50587. */
  50588. blurWidth: number;
  50589. /**
  50590. * Sets if the blur for highlighted surfaces must be only horizontal
  50591. */
  50592. horizontalBlur: boolean;
  50593. /**
  50594. * Sets the overall exposure used by the pipeline
  50595. */
  50596. exposure: number;
  50597. /**
  50598. * Texture used typically to simulate "dirty" on camera lens
  50599. */
  50600. lensTexture: Nullable<Texture>;
  50601. /**
  50602. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50603. */
  50604. volumetricLightCoefficient: number;
  50605. /**
  50606. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50607. */
  50608. volumetricLightPower: number;
  50609. /**
  50610. * Used the set the blur intensity to smooth the volumetric lights
  50611. */
  50612. volumetricLightBlurScale: number;
  50613. /**
  50614. * Light (spot or directional) used to generate the volumetric lights rays
  50615. * The source light must have a shadow generate so the pipeline can get its
  50616. * depth map
  50617. */
  50618. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50619. /**
  50620. * For eye adaptation, represents the minimum luminance the eye can see
  50621. */
  50622. hdrMinimumLuminance: number;
  50623. /**
  50624. * For eye adaptation, represents the decrease luminance speed
  50625. */
  50626. hdrDecreaseRate: number;
  50627. /**
  50628. * For eye adaptation, represents the increase luminance speed
  50629. */
  50630. hdrIncreaseRate: number;
  50631. /**
  50632. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50633. */
  50634. lensColorTexture: Nullable<Texture>;
  50635. /**
  50636. * The overall strengh for the lens flare effect
  50637. */
  50638. lensFlareStrength: number;
  50639. /**
  50640. * Dispersion coefficient for lens flare ghosts
  50641. */
  50642. lensFlareGhostDispersal: number;
  50643. /**
  50644. * Main lens flare halo width
  50645. */
  50646. lensFlareHaloWidth: number;
  50647. /**
  50648. * Based on the lens distortion effect, defines how much the lens flare result
  50649. * is distorted
  50650. */
  50651. lensFlareDistortionStrength: number;
  50652. /**
  50653. * Lens star texture must be used to simulate rays on the flares and is available
  50654. * in the documentation
  50655. */
  50656. lensStarTexture: Nullable<Texture>;
  50657. /**
  50658. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50659. * flare effect by taking account of the dirt texture
  50660. */
  50661. lensFlareDirtTexture: Nullable<Texture>;
  50662. /**
  50663. * Represents the focal length for the depth of field effect
  50664. */
  50665. depthOfFieldDistance: number;
  50666. /**
  50667. * Represents the blur intensity for the blurred part of the depth of field effect
  50668. */
  50669. depthOfFieldBlurWidth: number;
  50670. /**
  50671. * For motion blur, defines how much the image is blurred by the movement
  50672. */
  50673. motionStrength: number;
  50674. /**
  50675. * List of animations for the pipeline (IAnimatable implementation)
  50676. */
  50677. animations: Animation[];
  50678. /**
  50679. * Private members
  50680. */
  50681. private _scene;
  50682. private _currentDepthOfFieldSource;
  50683. private _basePostProcess;
  50684. private _hdrCurrentLuminance;
  50685. private _floatTextureType;
  50686. private _ratio;
  50687. private _bloomEnabled;
  50688. private _depthOfFieldEnabled;
  50689. private _vlsEnabled;
  50690. private _lensFlareEnabled;
  50691. private _hdrEnabled;
  50692. private _motionBlurEnabled;
  50693. private _fxaaEnabled;
  50694. private _motionBlurSamples;
  50695. private _volumetricLightStepsCount;
  50696. private _samples;
  50697. /**
  50698. * @ignore
  50699. * Specifies if the bloom pipeline is enabled
  50700. */
  50701. BloomEnabled: boolean;
  50702. /**
  50703. * @ignore
  50704. * Specifies if the depth of field pipeline is enabed
  50705. */
  50706. DepthOfFieldEnabled: boolean;
  50707. /**
  50708. * @ignore
  50709. * Specifies if the lens flare pipeline is enabed
  50710. */
  50711. LensFlareEnabled: boolean;
  50712. /**
  50713. * @ignore
  50714. * Specifies if the HDR pipeline is enabled
  50715. */
  50716. HDREnabled: boolean;
  50717. /**
  50718. * @ignore
  50719. * Specifies if the volumetric lights scattering effect is enabled
  50720. */
  50721. VLSEnabled: boolean;
  50722. /**
  50723. * @ignore
  50724. * Specifies if the motion blur effect is enabled
  50725. */
  50726. MotionBlurEnabled: boolean;
  50727. /**
  50728. * Specifies if anti-aliasing is enabled
  50729. */
  50730. fxaaEnabled: boolean;
  50731. /**
  50732. * Specifies the number of steps used to calculate the volumetric lights
  50733. * Typically in interval [50, 200]
  50734. */
  50735. volumetricLightStepsCount: number;
  50736. /**
  50737. * Specifies the number of samples used for the motion blur effect
  50738. * Typically in interval [16, 64]
  50739. */
  50740. motionBlurSamples: number;
  50741. /**
  50742. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50743. */
  50744. samples: number;
  50745. /**
  50746. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50747. * @constructor
  50748. * @param name The rendering pipeline name
  50749. * @param scene The scene linked to this pipeline
  50750. * @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)
  50751. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50752. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50753. */
  50754. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50755. private _buildPipeline;
  50756. private _createDownSampleX4PostProcess;
  50757. private _createBrightPassPostProcess;
  50758. private _createBlurPostProcesses;
  50759. private _createTextureAdderPostProcess;
  50760. private _createVolumetricLightPostProcess;
  50761. private _createLuminancePostProcesses;
  50762. private _createHdrPostProcess;
  50763. private _createLensFlarePostProcess;
  50764. private _createDepthOfFieldPostProcess;
  50765. private _createMotionBlurPostProcess;
  50766. private _getDepthTexture;
  50767. private _disposePostProcesses;
  50768. /**
  50769. * Dispose of the pipeline and stop all post processes
  50770. */
  50771. dispose(): void;
  50772. /**
  50773. * Serialize the rendering pipeline (Used when exporting)
  50774. * @returns the serialized object
  50775. */
  50776. serialize(): any;
  50777. /**
  50778. * Parse the serialized pipeline
  50779. * @param source Source pipeline.
  50780. * @param scene The scene to load the pipeline to.
  50781. * @param rootUrl The URL of the serialized pipeline.
  50782. * @returns An instantiated pipeline from the serialized object.
  50783. */
  50784. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50785. /**
  50786. * Luminance steps
  50787. */
  50788. static LuminanceSteps: number;
  50789. }
  50790. }
  50791. declare module BABYLON {
  50792. /**
  50793. * PostProcessRenderPipelineManager class
  50794. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50795. */
  50796. export class PostProcessRenderPipelineManager {
  50797. private _renderPipelines;
  50798. /**
  50799. * Initializes a PostProcessRenderPipelineManager
  50800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50801. */
  50802. constructor();
  50803. /**
  50804. * Adds a pipeline to the manager
  50805. * @param renderPipeline The pipeline to add
  50806. */
  50807. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  50808. /**
  50809. * Attaches a camera to the pipeline
  50810. * @param renderPipelineName The name of the pipeline to attach to
  50811. * @param cameras the camera to attach
  50812. * @param unique if the camera can be attached multiple times to the pipeline
  50813. */
  50814. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  50815. /**
  50816. * Detaches a camera from the pipeline
  50817. * @param renderPipelineName The name of the pipeline to detach from
  50818. * @param cameras the camera to detach
  50819. */
  50820. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  50821. /**
  50822. * Enables an effect by name on a pipeline
  50823. * @param renderPipelineName the name of the pipeline to enable the effect in
  50824. * @param renderEffectName the name of the effect to enable
  50825. * @param cameras the cameras that the effect should be enabled on
  50826. */
  50827. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50828. /**
  50829. * Disables an effect by name on a pipeline
  50830. * @param renderPipelineName the name of the pipeline to disable the effect in
  50831. * @param renderEffectName the name of the effect to disable
  50832. * @param cameras the cameras that the effect should be disabled on
  50833. */
  50834. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50835. /**
  50836. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  50837. */
  50838. update(): void;
  50839. /** @hidden */
  50840. _rebuild(): void;
  50841. /**
  50842. * Disposes of the manager and pipelines
  50843. */
  50844. dispose(): void;
  50845. }
  50846. }
  50847. declare module BABYLON {
  50848. interface Scene {
  50849. /** @hidden (Backing field) */
  50850. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50851. /**
  50852. * Gets the postprocess render pipeline manager
  50853. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50854. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50855. */
  50856. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50857. }
  50858. /**
  50859. * Defines the Render Pipeline scene component responsible to rendering pipelines
  50860. */
  50861. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  50862. /**
  50863. * The component name helpfull to identify the component in the list of scene components.
  50864. */
  50865. readonly name: string;
  50866. /**
  50867. * The scene the component belongs to.
  50868. */
  50869. scene: Scene;
  50870. /**
  50871. * Creates a new instance of the component for the given scene
  50872. * @param scene Defines the scene to register the component in
  50873. */
  50874. constructor(scene: Scene);
  50875. /**
  50876. * Registers the component in a given scene
  50877. */
  50878. register(): void;
  50879. /**
  50880. * Rebuilds the elements related to this component in case of
  50881. * context lost for instance.
  50882. */
  50883. rebuild(): void;
  50884. /**
  50885. * Disposes the component and the associated ressources
  50886. */
  50887. dispose(): void;
  50888. private _gatherRenderTargets;
  50889. }
  50890. }
  50891. declare module BABYLON {
  50892. /** @hidden */
  50893. export var tonemapPixelShader: {
  50894. name: string;
  50895. shader: string;
  50896. };
  50897. }
  50898. declare module BABYLON {
  50899. /** Defines operator used for tonemapping */
  50900. export enum TonemappingOperator {
  50901. /** Hable */
  50902. Hable = 0,
  50903. /** Reinhard */
  50904. Reinhard = 1,
  50905. /** HejiDawson */
  50906. HejiDawson = 2,
  50907. /** Photographic */
  50908. Photographic = 3
  50909. }
  50910. /**
  50911. * Defines a post process to apply tone mapping
  50912. */
  50913. export class TonemapPostProcess extends PostProcess {
  50914. private _operator;
  50915. /** Defines the required exposure adjustement */
  50916. exposureAdjustment: number;
  50917. /**
  50918. * Creates a new TonemapPostProcess
  50919. * @param name defines the name of the postprocess
  50920. * @param _operator defines the operator to use
  50921. * @param exposureAdjustment defines the required exposure adjustement
  50922. * @param camera defines the camera to use (can be null)
  50923. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  50924. * @param engine defines the hosting engine (can be ignore if camera is set)
  50925. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50926. */
  50927. constructor(name: string, _operator: TonemappingOperator,
  50928. /** Defines the required exposure adjustement */
  50929. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  50930. }
  50931. }
  50932. declare module BABYLON {
  50933. /** @hidden */
  50934. export var depthVertexShader: {
  50935. name: string;
  50936. shader: string;
  50937. };
  50938. }
  50939. declare module BABYLON {
  50940. /** @hidden */
  50941. export var volumetricLightScatteringPixelShader: {
  50942. name: string;
  50943. shader: string;
  50944. };
  50945. }
  50946. declare module BABYLON {
  50947. /** @hidden */
  50948. export var volumetricLightScatteringPassPixelShader: {
  50949. name: string;
  50950. shader: string;
  50951. };
  50952. }
  50953. declare module BABYLON {
  50954. /**
  50955. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  50956. */
  50957. export class VolumetricLightScatteringPostProcess extends PostProcess {
  50958. private _volumetricLightScatteringPass;
  50959. private _volumetricLightScatteringRTT;
  50960. private _viewPort;
  50961. private _screenCoordinates;
  50962. private _cachedDefines;
  50963. /**
  50964. * If not undefined, the mesh position is computed from the attached node position
  50965. */
  50966. attachedNode: {
  50967. position: Vector3;
  50968. };
  50969. /**
  50970. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  50971. */
  50972. customMeshPosition: Vector3;
  50973. /**
  50974. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  50975. */
  50976. useCustomMeshPosition: boolean;
  50977. /**
  50978. * If the post-process should inverse the light scattering direction
  50979. */
  50980. invert: boolean;
  50981. /**
  50982. * The internal mesh used by the post-process
  50983. */
  50984. mesh: Mesh;
  50985. /**
  50986. * @hidden
  50987. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  50988. */
  50989. useDiffuseColor: boolean;
  50990. /**
  50991. * Array containing the excluded meshes not rendered in the internal pass
  50992. */
  50993. excludedMeshes: AbstractMesh[];
  50994. /**
  50995. * Controls the overall intensity of the post-process
  50996. */
  50997. exposure: number;
  50998. /**
  50999. * Dissipates each sample's contribution in range [0, 1]
  51000. */
  51001. decay: number;
  51002. /**
  51003. * Controls the overall intensity of each sample
  51004. */
  51005. weight: number;
  51006. /**
  51007. * Controls the density of each sample
  51008. */
  51009. density: number;
  51010. /**
  51011. * @constructor
  51012. * @param name The post-process name
  51013. * @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)
  51014. * @param camera The camera that the post-process will be attached to
  51015. * @param mesh The mesh used to create the light scattering
  51016. * @param samples The post-process quality, default 100
  51017. * @param samplingModeThe post-process filtering mode
  51018. * @param engine The babylon engine
  51019. * @param reusable If the post-process is reusable
  51020. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  51021. */
  51022. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  51023. /**
  51024. * Returns the string "VolumetricLightScatteringPostProcess"
  51025. * @returns "VolumetricLightScatteringPostProcess"
  51026. */
  51027. getClassName(): string;
  51028. private _isReady;
  51029. /**
  51030. * Sets the new light position for light scattering effect
  51031. * @param position The new custom light position
  51032. */
  51033. setCustomMeshPosition(position: Vector3): void;
  51034. /**
  51035. * Returns the light position for light scattering effect
  51036. * @return Vector3 The custom light position
  51037. */
  51038. getCustomMeshPosition(): Vector3;
  51039. /**
  51040. * Disposes the internal assets and detaches the post-process from the camera
  51041. */
  51042. dispose(camera: Camera): void;
  51043. /**
  51044. * Returns the render target texture used by the post-process
  51045. * @return the render target texture used by the post-process
  51046. */
  51047. getPass(): RenderTargetTexture;
  51048. private _meshExcluded;
  51049. private _createPass;
  51050. private _updateMeshScreenCoordinates;
  51051. /**
  51052. * Creates a default mesh for the Volumeric Light Scattering post-process
  51053. * @param name The mesh name
  51054. * @param scene The scene where to create the mesh
  51055. * @return the default mesh
  51056. */
  51057. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  51058. }
  51059. }
  51060. declare module BABYLON {
  51061. interface Scene {
  51062. /** @hidden (Backing field) */
  51063. _boundingBoxRenderer: BoundingBoxRenderer;
  51064. /** @hidden (Backing field) */
  51065. _forceShowBoundingBoxes: boolean;
  51066. /**
  51067. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  51068. */
  51069. forceShowBoundingBoxes: boolean;
  51070. /**
  51071. * Gets the bounding box renderer associated with the scene
  51072. * @returns a BoundingBoxRenderer
  51073. */
  51074. getBoundingBoxRenderer(): BoundingBoxRenderer;
  51075. }
  51076. interface AbstractMesh {
  51077. /** @hidden (Backing field) */
  51078. _showBoundingBox: boolean;
  51079. /**
  51080. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  51081. */
  51082. showBoundingBox: boolean;
  51083. }
  51084. /**
  51085. * Component responsible of rendering the bounding box of the meshes in a scene.
  51086. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  51087. */
  51088. export class BoundingBoxRenderer implements ISceneComponent {
  51089. /**
  51090. * The component name helpfull to identify the component in the list of scene components.
  51091. */
  51092. readonly name: string;
  51093. /**
  51094. * The scene the component belongs to.
  51095. */
  51096. scene: Scene;
  51097. /**
  51098. * Color of the bounding box lines placed in front of an object
  51099. */
  51100. frontColor: Color3;
  51101. /**
  51102. * Color of the bounding box lines placed behind an object
  51103. */
  51104. backColor: Color3;
  51105. /**
  51106. * Defines if the renderer should show the back lines or not
  51107. */
  51108. showBackLines: boolean;
  51109. /**
  51110. * @hidden
  51111. */
  51112. renderList: SmartArray<BoundingBox>;
  51113. private _colorShader;
  51114. private _vertexBuffers;
  51115. private _indexBuffer;
  51116. /**
  51117. * Instantiates a new bounding box renderer in a scene.
  51118. * @param scene the scene the renderer renders in
  51119. */
  51120. constructor(scene: Scene);
  51121. /**
  51122. * Registers the component in a given scene
  51123. */
  51124. register(): void;
  51125. private _evaluateSubMesh;
  51126. private _activeMesh;
  51127. private _prepareRessources;
  51128. private _createIndexBuffer;
  51129. /**
  51130. * Rebuilds the elements related to this component in case of
  51131. * context lost for instance.
  51132. */
  51133. rebuild(): void;
  51134. /**
  51135. * @hidden
  51136. */
  51137. reset(): void;
  51138. /**
  51139. * Render the bounding boxes of a specific rendering group
  51140. * @param renderingGroupId defines the rendering group to render
  51141. */
  51142. render(renderingGroupId: number): void;
  51143. /**
  51144. * In case of occlusion queries, we can render the occlusion bounding box through this method
  51145. * @param mesh Define the mesh to render the occlusion bounding box for
  51146. */
  51147. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  51148. /**
  51149. * Dispose and release the resources attached to this renderer.
  51150. */
  51151. dispose(): void;
  51152. }
  51153. }
  51154. declare module BABYLON {
  51155. /** @hidden */
  51156. export var depthPixelShader: {
  51157. name: string;
  51158. shader: string;
  51159. };
  51160. }
  51161. declare module BABYLON {
  51162. /**
  51163. * This represents a depth renderer in Babylon.
  51164. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  51165. */
  51166. export class DepthRenderer {
  51167. private _scene;
  51168. private _depthMap;
  51169. private _effect;
  51170. private _cachedDefines;
  51171. private _camera;
  51172. /**
  51173. * Specifiess that the depth renderer will only be used within
  51174. * the camera it is created for.
  51175. * This can help forcing its rendering during the camera processing.
  51176. */
  51177. useOnlyInActiveCamera: boolean;
  51178. /** @hidden */
  51179. static _SceneComponentInitialization: (scene: Scene) => void;
  51180. /**
  51181. * Instantiates a depth renderer
  51182. * @param scene The scene the renderer belongs to
  51183. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  51184. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  51185. */
  51186. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  51187. /**
  51188. * Creates the depth rendering effect and checks if the effect is ready.
  51189. * @param subMesh The submesh to be used to render the depth map of
  51190. * @param useInstances If multiple world instances should be used
  51191. * @returns if the depth renderer is ready to render the depth map
  51192. */
  51193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51194. /**
  51195. * Gets the texture which the depth map will be written to.
  51196. * @returns The depth map texture
  51197. */
  51198. getDepthMap(): RenderTargetTexture;
  51199. /**
  51200. * Disposes of the depth renderer.
  51201. */
  51202. dispose(): void;
  51203. }
  51204. }
  51205. declare module BABYLON {
  51206. interface Scene {
  51207. /** @hidden (Backing field) */
  51208. _depthRenderer: {
  51209. [id: string]: DepthRenderer;
  51210. };
  51211. /**
  51212. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  51213. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  51214. * @returns the created depth renderer
  51215. */
  51216. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  51217. /**
  51218. * Disables a depth renderer for a given camera
  51219. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  51220. */
  51221. disableDepthRenderer(camera?: Nullable<Camera>): void;
  51222. }
  51223. /**
  51224. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  51225. * in several rendering techniques.
  51226. */
  51227. export class DepthRendererSceneComponent implements ISceneComponent {
  51228. /**
  51229. * The component name helpfull to identify the component in the list of scene components.
  51230. */
  51231. readonly name: string;
  51232. /**
  51233. * The scene the component belongs to.
  51234. */
  51235. scene: Scene;
  51236. /**
  51237. * Creates a new instance of the component for the given scene
  51238. * @param scene Defines the scene to register the component in
  51239. */
  51240. constructor(scene: Scene);
  51241. /**
  51242. * Registers the component in a given scene
  51243. */
  51244. register(): void;
  51245. /**
  51246. * Rebuilds the elements related to this component in case of
  51247. * context lost for instance.
  51248. */
  51249. rebuild(): void;
  51250. /**
  51251. * Disposes the component and the associated ressources
  51252. */
  51253. dispose(): void;
  51254. private _gatherRenderTargets;
  51255. private _gatherActiveCameraRenderTargets;
  51256. }
  51257. }
  51258. declare module BABYLON {
  51259. interface Scene {
  51260. /** @hidden (Backing field) */
  51261. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51262. /**
  51263. * Gets or Sets the current geometry buffer associated to the scene.
  51264. */
  51265. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51266. /**
  51267. * Enables a GeometryBufferRender and associates it with the scene
  51268. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51269. * @returns the GeometryBufferRenderer
  51270. */
  51271. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51272. /**
  51273. * Disables the GeometryBufferRender associated with the scene
  51274. */
  51275. disableGeometryBufferRenderer(): void;
  51276. }
  51277. /**
  51278. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51279. * in several rendering techniques.
  51280. */
  51281. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51282. /**
  51283. * The component name helpful to identify the component in the list of scene components.
  51284. */
  51285. readonly name: string;
  51286. /**
  51287. * The scene the component belongs to.
  51288. */
  51289. scene: Scene;
  51290. /**
  51291. * Creates a new instance of the component for the given scene
  51292. * @param scene Defines the scene to register the component in
  51293. */
  51294. constructor(scene: Scene);
  51295. /**
  51296. * Registers the component in a given scene
  51297. */
  51298. register(): void;
  51299. /**
  51300. * Rebuilds the elements related to this component in case of
  51301. * context lost for instance.
  51302. */
  51303. rebuild(): void;
  51304. /**
  51305. * Disposes the component and the associated ressources
  51306. */
  51307. dispose(): void;
  51308. private _gatherRenderTargets;
  51309. }
  51310. }
  51311. declare module BABYLON {
  51312. /** @hidden */
  51313. export var outlinePixelShader: {
  51314. name: string;
  51315. shader: string;
  51316. };
  51317. }
  51318. declare module BABYLON {
  51319. /** @hidden */
  51320. export var outlineVertexShader: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module BABYLON {
  51326. interface Scene {
  51327. /** @hidden */
  51328. _outlineRenderer: OutlineRenderer;
  51329. /**
  51330. * Gets the outline renderer associated with the scene
  51331. * @returns a OutlineRenderer
  51332. */
  51333. getOutlineRenderer(): OutlineRenderer;
  51334. }
  51335. interface AbstractMesh {
  51336. /** @hidden (Backing field) */
  51337. _renderOutline: boolean;
  51338. /**
  51339. * Gets or sets a boolean indicating if the outline must be rendered as well
  51340. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51341. */
  51342. renderOutline: boolean;
  51343. /** @hidden (Backing field) */
  51344. _renderOverlay: boolean;
  51345. /**
  51346. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51347. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51348. */
  51349. renderOverlay: boolean;
  51350. }
  51351. /**
  51352. * This class is responsible to draw bothe outline/overlay of meshes.
  51353. * It should not be used directly but through the available method on mesh.
  51354. */
  51355. export class OutlineRenderer implements ISceneComponent {
  51356. /**
  51357. * The name of the component. Each component must have a unique name.
  51358. */
  51359. name: string;
  51360. /**
  51361. * The scene the component belongs to.
  51362. */
  51363. scene: Scene;
  51364. /**
  51365. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51366. */
  51367. zOffset: number;
  51368. private _engine;
  51369. private _effect;
  51370. private _cachedDefines;
  51371. private _savedDepthWrite;
  51372. /**
  51373. * Instantiates a new outline renderer. (There could be only one per scene).
  51374. * @param scene Defines the scene it belongs to
  51375. */
  51376. constructor(scene: Scene);
  51377. /**
  51378. * Register the component to one instance of a scene.
  51379. */
  51380. register(): void;
  51381. /**
  51382. * Rebuilds the elements related to this component in case of
  51383. * context lost for instance.
  51384. */
  51385. rebuild(): void;
  51386. /**
  51387. * Disposes the component and the associated ressources.
  51388. */
  51389. dispose(): void;
  51390. /**
  51391. * Renders the outline in the canvas.
  51392. * @param subMesh Defines the sumesh to render
  51393. * @param batch Defines the batch of meshes in case of instances
  51394. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51395. */
  51396. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51397. /**
  51398. * Returns whether or not the outline renderer is ready for a given submesh.
  51399. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51400. * @param subMesh Defines the submesh to check readyness for
  51401. * @param useInstances Defines wheter wee are trying to render instances or not
  51402. * @returns true if ready otherwise false
  51403. */
  51404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51405. private _beforeRenderingMesh;
  51406. private _afterRenderingMesh;
  51407. }
  51408. }
  51409. declare module BABYLON {
  51410. /**
  51411. * Defines the list of states available for a task inside a AssetsManager
  51412. */
  51413. export enum AssetTaskState {
  51414. /**
  51415. * Initialization
  51416. */
  51417. INIT = 0,
  51418. /**
  51419. * Running
  51420. */
  51421. RUNNING = 1,
  51422. /**
  51423. * Done
  51424. */
  51425. DONE = 2,
  51426. /**
  51427. * Error
  51428. */
  51429. ERROR = 3
  51430. }
  51431. /**
  51432. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51433. */
  51434. export abstract class AbstractAssetTask {
  51435. /**
  51436. * Task name
  51437. */ name: string;
  51438. /**
  51439. * Callback called when the task is successful
  51440. */
  51441. onSuccess: (task: any) => void;
  51442. /**
  51443. * Callback called when the task is not successful
  51444. */
  51445. onError: (task: any, message?: string, exception?: any) => void;
  51446. /**
  51447. * Creates a new AssetsManager
  51448. * @param name defines the name of the task
  51449. */
  51450. constructor(
  51451. /**
  51452. * Task name
  51453. */ name: string);
  51454. private _isCompleted;
  51455. private _taskState;
  51456. private _errorObject;
  51457. /**
  51458. * Get if the task is completed
  51459. */
  51460. readonly isCompleted: boolean;
  51461. /**
  51462. * Gets the current state of the task
  51463. */
  51464. readonly taskState: AssetTaskState;
  51465. /**
  51466. * Gets the current error object (if task is in error)
  51467. */
  51468. readonly errorObject: {
  51469. message?: string;
  51470. exception?: any;
  51471. };
  51472. /**
  51473. * Internal only
  51474. * @hidden
  51475. */
  51476. _setErrorObject(message?: string, exception?: any): void;
  51477. /**
  51478. * Execute the current task
  51479. * @param scene defines the scene where you want your assets to be loaded
  51480. * @param onSuccess is a callback called when the task is successfully executed
  51481. * @param onError is a callback called if an error occurs
  51482. */
  51483. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51484. /**
  51485. * Execute the current task
  51486. * @param scene defines the scene where you want your assets to be loaded
  51487. * @param onSuccess is a callback called when the task is successfully executed
  51488. * @param onError is a callback called if an error occurs
  51489. */
  51490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51491. /**
  51492. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51493. * This can be used with failed tasks that have the reason for failure fixed.
  51494. */
  51495. reset(): void;
  51496. private onErrorCallback;
  51497. private onDoneCallback;
  51498. }
  51499. /**
  51500. * Define the interface used by progress events raised during assets loading
  51501. */
  51502. export interface IAssetsProgressEvent {
  51503. /**
  51504. * Defines the number of remaining tasks to process
  51505. */
  51506. remainingCount: number;
  51507. /**
  51508. * Defines the total number of tasks
  51509. */
  51510. totalCount: number;
  51511. /**
  51512. * Defines the task that was just processed
  51513. */
  51514. task: AbstractAssetTask;
  51515. }
  51516. /**
  51517. * Class used to share progress information about assets loading
  51518. */
  51519. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51520. /**
  51521. * Defines the number of remaining tasks to process
  51522. */
  51523. remainingCount: number;
  51524. /**
  51525. * Defines the total number of tasks
  51526. */
  51527. totalCount: number;
  51528. /**
  51529. * Defines the task that was just processed
  51530. */
  51531. task: AbstractAssetTask;
  51532. /**
  51533. * Creates a AssetsProgressEvent
  51534. * @param remainingCount defines the number of remaining tasks to process
  51535. * @param totalCount defines the total number of tasks
  51536. * @param task defines the task that was just processed
  51537. */
  51538. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51539. }
  51540. /**
  51541. * Define a task used by AssetsManager to load meshes
  51542. */
  51543. export class MeshAssetTask extends AbstractAssetTask {
  51544. /**
  51545. * Defines the name of the task
  51546. */
  51547. name: string;
  51548. /**
  51549. * Defines the list of mesh's names you want to load
  51550. */
  51551. meshesNames: any;
  51552. /**
  51553. * Defines the root url to use as a base to load your meshes and associated resources
  51554. */
  51555. rootUrl: string;
  51556. /**
  51557. * Defines the filename of the scene to load from
  51558. */
  51559. sceneFilename: string;
  51560. /**
  51561. * Gets the list of loaded meshes
  51562. */
  51563. loadedMeshes: Array<AbstractMesh>;
  51564. /**
  51565. * Gets the list of loaded particle systems
  51566. */
  51567. loadedParticleSystems: Array<IParticleSystem>;
  51568. /**
  51569. * Gets the list of loaded skeletons
  51570. */
  51571. loadedSkeletons: Array<Skeleton>;
  51572. /**
  51573. * Gets the list of loaded animation groups
  51574. */
  51575. loadedAnimationGroups: Array<AnimationGroup>;
  51576. /**
  51577. * Callback called when the task is successful
  51578. */
  51579. onSuccess: (task: MeshAssetTask) => void;
  51580. /**
  51581. * Callback called when the task is successful
  51582. */
  51583. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  51584. /**
  51585. * Creates a new MeshAssetTask
  51586. * @param name defines the name of the task
  51587. * @param meshesNames defines the list of mesh's names you want to load
  51588. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  51589. * @param sceneFilename defines the filename of the scene to load from
  51590. */
  51591. constructor(
  51592. /**
  51593. * Defines the name of the task
  51594. */
  51595. name: string,
  51596. /**
  51597. * Defines the list of mesh's names you want to load
  51598. */
  51599. meshesNames: any,
  51600. /**
  51601. * Defines the root url to use as a base to load your meshes and associated resources
  51602. */
  51603. rootUrl: string,
  51604. /**
  51605. * Defines the filename of the scene to load from
  51606. */
  51607. sceneFilename: string);
  51608. /**
  51609. * Execute the current task
  51610. * @param scene defines the scene where you want your assets to be loaded
  51611. * @param onSuccess is a callback called when the task is successfully executed
  51612. * @param onError is a callback called if an error occurs
  51613. */
  51614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51615. }
  51616. /**
  51617. * Define a task used by AssetsManager to load text content
  51618. */
  51619. export class TextFileAssetTask extends AbstractAssetTask {
  51620. /**
  51621. * Defines the name of the task
  51622. */
  51623. name: string;
  51624. /**
  51625. * Defines the location of the file to load
  51626. */
  51627. url: string;
  51628. /**
  51629. * Gets the loaded text string
  51630. */
  51631. text: string;
  51632. /**
  51633. * Callback called when the task is successful
  51634. */
  51635. onSuccess: (task: TextFileAssetTask) => void;
  51636. /**
  51637. * Callback called when the task is successful
  51638. */
  51639. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  51640. /**
  51641. * Creates a new TextFileAssetTask object
  51642. * @param name defines the name of the task
  51643. * @param url defines the location of the file to load
  51644. */
  51645. constructor(
  51646. /**
  51647. * Defines the name of the task
  51648. */
  51649. name: string,
  51650. /**
  51651. * Defines the location of the file to load
  51652. */
  51653. url: string);
  51654. /**
  51655. * Execute the current task
  51656. * @param scene defines the scene where you want your assets to be loaded
  51657. * @param onSuccess is a callback called when the task is successfully executed
  51658. * @param onError is a callback called if an error occurs
  51659. */
  51660. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51661. }
  51662. /**
  51663. * Define a task used by AssetsManager to load binary data
  51664. */
  51665. export class BinaryFileAssetTask extends AbstractAssetTask {
  51666. /**
  51667. * Defines the name of the task
  51668. */
  51669. name: string;
  51670. /**
  51671. * Defines the location of the file to load
  51672. */
  51673. url: string;
  51674. /**
  51675. * Gets the lodaded data (as an array buffer)
  51676. */
  51677. data: ArrayBuffer;
  51678. /**
  51679. * Callback called when the task is successful
  51680. */
  51681. onSuccess: (task: BinaryFileAssetTask) => void;
  51682. /**
  51683. * Callback called when the task is successful
  51684. */
  51685. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  51686. /**
  51687. * Creates a new BinaryFileAssetTask object
  51688. * @param name defines the name of the new task
  51689. * @param url defines the location of the file to load
  51690. */
  51691. constructor(
  51692. /**
  51693. * Defines the name of the task
  51694. */
  51695. name: string,
  51696. /**
  51697. * Defines the location of the file to load
  51698. */
  51699. url: string);
  51700. /**
  51701. * Execute the current task
  51702. * @param scene defines the scene where you want your assets to be loaded
  51703. * @param onSuccess is a callback called when the task is successfully executed
  51704. * @param onError is a callback called if an error occurs
  51705. */
  51706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51707. }
  51708. /**
  51709. * Define a task used by AssetsManager to load images
  51710. */
  51711. export class ImageAssetTask extends AbstractAssetTask {
  51712. /**
  51713. * Defines the name of the task
  51714. */
  51715. name: string;
  51716. /**
  51717. * Defines the location of the image to load
  51718. */
  51719. url: string;
  51720. /**
  51721. * Gets the loaded images
  51722. */
  51723. image: HTMLImageElement;
  51724. /**
  51725. * Callback called when the task is successful
  51726. */
  51727. onSuccess: (task: ImageAssetTask) => void;
  51728. /**
  51729. * Callback called when the task is successful
  51730. */
  51731. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  51732. /**
  51733. * Creates a new ImageAssetTask
  51734. * @param name defines the name of the task
  51735. * @param url defines the location of the image to load
  51736. */
  51737. constructor(
  51738. /**
  51739. * Defines the name of the task
  51740. */
  51741. name: string,
  51742. /**
  51743. * Defines the location of the image to load
  51744. */
  51745. url: string);
  51746. /**
  51747. * Execute the current task
  51748. * @param scene defines the scene where you want your assets to be loaded
  51749. * @param onSuccess is a callback called when the task is successfully executed
  51750. * @param onError is a callback called if an error occurs
  51751. */
  51752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51753. }
  51754. /**
  51755. * Defines the interface used by texture loading tasks
  51756. */
  51757. export interface ITextureAssetTask<TEX extends BaseTexture> {
  51758. /**
  51759. * Gets the loaded texture
  51760. */
  51761. texture: TEX;
  51762. }
  51763. /**
  51764. * Define a task used by AssetsManager to load 2D textures
  51765. */
  51766. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  51767. /**
  51768. * Defines the name of the task
  51769. */
  51770. name: string;
  51771. /**
  51772. * Defines the location of the file to load
  51773. */
  51774. url: string;
  51775. /**
  51776. * Defines if mipmap should not be generated (default is false)
  51777. */
  51778. noMipmap?: boolean | undefined;
  51779. /**
  51780. * Defines if texture must be inverted on Y axis (default is false)
  51781. */
  51782. invertY?: boolean | undefined;
  51783. /**
  51784. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51785. */
  51786. samplingMode: number;
  51787. /**
  51788. * Gets the loaded texture
  51789. */
  51790. texture: Texture;
  51791. /**
  51792. * Callback called when the task is successful
  51793. */
  51794. onSuccess: (task: TextureAssetTask) => void;
  51795. /**
  51796. * Callback called when the task is successful
  51797. */
  51798. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  51799. /**
  51800. * Creates a new TextureAssetTask object
  51801. * @param name defines the name of the task
  51802. * @param url defines the location of the file to load
  51803. * @param noMipmap defines if mipmap should not be generated (default is false)
  51804. * @param invertY defines if texture must be inverted on Y axis (default is false)
  51805. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51806. */
  51807. constructor(
  51808. /**
  51809. * Defines the name of the task
  51810. */
  51811. name: string,
  51812. /**
  51813. * Defines the location of the file to load
  51814. */
  51815. url: string,
  51816. /**
  51817. * Defines if mipmap should not be generated (default is false)
  51818. */
  51819. noMipmap?: boolean | undefined,
  51820. /**
  51821. * Defines if texture must be inverted on Y axis (default is false)
  51822. */
  51823. invertY?: boolean | undefined,
  51824. /**
  51825. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51826. */
  51827. samplingMode?: number);
  51828. /**
  51829. * Execute the current task
  51830. * @param scene defines the scene where you want your assets to be loaded
  51831. * @param onSuccess is a callback called when the task is successfully executed
  51832. * @param onError is a callback called if an error occurs
  51833. */
  51834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51835. }
  51836. /**
  51837. * Define a task used by AssetsManager to load cube textures
  51838. */
  51839. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  51840. /**
  51841. * Defines the name of the task
  51842. */
  51843. name: string;
  51844. /**
  51845. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51846. */
  51847. url: string;
  51848. /**
  51849. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51850. */
  51851. extensions?: string[] | undefined;
  51852. /**
  51853. * Defines if mipmaps should not be generated (default is false)
  51854. */
  51855. noMipmap?: boolean | undefined;
  51856. /**
  51857. * Defines the explicit list of files (undefined by default)
  51858. */
  51859. files?: string[] | undefined;
  51860. /**
  51861. * Gets the loaded texture
  51862. */
  51863. texture: CubeTexture;
  51864. /**
  51865. * Callback called when the task is successful
  51866. */
  51867. onSuccess: (task: CubeTextureAssetTask) => void;
  51868. /**
  51869. * Callback called when the task is successful
  51870. */
  51871. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  51872. /**
  51873. * Creates a new CubeTextureAssetTask
  51874. * @param name defines the name of the task
  51875. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51876. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51877. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51878. * @param files defines the explicit list of files (undefined by default)
  51879. */
  51880. constructor(
  51881. /**
  51882. * Defines the name of the task
  51883. */
  51884. name: string,
  51885. /**
  51886. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51887. */
  51888. url: string,
  51889. /**
  51890. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51891. */
  51892. extensions?: string[] | undefined,
  51893. /**
  51894. * Defines if mipmaps should not be generated (default is false)
  51895. */
  51896. noMipmap?: boolean | undefined,
  51897. /**
  51898. * Defines the explicit list of files (undefined by default)
  51899. */
  51900. files?: string[] | undefined);
  51901. /**
  51902. * Execute the current task
  51903. * @param scene defines the scene where you want your assets to be loaded
  51904. * @param onSuccess is a callback called when the task is successfully executed
  51905. * @param onError is a callback called if an error occurs
  51906. */
  51907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51908. }
  51909. /**
  51910. * Define a task used by AssetsManager to load HDR cube textures
  51911. */
  51912. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  51913. /**
  51914. * Defines the name of the task
  51915. */
  51916. name: string;
  51917. /**
  51918. * Defines the location of the file to load
  51919. */
  51920. url: string;
  51921. /**
  51922. * Defines the desired size (the more it increases the longer the generation will be)
  51923. */
  51924. size: number;
  51925. /**
  51926. * Defines if mipmaps should not be generated (default is false)
  51927. */
  51928. noMipmap: boolean;
  51929. /**
  51930. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51931. */
  51932. generateHarmonics: boolean;
  51933. /**
  51934. * 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)
  51935. */
  51936. gammaSpace: boolean;
  51937. /**
  51938. * Internal Use Only
  51939. */
  51940. reserved: boolean;
  51941. /**
  51942. * Gets the loaded texture
  51943. */
  51944. texture: HDRCubeTexture;
  51945. /**
  51946. * Callback called when the task is successful
  51947. */
  51948. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  51949. /**
  51950. * Callback called when the task is successful
  51951. */
  51952. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  51953. /**
  51954. * Creates a new HDRCubeTextureAssetTask object
  51955. * @param name defines the name of the task
  51956. * @param url defines the location of the file to load
  51957. * @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.
  51958. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51959. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51960. * @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)
  51961. * @param reserved Internal use only
  51962. */
  51963. constructor(
  51964. /**
  51965. * Defines the name of the task
  51966. */
  51967. name: string,
  51968. /**
  51969. * Defines the location of the file to load
  51970. */
  51971. url: string,
  51972. /**
  51973. * Defines the desired size (the more it increases the longer the generation will be)
  51974. */
  51975. size: number,
  51976. /**
  51977. * Defines if mipmaps should not be generated (default is false)
  51978. */
  51979. noMipmap?: boolean,
  51980. /**
  51981. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51982. */
  51983. generateHarmonics?: boolean,
  51984. /**
  51985. * 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)
  51986. */
  51987. gammaSpace?: boolean,
  51988. /**
  51989. * Internal Use Only
  51990. */
  51991. reserved?: boolean);
  51992. /**
  51993. * Execute the current task
  51994. * @param scene defines the scene where you want your assets to be loaded
  51995. * @param onSuccess is a callback called when the task is successfully executed
  51996. * @param onError is a callback called if an error occurs
  51997. */
  51998. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51999. }
  52000. /**
  52001. * This class can be used to easily import assets into a scene
  52002. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  52003. */
  52004. export class AssetsManager {
  52005. private _scene;
  52006. private _isLoading;
  52007. protected _tasks: AbstractAssetTask[];
  52008. protected _waitingTasksCount: number;
  52009. protected _totalTasksCount: number;
  52010. /**
  52011. * Callback called when all tasks are processed
  52012. */
  52013. onFinish: (tasks: AbstractAssetTask[]) => void;
  52014. /**
  52015. * Callback called when a task is successful
  52016. */
  52017. onTaskSuccess: (task: AbstractAssetTask) => void;
  52018. /**
  52019. * Callback called when a task had an error
  52020. */
  52021. onTaskError: (task: AbstractAssetTask) => void;
  52022. /**
  52023. * Callback called when a task is done (whatever the result is)
  52024. */
  52025. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  52026. /**
  52027. * Observable called when all tasks are processed
  52028. */
  52029. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  52030. /**
  52031. * Observable called when a task had an error
  52032. */
  52033. onTaskErrorObservable: Observable<AbstractAssetTask>;
  52034. /**
  52035. * Observable called when a task is successful
  52036. */
  52037. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  52038. /**
  52039. * Observable called when a task is done (whatever the result is)
  52040. */
  52041. onProgressObservable: Observable<IAssetsProgressEvent>;
  52042. /**
  52043. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  52044. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52045. */
  52046. useDefaultLoadingScreen: boolean;
  52047. /**
  52048. * Creates a new AssetsManager
  52049. * @param scene defines the scene to work on
  52050. */
  52051. constructor(scene: Scene);
  52052. /**
  52053. * Add a MeshAssetTask to the list of active tasks
  52054. * @param taskName defines the name of the new task
  52055. * @param meshesNames defines the name of meshes to load
  52056. * @param rootUrl defines the root url to use to locate files
  52057. * @param sceneFilename defines the filename of the scene file
  52058. * @returns a new MeshAssetTask object
  52059. */
  52060. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  52061. /**
  52062. * Add a TextFileAssetTask to the list of active tasks
  52063. * @param taskName defines the name of the new task
  52064. * @param url defines the url of the file to load
  52065. * @returns a new TextFileAssetTask object
  52066. */
  52067. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  52068. /**
  52069. * Add a BinaryFileAssetTask to the list of active tasks
  52070. * @param taskName defines the name of the new task
  52071. * @param url defines the url of the file to load
  52072. * @returns a new BinaryFileAssetTask object
  52073. */
  52074. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  52075. /**
  52076. * Add a ImageAssetTask to the list of active tasks
  52077. * @param taskName defines the name of the new task
  52078. * @param url defines the url of the file to load
  52079. * @returns a new ImageAssetTask object
  52080. */
  52081. addImageTask(taskName: string, url: string): ImageAssetTask;
  52082. /**
  52083. * Add a TextureAssetTask to the list of active tasks
  52084. * @param taskName defines the name of the new task
  52085. * @param url defines the url of the file to load
  52086. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52087. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  52088. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52089. * @returns a new TextureAssetTask object
  52090. */
  52091. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  52092. /**
  52093. * Add a CubeTextureAssetTask to the list of active tasks
  52094. * @param taskName defines the name of the new task
  52095. * @param url defines the url of the file to load
  52096. * @param extensions defines the extension to use to load the cube map (can be null)
  52097. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52098. * @param files defines the list of files to load (can be null)
  52099. * @returns a new CubeTextureAssetTask object
  52100. */
  52101. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  52102. /**
  52103. *
  52104. * Add a HDRCubeTextureAssetTask to the list of active tasks
  52105. * @param taskName defines the name of the new task
  52106. * @param url defines the url of the file to load
  52107. * @param size defines the size you want for the cubemap (can be null)
  52108. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52109. * @param generateHarmonics defines if you want to automatically generate (true by default)
  52110. * @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)
  52111. * @param reserved Internal use only
  52112. * @returns a new HDRCubeTextureAssetTask object
  52113. */
  52114. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  52115. /**
  52116. * Remove a task from the assets manager.
  52117. * @param task the task to remove
  52118. */
  52119. removeTask(task: AbstractAssetTask): void;
  52120. private _decreaseWaitingTasksCount;
  52121. private _runTask;
  52122. /**
  52123. * Reset the AssetsManager and remove all tasks
  52124. * @return the current instance of the AssetsManager
  52125. */
  52126. reset(): AssetsManager;
  52127. /**
  52128. * Start the loading process
  52129. * @return the current instance of the AssetsManager
  52130. */
  52131. load(): AssetsManager;
  52132. }
  52133. }
  52134. declare module BABYLON {
  52135. /**
  52136. * Wrapper class for promise with external resolve and reject.
  52137. */
  52138. export class Deferred<T> {
  52139. /**
  52140. * The promise associated with this deferred object.
  52141. */
  52142. readonly promise: Promise<T>;
  52143. private _resolve;
  52144. private _reject;
  52145. /**
  52146. * The resolve method of the promise associated with this deferred object.
  52147. */
  52148. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  52149. /**
  52150. * The reject method of the promise associated with this deferred object.
  52151. */
  52152. readonly reject: (reason?: any) => void;
  52153. /**
  52154. * Constructor for this deferred object.
  52155. */
  52156. constructor();
  52157. }
  52158. }
  52159. declare module BABYLON {
  52160. /**
  52161. * Class used to help managing file picking and drag'n'drop
  52162. */
  52163. export class FilesInput {
  52164. /**
  52165. * List of files ready to be loaded
  52166. */
  52167. static readonly FilesToLoad: {
  52168. [key: string]: File;
  52169. };
  52170. /**
  52171. * Callback called when a file is processed
  52172. */
  52173. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  52174. private _engine;
  52175. private _currentScene;
  52176. private _sceneLoadedCallback;
  52177. private _progressCallback;
  52178. private _additionalRenderLoopLogicCallback;
  52179. private _textureLoadingCallback;
  52180. private _startingProcessingFilesCallback;
  52181. private _onReloadCallback;
  52182. private _errorCallback;
  52183. private _elementToMonitor;
  52184. private _sceneFileToLoad;
  52185. private _filesToLoad;
  52186. /**
  52187. * Creates a new FilesInput
  52188. * @param engine defines the rendering engine
  52189. * @param scene defines the hosting scene
  52190. * @param sceneLoadedCallback callback called when scene is loaded
  52191. * @param progressCallback callback called to track progress
  52192. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  52193. * @param textureLoadingCallback callback called when a texture is loading
  52194. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  52195. * @param onReloadCallback callback called when a reload is requested
  52196. * @param errorCallback callback call if an error occurs
  52197. */
  52198. 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);
  52199. private _dragEnterHandler;
  52200. private _dragOverHandler;
  52201. private _dropHandler;
  52202. /**
  52203. * Calls this function to listen to drag'n'drop events on a specific DOM element
  52204. * @param elementToMonitor defines the DOM element to track
  52205. */
  52206. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  52207. /**
  52208. * Release all associated resources
  52209. */
  52210. dispose(): void;
  52211. private renderFunction;
  52212. private drag;
  52213. private drop;
  52214. private _traverseFolder;
  52215. private _processFiles;
  52216. /**
  52217. * Load files from a drop event
  52218. * @param event defines the drop event to use as source
  52219. */
  52220. loadFiles(event: any): void;
  52221. private _processReload;
  52222. /**
  52223. * Reload the current scene from the loaded files
  52224. */
  52225. reload(): void;
  52226. }
  52227. }
  52228. declare module BABYLON {
  52229. /**
  52230. * Defines the root class used to create scene optimization to use with SceneOptimizer
  52231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52232. */
  52233. export class SceneOptimization {
  52234. /**
  52235. * Defines the priority of this optimization (0 by default which means first in the list)
  52236. */
  52237. priority: number;
  52238. /**
  52239. * Gets a string describing the action executed by the current optimization
  52240. * @returns description string
  52241. */
  52242. getDescription(): string;
  52243. /**
  52244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52245. * @param scene defines the current scene where to apply this optimization
  52246. * @param optimizer defines the current optimizer
  52247. * @returns true if everything that can be done was applied
  52248. */
  52249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52250. /**
  52251. * Creates the SceneOptimization object
  52252. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52253. * @param desc defines the description associated with the optimization
  52254. */
  52255. constructor(
  52256. /**
  52257. * Defines the priority of this optimization (0 by default which means first in the list)
  52258. */
  52259. priority?: number);
  52260. }
  52261. /**
  52262. * Defines an optimization used to reduce the size of render target textures
  52263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52264. */
  52265. export class TextureOptimization extends SceneOptimization {
  52266. /**
  52267. * Defines the priority of this optimization (0 by default which means first in the list)
  52268. */
  52269. priority: number;
  52270. /**
  52271. * 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
  52272. */
  52273. maximumSize: number;
  52274. /**
  52275. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52276. */
  52277. step: number;
  52278. /**
  52279. * Gets a string describing the action executed by the current optimization
  52280. * @returns description string
  52281. */
  52282. getDescription(): string;
  52283. /**
  52284. * Creates the TextureOptimization object
  52285. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52286. * @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
  52287. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52288. */
  52289. constructor(
  52290. /**
  52291. * Defines the priority of this optimization (0 by default which means first in the list)
  52292. */
  52293. priority?: number,
  52294. /**
  52295. * 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
  52296. */
  52297. maximumSize?: number,
  52298. /**
  52299. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52300. */
  52301. step?: number);
  52302. /**
  52303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52304. * @param scene defines the current scene where to apply this optimization
  52305. * @param optimizer defines the current optimizer
  52306. * @returns true if everything that can be done was applied
  52307. */
  52308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52309. }
  52310. /**
  52311. * Defines an optimization used to increase or decrease the rendering resolution
  52312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52313. */
  52314. export class HardwareScalingOptimization extends SceneOptimization {
  52315. /**
  52316. * Defines the priority of this optimization (0 by default which means first in the list)
  52317. */
  52318. priority: number;
  52319. /**
  52320. * Defines the maximum scale to use (2 by default)
  52321. */
  52322. maximumScale: number;
  52323. /**
  52324. * Defines the step to use between two passes (0.5 by default)
  52325. */
  52326. step: number;
  52327. private _currentScale;
  52328. private _directionOffset;
  52329. /**
  52330. * Gets a string describing the action executed by the current optimization
  52331. * @return description string
  52332. */
  52333. getDescription(): string;
  52334. /**
  52335. * Creates the HardwareScalingOptimization object
  52336. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52337. * @param maximumScale defines the maximum scale to use (2 by default)
  52338. * @param step defines the step to use between two passes (0.5 by default)
  52339. */
  52340. constructor(
  52341. /**
  52342. * Defines the priority of this optimization (0 by default which means first in the list)
  52343. */
  52344. priority?: number,
  52345. /**
  52346. * Defines the maximum scale to use (2 by default)
  52347. */
  52348. maximumScale?: number,
  52349. /**
  52350. * Defines the step to use between two passes (0.5 by default)
  52351. */
  52352. step?: number);
  52353. /**
  52354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52355. * @param scene defines the current scene where to apply this optimization
  52356. * @param optimizer defines the current optimizer
  52357. * @returns true if everything that can be done was applied
  52358. */
  52359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52360. }
  52361. /**
  52362. * Defines an optimization used to remove shadows
  52363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52364. */
  52365. export class ShadowsOptimization extends SceneOptimization {
  52366. /**
  52367. * Gets a string describing the action executed by the current optimization
  52368. * @return description string
  52369. */
  52370. getDescription(): string;
  52371. /**
  52372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52373. * @param scene defines the current scene where to apply this optimization
  52374. * @param optimizer defines the current optimizer
  52375. * @returns true if everything that can be done was applied
  52376. */
  52377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52378. }
  52379. /**
  52380. * Defines an optimization used to turn post-processes off
  52381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52382. */
  52383. export class PostProcessesOptimization extends SceneOptimization {
  52384. /**
  52385. * Gets a string describing the action executed by the current optimization
  52386. * @return description string
  52387. */
  52388. getDescription(): string;
  52389. /**
  52390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52391. * @param scene defines the current scene where to apply this optimization
  52392. * @param optimizer defines the current optimizer
  52393. * @returns true if everything that can be done was applied
  52394. */
  52395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52396. }
  52397. /**
  52398. * Defines an optimization used to turn lens flares off
  52399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52400. */
  52401. export class LensFlaresOptimization extends SceneOptimization {
  52402. /**
  52403. * Gets a string describing the action executed by the current optimization
  52404. * @return description string
  52405. */
  52406. getDescription(): string;
  52407. /**
  52408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52409. * @param scene defines the current scene where to apply this optimization
  52410. * @param optimizer defines the current optimizer
  52411. * @returns true if everything that can be done was applied
  52412. */
  52413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52414. }
  52415. /**
  52416. * Defines an optimization based on user defined callback.
  52417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52418. */
  52419. export class CustomOptimization extends SceneOptimization {
  52420. /**
  52421. * Callback called to apply the custom optimization.
  52422. */
  52423. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52424. /**
  52425. * Callback called to get custom description
  52426. */
  52427. onGetDescription: () => string;
  52428. /**
  52429. * Gets a string describing the action executed by the current optimization
  52430. * @returns description string
  52431. */
  52432. getDescription(): string;
  52433. /**
  52434. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52435. * @param scene defines the current scene where to apply this optimization
  52436. * @param optimizer defines the current optimizer
  52437. * @returns true if everything that can be done was applied
  52438. */
  52439. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52440. }
  52441. /**
  52442. * Defines an optimization used to turn particles off
  52443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52444. */
  52445. export class ParticlesOptimization extends SceneOptimization {
  52446. /**
  52447. * Gets a string describing the action executed by the current optimization
  52448. * @return description string
  52449. */
  52450. getDescription(): string;
  52451. /**
  52452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52453. * @param scene defines the current scene where to apply this optimization
  52454. * @param optimizer defines the current optimizer
  52455. * @returns true if everything that can be done was applied
  52456. */
  52457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52458. }
  52459. /**
  52460. * Defines an optimization used to turn render targets off
  52461. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52462. */
  52463. export class RenderTargetsOptimization extends SceneOptimization {
  52464. /**
  52465. * Gets a string describing the action executed by the current optimization
  52466. * @return description string
  52467. */
  52468. getDescription(): string;
  52469. /**
  52470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52471. * @param scene defines the current scene where to apply this optimization
  52472. * @param optimizer defines the current optimizer
  52473. * @returns true if everything that can be done was applied
  52474. */
  52475. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52476. }
  52477. /**
  52478. * Defines an optimization used to merge meshes with compatible materials
  52479. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52480. */
  52481. export class MergeMeshesOptimization extends SceneOptimization {
  52482. private static _UpdateSelectionTree;
  52483. /**
  52484. * Gets or sets a boolean which defines if optimization octree has to be updated
  52485. */
  52486. /**
  52487. * Gets or sets a boolean which defines if optimization octree has to be updated
  52488. */
  52489. static UpdateSelectionTree: boolean;
  52490. /**
  52491. * Gets a string describing the action executed by the current optimization
  52492. * @return description string
  52493. */
  52494. getDescription(): string;
  52495. private _canBeMerged;
  52496. /**
  52497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52498. * @param scene defines the current scene where to apply this optimization
  52499. * @param optimizer defines the current optimizer
  52500. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52501. * @returns true if everything that can be done was applied
  52502. */
  52503. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52504. }
  52505. /**
  52506. * Defines a list of options used by SceneOptimizer
  52507. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52508. */
  52509. export class SceneOptimizerOptions {
  52510. /**
  52511. * Defines the target frame rate to reach (60 by default)
  52512. */
  52513. targetFrameRate: number;
  52514. /**
  52515. * Defines the interval between two checkes (2000ms by default)
  52516. */
  52517. trackerDuration: number;
  52518. /**
  52519. * Gets the list of optimizations to apply
  52520. */
  52521. optimizations: SceneOptimization[];
  52522. /**
  52523. * Creates a new list of options used by SceneOptimizer
  52524. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52525. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52526. */
  52527. constructor(
  52528. /**
  52529. * Defines the target frame rate to reach (60 by default)
  52530. */
  52531. targetFrameRate?: number,
  52532. /**
  52533. * Defines the interval between two checkes (2000ms by default)
  52534. */
  52535. trackerDuration?: number);
  52536. /**
  52537. * Add a new optimization
  52538. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52539. * @returns the current SceneOptimizerOptions
  52540. */
  52541. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52542. /**
  52543. * Add a new custom optimization
  52544. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52545. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52546. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52547. * @returns the current SceneOptimizerOptions
  52548. */
  52549. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52550. /**
  52551. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52552. * @param targetFrameRate defines the target frame rate (60 by default)
  52553. * @returns a SceneOptimizerOptions object
  52554. */
  52555. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52556. /**
  52557. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52558. * @param targetFrameRate defines the target frame rate (60 by default)
  52559. * @returns a SceneOptimizerOptions object
  52560. */
  52561. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52562. /**
  52563. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52564. * @param targetFrameRate defines the target frame rate (60 by default)
  52565. * @returns a SceneOptimizerOptions object
  52566. */
  52567. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52568. }
  52569. /**
  52570. * Class used to run optimizations in order to reach a target frame rate
  52571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52572. */
  52573. export class SceneOptimizer implements IDisposable {
  52574. private _isRunning;
  52575. private _options;
  52576. private _scene;
  52577. private _currentPriorityLevel;
  52578. private _targetFrameRate;
  52579. private _trackerDuration;
  52580. private _currentFrameRate;
  52581. private _sceneDisposeObserver;
  52582. private _improvementMode;
  52583. /**
  52584. * Defines an observable called when the optimizer reaches the target frame rate
  52585. */
  52586. onSuccessObservable: Observable<SceneOptimizer>;
  52587. /**
  52588. * Defines an observable called when the optimizer enables an optimization
  52589. */
  52590. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  52591. /**
  52592. * Defines an observable called when the optimizer is not able to reach the target frame rate
  52593. */
  52594. onFailureObservable: Observable<SceneOptimizer>;
  52595. /**
  52596. * Gets a boolean indicating if the optimizer is in improvement mode
  52597. */
  52598. readonly isInImprovementMode: boolean;
  52599. /**
  52600. * Gets the current priority level (0 at start)
  52601. */
  52602. readonly currentPriorityLevel: number;
  52603. /**
  52604. * Gets the current frame rate checked by the SceneOptimizer
  52605. */
  52606. readonly currentFrameRate: number;
  52607. /**
  52608. * Gets or sets the current target frame rate (60 by default)
  52609. */
  52610. /**
  52611. * Gets or sets the current target frame rate (60 by default)
  52612. */
  52613. targetFrameRate: number;
  52614. /**
  52615. * Gets or sets the current interval between two checks (every 2000ms by default)
  52616. */
  52617. /**
  52618. * Gets or sets the current interval between two checks (every 2000ms by default)
  52619. */
  52620. trackerDuration: number;
  52621. /**
  52622. * Gets the list of active optimizations
  52623. */
  52624. readonly optimizations: SceneOptimization[];
  52625. /**
  52626. * Creates a new SceneOptimizer
  52627. * @param scene defines the scene to work on
  52628. * @param options defines the options to use with the SceneOptimizer
  52629. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  52630. * @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)
  52631. */
  52632. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  52633. /**
  52634. * Stops the current optimizer
  52635. */
  52636. stop(): void;
  52637. /**
  52638. * Reset the optimizer to initial step (current priority level = 0)
  52639. */
  52640. reset(): void;
  52641. /**
  52642. * Start the optimizer. By default it will try to reach a specific framerate
  52643. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  52644. */
  52645. start(): void;
  52646. private _checkCurrentState;
  52647. /**
  52648. * Release all resources
  52649. */
  52650. dispose(): void;
  52651. /**
  52652. * Helper function to create a SceneOptimizer with one single line of code
  52653. * @param scene defines the scene to work on
  52654. * @param options defines the options to use with the SceneOptimizer
  52655. * @param onSuccess defines a callback to call on success
  52656. * @param onFailure defines a callback to call on failure
  52657. * @returns the new SceneOptimizer object
  52658. */
  52659. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  52660. }
  52661. }
  52662. declare module BABYLON {
  52663. /**
  52664. * Class used to serialize a scene into a string
  52665. */
  52666. export class SceneSerializer {
  52667. /**
  52668. * Clear cache used by a previous serialization
  52669. */
  52670. static ClearCache(): void;
  52671. /**
  52672. * Serialize a scene into a JSON compatible object
  52673. * @param scene defines the scene to serialize
  52674. * @returns a JSON compatible object
  52675. */
  52676. static Serialize(scene: Scene): any;
  52677. /**
  52678. * Serialize a mesh into a JSON compatible object
  52679. * @param toSerialize defines the mesh to serialize
  52680. * @param withParents defines if parents must be serialized as well
  52681. * @param withChildren defines if children must be serialized as well
  52682. * @returns a JSON compatible object
  52683. */
  52684. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  52685. }
  52686. }
  52687. declare module BABYLON {
  52688. /**
  52689. * This represents the different options avilable for the video capture.
  52690. */
  52691. export interface VideoRecorderOptions {
  52692. /** Defines the mime type of the video */
  52693. mimeType: string;
  52694. /** Defines the video the video should be recorded at */
  52695. fps: number;
  52696. /** Defines the chunk size for the recording data */
  52697. recordChunckSize: number;
  52698. }
  52699. /**
  52700. * This can helps recording videos from BabylonJS.
  52701. * This is based on the available WebRTC functionalities of the browser.
  52702. *
  52703. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  52704. */
  52705. export class VideoRecorder {
  52706. private static readonly _defaultOptions;
  52707. /**
  52708. * Returns wehther or not the VideoRecorder is available in your browser.
  52709. * @param engine Defines the Babylon Engine to check the support for
  52710. * @returns true if supported otherwise false
  52711. */
  52712. static IsSupported(engine: Engine): boolean;
  52713. private readonly _options;
  52714. private _canvas;
  52715. private _mediaRecorder;
  52716. private _recordedChunks;
  52717. private _fileName;
  52718. private _resolve;
  52719. private _reject;
  52720. /**
  52721. * True wether a recording is already in progress.
  52722. */
  52723. readonly isRecording: boolean;
  52724. /**
  52725. * Create a new VideoCapture object which can help converting what you see in Babylon to
  52726. * a video file.
  52727. * @param engine Defines the BabylonJS Engine you wish to record
  52728. * @param options Defines options that can be used to customized the capture
  52729. */
  52730. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  52731. /**
  52732. * Stops the current recording before the default capture timeout passed in the startRecording
  52733. * functions.
  52734. */
  52735. stopRecording(): void;
  52736. /**
  52737. * Starts recording the canvas for a max duration specified in parameters.
  52738. * @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.
  52739. * @param maxDuration Defines the maximum recording time in seconds.
  52740. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  52741. * @return a promise callback at the end of the recording with the video data in Blob.
  52742. */
  52743. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  52744. /**
  52745. * Releases internal resources used during the recording.
  52746. */
  52747. dispose(): void;
  52748. private _handleDataAvailable;
  52749. private _handleError;
  52750. private _handleStop;
  52751. }
  52752. }
  52753. declare module BABYLON {
  52754. /**
  52755. * Helper class to push actions to a pool of workers.
  52756. */
  52757. export class WorkerPool implements IDisposable {
  52758. private _workerInfos;
  52759. private _pendingActions;
  52760. /**
  52761. * Constructor
  52762. * @param workers Array of workers to use for actions
  52763. */
  52764. constructor(workers: Array<Worker>);
  52765. /**
  52766. * Terminates all workers and clears any pending actions.
  52767. */
  52768. dispose(): void;
  52769. /**
  52770. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52771. * pended until a worker has completed its action.
  52772. * @param action The action to perform. Call onComplete when the action is complete.
  52773. */
  52774. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52775. private _execute;
  52776. }
  52777. }
  52778. declare module BABYLON {
  52779. /**
  52780. * Class containing a set of static utilities functions for screenshots
  52781. */
  52782. export class ScreenshotTools {
  52783. /**
  52784. * Captures a screenshot of the current rendering
  52785. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52786. * @param engine defines the rendering engine
  52787. * @param camera defines the source camera
  52788. * @param size This parameter can be set to a single number or to an object with the
  52789. * following (optional) properties: precision, width, height. If a single number is passed,
  52790. * it will be used for both width and height. If an object is passed, the screenshot size
  52791. * will be derived from the parameters. The precision property is a multiplier allowing
  52792. * rendering at a higher or lower resolution
  52793. * @param successCallback defines the callback receives a single parameter which contains the
  52794. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52795. * src parameter of an <img> to display it
  52796. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  52797. * Check your browser for supported MIME types
  52798. */
  52799. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  52800. /**
  52801. * Generates an image screenshot from the specified camera.
  52802. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52803. * @param engine The engine to use for rendering
  52804. * @param camera The camera to use for rendering
  52805. * @param size This parameter can be set to a single number or to an object with the
  52806. * following (optional) properties: precision, width, height. If a single number is passed,
  52807. * it will be used for both width and height. If an object is passed, the screenshot size
  52808. * will be derived from the parameters. The precision property is a multiplier allowing
  52809. * rendering at a higher or lower resolution
  52810. * @param successCallback The callback receives a single parameter which contains the
  52811. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52812. * src parameter of an <img> to display it
  52813. * @param mimeType The MIME type of the screenshot image (default: image/png).
  52814. * Check your browser for supported MIME types
  52815. * @param samples Texture samples (default: 1)
  52816. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  52817. * @param fileName A name for for the downloaded file.
  52818. */
  52819. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  52820. }
  52821. }
  52822. declare module BABYLON {
  52823. /** @hidden */
  52824. export var blurPixelShader: {
  52825. name: string;
  52826. shader: string;
  52827. };
  52828. }
  52829. declare module BABYLON {
  52830. /** @hidden */
  52831. export var bones300Declaration: {
  52832. name: string;
  52833. shader: string;
  52834. };
  52835. }
  52836. declare module BABYLON {
  52837. /** @hidden */
  52838. export var instances300Declaration: {
  52839. name: string;
  52840. shader: string;
  52841. };
  52842. }
  52843. declare module BABYLON {
  52844. /** @hidden */
  52845. export var pointCloudVertexDeclaration: {
  52846. name: string;
  52847. shader: string;
  52848. };
  52849. }
  52850. // Mixins
  52851. interface Window {
  52852. mozIndexedDB: IDBFactory;
  52853. webkitIndexedDB: IDBFactory;
  52854. msIndexedDB: IDBFactory;
  52855. webkitURL: typeof URL;
  52856. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  52857. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  52858. WebGLRenderingContext: WebGLRenderingContext;
  52859. MSGesture: MSGesture;
  52860. CANNON: any;
  52861. AudioContext: AudioContext;
  52862. webkitAudioContext: AudioContext;
  52863. PointerEvent: any;
  52864. Math: Math;
  52865. Uint8Array: Uint8ArrayConstructor;
  52866. Float32Array: Float32ArrayConstructor;
  52867. mozURL: typeof URL;
  52868. msURL: typeof URL;
  52869. VRFrameData: any; // WebVR, from specs 1.1
  52870. DracoDecoderModule: any;
  52871. setImmediate(handler: (...args: any[]) => void): number;
  52872. }
  52873. interface Document {
  52874. mozCancelFullScreen(): void;
  52875. msCancelFullScreen(): void;
  52876. webkitCancelFullScreen(): void;
  52877. requestPointerLock(): void;
  52878. exitPointerLock(): void;
  52879. mozFullScreen: boolean;
  52880. msIsFullScreen: boolean;
  52881. readonly webkitIsFullScreen: boolean;
  52882. readonly pointerLockElement: Element;
  52883. mozPointerLockElement: HTMLElement;
  52884. msPointerLockElement: HTMLElement;
  52885. webkitPointerLockElement: HTMLElement;
  52886. }
  52887. interface HTMLCanvasElement {
  52888. requestPointerLock(): void;
  52889. msRequestPointerLock?(): void;
  52890. mozRequestPointerLock?(): void;
  52891. webkitRequestPointerLock?(): void;
  52892. /** Track wether a record is in progress */
  52893. isRecording: boolean;
  52894. /** Capture Stream method defined by some browsers */
  52895. captureStream(fps?: number): MediaStream;
  52896. }
  52897. interface CanvasRenderingContext2D {
  52898. msImageSmoothingEnabled: boolean;
  52899. }
  52900. interface MouseEvent {
  52901. mozMovementX: number;
  52902. mozMovementY: number;
  52903. webkitMovementX: number;
  52904. webkitMovementY: number;
  52905. msMovementX: number;
  52906. msMovementY: number;
  52907. }
  52908. interface Navigator {
  52909. mozGetVRDevices: (any: any) => any;
  52910. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52911. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52912. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52913. webkitGetGamepads(): Gamepad[];
  52914. msGetGamepads(): Gamepad[];
  52915. webkitGamepads(): Gamepad[];
  52916. }
  52917. interface HTMLVideoElement {
  52918. mozSrcObject: any;
  52919. }
  52920. interface Math {
  52921. fround(x: number): number;
  52922. imul(a: number, b: number): number;
  52923. }
  52924. interface WebGLProgram {
  52925. context?: WebGLRenderingContext;
  52926. vertexShader?: WebGLShader;
  52927. fragmentShader?: WebGLShader;
  52928. isParallelCompiled: boolean;
  52929. onCompiled?: () => void;
  52930. }
  52931. interface WebGLRenderingContext {
  52932. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  52933. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  52934. vertexAttribDivisor(index: number, divisor: number): void;
  52935. createVertexArray(): any;
  52936. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  52937. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  52938. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  52939. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  52940. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  52941. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  52942. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  52943. // Queries
  52944. createQuery(): WebGLQuery;
  52945. deleteQuery(query: WebGLQuery): void;
  52946. beginQuery(target: number, query: WebGLQuery): void;
  52947. endQuery(target: number): void;
  52948. getQueryParameter(query: WebGLQuery, pname: number): any;
  52949. getQuery(target: number, pname: number): any;
  52950. MAX_SAMPLES: number;
  52951. RGBA8: number;
  52952. READ_FRAMEBUFFER: number;
  52953. DRAW_FRAMEBUFFER: number;
  52954. UNIFORM_BUFFER: number;
  52955. HALF_FLOAT_OES: number;
  52956. RGBA16F: number;
  52957. RGBA32F: number;
  52958. R32F: number;
  52959. RG32F: number;
  52960. RGB32F: number;
  52961. R16F: number;
  52962. RG16F: number;
  52963. RGB16F: number;
  52964. RED: number;
  52965. RG: number;
  52966. R8: number;
  52967. RG8: number;
  52968. UNSIGNED_INT_24_8: number;
  52969. DEPTH24_STENCIL8: number;
  52970. /* Multiple Render Targets */
  52971. drawBuffers(buffers: number[]): void;
  52972. readBuffer(src: number): void;
  52973. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  52974. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  52975. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  52976. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  52977. // Occlusion Query
  52978. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  52979. ANY_SAMPLES_PASSED: number;
  52980. QUERY_RESULT_AVAILABLE: number;
  52981. QUERY_RESULT: number;
  52982. }
  52983. interface WebGLBuffer {
  52984. references: number;
  52985. capacity: number;
  52986. is32Bits: boolean;
  52987. }
  52988. interface WebGLProgram {
  52989. transformFeedback?: WebGLTransformFeedback | null;
  52990. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  52991. }
  52992. interface EXT_disjoint_timer_query {
  52993. QUERY_COUNTER_BITS_EXT: number;
  52994. TIME_ELAPSED_EXT: number;
  52995. TIMESTAMP_EXT: number;
  52996. GPU_DISJOINT_EXT: number;
  52997. QUERY_RESULT_EXT: number;
  52998. QUERY_RESULT_AVAILABLE_EXT: number;
  52999. queryCounterEXT(query: WebGLQuery, target: number): void;
  53000. createQueryEXT(): WebGLQuery;
  53001. beginQueryEXT(target: number, query: WebGLQuery): void;
  53002. endQueryEXT(target: number): void;
  53003. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  53004. deleteQueryEXT(query: WebGLQuery): void;
  53005. }
  53006. interface WebGLUniformLocation {
  53007. _currentState: any;
  53008. }
  53009. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  53010. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  53011. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  53012. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53013. interface WebGLRenderingContext {
  53014. readonly RASTERIZER_DISCARD: number;
  53015. readonly DEPTH_COMPONENT24: number;
  53016. readonly TEXTURE_3D: number;
  53017. readonly TEXTURE_2D_ARRAY: number;
  53018. readonly TEXTURE_COMPARE_FUNC: number;
  53019. readonly TEXTURE_COMPARE_MODE: number;
  53020. readonly COMPARE_REF_TO_TEXTURE: number;
  53021. readonly TEXTURE_WRAP_R: number;
  53022. readonly HALF_FLOAT: number;
  53023. readonly RGB8: number;
  53024. readonly RED_INTEGER: number;
  53025. readonly RG_INTEGER: number;
  53026. readonly RGB_INTEGER: number;
  53027. readonly RGBA_INTEGER: number;
  53028. readonly R8_SNORM: number;
  53029. readonly RG8_SNORM: number;
  53030. readonly RGB8_SNORM: number;
  53031. readonly RGBA8_SNORM: number;
  53032. readonly R8I: number;
  53033. readonly RG8I: number;
  53034. readonly RGB8I: number;
  53035. readonly RGBA8I: number;
  53036. readonly R8UI: number;
  53037. readonly RG8UI: number;
  53038. readonly RGB8UI: number;
  53039. readonly RGBA8UI: number;
  53040. readonly R16I: number;
  53041. readonly RG16I: number;
  53042. readonly RGB16I: number;
  53043. readonly RGBA16I: number;
  53044. readonly R16UI: number;
  53045. readonly RG16UI: number;
  53046. readonly RGB16UI: number;
  53047. readonly RGBA16UI: number;
  53048. readonly R32I: number;
  53049. readonly RG32I: number;
  53050. readonly RGB32I: number;
  53051. readonly RGBA32I: number;
  53052. readonly R32UI: number;
  53053. readonly RG32UI: number;
  53054. readonly RGB32UI: number;
  53055. readonly RGBA32UI: number;
  53056. readonly RGB10_A2UI: number;
  53057. readonly R11F_G11F_B10F: number;
  53058. readonly RGB9_E5: number;
  53059. readonly RGB10_A2: number;
  53060. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  53061. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  53062. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  53063. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  53064. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  53065. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  53066. 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;
  53067. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  53068. readonly TRANSFORM_FEEDBACK: number;
  53069. readonly INTERLEAVED_ATTRIBS: number;
  53070. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  53071. createTransformFeedback(): WebGLTransformFeedback;
  53072. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  53073. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  53074. beginTransformFeedback(primitiveMode: number): void;
  53075. endTransformFeedback(): void;
  53076. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  53077. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53078. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53079. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53080. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  53081. }
  53082. interface ImageBitmap {
  53083. readonly width: number;
  53084. readonly height: number;
  53085. close(): void;
  53086. }
  53087. interface WebGLQuery extends WebGLObject {
  53088. }
  53089. declare var WebGLQuery: {
  53090. prototype: WebGLQuery;
  53091. new(): WebGLQuery;
  53092. };
  53093. interface WebGLSampler extends WebGLObject {
  53094. }
  53095. declare var WebGLSampler: {
  53096. prototype: WebGLSampler;
  53097. new(): WebGLSampler;
  53098. };
  53099. interface WebGLSync extends WebGLObject {
  53100. }
  53101. declare var WebGLSync: {
  53102. prototype: WebGLSync;
  53103. new(): WebGLSync;
  53104. };
  53105. interface WebGLTransformFeedback extends WebGLObject {
  53106. }
  53107. declare var WebGLTransformFeedback: {
  53108. prototype: WebGLTransformFeedback;
  53109. new(): WebGLTransformFeedback;
  53110. };
  53111. interface WebGLVertexArrayObject extends WebGLObject {
  53112. }
  53113. declare var WebGLVertexArrayObject: {
  53114. prototype: WebGLVertexArrayObject;
  53115. new(): WebGLVertexArrayObject;
  53116. };
  53117. // Type definitions for WebVR API
  53118. // Project: https://w3c.github.io/webvr/
  53119. // Definitions by: six a <https://github.com/lostfictions>
  53120. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53121. interface VRDisplay extends EventTarget {
  53122. /**
  53123. * Dictionary of capabilities describing the VRDisplay.
  53124. */
  53125. readonly capabilities: VRDisplayCapabilities;
  53126. /**
  53127. * z-depth defining the far plane of the eye view frustum
  53128. * enables mapping of values in the render target depth
  53129. * attachment to scene coordinates. Initially set to 10000.0.
  53130. */
  53131. depthFar: number;
  53132. /**
  53133. * z-depth defining the near plane of the eye view frustum
  53134. * enables mapping of values in the render target depth
  53135. * attachment to scene coordinates. Initially set to 0.01.
  53136. */
  53137. depthNear: number;
  53138. /**
  53139. * An identifier for this distinct VRDisplay. Used as an
  53140. * association point in the Gamepad API.
  53141. */
  53142. readonly displayId: number;
  53143. /**
  53144. * A display name, a user-readable name identifying it.
  53145. */
  53146. readonly displayName: string;
  53147. readonly isConnected: boolean;
  53148. readonly isPresenting: boolean;
  53149. /**
  53150. * If this VRDisplay supports room-scale experiences, the optional
  53151. * stage attribute contains details on the room-scale parameters.
  53152. */
  53153. readonly stageParameters: VRStageParameters | null;
  53154. /**
  53155. * Passing the value returned by `requestAnimationFrame` to
  53156. * `cancelAnimationFrame` will unregister the callback.
  53157. * @param handle Define the hanle of the request to cancel
  53158. */
  53159. cancelAnimationFrame(handle: number): void;
  53160. /**
  53161. * Stops presenting to the VRDisplay.
  53162. * @returns a promise to know when it stopped
  53163. */
  53164. exitPresent(): Promise<void>;
  53165. /**
  53166. * Return the current VREyeParameters for the given eye.
  53167. * @param whichEye Define the eye we want the parameter for
  53168. * @returns the eye parameters
  53169. */
  53170. getEyeParameters(whichEye: string): VREyeParameters;
  53171. /**
  53172. * Populates the passed VRFrameData with the information required to render
  53173. * the current frame.
  53174. * @param frameData Define the data structure to populate
  53175. * @returns true if ok otherwise false
  53176. */
  53177. getFrameData(frameData: VRFrameData): boolean;
  53178. /**
  53179. * Get the layers currently being presented.
  53180. * @returns the list of VR layers
  53181. */
  53182. getLayers(): VRLayer[];
  53183. /**
  53184. * Return a VRPose containing the future predicted pose of the VRDisplay
  53185. * when the current frame will be presented. The value returned will not
  53186. * change until JavaScript has returned control to the browser.
  53187. *
  53188. * The VRPose will contain the position, orientation, velocity,
  53189. * and acceleration of each of these properties.
  53190. * @returns the pose object
  53191. */
  53192. getPose(): VRPose;
  53193. /**
  53194. * Return the current instantaneous pose of the VRDisplay, with no
  53195. * prediction applied.
  53196. * @returns the current instantaneous pose
  53197. */
  53198. getImmediatePose(): VRPose;
  53199. /**
  53200. * The callback passed to `requestAnimationFrame` will be called
  53201. * any time a new frame should be rendered. When the VRDisplay is
  53202. * presenting the callback will be called at the native refresh
  53203. * rate of the HMD. When not presenting this function acts
  53204. * identically to how window.requestAnimationFrame acts. Content should
  53205. * make no assumptions of frame rate or vsync behavior as the HMD runs
  53206. * asynchronously from other displays and at differing refresh rates.
  53207. * @param callback Define the eaction to run next frame
  53208. * @returns the request handle it
  53209. */
  53210. requestAnimationFrame(callback: FrameRequestCallback): number;
  53211. /**
  53212. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  53213. * Repeat calls while already presenting will update the VRLayers being displayed.
  53214. * @param layers Define the list of layer to present
  53215. * @returns a promise to know when the request has been fulfilled
  53216. */
  53217. requestPresent(layers: VRLayer[]): Promise<void>;
  53218. /**
  53219. * Reset the pose for this display, treating its current position and
  53220. * orientation as the "origin/zero" values. VRPose.position,
  53221. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53222. * updated when calling resetPose(). This should be called in only
  53223. * sitting-space experiences.
  53224. */
  53225. resetPose(): void;
  53226. /**
  53227. * The VRLayer provided to the VRDisplay will be captured and presented
  53228. * in the HMD. Calling this function has the same effect on the source
  53229. * canvas as any other operation that uses its source image, and canvases
  53230. * created without preserveDrawingBuffer set to true will be cleared.
  53231. * @param pose Define the pose to submit
  53232. */
  53233. submitFrame(pose?: VRPose): void;
  53234. }
  53235. declare var VRDisplay: {
  53236. prototype: VRDisplay;
  53237. new(): VRDisplay;
  53238. };
  53239. interface VRLayer {
  53240. leftBounds?: number[] | Float32Array | null;
  53241. rightBounds?: number[] | Float32Array | null;
  53242. source?: HTMLCanvasElement | null;
  53243. }
  53244. interface VRDisplayCapabilities {
  53245. readonly canPresent: boolean;
  53246. readonly hasExternalDisplay: boolean;
  53247. readonly hasOrientation: boolean;
  53248. readonly hasPosition: boolean;
  53249. readonly maxLayers: number;
  53250. }
  53251. interface VREyeParameters {
  53252. /** @deprecated */
  53253. readonly fieldOfView: VRFieldOfView;
  53254. readonly offset: Float32Array;
  53255. readonly renderHeight: number;
  53256. readonly renderWidth: number;
  53257. }
  53258. interface VRFieldOfView {
  53259. readonly downDegrees: number;
  53260. readonly leftDegrees: number;
  53261. readonly rightDegrees: number;
  53262. readonly upDegrees: number;
  53263. }
  53264. interface VRFrameData {
  53265. readonly leftProjectionMatrix: Float32Array;
  53266. readonly leftViewMatrix: Float32Array;
  53267. readonly pose: VRPose;
  53268. readonly rightProjectionMatrix: Float32Array;
  53269. readonly rightViewMatrix: Float32Array;
  53270. readonly timestamp: number;
  53271. }
  53272. interface VRPose {
  53273. readonly angularAcceleration: Float32Array | null;
  53274. readonly angularVelocity: Float32Array | null;
  53275. readonly linearAcceleration: Float32Array | null;
  53276. readonly linearVelocity: Float32Array | null;
  53277. readonly orientation: Float32Array | null;
  53278. readonly position: Float32Array | null;
  53279. readonly timestamp: number;
  53280. }
  53281. interface VRStageParameters {
  53282. sittingToStandingTransform?: Float32Array;
  53283. sizeX?: number;
  53284. sizeY?: number;
  53285. }
  53286. interface Navigator {
  53287. getVRDisplays(): Promise<VRDisplay[]>;
  53288. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53289. }
  53290. interface Window {
  53291. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53292. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53293. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53294. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53295. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53296. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53297. }
  53298. interface Gamepad {
  53299. readonly displayId: number;
  53300. }
  53301. interface XRDevice {
  53302. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53303. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53304. }
  53305. interface XRSession {
  53306. getInputSources(): Array<any>;
  53307. baseLayer: XRWebGLLayer;
  53308. requestFrameOfReference(type: string): Promise<void>;
  53309. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53310. end(): Promise<void>;
  53311. requestAnimationFrame: Function;
  53312. addEventListener: Function;
  53313. }
  53314. interface XRSessionCreationOptions {
  53315. outputContext?: WebGLRenderingContext | null;
  53316. immersive?: boolean;
  53317. environmentIntegration?: boolean;
  53318. }
  53319. interface XRLayer {
  53320. getViewport: Function;
  53321. framebufferWidth: number;
  53322. framebufferHeight: number;
  53323. }
  53324. interface XRView {
  53325. projectionMatrix: Float32Array;
  53326. }
  53327. interface XRFrame {
  53328. getDevicePose: Function;
  53329. getInputPose: Function;
  53330. views: Array<XRView>;
  53331. baseLayer: XRLayer;
  53332. }
  53333. interface XRFrameOfReference {
  53334. }
  53335. interface XRWebGLLayer extends XRLayer {
  53336. framebuffer: WebGLFramebuffer;
  53337. }
  53338. declare var XRWebGLLayer: {
  53339. prototype: XRWebGLLayer;
  53340. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53341. };