babylon.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * 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)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * 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
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. 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;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. 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;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * 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"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * 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".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  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 firstNormal (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. * Moves the observable to the top of the observer list making it get called first when notified
  4354. * @param observer the observer to move
  4355. */
  4356. makeObserverTopPriority(observer: Observer<T>): void;
  4357. /**
  4358. * Moves the observable to the bottom of the observer list making it get called last when notified
  4359. * @param observer the observer to move
  4360. */
  4361. makeObserverBottomPriority(observer: Observer<T>): void;
  4362. /**
  4363. * Notify all Observers by calling their respective callback with the given data
  4364. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4365. * @param eventData defines the data to send to all observers
  4366. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4367. * @param target defines the original target of the state
  4368. * @param currentTarget defines the current target of the state
  4369. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4370. */
  4371. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4372. /**
  4373. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4374. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4375. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4376. * and it is crucial that all callbacks will be executed.
  4377. * The order of the callbacks is kept, callbacks are not executed parallel.
  4378. *
  4379. * @param eventData The data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. * @param target defines the callback target (see EventState)
  4382. * @param currentTarget defines he current object in the bubbling phase
  4383. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4384. */
  4385. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4386. /**
  4387. * Notify a specific observer
  4388. * @param observer defines the observer to notify
  4389. * @param eventData defines the data to be sent to each callback
  4390. * @param mask is used to filter observers defaults to -1
  4391. */
  4392. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4393. /**
  4394. * Gets a boolean indicating if the observable has at least one observer
  4395. * @returns true is the Observable has at least one Observer registered
  4396. */
  4397. hasObservers(): boolean;
  4398. /**
  4399. * Clear the list of observers
  4400. */
  4401. clear(): void;
  4402. /**
  4403. * Clone the current observable
  4404. * @returns a new observable
  4405. */
  4406. clone(): Observable<T>;
  4407. /**
  4408. * Does this observable handles observer registered with a given mask
  4409. * @param mask defines the mask to be tested
  4410. * @return whether or not one observer registered with the given mask is handeled
  4411. **/
  4412. hasSpecificMask(mask?: number): boolean;
  4413. }
  4414. }
  4415. declare module BABYLON {
  4416. /**
  4417. * Class used to help managing file picking and drag'n'drop
  4418. * File Storage
  4419. */
  4420. export class FilesInputStore {
  4421. /**
  4422. * List of files ready to be loaded
  4423. */
  4424. static FilesToLoad: {
  4425. [key: string]: File;
  4426. };
  4427. }
  4428. }
  4429. declare module BABYLON {
  4430. /** Defines the cross module used constants to avoid circular dependncies */
  4431. export class Constants {
  4432. /** Defines that alpha blending is disabled */
  4433. static readonly ALPHA_DISABLE: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4435. static readonly ALPHA_ADD: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_COMBINE: number;
  4438. /** Defines that alpha blending to DEST - SRC * DEST */
  4439. static readonly ALPHA_SUBTRACT: number;
  4440. /** Defines that alpha blending to SRC * DEST */
  4441. static readonly ALPHA_MULTIPLY: number;
  4442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4443. static readonly ALPHA_MAXIMIZED: number;
  4444. /** Defines that alpha blending to SRC + DEST */
  4445. static readonly ALPHA_ONEONE: number;
  4446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4447. static readonly ALPHA_PREMULTIPLIED: number;
  4448. /**
  4449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4451. */
  4452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4454. static readonly ALPHA_INTERPOLATE: number;
  4455. /**
  4456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4458. */
  4459. static readonly ALPHA_SCREENMODE: number;
  4460. /** Defines that the ressource is not delayed*/
  4461. static readonly DELAYLOADSTATE_NONE: number;
  4462. /** Defines that the ressource was successfully delay loaded */
  4463. static readonly DELAYLOADSTATE_LOADED: number;
  4464. /** Defines that the ressource is currently delay loading */
  4465. static readonly DELAYLOADSTATE_LOADING: number;
  4466. /** Defines that the ressource is delayed and has not started loading */
  4467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4469. static readonly NEVER: number;
  4470. /** 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 */
  4471. static readonly ALWAYS: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4473. static readonly LESS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4475. static readonly EQUAL: number;
  4476. /** 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 */
  4477. static readonly LEQUAL: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4479. static readonly GREATER: number;
  4480. /** 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 */
  4481. static readonly GEQUAL: number;
  4482. /** 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 */
  4483. static readonly NOTEQUAL: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be kept */
  4485. static readonly KEEP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4487. static readonly REPLACE: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4489. static readonly INCR: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4491. static readonly DECR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4493. static readonly INVERT: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4495. static readonly INCR_WRAP: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4497. static readonly DECR_WRAP: number;
  4498. /** Texture is not repeating outside of 0..1 UVs */
  4499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4500. /** Texture is repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4502. /** Texture is repeating and mirrored */
  4503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4504. /** ALPHA */
  4505. static readonly TEXTUREFORMAT_ALPHA: number;
  4506. /** LUMINANCE */
  4507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4508. /** LUMINANCE_ALPHA */
  4509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4510. /** RGB */
  4511. static readonly TEXTUREFORMAT_RGB: number;
  4512. /** RGBA */
  4513. static readonly TEXTUREFORMAT_RGBA: number;
  4514. /** RED */
  4515. static readonly TEXTUREFORMAT_RED: number;
  4516. /** RED (2nd reference) */
  4517. static readonly TEXTUREFORMAT_R: number;
  4518. /** RG */
  4519. static readonly TEXTUREFORMAT_RG: number;
  4520. /** RED_INTEGER */
  4521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4522. /** RED_INTEGER (2nd reference) */
  4523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4524. /** RG_INTEGER */
  4525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4526. /** RGB_INTEGER */
  4527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4528. /** RGBA_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4530. /** UNSIGNED_BYTE */
  4531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4532. /** UNSIGNED_BYTE (2nd reference) */
  4533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4534. /** FLOAT */
  4535. static readonly TEXTURETYPE_FLOAT: number;
  4536. /** HALF_FLOAT */
  4537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4538. /** BYTE */
  4539. static readonly TEXTURETYPE_BYTE: number;
  4540. /** SHORT */
  4541. static readonly TEXTURETYPE_SHORT: number;
  4542. /** UNSIGNED_SHORT */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4544. /** INT */
  4545. static readonly TEXTURETYPE_INT: number;
  4546. /** UNSIGNED_INT */
  4547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4548. /** UNSIGNED_SHORT_4_4_4_4 */
  4549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4550. /** UNSIGNED_SHORT_5_5_5_1 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4552. /** UNSIGNED_SHORT_5_6_5 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4554. /** UNSIGNED_INT_2_10_10_10_REV */
  4555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4556. /** UNSIGNED_INT_24_8 */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4558. /** UNSIGNED_INT_10F_11F_11F_REV */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4560. /** UNSIGNED_INT_5_9_9_9_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4564. /** nearest is mag = nearest and min = nearest and mip = linear */
  4565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4568. /** Trilinear is mag = linear and min = linear and mip = linear */
  4569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4570. /** nearest is mag = nearest and min = nearest and mip = linear */
  4571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4574. /** Trilinear is mag = linear and min = linear and mip = linear */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4578. /** mag = nearest and min = linear and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = linear */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4582. /** mag = nearest and min = linear and mip = none */
  4583. static readonly TEXTURE_NEAREST_LINEAR: number;
  4584. /** mag = nearest and min = nearest and mip = none */
  4585. static readonly TEXTURE_NEAREST_NEAREST: number;
  4586. /** mag = linear and min = nearest and mip = nearest */
  4587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4588. /** mag = linear and min = nearest and mip = linear */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4590. /** mag = linear and min = linear and mip = none */
  4591. static readonly TEXTURE_LINEAR_LINEAR: number;
  4592. /** mag = linear and min = nearest and mip = none */
  4593. static readonly TEXTURE_LINEAR_NEAREST: number;
  4594. /** Explicit coordinates mode */
  4595. static readonly TEXTURE_EXPLICIT_MODE: number;
  4596. /** Spherical coordinates mode */
  4597. static readonly TEXTURE_SPHERICAL_MODE: number;
  4598. /** Planar coordinates mode */
  4599. static readonly TEXTURE_PLANAR_MODE: number;
  4600. /** Cubic coordinates mode */
  4601. static readonly TEXTURE_CUBIC_MODE: number;
  4602. /** Projection coordinates mode */
  4603. static readonly TEXTURE_PROJECTION_MODE: number;
  4604. /** Skybox coordinates mode */
  4605. static readonly TEXTURE_SKYBOX_MODE: number;
  4606. /** Inverse Cubic coordinates mode */
  4607. static readonly TEXTURE_INVCUBIC_MODE: number;
  4608. /** Equirectangular coordinates mode */
  4609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4610. /** Equirectangular Fixed coordinates mode */
  4611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed Mirrored coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4615. static readonly SCALEMODE_FLOOR: number;
  4616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4617. static readonly SCALEMODE_NEAREST: number;
  4618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4619. static readonly SCALEMODE_CEILING: number;
  4620. /**
  4621. * The dirty texture flag value
  4622. */
  4623. static readonly MATERIAL_TextureDirtyFlag: number;
  4624. /**
  4625. * The dirty light flag value
  4626. */
  4627. static readonly MATERIAL_LightDirtyFlag: number;
  4628. /**
  4629. * The dirty fresnel flag value
  4630. */
  4631. static readonly MATERIAL_FresnelDirtyFlag: number;
  4632. /**
  4633. * The dirty attribute flag value
  4634. */
  4635. static readonly MATERIAL_AttributesDirtyFlag: number;
  4636. /**
  4637. * The dirty misc flag value
  4638. */
  4639. static readonly MATERIAL_MiscDirtyFlag: number;
  4640. /**
  4641. * The all dirty flag value
  4642. */
  4643. static readonly MATERIAL_AllDirtyFlag: number;
  4644. /**
  4645. * Returns the triangle fill mode
  4646. */
  4647. static readonly MATERIAL_TriangleFillMode: number;
  4648. /**
  4649. * Returns the wireframe mode
  4650. */
  4651. static readonly MATERIAL_WireFrameFillMode: number;
  4652. /**
  4653. * Returns the point fill mode
  4654. */
  4655. static readonly MATERIAL_PointFillMode: number;
  4656. /**
  4657. * Returns the point list draw mode
  4658. */
  4659. static readonly MATERIAL_PointListDrawMode: number;
  4660. /**
  4661. * Returns the line list draw mode
  4662. */
  4663. static readonly MATERIAL_LineListDrawMode: number;
  4664. /**
  4665. * Returns the line loop draw mode
  4666. */
  4667. static readonly MATERIAL_LineLoopDrawMode: number;
  4668. /**
  4669. * Returns the line strip draw mode
  4670. */
  4671. static readonly MATERIAL_LineStripDrawMode: number;
  4672. /**
  4673. * Returns the triangle strip draw mode
  4674. */
  4675. static readonly MATERIAL_TriangleStripDrawMode: number;
  4676. /**
  4677. * Returns the triangle fan draw mode
  4678. */
  4679. static readonly MATERIAL_TriangleFanDrawMode: number;
  4680. /**
  4681. * Stores the clock-wise side orientation
  4682. */
  4683. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4684. /**
  4685. * Stores the counter clock-wise side orientation
  4686. */
  4687. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4688. /**
  4689. * Nothing
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_NothingTrigger: number;
  4693. /**
  4694. * On pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnPickTrigger: number;
  4698. /**
  4699. * On left pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnLeftPickTrigger: number;
  4703. /**
  4704. * On right pick
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnRightPickTrigger: number;
  4708. /**
  4709. * On center pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnCenterPickTrigger: number;
  4713. /**
  4714. * On pick down
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickDownTrigger: number;
  4718. /**
  4719. * On double pick
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnDoublePickTrigger: number;
  4723. /**
  4724. * On pick up
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnPickUpTrigger: number;
  4728. /**
  4729. * On pick out.
  4730. * This trigger will only be raised if you also declared a OnPickDown
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickOutTrigger: number;
  4734. /**
  4735. * On long press
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLongPressTrigger: number;
  4739. /**
  4740. * On pointer over
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPointerOverTrigger: number;
  4744. /**
  4745. * On pointer out
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnPointerOutTrigger: number;
  4749. /**
  4750. * On every frame
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnEveryFrameTrigger: number;
  4754. /**
  4755. * On intersection enter
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4759. /**
  4760. * On intersection exit
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnIntersectionExitTrigger: number;
  4764. /**
  4765. * On key down
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnKeyDownTrigger: number;
  4769. /**
  4770. * On key up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnKeyUpTrigger: number;
  4774. /**
  4775. * Billboard mode will only apply to Y axis
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4778. /**
  4779. * Billboard mode will apply to all axes
  4780. */
  4781. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4782. /**
  4783. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4784. */
  4785. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4786. /**
  4787. * Gets or sets base Assets URL
  4788. */
  4789. static readonly PARTICLES_BaseAssetsUrl: string;
  4790. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4791. * Test order :
  4792. * Is the bounding sphere outside the frustum ?
  4793. * If not, are the bounding box vertices outside the frustum ?
  4794. * It not, then the cullable object is in the frustum.
  4795. */
  4796. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4797. /** Culling strategy : Bounding Sphere Only.
  4798. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4799. * It's also less accurate than the standard because some not visible objects can still be selected.
  4800. * Test : is the bounding sphere outside the frustum ?
  4801. * If not, then the cullable object is in the frustum.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4804. /** Culling strategy : Optimistic Inclusion.
  4805. * This in an inclusion test first, then the standard exclusion test.
  4806. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4807. * 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.
  4808. * Anyway, it's as accurate as the standard strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the default culling strategy.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4814. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4815. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4816. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4817. * 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.
  4818. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4819. * Test :
  4820. * Is the cullable object bounding sphere center in the frustum ?
  4821. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4822. */
  4823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4824. /**
  4825. * No logging while loading
  4826. */
  4827. static readonly SCENELOADER_NO_LOGGING: number;
  4828. /**
  4829. * Minimal logging while loading
  4830. */
  4831. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4832. /**
  4833. * Summary logging while loading
  4834. */
  4835. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4836. /**
  4837. * Detailled logging while loading
  4838. */
  4839. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4840. }
  4841. }
  4842. declare module BABYLON {
  4843. /**
  4844. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4845. * Babylon.js
  4846. */
  4847. export class DomManagement {
  4848. /**
  4849. * Checks if the window object exists
  4850. * @returns true if the window object exists
  4851. */
  4852. static IsWindowObjectExist(): boolean;
  4853. /**
  4854. * Extracts text content from a DOM element hierarchy
  4855. * @param element defines the root element
  4856. * @returns a string
  4857. */
  4858. static GetDOMTextContent(element: HTMLElement): string;
  4859. }
  4860. }
  4861. declare module BABYLON {
  4862. /**
  4863. * Logger used througouht the application to allow configuration of
  4864. * the log level required for the messages.
  4865. */
  4866. export class Logger {
  4867. /**
  4868. * No log
  4869. */
  4870. static readonly NoneLogLevel: number;
  4871. /**
  4872. * Only message logs
  4873. */
  4874. static readonly MessageLogLevel: number;
  4875. /**
  4876. * Only warning logs
  4877. */
  4878. static readonly WarningLogLevel: number;
  4879. /**
  4880. * Only error logs
  4881. */
  4882. static readonly ErrorLogLevel: number;
  4883. /**
  4884. * All logs
  4885. */
  4886. static readonly AllLogLevel: number;
  4887. private static _LogCache;
  4888. /**
  4889. * Gets a value indicating the number of loading errors
  4890. * @ignorenaming
  4891. */
  4892. static errorsCount: number;
  4893. /**
  4894. * Callback called when a new log is added
  4895. */
  4896. static OnNewCacheEntry: (entry: string) => void;
  4897. private static _AddLogEntry;
  4898. private static _FormatMessage;
  4899. private static _LogDisabled;
  4900. private static _LogEnabled;
  4901. private static _WarnDisabled;
  4902. private static _WarnEnabled;
  4903. private static _ErrorDisabled;
  4904. private static _ErrorEnabled;
  4905. /**
  4906. * Log a message to the console
  4907. */
  4908. static Log: (message: string) => void;
  4909. /**
  4910. * Write a warning message to the console
  4911. */
  4912. static Warn: (message: string) => void;
  4913. /**
  4914. * Write an error message to the console
  4915. */
  4916. static Error: (message: string) => void;
  4917. /**
  4918. * Gets current log cache (list of logs)
  4919. */
  4920. static readonly LogCache: string;
  4921. /**
  4922. * Clears the log cache
  4923. */
  4924. static ClearLogCache(): void;
  4925. /**
  4926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4927. */
  4928. static LogLevels: number;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /** @hidden */
  4933. export class _TypeStore {
  4934. /** @hidden */
  4935. static RegisteredTypes: {
  4936. [key: string]: Object;
  4937. };
  4938. /** @hidden */
  4939. static GetClass(fqdn: string): any;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. /**
  4944. * Class containing a set of static utilities functions for deep copy.
  4945. */
  4946. export class DeepCopier {
  4947. /**
  4948. * Tries to copy an object by duplicating every property
  4949. * @param source defines the source object
  4950. * @param destination defines the target object
  4951. * @param doNotCopyList defines a list of properties to avoid
  4952. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4953. */
  4954. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /**
  4959. * Class containing a set of static utilities functions for precision date
  4960. */
  4961. export class PrecisionDate {
  4962. /**
  4963. * Gets either window.performance.now() if supported or Date.now() else
  4964. */
  4965. static readonly Now: number;
  4966. }
  4967. }
  4968. declare module BABYLON {
  4969. /** @hidden */
  4970. export class _DevTools {
  4971. static WarnImport(name: string): string;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4977. */
  4978. export class WebRequest {
  4979. private _xhr;
  4980. /**
  4981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4982. * i.e. when loading files, where the server/service expects an Authorization header
  4983. */
  4984. static CustomRequestHeaders: {
  4985. [key: string]: string;
  4986. };
  4987. /**
  4988. * Add callback functions in this array to update all the requests before they get sent to the network
  4989. */
  4990. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4991. private _injectCustomRequestHeaders;
  4992. /**
  4993. * Gets or sets a function to be called when loading progress changes
  4994. */
  4995. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4996. /**
  4997. * Returns client's state
  4998. */
  4999. readonly readyState: number;
  5000. /**
  5001. * Returns client's status
  5002. */
  5003. readonly status: number;
  5004. /**
  5005. * Returns client's status as a text
  5006. */
  5007. readonly statusText: string;
  5008. /**
  5009. * Returns client's response
  5010. */
  5011. readonly response: any;
  5012. /**
  5013. * Returns client's response url
  5014. */
  5015. readonly responseURL: string;
  5016. /**
  5017. * Returns client's response as text
  5018. */
  5019. readonly responseText: string;
  5020. /**
  5021. * Gets or sets the expected response type
  5022. */
  5023. responseType: XMLHttpRequestResponseType;
  5024. /** @hidden */
  5025. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5026. /** @hidden */
  5027. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5028. /**
  5029. * Cancels any network activity
  5030. */
  5031. abort(): void;
  5032. /**
  5033. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5034. * @param body defines an optional request body
  5035. */
  5036. send(body?: Document | BodyInit | null): void;
  5037. /**
  5038. * Sets the request method, request URL
  5039. * @param method defines the method to use (GET, POST, etc..)
  5040. * @param url defines the url to connect with
  5041. */
  5042. open(method: string, url: string): void;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /**
  5047. * Class used to evalaute queries containing `and` and `or` operators
  5048. */
  5049. export class AndOrNotEvaluator {
  5050. /**
  5051. * Evaluate a query
  5052. * @param query defines the query to evaluate
  5053. * @param evaluateCallback defines the callback used to filter result
  5054. * @returns true if the query matches
  5055. */
  5056. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5057. private static _HandleParenthesisContent;
  5058. private static _SimplifyNegation;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to store custom tags
  5064. */
  5065. export class Tags {
  5066. /**
  5067. * Adds support for tags on the given object
  5068. * @param obj defines the object to use
  5069. */
  5070. static EnableFor(obj: any): void;
  5071. /**
  5072. * Removes tags support
  5073. * @param obj defines the object to use
  5074. */
  5075. static DisableFor(obj: any): void;
  5076. /**
  5077. * Gets a boolean indicating if the given object has tags
  5078. * @param obj defines the object to use
  5079. * @returns a boolean
  5080. */
  5081. static HasTags(obj: any): boolean;
  5082. /**
  5083. * Gets the tags available on a given object
  5084. * @param obj defines the object to use
  5085. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5086. * @returns the tags
  5087. */
  5088. static GetTags(obj: any, asString?: boolean): any;
  5089. /**
  5090. * Adds tags to an object
  5091. * @param obj defines the object to use
  5092. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5093. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5094. */
  5095. static AddTagsTo(obj: any, tagsString: string): void;
  5096. /**
  5097. * @hidden
  5098. */
  5099. static _AddTagTo(obj: any, tag: string): void;
  5100. /**
  5101. * Removes specific tags from a specific object
  5102. * @param obj defines the object to use
  5103. * @param tagsString defines the tags to remove
  5104. */
  5105. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5106. /**
  5107. * @hidden
  5108. */
  5109. static _RemoveTagFrom(obj: any, tag: string): void;
  5110. /**
  5111. * Defines if tags hosted on an object match a given query
  5112. * @param obj defines the object to use
  5113. * @param tagsQuery defines the tag query
  5114. * @returns a boolean
  5115. */
  5116. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5117. }
  5118. }
  5119. declare module BABYLON {
  5120. /**
  5121. * Manages the defines for the Material
  5122. */
  5123. export class MaterialDefines {
  5124. private _keys;
  5125. private _isDirty;
  5126. /** @hidden */
  5127. _renderId: number;
  5128. /** @hidden */
  5129. _areLightsDirty: boolean;
  5130. /** @hidden */
  5131. _areAttributesDirty: boolean;
  5132. /** @hidden */
  5133. _areTexturesDirty: boolean;
  5134. /** @hidden */
  5135. _areFresnelDirty: boolean;
  5136. /** @hidden */
  5137. _areMiscDirty: boolean;
  5138. /** @hidden */
  5139. _areImageProcessingDirty: boolean;
  5140. /** @hidden */
  5141. _normals: boolean;
  5142. /** @hidden */
  5143. _uvs: boolean;
  5144. /** @hidden */
  5145. _needNormals: boolean;
  5146. /** @hidden */
  5147. _needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @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
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */
  5439. _data: Nullable<DataArray>;
  5440. private _updatable;
  5441. private _instanced;
  5442. /**
  5443. * Gets the byte stride.
  5444. */
  5445. readonly byteStride: number;
  5446. /**
  5447. * Constructor
  5448. * @param engine the engine
  5449. * @param data the data to use for this buffer
  5450. * @param updatable whether the data is updatable
  5451. * @param stride the stride (optional)
  5452. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5453. * @param instanced whether the buffer is instanced (optional)
  5454. * @param useBytes set to true if the stride in in bytes (optional)
  5455. */
  5456. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5457. /**
  5458. * Create a new VertexBuffer based on the current buffer
  5459. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5460. * @param offset defines offset in the buffer (0 by default)
  5461. * @param size defines the size in floats of attributes (position is 3 for instance)
  5462. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5463. * @param instanced defines if the vertex buffer contains indexed data
  5464. * @param useBytes defines if the offset and stride are in bytes
  5465. * @returns the new vertex buffer
  5466. */
  5467. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5468. /**
  5469. * Gets a boolean indicating if the Buffer is updatable?
  5470. * @returns true if the buffer is updatable
  5471. */
  5472. isUpdatable(): boolean;
  5473. /**
  5474. * Gets current buffer's data
  5475. * @returns a DataArray or null
  5476. */
  5477. getData(): Nullable<DataArray>;
  5478. /**
  5479. * Gets underlying native buffer
  5480. * @returns underlying native buffer
  5481. */
  5482. getBuffer(): Nullable<WebGLBuffer>;
  5483. /**
  5484. * Gets the stride in float32 units (i.e. byte stride / 4).
  5485. * May not be an integer if the byte stride is not divisible by 4.
  5486. * DEPRECATED. Use byteStride instead.
  5487. * @returns the stride in float32 units
  5488. */
  5489. getStrideSize(): number;
  5490. /**
  5491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5492. * @param data defines the data to store
  5493. */
  5494. create(data?: Nullable<DataArray>): void;
  5495. /** @hidden */
  5496. _rebuild(): void;
  5497. /**
  5498. * Update current buffer data
  5499. * @param data defines the data to store
  5500. */
  5501. update(data: DataArray): void;
  5502. /**
  5503. * Updates the data directly.
  5504. * @param data the new data
  5505. * @param offset the new offset
  5506. * @param vertexCount the vertex count (optional)
  5507. * @param useBytes set to true if the offset is in bytes
  5508. */
  5509. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5510. /**
  5511. * Release all resources
  5512. */
  5513. dispose(): void;
  5514. }
  5515. /**
  5516. * Specialized buffer used to store vertex data
  5517. */
  5518. export class VertexBuffer {
  5519. /** @hidden */
  5520. _buffer: Buffer;
  5521. private _kind;
  5522. private _size;
  5523. private _ownsBuffer;
  5524. private _instanced;
  5525. private _instanceDivisor;
  5526. /**
  5527. * The byte type.
  5528. */
  5529. static readonly BYTE: number;
  5530. /**
  5531. * The unsigned byte type.
  5532. */
  5533. static readonly UNSIGNED_BYTE: number;
  5534. /**
  5535. * The short type.
  5536. */
  5537. static readonly SHORT: number;
  5538. /**
  5539. * The unsigned short type.
  5540. */
  5541. static readonly UNSIGNED_SHORT: number;
  5542. /**
  5543. * The integer type.
  5544. */
  5545. static readonly INT: number;
  5546. /**
  5547. * The unsigned integer type.
  5548. */
  5549. static readonly UNSIGNED_INT: number;
  5550. /**
  5551. * The float type.
  5552. */
  5553. static readonly FLOAT: number;
  5554. /**
  5555. * Gets or sets the instance divisor when in instanced mode
  5556. */
  5557. instanceDivisor: number;
  5558. /**
  5559. * Gets the byte stride.
  5560. */
  5561. readonly byteStride: number;
  5562. /**
  5563. * Gets the byte offset.
  5564. */
  5565. readonly byteOffset: number;
  5566. /**
  5567. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5568. */
  5569. readonly normalized: boolean;
  5570. /**
  5571. * Gets the data type of each component in the array.
  5572. */
  5573. readonly type: number;
  5574. /**
  5575. * Constructor
  5576. * @param engine the engine
  5577. * @param data the data to use for this vertex buffer
  5578. * @param kind the vertex buffer kind
  5579. * @param updatable whether the data is updatable
  5580. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5581. * @param stride the stride (optional)
  5582. * @param instanced whether the buffer is instanced (optional)
  5583. * @param offset the offset of the data (optional)
  5584. * @param size the number of components (optional)
  5585. * @param type the type of the component (optional)
  5586. * @param normalized whether the data contains normalized data (optional)
  5587. * @param useBytes set to true if stride and offset are in bytes (optional)
  5588. */
  5589. 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);
  5590. /** @hidden */
  5591. _rebuild(): void;
  5592. /**
  5593. * Returns the kind of the VertexBuffer (string)
  5594. * @returns a string
  5595. */
  5596. getKind(): string;
  5597. /**
  5598. * Gets a boolean indicating if the VertexBuffer is updatable?
  5599. * @returns true if the buffer is updatable
  5600. */
  5601. isUpdatable(): boolean;
  5602. /**
  5603. * Gets current buffer's data
  5604. * @returns a DataArray or null
  5605. */
  5606. getData(): Nullable<DataArray>;
  5607. /**
  5608. * Gets underlying native buffer
  5609. * @returns underlying native buffer
  5610. */
  5611. getBuffer(): Nullable<WebGLBuffer>;
  5612. /**
  5613. * Gets the stride in float32 units (i.e. byte stride / 4).
  5614. * May not be an integer if the byte stride is not divisible by 4.
  5615. * DEPRECATED. Use byteStride instead.
  5616. * @returns the stride in float32 units
  5617. */
  5618. getStrideSize(): number;
  5619. /**
  5620. * Returns the offset as a multiple of the type byte length.
  5621. * DEPRECATED. Use byteOffset instead.
  5622. * @returns the offset in bytes
  5623. */
  5624. getOffset(): number;
  5625. /**
  5626. * Returns the number of components per vertex attribute (integer)
  5627. * @returns the size in float
  5628. */
  5629. getSize(): number;
  5630. /**
  5631. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5632. * @returns true if this buffer is instanced
  5633. */
  5634. getIsInstanced(): boolean;
  5635. /**
  5636. * Returns the instancing divisor, zero for non-instanced (integer).
  5637. * @returns a number
  5638. */
  5639. getInstanceDivisor(): number;
  5640. /**
  5641. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5642. * @param data defines the data to store
  5643. */
  5644. create(data?: DataArray): void;
  5645. /**
  5646. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5647. * This function will create a new buffer if the current one is not updatable
  5648. * @param data defines the data to store
  5649. */
  5650. update(data: DataArray): void;
  5651. /**
  5652. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5653. * Returns the directly updated WebGLBuffer.
  5654. * @param data the new data
  5655. * @param offset the new offset
  5656. * @param useBytes set to true if the offset is in bytes
  5657. */
  5658. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5659. /**
  5660. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5661. */
  5662. dispose(): void;
  5663. /**
  5664. * Enumerates each value of this vertex buffer as numbers.
  5665. * @param count the number of values to enumerate
  5666. * @param callback the callback function called for each value
  5667. */
  5668. forEach(count: number, callback: (value: number, index: number) => void): void;
  5669. /**
  5670. * Positions
  5671. */
  5672. static readonly PositionKind: string;
  5673. /**
  5674. * Normals
  5675. */
  5676. static readonly NormalKind: string;
  5677. /**
  5678. * Tangents
  5679. */
  5680. static readonly TangentKind: string;
  5681. /**
  5682. * Texture coordinates
  5683. */
  5684. static readonly UVKind: string;
  5685. /**
  5686. * Texture coordinates 2
  5687. */
  5688. static readonly UV2Kind: string;
  5689. /**
  5690. * Texture coordinates 3
  5691. */
  5692. static readonly UV3Kind: string;
  5693. /**
  5694. * Texture coordinates 4
  5695. */
  5696. static readonly UV4Kind: string;
  5697. /**
  5698. * Texture coordinates 5
  5699. */
  5700. static readonly UV5Kind: string;
  5701. /**
  5702. * Texture coordinates 6
  5703. */
  5704. static readonly UV6Kind: string;
  5705. /**
  5706. * Colors
  5707. */
  5708. static readonly ColorKind: string;
  5709. /**
  5710. * Matrix indices (for bones)
  5711. */
  5712. static readonly MatricesIndicesKind: string;
  5713. /**
  5714. * Matrix weights (for bones)
  5715. */
  5716. static readonly MatricesWeightsKind: string;
  5717. /**
  5718. * Additional matrix indices (for bones)
  5719. */
  5720. static readonly MatricesIndicesExtraKind: string;
  5721. /**
  5722. * Additional matrix weights (for bones)
  5723. */
  5724. static readonly MatricesWeightsExtraKind: string;
  5725. /**
  5726. * Deduces the stride given a kind.
  5727. * @param kind The kind string to deduce
  5728. * @returns The deduced stride
  5729. */
  5730. static DeduceStride(kind: string): number;
  5731. /**
  5732. * Gets the byte length of the given type.
  5733. * @param type the type
  5734. * @returns the number of bytes
  5735. */
  5736. static GetTypeByteLength(type: number): number;
  5737. /**
  5738. * Enumerates each value of the given parameters as numbers.
  5739. * @param data the data to enumerate
  5740. * @param byteOffset the byte offset of the data
  5741. * @param byteStride the byte stride of the data
  5742. * @param componentCount the number of components per element
  5743. * @param componentType the type of the component
  5744. * @param count the total number of components
  5745. * @param normalized whether the data is normalized
  5746. * @param callback the callback function called for each value
  5747. */
  5748. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5749. private static _GetFloatValue;
  5750. }
  5751. }
  5752. declare module BABYLON {
  5753. /**
  5754. * Class representing spherical polynomial coefficients to the 3rd degree
  5755. */
  5756. export class SphericalPolynomial {
  5757. /**
  5758. * The x coefficients of the spherical polynomial
  5759. */
  5760. x: Vector3;
  5761. /**
  5762. * The y coefficients of the spherical polynomial
  5763. */
  5764. y: Vector3;
  5765. /**
  5766. * The z coefficients of the spherical polynomial
  5767. */
  5768. z: Vector3;
  5769. /**
  5770. * The xx coefficients of the spherical polynomial
  5771. */
  5772. xx: Vector3;
  5773. /**
  5774. * The yy coefficients of the spherical polynomial
  5775. */
  5776. yy: Vector3;
  5777. /**
  5778. * The zz coefficients of the spherical polynomial
  5779. */
  5780. zz: Vector3;
  5781. /**
  5782. * The xy coefficients of the spherical polynomial
  5783. */
  5784. xy: Vector3;
  5785. /**
  5786. * The yz coefficients of the spherical polynomial
  5787. */
  5788. yz: Vector3;
  5789. /**
  5790. * The zx coefficients of the spherical polynomial
  5791. */
  5792. zx: Vector3;
  5793. /**
  5794. * Adds an ambient color to the spherical polynomial
  5795. * @param color the color to add
  5796. */
  5797. addAmbient(color: Color3): void;
  5798. /**
  5799. * Scales the spherical polynomial by the given amount
  5800. * @param scale the amount to scale
  5801. */
  5802. scale(scale: number): void;
  5803. /**
  5804. * Gets the spherical polynomial from harmonics
  5805. * @param harmonics the spherical harmonics
  5806. * @returns the spherical polynomial
  5807. */
  5808. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5809. /**
  5810. * Constructs a spherical polynomial from an array.
  5811. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5812. * @returns the spherical polynomial
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5815. }
  5816. /**
  5817. * Class representing spherical harmonics coefficients to the 3rd degree
  5818. */
  5819. export class SphericalHarmonics {
  5820. /**
  5821. * The l0,0 coefficients of the spherical harmonics
  5822. */
  5823. l00: Vector3;
  5824. /**
  5825. * The l1,-1 coefficients of the spherical harmonics
  5826. */
  5827. l1_1: Vector3;
  5828. /**
  5829. * The l1,0 coefficients of the spherical harmonics
  5830. */
  5831. l10: Vector3;
  5832. /**
  5833. * The l1,1 coefficients of the spherical harmonics
  5834. */
  5835. l11: Vector3;
  5836. /**
  5837. * The l2,-2 coefficients of the spherical harmonics
  5838. */
  5839. l2_2: Vector3;
  5840. /**
  5841. * The l2,-1 coefficients of the spherical harmonics
  5842. */
  5843. l2_1: Vector3;
  5844. /**
  5845. * The l2,0 coefficients of the spherical harmonics
  5846. */
  5847. l20: Vector3;
  5848. /**
  5849. * The l2,1 coefficients of the spherical harmonics
  5850. */
  5851. l21: Vector3;
  5852. /**
  5853. * The l2,2 coefficients of the spherical harmonics
  5854. */
  5855. lL22: Vector3;
  5856. /**
  5857. * Adds a light to the spherical harmonics
  5858. * @param direction the direction of the light
  5859. * @param color the color of the light
  5860. * @param deltaSolidAngle the delta solid angle of the light
  5861. */
  5862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5863. /**
  5864. * Scales the spherical harmonics by the given amount
  5865. * @param scale the amount to scale
  5866. */
  5867. scale(scale: number): void;
  5868. /**
  5869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5870. *
  5871. * ```
  5872. * E_lm = A_l * L_lm
  5873. * ```
  5874. *
  5875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5877. * the scaling factors are given in equation 9.
  5878. */
  5879. convertIncidentRadianceToIrradiance(): void;
  5880. /**
  5881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5882. *
  5883. * ```
  5884. * L = (1/pi) * E * rho
  5885. * ```
  5886. *
  5887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5888. */
  5889. convertIrradianceToLambertianRadiance(): void;
  5890. /**
  5891. * Gets the spherical harmonics from polynomial
  5892. * @param polynomial the spherical polynomial
  5893. * @returns the spherical harmonics
  5894. */
  5895. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5896. /**
  5897. * Constructs a spherical harmonics from an array.
  5898. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5899. * @returns the spherical harmonics
  5900. */
  5901. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5907. */
  5908. export interface CubeMapInfo {
  5909. /**
  5910. * The pixel array for the front face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. front: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the back face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. back: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The pixel array for the left face.
  5921. * This is stored in format, left to right, up to down format.
  5922. */
  5923. left: Nullable<ArrayBufferView>;
  5924. /**
  5925. * The pixel array for the right face.
  5926. * This is stored in format, left to right, up to down format.
  5927. */
  5928. right: Nullable<ArrayBufferView>;
  5929. /**
  5930. * The pixel array for the up face.
  5931. * This is stored in format, left to right, up to down format.
  5932. */
  5933. up: Nullable<ArrayBufferView>;
  5934. /**
  5935. * The pixel array for the down face.
  5936. * This is stored in format, left to right, up to down format.
  5937. */
  5938. down: Nullable<ArrayBufferView>;
  5939. /**
  5940. * The size of the cubemap stored.
  5941. *
  5942. * Each faces will be size * size pixels.
  5943. */
  5944. size: number;
  5945. /**
  5946. * The format of the texture.
  5947. *
  5948. * RGBA, RGB.
  5949. */
  5950. format: number;
  5951. /**
  5952. * The type of the texture data.
  5953. *
  5954. * UNSIGNED_INT, FLOAT.
  5955. */
  5956. type: number;
  5957. /**
  5958. * Specifies whether the texture is in gamma space.
  5959. */
  5960. gammaSpace: boolean;
  5961. }
  5962. /**
  5963. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5964. */
  5965. export class PanoramaToCubeMapTools {
  5966. private static FACE_FRONT;
  5967. private static FACE_BACK;
  5968. private static FACE_RIGHT;
  5969. private static FACE_LEFT;
  5970. private static FACE_DOWN;
  5971. private static FACE_UP;
  5972. /**
  5973. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5974. *
  5975. * @param float32Array The source data.
  5976. * @param inputWidth The width of the input panorama.
  5977. * @param inputHeight The height of the input panorama.
  5978. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5979. * @return The cubemap data
  5980. */
  5981. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5982. private static CreateCubemapTexture;
  5983. private static CalcProjectionSpherical;
  5984. }
  5985. }
  5986. declare module BABYLON {
  5987. /**
  5988. * Helper class dealing with the extraction of spherical polynomial dataArray
  5989. * from a cube map.
  5990. */
  5991. export class CubeMapToSphericalPolynomialTools {
  5992. private static FileFaces;
  5993. /**
  5994. * Converts a texture to the according Spherical Polynomial data.
  5995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5996. *
  5997. * @param texture The texture to extract the information from.
  5998. * @return The Spherical Polynomial data.
  5999. */
  6000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6001. /**
  6002. * Converts a cubemap to the according Spherical Polynomial data.
  6003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6004. *
  6005. * @param cubeInfo The Cube map to extract the information from.
  6006. * @return The Spherical Polynomial data.
  6007. */
  6008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6014. * during the life time of the application.
  6015. */
  6016. export class EngineStore {
  6017. /** Gets the list of created engines */
  6018. static Instances: Engine[];
  6019. /**
  6020. * Gets the latest created engine
  6021. */
  6022. static readonly LastCreatedEngine: Nullable<Engine>;
  6023. /**
  6024. * Gets the latest created scene
  6025. */
  6026. static readonly LastCreatedScene: Nullable<Scene>;
  6027. }
  6028. }
  6029. declare module BABYLON {
  6030. /**
  6031. * Define options used to create a render target texture
  6032. */
  6033. export class RenderTargetCreationOptions {
  6034. /**
  6035. * Specifies is mipmaps must be generated
  6036. */
  6037. generateMipMaps?: boolean;
  6038. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6039. generateDepthBuffer?: boolean;
  6040. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6041. generateStencilBuffer?: boolean;
  6042. /** Defines texture type (int by default) */
  6043. type?: number;
  6044. /** Defines sampling mode (trilinear by default) */
  6045. samplingMode?: number;
  6046. /** Defines format (RGBA by default) */
  6047. format?: number;
  6048. }
  6049. }
  6050. declare module BABYLON {
  6051. /**
  6052. * @hidden
  6053. **/
  6054. export class _AlphaState {
  6055. private _isAlphaBlendDirty;
  6056. private _isBlendFunctionParametersDirty;
  6057. private _isBlendEquationParametersDirty;
  6058. private _isBlendConstantsDirty;
  6059. private _alphaBlend;
  6060. private _blendFunctionParameters;
  6061. private _blendEquationParameters;
  6062. private _blendConstants;
  6063. /**
  6064. * Initializes the state.
  6065. */
  6066. constructor();
  6067. readonly isDirty: boolean;
  6068. alphaBlend: boolean;
  6069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6072. reset(): void;
  6073. apply(gl: WebGLRenderingContext): void;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. /**
  6078. * @hidden
  6079. **/
  6080. export class _DepthCullingState {
  6081. private _isDepthTestDirty;
  6082. private _isDepthMaskDirty;
  6083. private _isDepthFuncDirty;
  6084. private _isCullFaceDirty;
  6085. private _isCullDirty;
  6086. private _isZOffsetDirty;
  6087. private _isFrontFaceDirty;
  6088. private _depthTest;
  6089. private _depthMask;
  6090. private _depthFunc;
  6091. private _cull;
  6092. private _cullFace;
  6093. private _zOffset;
  6094. private _frontFace;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. zOffset: number;
  6101. cullFace: Nullable<number>;
  6102. cull: Nullable<boolean>;
  6103. depthFunc: Nullable<number>;
  6104. depthMask: boolean;
  6105. depthTest: boolean;
  6106. frontFace: Nullable<number>;
  6107. reset(): void;
  6108. apply(gl: WebGLRenderingContext): void;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * @hidden
  6114. **/
  6115. export class _StencilState {
  6116. /** 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 */
  6117. static readonly ALWAYS: number;
  6118. /** Passed to stencilOperation to specify that stencil value must be kept */
  6119. static readonly KEEP: number;
  6120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6121. static readonly REPLACE: number;
  6122. private _isStencilTestDirty;
  6123. private _isStencilMaskDirty;
  6124. private _isStencilFuncDirty;
  6125. private _isStencilOpDirty;
  6126. private _stencilTest;
  6127. private _stencilMask;
  6128. private _stencilFunc;
  6129. private _stencilFuncRef;
  6130. private _stencilFuncMask;
  6131. private _stencilOpStencilFail;
  6132. private _stencilOpDepthFail;
  6133. private _stencilOpStencilDepthPass;
  6134. readonly isDirty: boolean;
  6135. stencilFunc: number;
  6136. stencilFuncRef: number;
  6137. stencilFuncMask: number;
  6138. stencilOpStencilFail: number;
  6139. stencilOpDepthFail: number;
  6140. stencilOpStencilDepthPass: number;
  6141. stencilMask: number;
  6142. stencilTest: boolean;
  6143. constructor();
  6144. reset(): void;
  6145. apply(gl: WebGLRenderingContext): void;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _TimeToken {
  6153. _startTimeQuery: Nullable<WebGLQuery>;
  6154. _endTimeQuery: Nullable<WebGLQuery>;
  6155. _timeElapsedQuery: Nullable<WebGLQuery>;
  6156. _timeElapsedQueryEnded: boolean;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Internal interface used to track InternalTexture already bound to the GL context
  6162. */
  6163. export interface IInternalTextureTracker {
  6164. /**
  6165. * Gets or set the previous tracker in the list
  6166. */
  6167. previous: Nullable<IInternalTextureTracker>;
  6168. /**
  6169. * Gets or set the next tracker in the list
  6170. */
  6171. next: Nullable<IInternalTextureTracker>;
  6172. }
  6173. /**
  6174. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6175. */
  6176. export class DummyInternalTextureTracker {
  6177. /**
  6178. * Gets or set the previous tracker in the list
  6179. */
  6180. previous: Nullable<IInternalTextureTracker>;
  6181. /**
  6182. * Gets or set the next tracker in the list
  6183. */
  6184. next: Nullable<IInternalTextureTracker>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture implements IInternalTextureTracker {
  6193. /** hidden */
  6194. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6195. /**
  6196. * The source of the texture data is unknown
  6197. */
  6198. static DATASOURCE_UNKNOWN: number;
  6199. /**
  6200. * Texture data comes from an URL
  6201. */
  6202. static DATASOURCE_URL: number;
  6203. /**
  6204. * Texture data is only used for temporary storage
  6205. */
  6206. static DATASOURCE_TEMP: number;
  6207. /**
  6208. * Texture data comes from raw data (ArrayBuffer)
  6209. */
  6210. static DATASOURCE_RAW: number;
  6211. /**
  6212. * Texture content is dynamic (video or dynamic texture)
  6213. */
  6214. static DATASOURCE_DYNAMIC: number;
  6215. /**
  6216. * Texture content is generated by rendering to it
  6217. */
  6218. static DATASOURCE_RENDERTARGET: number;
  6219. /**
  6220. * Texture content is part of a multi render target process
  6221. */
  6222. static DATASOURCE_MULTIRENDERTARGET: number;
  6223. /**
  6224. * Texture data comes from a cube data file
  6225. */
  6226. static DATASOURCE_CUBE: number;
  6227. /**
  6228. * Texture data comes from a raw cube data
  6229. */
  6230. static DATASOURCE_CUBERAW: number;
  6231. /**
  6232. * Texture data come from a prefiltered cube data file
  6233. */
  6234. static DATASOURCE_CUBEPREFILTERED: number;
  6235. /**
  6236. * Texture content is raw 3D data
  6237. */
  6238. static DATASOURCE_RAW3D: number;
  6239. /**
  6240. * Texture content is a depth texture
  6241. */
  6242. static DATASOURCE_DEPTHTEXTURE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data encoded with RGBD
  6245. */
  6246. static DATASOURCE_CUBERAW_RGBD: number;
  6247. /**
  6248. * Defines if the texture is ready
  6249. */
  6250. isReady: boolean;
  6251. /**
  6252. * Defines if the texture is a cube texture
  6253. */
  6254. isCube: boolean;
  6255. /**
  6256. * Defines if the texture contains 3D data
  6257. */
  6258. is3D: boolean;
  6259. /**
  6260. * Gets the URL used to load this texture
  6261. */
  6262. url: string;
  6263. /**
  6264. * Gets the sampling mode of the texture
  6265. */
  6266. samplingMode: number;
  6267. /**
  6268. * Gets a boolean indicating if the texture needs mipmaps generation
  6269. */
  6270. generateMipMaps: boolean;
  6271. /**
  6272. * Gets the number of samples used by the texture (WebGL2+ only)
  6273. */
  6274. samples: number;
  6275. /**
  6276. * Gets the type of the texture (int, float...)
  6277. */
  6278. type: number;
  6279. /**
  6280. * Gets the format of the texture (RGB, RGBA...)
  6281. */
  6282. format: number;
  6283. /**
  6284. * Observable called when the texture is loaded
  6285. */
  6286. onLoadedObservable: Observable<InternalTexture>;
  6287. /**
  6288. * Gets the width of the texture
  6289. */
  6290. width: number;
  6291. /**
  6292. * Gets the height of the texture
  6293. */
  6294. height: number;
  6295. /**
  6296. * Gets the depth of the texture
  6297. */
  6298. depth: number;
  6299. /**
  6300. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6301. */
  6302. baseWidth: number;
  6303. /**
  6304. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6305. */
  6306. baseHeight: number;
  6307. /**
  6308. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6309. */
  6310. baseDepth: number;
  6311. /**
  6312. * Gets a boolean indicating if the texture is inverted on Y axis
  6313. */
  6314. invertY: boolean;
  6315. /**
  6316. * Gets or set the previous tracker in the list
  6317. */
  6318. previous: Nullable<IInternalTextureTracker>;
  6319. /**
  6320. * Gets or set the next tracker in the list
  6321. */
  6322. next: Nullable<IInternalTextureTracker>;
  6323. /** @hidden */
  6324. _invertVScale: boolean;
  6325. /** @hidden */
  6326. _initialSlot: number;
  6327. /** @hidden */
  6328. _designatedSlot: number;
  6329. /** @hidden */
  6330. _dataSource: number;
  6331. /** @hidden */
  6332. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6333. /** @hidden */
  6334. _bufferView: Nullable<ArrayBufferView>;
  6335. /** @hidden */
  6336. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6337. /** @hidden */
  6338. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6339. /** @hidden */
  6340. _size: number;
  6341. /** @hidden */
  6342. _extension: string;
  6343. /** @hidden */
  6344. _files: Nullable<string[]>;
  6345. /** @hidden */
  6346. _workingCanvas: HTMLCanvasElement;
  6347. /** @hidden */
  6348. _workingContext: CanvasRenderingContext2D;
  6349. /** @hidden */
  6350. _framebuffer: Nullable<WebGLFramebuffer>;
  6351. /** @hidden */
  6352. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6353. /** @hidden */
  6354. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6355. /** @hidden */
  6356. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6357. /** @hidden */
  6358. _attachments: Nullable<number[]>;
  6359. /** @hidden */
  6360. _cachedCoordinatesMode: Nullable<number>;
  6361. /** @hidden */
  6362. _cachedWrapU: Nullable<number>;
  6363. /** @hidden */
  6364. _cachedWrapV: Nullable<number>;
  6365. /** @hidden */
  6366. _cachedWrapR: Nullable<number>;
  6367. /** @hidden */
  6368. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6369. /** @hidden */
  6370. _isDisabled: boolean;
  6371. /** @hidden */
  6372. _compression: Nullable<string>;
  6373. /** @hidden */
  6374. _generateStencilBuffer: boolean;
  6375. /** @hidden */
  6376. _generateDepthBuffer: boolean;
  6377. /** @hidden */
  6378. _comparisonFunction: number;
  6379. /** @hidden */
  6380. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6381. /** @hidden */
  6382. _lodGenerationScale: number;
  6383. /** @hidden */
  6384. _lodGenerationOffset: number;
  6385. /** @hidden */
  6386. _lodTextureHigh: BaseTexture;
  6387. /** @hidden */
  6388. _lodTextureMid: BaseTexture;
  6389. /** @hidden */
  6390. _lodTextureLow: BaseTexture;
  6391. /** @hidden */
  6392. _isRGBD: boolean;
  6393. /** @hidden */
  6394. _webGLTexture: Nullable<WebGLTexture>;
  6395. /** @hidden */
  6396. _references: number;
  6397. private _engine;
  6398. /**
  6399. * Gets the Engine the texture belongs to.
  6400. * @returns The babylon engine
  6401. */
  6402. getEngine(): Engine;
  6403. /**
  6404. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6405. */
  6406. readonly dataSource: number;
  6407. /**
  6408. * Creates a new InternalTexture
  6409. * @param engine defines the engine to use
  6410. * @param dataSource defines the type of data that will be used
  6411. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6412. */
  6413. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6414. /**
  6415. * Increments the number of references (ie. the number of Texture that point to it)
  6416. */
  6417. incrementReferences(): void;
  6418. /**
  6419. * Change the size of the texture (not the size of the content)
  6420. * @param width defines the new width
  6421. * @param height defines the new height
  6422. * @param depth defines the new depth (1 by default)
  6423. */
  6424. updateSize(width: int, height: int, depth?: int): void;
  6425. /** @hidden */
  6426. _rebuild(): void;
  6427. /** @hidden */
  6428. _swapAndDie(target: InternalTexture): void;
  6429. /**
  6430. * Dispose the current allocated resources
  6431. */
  6432. dispose(): void;
  6433. }
  6434. }
  6435. declare module BABYLON {
  6436. /**
  6437. * This represents the main contract an easing function should follow.
  6438. * Easing functions are used throughout the animation system.
  6439. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6440. */
  6441. export interface IEasingFunction {
  6442. /**
  6443. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6444. * of the easing function.
  6445. * The link below provides some of the most common examples of easing functions.
  6446. * @see https://easings.net/
  6447. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6448. * @returns the corresponding value on the curve defined by the easing function
  6449. */
  6450. ease(gradient: number): number;
  6451. }
  6452. /**
  6453. * Base class used for every default easing function.
  6454. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6455. */
  6456. export class EasingFunction implements IEasingFunction {
  6457. /**
  6458. * Interpolation follows the mathematical formula associated with the easing function.
  6459. */
  6460. static readonly EASINGMODE_EASEIN: number;
  6461. /**
  6462. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6463. */
  6464. static readonly EASINGMODE_EASEOUT: number;
  6465. /**
  6466. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6467. */
  6468. static readonly EASINGMODE_EASEINOUT: number;
  6469. private _easingMode;
  6470. /**
  6471. * Sets the easing mode of the current function.
  6472. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6473. */
  6474. setEasingMode(easingMode: number): void;
  6475. /**
  6476. * Gets the current easing mode.
  6477. * @returns the easing mode
  6478. */
  6479. getEasingMode(): number;
  6480. /**
  6481. * @hidden
  6482. */
  6483. easeInCore(gradient: number): number;
  6484. /**
  6485. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6486. * of the easing function.
  6487. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6488. * @returns the corresponding value on the curve defined by the easing function
  6489. */
  6490. ease(gradient: number): number;
  6491. }
  6492. /**
  6493. * Easing function with a circle shape (see link below).
  6494. * @see https://easings.net/#easeInCirc
  6495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6496. */
  6497. export class CircleEase extends EasingFunction implements IEasingFunction {
  6498. /** @hidden */
  6499. easeInCore(gradient: number): number;
  6500. }
  6501. /**
  6502. * Easing function with a ease back shape (see link below).
  6503. * @see https://easings.net/#easeInBack
  6504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6505. */
  6506. export class BackEase extends EasingFunction implements IEasingFunction {
  6507. /** Defines the amplitude of the function */
  6508. amplitude: number;
  6509. /**
  6510. * Instantiates a back ease easing
  6511. * @see https://easings.net/#easeInBack
  6512. * @param amplitude Defines the amplitude of the function
  6513. */
  6514. constructor(
  6515. /** Defines the amplitude of the function */
  6516. amplitude?: number);
  6517. /** @hidden */
  6518. easeInCore(gradient: number): number;
  6519. }
  6520. /**
  6521. * Easing function with a bouncing shape (see link below).
  6522. * @see https://easings.net/#easeInBounce
  6523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6524. */
  6525. export class BounceEase extends EasingFunction implements IEasingFunction {
  6526. /** Defines the number of bounces */
  6527. bounces: number;
  6528. /** Defines the amplitude of the bounce */
  6529. bounciness: number;
  6530. /**
  6531. * Instantiates a bounce easing
  6532. * @see https://easings.net/#easeInBounce
  6533. * @param bounces Defines the number of bounces
  6534. * @param bounciness Defines the amplitude of the bounce
  6535. */
  6536. constructor(
  6537. /** Defines the number of bounces */
  6538. bounces?: number,
  6539. /** Defines the amplitude of the bounce */
  6540. bounciness?: number);
  6541. /** @hidden */
  6542. easeInCore(gradient: number): number;
  6543. }
  6544. /**
  6545. * Easing function with a power of 3 shape (see link below).
  6546. * @see https://easings.net/#easeInCubic
  6547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6548. */
  6549. export class CubicEase extends EasingFunction implements IEasingFunction {
  6550. /** @hidden */
  6551. easeInCore(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with an elastic shape (see link below).
  6555. * @see https://easings.net/#easeInElastic
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6559. /** Defines the number of oscillations*/
  6560. oscillations: number;
  6561. /** Defines the amplitude of the oscillations*/
  6562. springiness: number;
  6563. /**
  6564. * Instantiates an elastic easing function
  6565. * @see https://easings.net/#easeInElastic
  6566. * @param oscillations Defines the number of oscillations
  6567. * @param springiness Defines the amplitude of the oscillations
  6568. */
  6569. constructor(
  6570. /** Defines the number of oscillations*/
  6571. oscillations?: number,
  6572. /** Defines the amplitude of the oscillations*/
  6573. springiness?: number);
  6574. /** @hidden */
  6575. easeInCore(gradient: number): number;
  6576. }
  6577. /**
  6578. * Easing function with an exponential shape (see link below).
  6579. * @see https://easings.net/#easeInExpo
  6580. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6581. */
  6582. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6583. /** Defines the exponent of the function */
  6584. exponent: number;
  6585. /**
  6586. * Instantiates an exponential easing function
  6587. * @see https://easings.net/#easeInExpo
  6588. * @param exponent Defines the exponent of the function
  6589. */
  6590. constructor(
  6591. /** Defines the exponent of the function */
  6592. exponent?: number);
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a power shape (see link below).
  6598. * @see https://easings.net/#easeInQuad
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class PowerEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the power of the function */
  6603. power: number;
  6604. /**
  6605. * Instantiates an power base easing function
  6606. * @see https://easings.net/#easeInQuad
  6607. * @param power Defines the power of the function
  6608. */
  6609. constructor(
  6610. /** Defines the power of the function */
  6611. power?: number);
  6612. /** @hidden */
  6613. easeInCore(gradient: number): number;
  6614. }
  6615. /**
  6616. * Easing function with a power of 2 shape (see link below).
  6617. * @see https://easings.net/#easeInQuad
  6618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6619. */
  6620. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6621. /** @hidden */
  6622. easeInCore(gradient: number): number;
  6623. }
  6624. /**
  6625. * Easing function with a power of 4 shape (see link below).
  6626. * @see https://easings.net/#easeInQuart
  6627. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6628. */
  6629. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6630. /** @hidden */
  6631. easeInCore(gradient: number): number;
  6632. }
  6633. /**
  6634. * Easing function with a power of 5 shape (see link below).
  6635. * @see https://easings.net/#easeInQuint
  6636. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6637. */
  6638. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6639. /** @hidden */
  6640. easeInCore(gradient: number): number;
  6641. }
  6642. /**
  6643. * Easing function with a sin shape (see link below).
  6644. * @see https://easings.net/#easeInSine
  6645. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6646. */
  6647. export class SineEase extends EasingFunction implements IEasingFunction {
  6648. /** @hidden */
  6649. easeInCore(gradient: number): number;
  6650. }
  6651. /**
  6652. * Easing function with a bezier shape (see link below).
  6653. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6654. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6655. */
  6656. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6657. /** Defines the x component of the start tangent in the bezier curve */
  6658. x1: number;
  6659. /** Defines the y component of the start tangent in the bezier curve */
  6660. y1: number;
  6661. /** Defines the x component of the end tangent in the bezier curve */
  6662. x2: number;
  6663. /** Defines the y component of the end tangent in the bezier curve */
  6664. y2: number;
  6665. /**
  6666. * Instantiates a bezier function
  6667. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6668. * @param x1 Defines the x component of the start tangent in the bezier curve
  6669. * @param y1 Defines the y component of the start tangent in the bezier curve
  6670. * @param x2 Defines the x component of the end tangent in the bezier curve
  6671. * @param y2 Defines the y component of the end tangent in the bezier curve
  6672. */
  6673. constructor(
  6674. /** Defines the x component of the start tangent in the bezier curve */
  6675. x1?: number,
  6676. /** Defines the y component of the start tangent in the bezier curve */
  6677. y1?: number,
  6678. /** Defines the x component of the end tangent in the bezier curve */
  6679. x2?: number,
  6680. /** Defines the y component of the end tangent in the bezier curve */
  6681. y2?: number);
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. }
  6686. declare module BABYLON {
  6687. /**
  6688. * Defines an interface which represents an animation key frame
  6689. */
  6690. export interface IAnimationKey {
  6691. /**
  6692. * Frame of the key frame
  6693. */
  6694. frame: number;
  6695. /**
  6696. * Value at the specifies key frame
  6697. */
  6698. value: any;
  6699. /**
  6700. * The input tangent for the cubic hermite spline
  6701. */
  6702. inTangent?: any;
  6703. /**
  6704. * The output tangent for the cubic hermite spline
  6705. */
  6706. outTangent?: any;
  6707. /**
  6708. * The animation interpolation type
  6709. */
  6710. interpolation?: AnimationKeyInterpolation;
  6711. }
  6712. /**
  6713. * Enum for the animation key frame interpolation type
  6714. */
  6715. export enum AnimationKeyInterpolation {
  6716. /**
  6717. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6718. */
  6719. STEP = 1
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Represents the range of an animation
  6725. */
  6726. export class AnimationRange {
  6727. /**The name of the animation range**/
  6728. name: string;
  6729. /**The starting frame of the animation */
  6730. from: number;
  6731. /**The ending frame of the animation*/
  6732. to: number;
  6733. /**
  6734. * Initializes the range of an animation
  6735. * @param name The name of the animation range
  6736. * @param from The starting frame of the animation
  6737. * @param to The ending frame of the animation
  6738. */
  6739. constructor(
  6740. /**The name of the animation range**/
  6741. name: string,
  6742. /**The starting frame of the animation */
  6743. from: number,
  6744. /**The ending frame of the animation*/
  6745. to: number);
  6746. /**
  6747. * Makes a copy of the animation range
  6748. * @returns A copy of the animation range
  6749. */
  6750. clone(): AnimationRange;
  6751. }
  6752. }
  6753. declare module BABYLON {
  6754. /**
  6755. * Composed of a frame, and an action function
  6756. */
  6757. export class AnimationEvent {
  6758. /** The frame for which the event is triggered **/
  6759. frame: number;
  6760. /** The event to perform when triggered **/
  6761. action: (currentFrame: number) => void;
  6762. /** Specifies if the event should be triggered only once**/
  6763. onlyOnce?: boolean | undefined;
  6764. /**
  6765. * Specifies if the animation event is done
  6766. */
  6767. isDone: boolean;
  6768. /**
  6769. * Initializes the animation event
  6770. * @param frame The frame for which the event is triggered
  6771. * @param action The event to perform when triggered
  6772. * @param onlyOnce Specifies if the event should be triggered only once
  6773. */
  6774. constructor(
  6775. /** The frame for which the event is triggered **/
  6776. frame: number,
  6777. /** The event to perform when triggered **/
  6778. action: (currentFrame: number) => void,
  6779. /** Specifies if the event should be triggered only once**/
  6780. onlyOnce?: boolean | undefined);
  6781. /** @hidden */
  6782. _clone(): AnimationEvent;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /**
  6787. * Interface used to define a behavior
  6788. */
  6789. export interface Behavior<T> {
  6790. /** gets or sets behavior's name */
  6791. name: string;
  6792. /**
  6793. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6794. */
  6795. init(): void;
  6796. /**
  6797. * Called when the behavior is attached to a target
  6798. * @param target defines the target where the behavior is attached to
  6799. */
  6800. attach(target: T): void;
  6801. /**
  6802. * Called when the behavior is detached from its target
  6803. */
  6804. detach(): void;
  6805. }
  6806. /**
  6807. * Interface implemented by classes supporting behaviors
  6808. */
  6809. export interface IBehaviorAware<T> {
  6810. /**
  6811. * Attach a behavior
  6812. * @param behavior defines the behavior to attach
  6813. * @returns the current host
  6814. */
  6815. addBehavior(behavior: Behavior<T>): T;
  6816. /**
  6817. * Remove a behavior from the current object
  6818. * @param behavior defines the behavior to detach
  6819. * @returns the current host
  6820. */
  6821. removeBehavior(behavior: Behavior<T>): T;
  6822. /**
  6823. * Gets a behavior using its name to search
  6824. * @param name defines the name to search
  6825. * @returns the behavior or null if not found
  6826. */
  6827. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * @hidden
  6833. */
  6834. export class IntersectionInfo {
  6835. bu: Nullable<number>;
  6836. bv: Nullable<number>;
  6837. distance: number;
  6838. faceId: number;
  6839. subMeshId: number;
  6840. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6841. }
  6842. }
  6843. declare module BABYLON {
  6844. /**
  6845. * Class used to store bounding sphere information
  6846. */
  6847. export class BoundingSphere {
  6848. /**
  6849. * Gets the center of the bounding sphere in local space
  6850. */
  6851. readonly center: Vector3;
  6852. /**
  6853. * Radius of the bounding sphere in local space
  6854. */
  6855. radius: number;
  6856. /**
  6857. * Gets the center of the bounding sphere in world space
  6858. */
  6859. readonly centerWorld: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in world space
  6862. */
  6863. radiusWorld: number;
  6864. /**
  6865. * Gets the minimum vector in local space
  6866. */
  6867. readonly minimum: Vector3;
  6868. /**
  6869. * Gets the maximum vector in local space
  6870. */
  6871. readonly maximum: Vector3;
  6872. private _worldMatrix;
  6873. private static readonly TmpVector3;
  6874. /**
  6875. * Creates a new bounding sphere
  6876. * @param min defines the minimum vector (in local space)
  6877. * @param max defines the maximum vector (in local space)
  6878. * @param worldMatrix defines the new world matrix
  6879. */
  6880. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6881. /**
  6882. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6883. * @param min defines the new minimum vector (in local space)
  6884. * @param max defines the new maximum vector (in local space)
  6885. * @param worldMatrix defines the new world matrix
  6886. */
  6887. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Scale the current bounding sphere by applying a scale factor
  6890. * @param factor defines the scale factor to apply
  6891. * @returns the current bounding box
  6892. */
  6893. scale(factor: number): BoundingSphere;
  6894. /**
  6895. * Gets the world matrix of the bounding box
  6896. * @returns a matrix
  6897. */
  6898. getWorldMatrix(): DeepImmutable<Matrix>;
  6899. /** @hidden */
  6900. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Tests if the bounding sphere is intersecting the frustum planes
  6903. * @param frustumPlanes defines the frustum planes to test
  6904. * @returns true if there is an intersection
  6905. */
  6906. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6907. /**
  6908. * Tests if the bounding sphere center is in between the frustum planes.
  6909. * Used for optimistic fast inclusion.
  6910. * @param frustumPlanes defines the frustum planes to test
  6911. * @returns true if the sphere center is in between the frustum planes
  6912. */
  6913. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6914. /**
  6915. * Tests if a point is inside the bounding sphere
  6916. * @param point defines the point to test
  6917. * @returns true if the point is inside the bounding sphere
  6918. */
  6919. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6920. /**
  6921. * Checks if two sphere intersct
  6922. * @param sphere0 sphere 0
  6923. * @param sphere1 sphere 1
  6924. * @returns true if the speres intersect
  6925. */
  6926. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6927. }
  6928. }
  6929. declare module BABYLON {
  6930. /**
  6931. * Class used to store bounding box information
  6932. */
  6933. export class BoundingBox implements ICullable {
  6934. /**
  6935. * Gets the 8 vectors representing the bounding box in local space
  6936. */
  6937. readonly vectors: Vector3[];
  6938. /**
  6939. * Gets the center of the bounding box in local space
  6940. */
  6941. readonly center: Vector3;
  6942. /**
  6943. * Gets the center of the bounding box in world space
  6944. */
  6945. readonly centerWorld: Vector3;
  6946. /**
  6947. * Gets the extend size in local space
  6948. */
  6949. readonly extendSize: Vector3;
  6950. /**
  6951. * Gets the extend size in world space
  6952. */
  6953. readonly extendSizeWorld: Vector3;
  6954. /**
  6955. * Gets the OBB (object bounding box) directions
  6956. */
  6957. readonly directions: Vector3[];
  6958. /**
  6959. * Gets the 8 vectors representing the bounding box in world space
  6960. */
  6961. readonly vectorsWorld: Vector3[];
  6962. /**
  6963. * Gets the minimum vector in world space
  6964. */
  6965. readonly minimumWorld: Vector3;
  6966. /**
  6967. * Gets the maximum vector in world space
  6968. */
  6969. readonly maximumWorld: Vector3;
  6970. /**
  6971. * Gets the minimum vector in local space
  6972. */
  6973. readonly minimum: Vector3;
  6974. /**
  6975. * Gets the maximum vector in local space
  6976. */
  6977. readonly maximum: Vector3;
  6978. private _worldMatrix;
  6979. private static readonly TmpVector3;
  6980. /**
  6981. * @hidden
  6982. */
  6983. _tag: number;
  6984. /**
  6985. * Creates a new bounding box
  6986. * @param min defines the minimum vector (in local space)
  6987. * @param max defines the maximum vector (in local space)
  6988. * @param worldMatrix defines the new world matrix
  6989. */
  6990. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6991. /**
  6992. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6993. * @param min defines the new minimum vector (in local space)
  6994. * @param max defines the new maximum vector (in local space)
  6995. * @param worldMatrix defines the new world matrix
  6996. */
  6997. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Scale the current bounding box by applying a scale factor
  7000. * @param factor defines the scale factor to apply
  7001. * @returns the current bounding box
  7002. */
  7003. scale(factor: number): BoundingBox;
  7004. /**
  7005. * Gets the world matrix of the bounding box
  7006. * @returns a matrix
  7007. */
  7008. getWorldMatrix(): DeepImmutable<Matrix>;
  7009. /** @hidden */
  7010. _update(world: DeepImmutable<Matrix>): void;
  7011. /**
  7012. * Tests if the bounding box is intersecting the frustum planes
  7013. * @param frustumPlanes defines the frustum planes to test
  7014. * @returns true if there is an intersection
  7015. */
  7016. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7017. /**
  7018. * Tests if the bounding box is entirely inside the frustum planes
  7019. * @param frustumPlanes defines the frustum planes to test
  7020. * @returns true if there is an inclusion
  7021. */
  7022. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7023. /**
  7024. * Tests if a point is inside the bounding box
  7025. * @param point defines the point to test
  7026. * @returns true if the point is inside the bounding box
  7027. */
  7028. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if the bounding box intersects with a bounding sphere
  7031. * @param sphere defines the sphere to test
  7032. * @returns true if there is an intersection
  7033. */
  7034. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7035. /**
  7036. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7037. * @param min defines the min vector to use
  7038. * @param max defines the max vector to use
  7039. * @returns true if there is an intersection
  7040. */
  7041. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7042. /**
  7043. * Tests if two bounding boxes are intersections
  7044. * @param box0 defines the first box to test
  7045. * @param box1 defines the second box to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7049. /**
  7050. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7051. * @param minPoint defines the minimum vector of the bounding box
  7052. * @param maxPoint defines the maximum vector of the bounding box
  7053. * @param sphereCenter defines the sphere center
  7054. * @param sphereRadius defines the sphere radius
  7055. * @returns true if there is an intersection
  7056. */
  7057. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7058. /**
  7059. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7060. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @return true if there is an inclusion
  7063. */
  7064. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7067. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @return true if there is an intersection
  7070. */
  7071. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. }
  7073. }
  7074. declare module BABYLON {
  7075. /** @hidden */
  7076. export class Collider {
  7077. /** Define if a collision was found */
  7078. collisionFound: boolean;
  7079. /**
  7080. * Define last intersection point in local space
  7081. */
  7082. intersectionPoint: Vector3;
  7083. /**
  7084. * Define last collided mesh
  7085. */
  7086. collidedMesh: Nullable<AbstractMesh>;
  7087. private _collisionPoint;
  7088. private _planeIntersectionPoint;
  7089. private _tempVector;
  7090. private _tempVector2;
  7091. private _tempVector3;
  7092. private _tempVector4;
  7093. private _edge;
  7094. private _baseToVertex;
  7095. private _destinationPoint;
  7096. private _slidePlaneNormal;
  7097. private _displacementVector;
  7098. /** @hidden */
  7099. _radius: Vector3;
  7100. /** @hidden */
  7101. _retry: number;
  7102. private _velocity;
  7103. private _basePoint;
  7104. private _epsilon;
  7105. /** @hidden */
  7106. _velocityWorldLength: number;
  7107. /** @hidden */
  7108. _basePointWorld: Vector3;
  7109. private _velocityWorld;
  7110. private _normalizedVelocity;
  7111. /** @hidden */
  7112. _initialVelocity: Vector3;
  7113. /** @hidden */
  7114. _initialPosition: Vector3;
  7115. private _nearestDistance;
  7116. private _collisionMask;
  7117. collisionMask: number;
  7118. /**
  7119. * Gets the plane normal used to compute the sliding response (in local space)
  7120. */
  7121. readonly slidePlaneNormal: Vector3;
  7122. /** @hidden */
  7123. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7124. /** @hidden */
  7125. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7126. /** @hidden */
  7127. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7128. /** @hidden */
  7129. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7130. /** @hidden */
  7131. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7132. /** @hidden */
  7133. _getResponse(pos: Vector3, vel: Vector3): void;
  7134. }
  7135. }
  7136. declare module BABYLON {
  7137. /**
  7138. * Interface for cullable objects
  7139. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7140. */
  7141. export interface ICullable {
  7142. /**
  7143. * Checks if the object or part of the object is in the frustum
  7144. * @param frustumPlanes Camera near/planes
  7145. * @returns true if the object is in frustum otherwise false
  7146. */
  7147. isInFrustum(frustumPlanes: Plane[]): boolean;
  7148. /**
  7149. * Checks if a cullable object (mesh...) is in the camera frustum
  7150. * Unlike isInFrustum this cheks the full bounding box
  7151. * @param frustumPlanes Camera near/planes
  7152. * @returns true if the object is in frustum otherwise false
  7153. */
  7154. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7155. }
  7156. /**
  7157. * Info for a bounding data of a mesh
  7158. */
  7159. export class BoundingInfo implements ICullable {
  7160. /**
  7161. * Bounding box for the mesh
  7162. */
  7163. readonly boundingBox: BoundingBox;
  7164. /**
  7165. * Bounding sphere for the mesh
  7166. */
  7167. readonly boundingSphere: BoundingSphere;
  7168. private _isLocked;
  7169. private static readonly TmpVector3;
  7170. /**
  7171. * Constructs bounding info
  7172. * @param minimum min vector of the bounding box/sphere
  7173. * @param maximum max vector of the bounding box/sphere
  7174. * @param worldMatrix defines the new world matrix
  7175. */
  7176. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7177. /**
  7178. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7179. * @param min defines the new minimum vector (in local space)
  7180. * @param max defines the new maximum vector (in local space)
  7181. * @param worldMatrix defines the new world matrix
  7182. */
  7183. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7184. /**
  7185. * min vector of the bounding box/sphere
  7186. */
  7187. readonly minimum: Vector3;
  7188. /**
  7189. * max vector of the bounding box/sphere
  7190. */
  7191. readonly maximum: Vector3;
  7192. /**
  7193. * If the info is locked and won't be updated to avoid perf overhead
  7194. */
  7195. isLocked: boolean;
  7196. /**
  7197. * Updates the bounding sphere and box
  7198. * @param world world matrix to be used to update
  7199. */
  7200. update(world: DeepImmutable<Matrix>): void;
  7201. /**
  7202. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7203. * @param center New center of the bounding info
  7204. * @param extend New extend of the bounding info
  7205. * @returns the current bounding info
  7206. */
  7207. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7208. /**
  7209. * Scale the current bounding info by applying a scale factor
  7210. * @param factor defines the scale factor to apply
  7211. * @returns the current bounding info
  7212. */
  7213. scale(factor: number): BoundingInfo;
  7214. /**
  7215. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7216. * @param frustumPlanes defines the frustum to test
  7217. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7218. * @returns true if the bounding info is in the frustum planes
  7219. */
  7220. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7221. /**
  7222. * Gets the world distance between the min and max points of the bounding box
  7223. */
  7224. readonly diagonalLength: number;
  7225. /**
  7226. * Checks if a cullable object (mesh...) is in the camera frustum
  7227. * Unlike isInFrustum this cheks the full bounding box
  7228. * @param frustumPlanes Camera near/planes
  7229. * @returns true if the object is in frustum otherwise false
  7230. */
  7231. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7232. /** @hidden */
  7233. _checkCollision(collider: Collider): boolean;
  7234. /**
  7235. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7236. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7237. * @param point the point to check intersection with
  7238. * @returns if the point intersects
  7239. */
  7240. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7241. /**
  7242. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7243. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7244. * @param boundingInfo the bounding info to check intersection with
  7245. * @param precise if the intersection should be done using OBB
  7246. * @returns if the bounding info intersects
  7247. */
  7248. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7249. }
  7250. }
  7251. declare module BABYLON {
  7252. /**
  7253. * Defines an array and its length.
  7254. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7255. */
  7256. export interface ISmartArrayLike<T> {
  7257. /**
  7258. * The data of the array.
  7259. */
  7260. data: Array<T>;
  7261. /**
  7262. * The active length of the array.
  7263. */
  7264. length: number;
  7265. }
  7266. /**
  7267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7268. */
  7269. export class SmartArray<T> implements ISmartArrayLike<T> {
  7270. /**
  7271. * The full set of data from the array.
  7272. */
  7273. data: Array<T>;
  7274. /**
  7275. * The active length of the array.
  7276. */
  7277. length: number;
  7278. protected _id: number;
  7279. /**
  7280. * Instantiates a Smart Array.
  7281. * @param capacity defines the default capacity of the array.
  7282. */
  7283. constructor(capacity: number);
  7284. /**
  7285. * Pushes a value at the end of the active data.
  7286. * @param value defines the object to push in the array.
  7287. */
  7288. push(value: T): void;
  7289. /**
  7290. * Iterates over the active data and apply the lambda to them.
  7291. * @param func defines the action to apply on each value.
  7292. */
  7293. forEach(func: (content: T) => void): void;
  7294. /**
  7295. * Sorts the full sets of data.
  7296. * @param compareFn defines the comparison function to apply.
  7297. */
  7298. sort(compareFn: (a: T, b: T) => number): void;
  7299. /**
  7300. * Resets the active data to an empty array.
  7301. */
  7302. reset(): void;
  7303. /**
  7304. * Releases all the data from the array as well as the array.
  7305. */
  7306. dispose(): void;
  7307. /**
  7308. * Concats the active data with a given array.
  7309. * @param array defines the data to concatenate with.
  7310. */
  7311. concat(array: any): void;
  7312. /**
  7313. * Returns the position of a value in the active data.
  7314. * @param value defines the value to find the index for
  7315. * @returns the index if found in the active data otherwise -1
  7316. */
  7317. indexOf(value: T): number;
  7318. /**
  7319. * Returns whether an element is part of the active data.
  7320. * @param value defines the value to look for
  7321. * @returns true if found in the active data otherwise false
  7322. */
  7323. contains(value: T): boolean;
  7324. private static _GlobalId;
  7325. }
  7326. /**
  7327. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7328. * The data in this array can only be present once
  7329. */
  7330. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7331. private _duplicateId;
  7332. /**
  7333. * Pushes a value at the end of the active data.
  7334. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7335. * @param value defines the object to push in the array.
  7336. */
  7337. push(value: T): void;
  7338. /**
  7339. * Pushes a value at the end of the active data.
  7340. * If the data is already present, it won t be added again
  7341. * @param value defines the object to push in the array.
  7342. * @returns true if added false if it was already present
  7343. */
  7344. pushNoDuplicate(value: T): boolean;
  7345. /**
  7346. * Resets the active data to an empty array.
  7347. */
  7348. reset(): void;
  7349. /**
  7350. * Concats the active data with a given array.
  7351. * This ensures no dupplicate will be present in the result.
  7352. * @param array defines the data to concatenate with.
  7353. */
  7354. concatWithNoDuplicate(array: any): void;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7360. * separate meshes. This can be use to improve performances.
  7361. * @see http://doc.babylonjs.com/how_to/multi_materials
  7362. */
  7363. export class MultiMaterial extends Material {
  7364. private _subMaterials;
  7365. /**
  7366. * Gets or Sets the list of Materials used within the multi material.
  7367. * They need to be ordered according to the submeshes order in the associated mesh
  7368. */
  7369. subMaterials: Nullable<Material>[];
  7370. /**
  7371. * Function used to align with Node.getChildren()
  7372. * @returns the list of Materials used within the multi material
  7373. */
  7374. getChildren(): Nullable<Material>[];
  7375. /**
  7376. * Instantiates a new Multi Material
  7377. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7378. * separate meshes. This can be use to improve performances.
  7379. * @see http://doc.babylonjs.com/how_to/multi_materials
  7380. * @param name Define the name in the scene
  7381. * @param scene Define the scene the material belongs to
  7382. */
  7383. constructor(name: string, scene: Scene);
  7384. private _hookArray;
  7385. /**
  7386. * Get one of the submaterial by its index in the submaterials array
  7387. * @param index The index to look the sub material at
  7388. * @returns The Material if the index has been defined
  7389. */
  7390. getSubMaterial(index: number): Nullable<Material>;
  7391. /**
  7392. * Get the list of active textures for the whole sub materials list.
  7393. * @returns All the textures that will be used during the rendering
  7394. */
  7395. getActiveTextures(): BaseTexture[];
  7396. /**
  7397. * Gets the current class name of the material e.g. "MultiMaterial"
  7398. * Mainly use in serialization.
  7399. * @returns the class name
  7400. */
  7401. getClassName(): string;
  7402. /**
  7403. * Checks if the material is ready to render the requested sub mesh
  7404. * @param mesh Define the mesh the submesh belongs to
  7405. * @param subMesh Define the sub mesh to look readyness for
  7406. * @param useInstances Define whether or not the material is used with instances
  7407. * @returns true if ready, otherwise false
  7408. */
  7409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7410. /**
  7411. * Clones the current material and its related sub materials
  7412. * @param name Define the name of the newly cloned material
  7413. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7414. * @returns the cloned material
  7415. */
  7416. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7417. /**
  7418. * Serializes the materials into a JSON representation.
  7419. * @returns the JSON representation
  7420. */
  7421. serialize(): any;
  7422. /**
  7423. * Dispose the material and release its associated resources
  7424. * @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)
  7425. * @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)
  7426. * @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)
  7427. */
  7428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7429. /**
  7430. * Creates a MultiMaterial from parsed MultiMaterial data.
  7431. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7432. * @param scene defines the hosting scene
  7433. * @returns a new MultiMaterial
  7434. */
  7435. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7436. }
  7437. }
  7438. declare module BABYLON {
  7439. /**
  7440. * Class used to represent data loading progression
  7441. */
  7442. export class SceneLoaderFlags {
  7443. private static _ForceFullSceneLoadingForIncremental;
  7444. private static _ShowLoadingScreen;
  7445. private static _CleanBoneMatrixWeights;
  7446. private static _loggingLevel;
  7447. /**
  7448. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7449. */
  7450. static ForceFullSceneLoadingForIncremental: boolean;
  7451. /**
  7452. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7453. */
  7454. static ShowLoadingScreen: boolean;
  7455. /**
  7456. * Defines the current logging level (while loading the scene)
  7457. * @ignorenaming
  7458. */
  7459. static loggingLevel: number;
  7460. /**
  7461. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7462. */
  7463. static CleanBoneMatrixWeights: boolean;
  7464. }
  7465. }
  7466. declare module BABYLON {
  7467. /**
  7468. * 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.
  7469. * @see https://doc.babylonjs.com/how_to/transformnode
  7470. */
  7471. export class TransformNode extends Node {
  7472. /**
  7473. * Object will not rotate to face the camera
  7474. */
  7475. static BILLBOARDMODE_NONE: number;
  7476. /**
  7477. * Object will rotate to face the camera but only on the x axis
  7478. */
  7479. static BILLBOARDMODE_X: number;
  7480. /**
  7481. * Object will rotate to face the camera but only on the y axis
  7482. */
  7483. static BILLBOARDMODE_Y: number;
  7484. /**
  7485. * Object will rotate to face the camera but only on the z axis
  7486. */
  7487. static BILLBOARDMODE_Z: number;
  7488. /**
  7489. * Object will rotate to face the camera
  7490. */
  7491. static BILLBOARDMODE_ALL: number;
  7492. private _forward;
  7493. private _forwardInverted;
  7494. private _up;
  7495. private _right;
  7496. private _rightInverted;
  7497. private _position;
  7498. private _rotation;
  7499. private _rotationQuaternion;
  7500. protected _scaling: Vector3;
  7501. protected _isDirty: boolean;
  7502. private _transformToBoneReferal;
  7503. /**
  7504. * Set the billboard mode. Default is 0.
  7505. *
  7506. * | Value | Type | Description |
  7507. * | --- | --- | --- |
  7508. * | 0 | BILLBOARDMODE_NONE | |
  7509. * | 1 | BILLBOARDMODE_X | |
  7510. * | 2 | BILLBOARDMODE_Y | |
  7511. * | 4 | BILLBOARDMODE_Z | |
  7512. * | 7 | BILLBOARDMODE_ALL | |
  7513. *
  7514. */
  7515. billboardMode: number;
  7516. /**
  7517. * 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
  7518. */
  7519. scalingDeterminant: number;
  7520. /**
  7521. * Sets the distance of the object to max, often used by skybox
  7522. */
  7523. infiniteDistance: boolean;
  7524. /**
  7525. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7526. * By default the system will update normals to compensate
  7527. */
  7528. ignoreNonUniformScaling: boolean;
  7529. /** @hidden */
  7530. _poseMatrix: Matrix;
  7531. /** @hidden */
  7532. _localMatrix: Matrix;
  7533. private _absolutePosition;
  7534. private _pivotMatrix;
  7535. private _pivotMatrixInverse;
  7536. protected _postMultiplyPivotMatrix: boolean;
  7537. private _tempMatrix;
  7538. private _tempMatrix2;
  7539. protected _isWorldMatrixFrozen: boolean;
  7540. /** @hidden */
  7541. _indexInSceneTransformNodesArray: number;
  7542. /**
  7543. * An event triggered after the world matrix is updated
  7544. */
  7545. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7546. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7547. /**
  7548. * Gets a string identifying the name of the class
  7549. * @returns "TransformNode" string
  7550. */
  7551. getClassName(): string;
  7552. /**
  7553. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7554. */
  7555. position: Vector3;
  7556. /**
  7557. * 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)).
  7558. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7559. */
  7560. rotation: Vector3;
  7561. /**
  7562. * 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)).
  7563. */
  7564. scaling: Vector3;
  7565. /**
  7566. * 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).
  7567. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7568. */
  7569. rotationQuaternion: Nullable<Quaternion>;
  7570. /**
  7571. * The forward direction of that transform in world space.
  7572. */
  7573. readonly forward: Vector3;
  7574. /**
  7575. * The up direction of that transform in world space.
  7576. */
  7577. readonly up: Vector3;
  7578. /**
  7579. * The right direction of that transform in world space.
  7580. */
  7581. readonly right: Vector3;
  7582. /**
  7583. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7584. * @param matrix the matrix to copy the pose from
  7585. * @returns this TransformNode.
  7586. */
  7587. updatePoseMatrix(matrix: Matrix): TransformNode;
  7588. /**
  7589. * Returns the mesh Pose matrix.
  7590. * @returns the pose matrix
  7591. */
  7592. getPoseMatrix(): Matrix;
  7593. /** @hidden */
  7594. _isSynchronized(): boolean;
  7595. /** @hidden */
  7596. _initCache(): void;
  7597. /**
  7598. * Flag the transform node as dirty (Forcing it to update everything)
  7599. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7600. * @returns this transform node
  7601. */
  7602. markAsDirty(property: string): TransformNode;
  7603. /**
  7604. * Returns the current mesh absolute position.
  7605. * Returns a Vector3.
  7606. */
  7607. readonly absolutePosition: Vector3;
  7608. /**
  7609. * Sets a new matrix to apply before all other transformation
  7610. * @param matrix defines the transform matrix
  7611. * @returns the current TransformNode
  7612. */
  7613. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7614. /**
  7615. * Sets a new pivot matrix to the current node
  7616. * @param matrix defines the new pivot matrix to use
  7617. * @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
  7618. * @returns the current TransformNode
  7619. */
  7620. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7621. /**
  7622. * Returns the mesh pivot matrix.
  7623. * Default : Identity.
  7624. * @returns the matrix
  7625. */
  7626. getPivotMatrix(): Matrix;
  7627. /**
  7628. * Prevents the World matrix to be computed any longer.
  7629. * @returns the TransformNode.
  7630. */
  7631. freezeWorldMatrix(): TransformNode;
  7632. /**
  7633. * Allows back the World matrix computation.
  7634. * @returns the TransformNode.
  7635. */
  7636. unfreezeWorldMatrix(): this;
  7637. /**
  7638. * True if the World matrix has been frozen.
  7639. */
  7640. readonly isWorldMatrixFrozen: boolean;
  7641. /**
  7642. * Retuns the mesh absolute position in the World.
  7643. * @returns a Vector3.
  7644. */
  7645. getAbsolutePosition(): Vector3;
  7646. /**
  7647. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7648. * @param absolutePosition the absolute position to set
  7649. * @returns the TransformNode.
  7650. */
  7651. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7652. /**
  7653. * Sets the mesh position in its local space.
  7654. * @param vector3 the position to set in localspace
  7655. * @returns the TransformNode.
  7656. */
  7657. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7658. /**
  7659. * Returns the mesh position in the local space from the current World matrix values.
  7660. * @returns a new Vector3.
  7661. */
  7662. getPositionExpressedInLocalSpace(): Vector3;
  7663. /**
  7664. * Translates the mesh along the passed Vector3 in its local space.
  7665. * @param vector3 the distance to translate in localspace
  7666. * @returns the TransformNode.
  7667. */
  7668. locallyTranslate(vector3: Vector3): TransformNode;
  7669. private static _lookAtVectorCache;
  7670. /**
  7671. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7672. * @param targetPoint the position (must be in same space as current mesh) to look at
  7673. * @param yawCor optional yaw (y-axis) correction in radians
  7674. * @param pitchCor optional pitch (x-axis) correction in radians
  7675. * @param rollCor optional roll (z-axis) correction in radians
  7676. * @param space the choosen space of the target
  7677. * @returns the TransformNode.
  7678. */
  7679. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7680. /**
  7681. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7682. * This Vector3 is expressed in the World space.
  7683. * @param localAxis axis to rotate
  7684. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7685. */
  7686. getDirection(localAxis: Vector3): Vector3;
  7687. /**
  7688. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7689. * localAxis is expressed in the mesh local space.
  7690. * result is computed in the Wordl space from the mesh World matrix.
  7691. * @param localAxis axis to rotate
  7692. * @param result the resulting transformnode
  7693. * @returns this TransformNode.
  7694. */
  7695. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7696. /**
  7697. * Sets this transform node rotation to the given local axis.
  7698. * @param localAxis the axis in local space
  7699. * @param yawCor optional yaw (y-axis) correction in radians
  7700. * @param pitchCor optional pitch (x-axis) correction in radians
  7701. * @param rollCor optional roll (z-axis) correction in radians
  7702. * @returns this TransformNode
  7703. */
  7704. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7705. /**
  7706. * Sets a new pivot point to the current node
  7707. * @param point defines the new pivot point to use
  7708. * @param space defines if the point is in world or local space (local by default)
  7709. * @returns the current TransformNode
  7710. */
  7711. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7712. /**
  7713. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7714. * @returns the pivot point
  7715. */
  7716. getPivotPoint(): Vector3;
  7717. /**
  7718. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7719. * @param result the vector3 to store the result
  7720. * @returns this TransformNode.
  7721. */
  7722. getPivotPointToRef(result: Vector3): TransformNode;
  7723. /**
  7724. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7725. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7726. */
  7727. getAbsolutePivotPoint(): Vector3;
  7728. /**
  7729. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7730. * @param result vector3 to store the result
  7731. * @returns this TransformNode.
  7732. */
  7733. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7734. /**
  7735. * Defines the passed node as the parent of the current node.
  7736. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7737. * @see https://doc.babylonjs.com/how_to/parenting
  7738. * @param node the node ot set as the parent
  7739. * @returns this TransformNode.
  7740. */
  7741. setParent(node: Nullable<Node>): TransformNode;
  7742. private _nonUniformScaling;
  7743. /**
  7744. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7745. */
  7746. readonly nonUniformScaling: boolean;
  7747. /** @hidden */
  7748. _updateNonUniformScalingState(value: boolean): boolean;
  7749. /**
  7750. * Attach the current TransformNode to another TransformNode associated with a bone
  7751. * @param bone Bone affecting the TransformNode
  7752. * @param affectedTransformNode TransformNode associated with the bone
  7753. * @returns this object
  7754. */
  7755. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7756. /**
  7757. * Detach the transform node if its associated with a bone
  7758. * @returns this object
  7759. */
  7760. detachFromBone(): TransformNode;
  7761. private static _rotationAxisCache;
  7762. /**
  7763. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7764. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7765. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7766. * The passed axis is also normalized.
  7767. * @param axis the axis to rotate around
  7768. * @param amount the amount to rotate in radians
  7769. * @param space Space to rotate in (Default: local)
  7770. * @returns the TransformNode.
  7771. */
  7772. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7773. /**
  7774. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7775. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7776. * The passed axis is also normalized. .
  7777. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7778. * @param point the point to rotate around
  7779. * @param axis the axis to rotate around
  7780. * @param amount the amount to rotate in radians
  7781. * @returns the TransformNode
  7782. */
  7783. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7784. /**
  7785. * Translates the mesh along the axis vector for the passed distance in the given space.
  7786. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7787. * @param axis the axis to translate in
  7788. * @param distance the distance to translate
  7789. * @param space Space to rotate in (Default: local)
  7790. * @returns the TransformNode.
  7791. */
  7792. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7793. /**
  7794. * Adds a rotation step to the mesh current rotation.
  7795. * x, y, z are Euler angles expressed in radians.
  7796. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7797. * This means this rotation is made in the mesh local space only.
  7798. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7799. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7800. * ```javascript
  7801. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7802. * ```
  7803. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7804. * 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.
  7805. * @param x Rotation to add
  7806. * @param y Rotation to add
  7807. * @param z Rotation to add
  7808. * @returns the TransformNode.
  7809. */
  7810. addRotation(x: number, y: number, z: number): TransformNode;
  7811. /**
  7812. * Computes the world matrix of the node
  7813. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7814. * @returns the world matrix
  7815. */
  7816. computeWorldMatrix(force?: boolean): Matrix;
  7817. protected _afterComputeWorldMatrix(): void;
  7818. /**
  7819. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7820. * @param func callback function to add
  7821. *
  7822. * @returns the TransformNode.
  7823. */
  7824. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7825. /**
  7826. * Removes a registered callback function.
  7827. * @param func callback function to remove
  7828. * @returns the TransformNode.
  7829. */
  7830. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7831. /**
  7832. * Gets the position of the current mesh in camera space
  7833. * @param camera defines the camera to use
  7834. * @returns a position
  7835. */
  7836. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7837. /**
  7838. * Returns the distance from the mesh to the active camera
  7839. * @param camera defines the camera to use
  7840. * @returns the distance
  7841. */
  7842. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7843. /**
  7844. * Clone the current transform node
  7845. * @param name Name of the new clone
  7846. * @param newParent New parent for the clone
  7847. * @param doNotCloneChildren Do not clone children hierarchy
  7848. * @returns the new transform node
  7849. */
  7850. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7851. /**
  7852. * Serializes the objects information.
  7853. * @param currentSerializationObject defines the object to serialize in
  7854. * @returns the serialized object
  7855. */
  7856. serialize(currentSerializationObject?: any): any;
  7857. /**
  7858. * Returns a new TransformNode object parsed from the source provided.
  7859. * @param parsedTransformNode is the source.
  7860. * @param scene the scne the object belongs to
  7861. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7862. * @returns a new TransformNode object parsed from the source provided.
  7863. */
  7864. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7865. /**
  7866. * Get all child-transformNodes of this node
  7867. * @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
  7868. * @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
  7869. * @returns an array of TransformNode
  7870. */
  7871. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7872. /**
  7873. * Releases resources associated with this transform node.
  7874. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7875. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7876. */
  7877. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7878. }
  7879. }
  7880. declare module BABYLON {
  7881. /**
  7882. * Class used to override all child animations of a given target
  7883. */
  7884. export class AnimationPropertiesOverride {
  7885. /**
  7886. * Gets or sets a value indicating if animation blending must be used
  7887. */
  7888. enableBlending: boolean;
  7889. /**
  7890. * Gets or sets the blending speed to use when enableBlending is true
  7891. */
  7892. blendingSpeed: number;
  7893. /**
  7894. * Gets or sets the default loop mode to use
  7895. */
  7896. loopMode: number;
  7897. }
  7898. }
  7899. declare module BABYLON {
  7900. /**
  7901. * Class used to store bone information
  7902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7903. */
  7904. export class Bone extends Node {
  7905. /**
  7906. * defines the bone name
  7907. */
  7908. name: string;
  7909. private static _tmpVecs;
  7910. private static _tmpQuat;
  7911. private static _tmpMats;
  7912. /**
  7913. * Gets the list of child bones
  7914. */
  7915. children: Bone[];
  7916. /** Gets the animations associated with this bone */
  7917. animations: Animation[];
  7918. /**
  7919. * Gets or sets bone length
  7920. */
  7921. length: number;
  7922. /**
  7923. * @hidden Internal only
  7924. * Set this value to map this bone to a different index in the transform matrices
  7925. * Set this value to -1 to exclude the bone from the transform matrices
  7926. */
  7927. _index: Nullable<number>;
  7928. private _skeleton;
  7929. private _localMatrix;
  7930. private _restPose;
  7931. private _baseMatrix;
  7932. private _absoluteTransform;
  7933. private _invertedAbsoluteTransform;
  7934. private _parent;
  7935. private _scalingDeterminant;
  7936. private _worldTransform;
  7937. private _localScaling;
  7938. private _localRotation;
  7939. private _localPosition;
  7940. private _needToDecompose;
  7941. private _needToCompose;
  7942. /** @hidden */
  7943. _linkedTransformNode: Nullable<TransformNode>;
  7944. /** @hidden */
  7945. /** @hidden */
  7946. _matrix: Matrix;
  7947. /**
  7948. * Create a new bone
  7949. * @param name defines the bone name
  7950. * @param skeleton defines the parent skeleton
  7951. * @param parentBone defines the parent (can be null if the bone is the root)
  7952. * @param localMatrix defines the local matrix
  7953. * @param restPose defines the rest pose matrix
  7954. * @param baseMatrix defines the base matrix
  7955. * @param index defines index of the bone in the hiearchy
  7956. */
  7957. constructor(
  7958. /**
  7959. * defines the bone name
  7960. */
  7961. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7962. /**
  7963. * Gets the current object class name.
  7964. * @return the class name
  7965. */
  7966. getClassName(): string;
  7967. /**
  7968. * Gets the parent skeleton
  7969. * @returns a skeleton
  7970. */
  7971. getSkeleton(): Skeleton;
  7972. /**
  7973. * Gets parent bone
  7974. * @returns a bone or null if the bone is the root of the bone hierarchy
  7975. */
  7976. getParent(): Nullable<Bone>;
  7977. /**
  7978. * Returns an array containing the root bones
  7979. * @returns an array containing the root bones
  7980. */
  7981. getChildren(): Array<Bone>;
  7982. /**
  7983. * Sets the parent bone
  7984. * @param parent defines the parent (can be null if the bone is the root)
  7985. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7986. */
  7987. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7988. /**
  7989. * Gets the local matrix
  7990. * @returns a matrix
  7991. */
  7992. getLocalMatrix(): Matrix;
  7993. /**
  7994. * Gets the base matrix (initial matrix which remains unchanged)
  7995. * @returns a matrix
  7996. */
  7997. getBaseMatrix(): Matrix;
  7998. /**
  7999. * Gets the rest pose matrix
  8000. * @returns a matrix
  8001. */
  8002. getRestPose(): Matrix;
  8003. /**
  8004. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8005. */
  8006. getWorldMatrix(): Matrix;
  8007. /**
  8008. * Sets the local matrix to rest pose matrix
  8009. */
  8010. returnToRest(): void;
  8011. /**
  8012. * Gets the inverse of the absolute transform matrix.
  8013. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8014. * @returns a matrix
  8015. */
  8016. getInvertedAbsoluteTransform(): Matrix;
  8017. /**
  8018. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8019. * @returns a matrix
  8020. */
  8021. getAbsoluteTransform(): Matrix;
  8022. /**
  8023. * Links with the given transform node.
  8024. * The local matrix of this bone is copied from the transform node every frame.
  8025. * @param transformNode defines the transform node to link to
  8026. */
  8027. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8028. /** Gets or sets current position (in local space) */
  8029. position: Vector3;
  8030. /** Gets or sets current rotation (in local space) */
  8031. rotation: Vector3;
  8032. /** Gets or sets current rotation quaternion (in local space) */
  8033. rotationQuaternion: Quaternion;
  8034. /** Gets or sets current scaling (in local space) */
  8035. scaling: Vector3;
  8036. /**
  8037. * Gets the animation properties override
  8038. */
  8039. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8040. private _decompose;
  8041. private _compose;
  8042. /**
  8043. * Update the base and local matrices
  8044. * @param matrix defines the new base or local matrix
  8045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8046. * @param updateLocalMatrix defines if the local matrix should be updated
  8047. */
  8048. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8049. /** @hidden */
  8050. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8051. /**
  8052. * Flag the bone as dirty (Forcing it to update everything)
  8053. */
  8054. markAsDirty(): void;
  8055. private _markAsDirtyAndCompose;
  8056. private _markAsDirtyAndDecompose;
  8057. /**
  8058. * Translate the bone in local or world space
  8059. * @param vec The amount to translate the bone
  8060. * @param space The space that the translation is in
  8061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8062. */
  8063. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8064. /**
  8065. * Set the postion of the bone in local or world space
  8066. * @param position The position to set the bone
  8067. * @param space The space that the position is in
  8068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8069. */
  8070. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8071. /**
  8072. * Set the absolute position of the bone (world space)
  8073. * @param position The position to set the bone
  8074. * @param mesh The mesh that this bone is attached to
  8075. */
  8076. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8077. /**
  8078. * Scale the bone on the x, y and z axes (in local space)
  8079. * @param x The amount to scale the bone on the x axis
  8080. * @param y The amount to scale the bone on the y axis
  8081. * @param z The amount to scale the bone on the z axis
  8082. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8083. */
  8084. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8085. /**
  8086. * Set the bone scaling in local space
  8087. * @param scale defines the scaling vector
  8088. */
  8089. setScale(scale: Vector3): void;
  8090. /**
  8091. * Gets the current scaling in local space
  8092. * @returns the current scaling vector
  8093. */
  8094. getScale(): Vector3;
  8095. /**
  8096. * Gets the current scaling in local space and stores it in a target vector
  8097. * @param result defines the target vector
  8098. */
  8099. getScaleToRef(result: Vector3): void;
  8100. /**
  8101. * Set the yaw, pitch, and roll of the bone in local or world space
  8102. * @param yaw The rotation of the bone on the y axis
  8103. * @param pitch The rotation of the bone on the x axis
  8104. * @param roll The rotation of the bone on the z axis
  8105. * @param space The space that the axes of rotation are in
  8106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8107. */
  8108. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8109. /**
  8110. * Add a rotation to the bone on an axis in local or world space
  8111. * @param axis The axis to rotate the bone on
  8112. * @param amount The amount to rotate the bone
  8113. * @param space The space that the axis is in
  8114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8115. */
  8116. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8117. /**
  8118. * Set the rotation of the bone to a particular axis angle in local or world space
  8119. * @param axis The axis to rotate the bone on
  8120. * @param angle The angle that the bone should be rotated to
  8121. * @param space The space that the axis is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8125. /**
  8126. * Set the euler rotation of the bone in local of world space
  8127. * @param rotation The euler rotation that the bone should be set to
  8128. * @param space The space that the rotation is in
  8129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8130. */
  8131. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8132. /**
  8133. * Set the quaternion rotation of the bone in local of world space
  8134. * @param quat The quaternion rotation that the bone should be set to
  8135. * @param space The space that the rotation is in
  8136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8137. */
  8138. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8139. /**
  8140. * Set the rotation matrix of the bone in local of world space
  8141. * @param rotMat The rotation matrix that the bone should be set to
  8142. * @param space The space that the rotation is in
  8143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8144. */
  8145. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8146. private _rotateWithMatrix;
  8147. private _getNegativeRotationToRef;
  8148. /**
  8149. * Get the position of the bone in local or world space
  8150. * @param space The space that the returned position is in
  8151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8152. * @returns The position of the bone
  8153. */
  8154. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8155. /**
  8156. * Copy the position of the bone to a vector3 in local or world space
  8157. * @param space The space that the returned position is in
  8158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8159. * @param result The vector3 to copy the position to
  8160. */
  8161. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8162. /**
  8163. * Get the absolute position of the bone (world space)
  8164. * @param mesh The mesh that this bone is attached to
  8165. * @returns The absolute position of the bone
  8166. */
  8167. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8168. /**
  8169. * Copy the absolute position of the bone (world space) to the result param
  8170. * @param mesh The mesh that this bone is attached to
  8171. * @param result The vector3 to copy the absolute position to
  8172. */
  8173. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8174. /**
  8175. * Compute the absolute transforms of this bone and its children
  8176. */
  8177. computeAbsoluteTransforms(): void;
  8178. /**
  8179. * Get the world direction from an axis that is in the local space of the bone
  8180. * @param localAxis The local direction that is used to compute the world direction
  8181. * @param mesh The mesh that this bone is attached to
  8182. * @returns The world direction
  8183. */
  8184. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8185. /**
  8186. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8187. * @param localAxis The local direction that is used to compute the world direction
  8188. * @param mesh The mesh that this bone is attached to
  8189. * @param result The vector3 that the world direction will be copied to
  8190. */
  8191. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8192. /**
  8193. * Get the euler rotation of the bone in local or world space
  8194. * @param space The space that the rotation should be in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. * @returns The euler rotation
  8197. */
  8198. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8199. /**
  8200. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8201. * @param space The space that the rotation should be in
  8202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8203. * @param result The vector3 that the rotation should be copied to
  8204. */
  8205. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8206. /**
  8207. * Get the quaternion rotation of the bone in either local or world space
  8208. * @param space The space that the rotation should be in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. * @returns The quaternion rotation
  8211. */
  8212. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8213. /**
  8214. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8215. * @param space The space that the rotation should be in
  8216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8217. * @param result The quaternion that the rotation should be copied to
  8218. */
  8219. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8220. /**
  8221. * Get the rotation matrix of the bone in local or world space
  8222. * @param space The space that the rotation should be in
  8223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8224. * @returns The rotation matrix
  8225. */
  8226. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8227. /**
  8228. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8229. * @param space The space that the rotation should be in
  8230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8231. * @param result The quaternion that the rotation should be copied to
  8232. */
  8233. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8234. /**
  8235. * Get the world position of a point that is in the local space of the bone
  8236. * @param position The local position
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @returns The world position
  8239. */
  8240. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8241. /**
  8242. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8243. * @param position The local position
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @param result The vector3 that the world position should be copied to
  8246. */
  8247. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8248. /**
  8249. * Get the local position of a point that is in world space
  8250. * @param position The world position
  8251. * @param mesh The mesh that this bone is attached to
  8252. * @returns The local position
  8253. */
  8254. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8255. /**
  8256. * Get the local position of a point that is in world space and copy it to the result param
  8257. * @param position The world position
  8258. * @param mesh The mesh that this bone is attached to
  8259. * @param result The vector3 that the local position should be copied to
  8260. */
  8261. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8262. }
  8263. }
  8264. declare module BABYLON {
  8265. /**
  8266. * Enum that determines the text-wrapping mode to use.
  8267. */
  8268. export enum InspectableType {
  8269. /**
  8270. * Checkbox for booleans
  8271. */
  8272. Checkbox = 0,
  8273. /**
  8274. * Sliders for numbers
  8275. */
  8276. Slider = 1,
  8277. /**
  8278. * Vector3
  8279. */
  8280. Vector3 = 2,
  8281. /**
  8282. * Quaternions
  8283. */
  8284. Quaternion = 3,
  8285. /**
  8286. * Color3
  8287. */
  8288. Color3 = 4
  8289. }
  8290. /**
  8291. * Interface used to define custom inspectable properties.
  8292. * This interface is used by the inspector to display custom property grids
  8293. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8294. */
  8295. export interface IInspectable {
  8296. /**
  8297. * Gets the label to display
  8298. */
  8299. label: string;
  8300. /**
  8301. * Gets the name of the property to edit
  8302. */
  8303. propertyName: string;
  8304. /**
  8305. * Gets the type of the editor to use
  8306. */
  8307. type: InspectableType;
  8308. /**
  8309. * Gets the minimum value of the property when using in "slider" mode
  8310. */
  8311. min?: number;
  8312. /**
  8313. * Gets the maximum value of the property when using in "slider" mode
  8314. */
  8315. max?: number;
  8316. /**
  8317. * Gets the setp to use when using in "slider" mode
  8318. */
  8319. step?: number;
  8320. }
  8321. }
  8322. declare module BABYLON {
  8323. /**
  8324. * Class for creating a cube texture
  8325. */
  8326. export class CubeTexture extends BaseTexture {
  8327. private _delayedOnLoad;
  8328. /**
  8329. * The url of the texture
  8330. */
  8331. url: string;
  8332. /**
  8333. * Gets or sets the center of the bounding box associated with the cube texture.
  8334. * It must define where the camera used to render the texture was set
  8335. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8336. */
  8337. boundingBoxPosition: Vector3;
  8338. private _boundingBoxSize;
  8339. /**
  8340. * Gets or sets the size of the bounding box associated with the cube texture
  8341. * When defined, the cubemap will switch to local mode
  8342. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8343. * @example https://www.babylonjs-playground.com/#RNASML
  8344. */
  8345. /**
  8346. * Returns the bounding box size
  8347. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8348. */
  8349. boundingBoxSize: Vector3;
  8350. protected _rotationY: number;
  8351. /**
  8352. * Sets texture matrix rotation angle around Y axis in radians.
  8353. */
  8354. /**
  8355. * Gets texture matrix rotation angle around Y axis radians.
  8356. */
  8357. rotationY: number;
  8358. /**
  8359. * Are mip maps generated for this texture or not.
  8360. */
  8361. readonly noMipmap: boolean;
  8362. private _noMipmap;
  8363. private _files;
  8364. private _extensions;
  8365. private _textureMatrix;
  8366. private _format;
  8367. private _createPolynomials;
  8368. /** @hidden */
  8369. _prefiltered: boolean;
  8370. /**
  8371. * Creates a cube texture from an array of image urls
  8372. * @param files defines an array of image urls
  8373. * @param scene defines the hosting scene
  8374. * @param noMipmap specifies if mip maps are not used
  8375. * @returns a cube texture
  8376. */
  8377. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8378. /**
  8379. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8380. * @param url defines the url of the prefiltered texture
  8381. * @param scene defines the scene the texture is attached to
  8382. * @param forcedExtension defines the extension of the file if different from the url
  8383. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8384. * @return the prefiltered texture
  8385. */
  8386. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8387. /**
  8388. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8389. * as prefiltered data.
  8390. * @param rootUrl defines the url of the texture or the root name of the six images
  8391. * @param scene defines the scene the texture is attached to
  8392. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8393. * @param noMipmap defines if mipmaps should be created or not
  8394. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8395. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8396. * @param onError defines a callback triggered in case of error during load
  8397. * @param format defines the internal format to use for the texture once loaded
  8398. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8399. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8400. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8401. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8402. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8403. * @return the cube texture
  8404. */
  8405. 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);
  8406. /**
  8407. * Get the current class name of the texture useful for serialization or dynamic coding.
  8408. * @returns "CubeTexture"
  8409. */
  8410. getClassName(): string;
  8411. /**
  8412. * Update the url (and optional buffer) of this texture if url was null during construction.
  8413. * @param url the url of the texture
  8414. * @param forcedExtension defines the extension to use
  8415. * @param onLoad callback called when the texture is loaded (defaults to null)
  8416. */
  8417. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8418. /**
  8419. * Delays loading of the cube texture
  8420. * @param forcedExtension defines the extension to use
  8421. */
  8422. delayLoad(forcedExtension?: string): void;
  8423. /**
  8424. * Returns the reflection texture matrix
  8425. * @returns the reflection texture matrix
  8426. */
  8427. getReflectionTextureMatrix(): Matrix;
  8428. /**
  8429. * Sets the reflection texture matrix
  8430. * @param value Reflection texture matrix
  8431. */
  8432. setReflectionTextureMatrix(value: Matrix): void;
  8433. /**
  8434. * Parses text to create a cube texture
  8435. * @param parsedTexture define the serialized text to read from
  8436. * @param scene defines the hosting scene
  8437. * @param rootUrl defines the root url of the cube texture
  8438. * @returns a cube texture
  8439. */
  8440. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8441. /**
  8442. * Makes a clone, or deep copy, of the cube texture
  8443. * @returns a new cube texture
  8444. */
  8445. clone(): CubeTexture;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /** @hidden */
  8450. export var postprocessVertexShader: {
  8451. name: string;
  8452. shader: string;
  8453. };
  8454. }
  8455. declare module BABYLON {
  8456. /**
  8457. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8458. * This is the base of the follow, arc rotate cameras and Free camera
  8459. * @see http://doc.babylonjs.com/features/cameras
  8460. */
  8461. export class TargetCamera extends Camera {
  8462. private static _RigCamTransformMatrix;
  8463. private static _TargetTransformMatrix;
  8464. private static _TargetFocalPoint;
  8465. /**
  8466. * Define the current direction the camera is moving to
  8467. */
  8468. cameraDirection: Vector3;
  8469. /**
  8470. * Define the current rotation the camera is rotating to
  8471. */
  8472. cameraRotation: Vector2;
  8473. /**
  8474. * When set, the up vector of the camera will be updated by the rotation of the camera
  8475. */
  8476. updateUpVectorFromRotation: boolean;
  8477. private _tmpQuaternion;
  8478. /**
  8479. * Define the current rotation of the camera
  8480. */
  8481. rotation: Vector3;
  8482. /**
  8483. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8484. */
  8485. rotationQuaternion: Quaternion;
  8486. /**
  8487. * Define the current speed of the camera
  8488. */
  8489. speed: number;
  8490. /**
  8491. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8492. * around all axis.
  8493. */
  8494. noRotationConstraint: boolean;
  8495. /**
  8496. * Define the current target of the camera as an object or a position.
  8497. */
  8498. lockedTarget: any;
  8499. /** @hidden */
  8500. _currentTarget: Vector3;
  8501. /** @hidden */
  8502. _initialFocalDistance: number;
  8503. /** @hidden */
  8504. _viewMatrix: Matrix;
  8505. /** @hidden */
  8506. _camMatrix: Matrix;
  8507. /** @hidden */
  8508. _cameraTransformMatrix: Matrix;
  8509. /** @hidden */
  8510. _cameraRotationMatrix: Matrix;
  8511. /** @hidden */
  8512. _referencePoint: Vector3;
  8513. /** @hidden */
  8514. _transformedReferencePoint: Vector3;
  8515. protected _globalCurrentTarget: Vector3;
  8516. protected _globalCurrentUpVector: Vector3;
  8517. /** @hidden */
  8518. _reset: () => void;
  8519. private _defaultUp;
  8520. /**
  8521. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. * @param name Defines the name of the camera in the scene
  8525. * @param position Defines the start position of the camera in the scene
  8526. * @param scene Defines the scene the camera belongs to
  8527. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8528. */
  8529. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8530. /**
  8531. * Gets the position in front of the camera at a given distance.
  8532. * @param distance The distance from the camera we want the position to be
  8533. * @returns the position
  8534. */
  8535. getFrontPosition(distance: number): Vector3;
  8536. /** @hidden */
  8537. _getLockedTargetPosition(): Nullable<Vector3>;
  8538. private _storedPosition;
  8539. private _storedRotation;
  8540. private _storedRotationQuaternion;
  8541. /**
  8542. * Store current camera state of the camera (fov, position, rotation, etc..)
  8543. * @returns the camera
  8544. */
  8545. storeState(): Camera;
  8546. /**
  8547. * Restored camera state. You must call storeState() first
  8548. * @returns whether it was successful or not
  8549. * @hidden
  8550. */
  8551. _restoreStateValues(): boolean;
  8552. /** @hidden */
  8553. _initCache(): void;
  8554. /** @hidden */
  8555. _updateCache(ignoreParentClass?: boolean): void;
  8556. /** @hidden */
  8557. _isSynchronizedViewMatrix(): boolean;
  8558. /** @hidden */
  8559. _computeLocalCameraSpeed(): number;
  8560. /**
  8561. * Defines the target the camera should look at.
  8562. * This will automatically adapt alpha beta and radius to fit within the new target.
  8563. * @param target Defines the new target as a Vector or a mesh
  8564. */
  8565. setTarget(target: Vector3): void;
  8566. /**
  8567. * Return the current target position of the camera. This value is expressed in local space.
  8568. * @returns the target position
  8569. */
  8570. getTarget(): Vector3;
  8571. /** @hidden */
  8572. _decideIfNeedsToMove(): boolean;
  8573. /** @hidden */
  8574. _updatePosition(): void;
  8575. /** @hidden */
  8576. _checkInputs(): void;
  8577. protected _updateCameraRotationMatrix(): void;
  8578. /**
  8579. * 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)
  8580. * @returns the current camera
  8581. */
  8582. private _rotateUpVectorWithCameraRotationMatrix;
  8583. private _cachedRotationZ;
  8584. private _cachedQuaternionRotationZ;
  8585. /** @hidden */
  8586. _getViewMatrix(): Matrix;
  8587. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8588. /**
  8589. * @hidden
  8590. */
  8591. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8592. /**
  8593. * @hidden
  8594. */
  8595. _updateRigCameras(): void;
  8596. private _getRigCamPositionAndTarget;
  8597. /**
  8598. * Gets the current object class name.
  8599. * @return the class name
  8600. */
  8601. getClassName(): string;
  8602. }
  8603. }
  8604. declare module BABYLON {
  8605. /**
  8606. * @ignore
  8607. * This is a list of all the different input types that are available in the application.
  8608. * Fo instance: ArcRotateCameraGamepadInput...
  8609. */
  8610. export var CameraInputTypes: {};
  8611. /**
  8612. * This is the contract to implement in order to create a new input class.
  8613. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8614. */
  8615. export interface ICameraInput<TCamera extends Camera> {
  8616. /**
  8617. * Defines the camera the input is attached to.
  8618. */
  8619. camera: Nullable<TCamera>;
  8620. /**
  8621. * Gets the class name of the current intput.
  8622. * @returns the class name
  8623. */
  8624. getClassName(): string;
  8625. /**
  8626. * Get the friendly name associated with the input class.
  8627. * @returns the input friendly name
  8628. */
  8629. getSimpleName(): string;
  8630. /**
  8631. * Attach the input controls to a specific dom element to get the input from.
  8632. * @param element Defines the element the controls should be listened from
  8633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8634. */
  8635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8636. /**
  8637. * Detach the current controls from the specified dom element.
  8638. * @param element Defines the element to stop listening the inputs from
  8639. */
  8640. detachControl(element: Nullable<HTMLElement>): void;
  8641. /**
  8642. * Update the current camera state depending on the inputs that have been used this frame.
  8643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8644. */
  8645. checkInputs?: () => void;
  8646. }
  8647. /**
  8648. * Represents a map of input types to input instance or input index to input instance.
  8649. */
  8650. export interface CameraInputsMap<TCamera extends Camera> {
  8651. /**
  8652. * Accessor to the input by input type.
  8653. */
  8654. [name: string]: ICameraInput<TCamera>;
  8655. /**
  8656. * Accessor to the input by input index.
  8657. */
  8658. [idx: number]: ICameraInput<TCamera>;
  8659. }
  8660. /**
  8661. * This represents the input manager used within a camera.
  8662. * It helps dealing with all the different kind of input attached to a camera.
  8663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8664. */
  8665. export class CameraInputsManager<TCamera extends Camera> {
  8666. /**
  8667. * Defines the list of inputs attahed to the camera.
  8668. */
  8669. attached: CameraInputsMap<TCamera>;
  8670. /**
  8671. * Defines the dom element the camera is collecting inputs from.
  8672. * This is null if the controls have not been attached.
  8673. */
  8674. attachedElement: Nullable<HTMLElement>;
  8675. /**
  8676. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8677. */
  8678. noPreventDefault: boolean;
  8679. /**
  8680. * Defined the camera the input manager belongs to.
  8681. */
  8682. camera: TCamera;
  8683. /**
  8684. * Update the current camera state depending on the inputs that have been used this frame.
  8685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8686. */
  8687. checkInputs: () => void;
  8688. /**
  8689. * Instantiate a new Camera Input Manager.
  8690. * @param camera Defines the camera the input manager blongs to
  8691. */
  8692. constructor(camera: TCamera);
  8693. /**
  8694. * Add an input method to a camera
  8695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8696. * @param input camera input method
  8697. */
  8698. add(input: ICameraInput<TCamera>): void;
  8699. /**
  8700. * Remove a specific input method from a camera
  8701. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8702. * @param inputToRemove camera input method
  8703. */
  8704. remove(inputToRemove: ICameraInput<TCamera>): void;
  8705. /**
  8706. * Remove a specific input type from a camera
  8707. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8708. * @param inputType the type of the input to remove
  8709. */
  8710. removeByType(inputType: string): void;
  8711. private _addCheckInputs;
  8712. /**
  8713. * Attach the input controls to the currently attached dom element to listen the events from.
  8714. * @param input Defines the input to attach
  8715. */
  8716. attachInput(input: ICameraInput<TCamera>): void;
  8717. /**
  8718. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8719. * @param element Defines the dom element to collect the events from
  8720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8721. */
  8722. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8723. /**
  8724. * Detach the current manager inputs controls from a specific dom element.
  8725. * @param element Defines the dom element to collect the events from
  8726. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8727. */
  8728. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8729. /**
  8730. * Rebuild the dynamic inputCheck function from the current list of
  8731. * defined inputs in the manager.
  8732. */
  8733. rebuildInputCheck(): void;
  8734. /**
  8735. * Remove all attached input methods from a camera
  8736. */
  8737. clear(): void;
  8738. /**
  8739. * Serialize the current input manager attached to a camera.
  8740. * This ensures than once parsed,
  8741. * the input associated to the camera will be identical to the current ones
  8742. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8743. */
  8744. serialize(serializedCamera: any): void;
  8745. /**
  8746. * Parses an input manager serialized JSON to restore the previous list of inputs
  8747. * and states associated to a camera.
  8748. * @param parsedCamera Defines the JSON to parse
  8749. */
  8750. parse(parsedCamera: any): void;
  8751. }
  8752. }
  8753. declare module BABYLON {
  8754. /**
  8755. * Gather the list of keyboard event types as constants.
  8756. */
  8757. export class KeyboardEventTypes {
  8758. /**
  8759. * The keydown event is fired when a key becomes active (pressed).
  8760. */
  8761. static readonly KEYDOWN: number;
  8762. /**
  8763. * The keyup event is fired when a key has been released.
  8764. */
  8765. static readonly KEYUP: number;
  8766. }
  8767. /**
  8768. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8769. */
  8770. export class KeyboardInfo {
  8771. /**
  8772. * Defines the type of event (KeyboardEventTypes)
  8773. */
  8774. type: number;
  8775. /**
  8776. * Defines the related dom event
  8777. */
  8778. event: KeyboardEvent;
  8779. /**
  8780. * Instantiates a new keyboard info.
  8781. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8782. * @param type Defines the type of event (KeyboardEventTypes)
  8783. * @param event Defines the related dom event
  8784. */
  8785. constructor(
  8786. /**
  8787. * Defines the type of event (KeyboardEventTypes)
  8788. */
  8789. type: number,
  8790. /**
  8791. * Defines the related dom event
  8792. */
  8793. event: KeyboardEvent);
  8794. }
  8795. /**
  8796. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8797. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8798. */
  8799. export class KeyboardInfoPre extends KeyboardInfo {
  8800. /**
  8801. * Defines the type of event (KeyboardEventTypes)
  8802. */
  8803. type: number;
  8804. /**
  8805. * Defines the related dom event
  8806. */
  8807. event: KeyboardEvent;
  8808. /**
  8809. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8810. */
  8811. skipOnPointerObservable: boolean;
  8812. /**
  8813. * Instantiates a new keyboard pre info.
  8814. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8815. * @param type Defines the type of event (KeyboardEventTypes)
  8816. * @param event Defines the related dom event
  8817. */
  8818. constructor(
  8819. /**
  8820. * Defines the type of event (KeyboardEventTypes)
  8821. */
  8822. type: number,
  8823. /**
  8824. * Defines the related dom event
  8825. */
  8826. event: KeyboardEvent);
  8827. }
  8828. }
  8829. declare module BABYLON {
  8830. /**
  8831. * Manage the keyboard inputs to control the movement of a free camera.
  8832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8833. */
  8834. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8835. /**
  8836. * Defines the camera the input is attached to.
  8837. */
  8838. camera: FreeCamera;
  8839. /**
  8840. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8841. */
  8842. keysUp: number[];
  8843. /**
  8844. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8845. */
  8846. keysDown: number[];
  8847. /**
  8848. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8849. */
  8850. keysLeft: number[];
  8851. /**
  8852. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8853. */
  8854. keysRight: number[];
  8855. private _keys;
  8856. private _onCanvasBlurObserver;
  8857. private _onKeyboardObserver;
  8858. private _engine;
  8859. private _scene;
  8860. /**
  8861. * Attach the input controls to a specific dom element to get the input from.
  8862. * @param element Defines the element the controls should be listened from
  8863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8864. */
  8865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8866. /**
  8867. * Detach the current controls from the specified dom element.
  8868. * @param element Defines the element to stop listening the inputs from
  8869. */
  8870. detachControl(element: Nullable<HTMLElement>): void;
  8871. /**
  8872. * Update the current camera state depending on the inputs that have been used this frame.
  8873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8874. */
  8875. checkInputs(): void;
  8876. /**
  8877. * Gets the class name of the current intput.
  8878. * @returns the class name
  8879. */
  8880. getClassName(): string;
  8881. /** @hidden */
  8882. _onLostFocus(): void;
  8883. /**
  8884. * Get the friendly name associated with the input class.
  8885. * @returns the input friendly name
  8886. */
  8887. getSimpleName(): string;
  8888. }
  8889. }
  8890. declare module BABYLON {
  8891. /**
  8892. * Interface describing all the common properties and methods a shadow light needs to implement.
  8893. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8894. * as well as binding the different shadow properties to the effects.
  8895. */
  8896. export interface IShadowLight extends Light {
  8897. /**
  8898. * The light id in the scene (used in scene.findLighById for instance)
  8899. */
  8900. id: string;
  8901. /**
  8902. * The position the shdow will be casted from.
  8903. */
  8904. position: Vector3;
  8905. /**
  8906. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8907. */
  8908. direction: Vector3;
  8909. /**
  8910. * The transformed position. Position of the light in world space taking parenting in account.
  8911. */
  8912. transformedPosition: Vector3;
  8913. /**
  8914. * The transformed direction. Direction of the light in world space taking parenting in account.
  8915. */
  8916. transformedDirection: Vector3;
  8917. /**
  8918. * The friendly name of the light in the scene.
  8919. */
  8920. name: string;
  8921. /**
  8922. * Defines the shadow projection clipping minimum z value.
  8923. */
  8924. shadowMinZ: number;
  8925. /**
  8926. * Defines the shadow projection clipping maximum z value.
  8927. */
  8928. shadowMaxZ: number;
  8929. /**
  8930. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8931. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8932. */
  8933. computeTransformedInformation(): boolean;
  8934. /**
  8935. * Gets the scene the light belongs to.
  8936. * @returns The scene
  8937. */
  8938. getScene(): Scene;
  8939. /**
  8940. * Callback defining a custom Projection Matrix Builder.
  8941. * This can be used to override the default projection matrix computation.
  8942. */
  8943. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8944. /**
  8945. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8946. * @param matrix The materix to updated with the projection information
  8947. * @param viewMatrix The transform matrix of the light
  8948. * @param renderList The list of mesh to render in the map
  8949. * @returns The current light
  8950. */
  8951. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8952. /**
  8953. * Gets the current depth scale used in ESM.
  8954. * @returns The scale
  8955. */
  8956. getDepthScale(): number;
  8957. /**
  8958. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8959. * @returns true if a cube texture needs to be use
  8960. */
  8961. needCube(): boolean;
  8962. /**
  8963. * Detects if the projection matrix requires to be recomputed this frame.
  8964. * @returns true if it requires to be recomputed otherwise, false.
  8965. */
  8966. needProjectionMatrixCompute(): boolean;
  8967. /**
  8968. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8969. */
  8970. forceProjectionMatrixCompute(): void;
  8971. /**
  8972. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8973. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8974. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8975. */
  8976. getShadowDirection(faceIndex?: number): Vector3;
  8977. /**
  8978. * Gets the minZ used for shadow according to both the scene and the light.
  8979. * @param activeCamera The camera we are returning the min for
  8980. * @returns the depth min z
  8981. */
  8982. getDepthMinZ(activeCamera: Camera): number;
  8983. /**
  8984. * Gets the maxZ used for shadow according to both the scene and the light.
  8985. * @param activeCamera The camera we are returning the max for
  8986. * @returns the depth max z
  8987. */
  8988. getDepthMaxZ(activeCamera: Camera): number;
  8989. }
  8990. /**
  8991. * Base implementation IShadowLight
  8992. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8993. */
  8994. export abstract class ShadowLight extends Light implements IShadowLight {
  8995. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8996. protected _position: Vector3;
  8997. protected _setPosition(value: Vector3): void;
  8998. /**
  8999. * Sets the position the shadow will be casted from. Also use as the light position for both
  9000. * point and spot lights.
  9001. */
  9002. /**
  9003. * Sets the position the shadow will be casted from. Also use as the light position for both
  9004. * point and spot lights.
  9005. */
  9006. position: Vector3;
  9007. protected _direction: Vector3;
  9008. protected _setDirection(value: Vector3): void;
  9009. /**
  9010. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9011. * Also use as the light direction on spot and directional lights.
  9012. */
  9013. /**
  9014. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. direction: Vector3;
  9018. private _shadowMinZ;
  9019. /**
  9020. * Gets the shadow projection clipping minimum z value.
  9021. */
  9022. /**
  9023. * Sets the shadow projection clipping minimum z value.
  9024. */
  9025. shadowMinZ: number;
  9026. private _shadowMaxZ;
  9027. /**
  9028. * Sets the shadow projection clipping maximum z value.
  9029. */
  9030. /**
  9031. * Gets the shadow projection clipping maximum z value.
  9032. */
  9033. shadowMaxZ: number;
  9034. /**
  9035. * Callback defining a custom Projection Matrix Builder.
  9036. * This can be used to override the default projection matrix computation.
  9037. */
  9038. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9039. /**
  9040. * The transformed position. Position of the light in world space taking parenting in account.
  9041. */
  9042. transformedPosition: Vector3;
  9043. /**
  9044. * The transformed direction. Direction of the light in world space taking parenting in account.
  9045. */
  9046. transformedDirection: Vector3;
  9047. private _needProjectionMatrixCompute;
  9048. /**
  9049. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9050. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9051. */
  9052. computeTransformedInformation(): boolean;
  9053. /**
  9054. * Return the depth scale used for the shadow map.
  9055. * @returns the depth scale.
  9056. */
  9057. getDepthScale(): number;
  9058. /**
  9059. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9060. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9061. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9062. */
  9063. getShadowDirection(faceIndex?: number): Vector3;
  9064. /**
  9065. * Returns the ShadowLight absolute position in the World.
  9066. * @returns the position vector in world space
  9067. */
  9068. getAbsolutePosition(): Vector3;
  9069. /**
  9070. * Sets the ShadowLight direction toward the passed target.
  9071. * @param target The point to target in local space
  9072. * @returns the updated ShadowLight direction
  9073. */
  9074. setDirectionToTarget(target: Vector3): Vector3;
  9075. /**
  9076. * Returns the light rotation in euler definition.
  9077. * @returns the x y z rotation in local space.
  9078. */
  9079. getRotation(): Vector3;
  9080. /**
  9081. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9082. * @returns true if a cube texture needs to be use
  9083. */
  9084. needCube(): boolean;
  9085. /**
  9086. * Detects if the projection matrix requires to be recomputed this frame.
  9087. * @returns true if it requires to be recomputed otherwise, false.
  9088. */
  9089. needProjectionMatrixCompute(): boolean;
  9090. /**
  9091. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9092. */
  9093. forceProjectionMatrixCompute(): void;
  9094. /** @hidden */
  9095. _initCache(): void;
  9096. /** @hidden */
  9097. _isSynchronized(): boolean;
  9098. /**
  9099. * Computes the world matrix of the node
  9100. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9101. * @returns the world matrix
  9102. */
  9103. computeWorldMatrix(force?: boolean): Matrix;
  9104. /**
  9105. * Gets the minZ used for shadow according to both the scene and the light.
  9106. * @param activeCamera The camera we are returning the min for
  9107. * @returns the depth min z
  9108. */
  9109. getDepthMinZ(activeCamera: Camera): number;
  9110. /**
  9111. * Gets the maxZ used for shadow according to both the scene and the light.
  9112. * @param activeCamera The camera we are returning the max for
  9113. * @returns the depth max z
  9114. */
  9115. getDepthMaxZ(activeCamera: Camera): number;
  9116. /**
  9117. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9118. * @param matrix The materix to updated with the projection information
  9119. * @param viewMatrix The transform matrix of the light
  9120. * @param renderList The list of mesh to render in the map
  9121. * @returns The current light
  9122. */
  9123. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9124. }
  9125. }
  9126. declare module BABYLON {
  9127. /**
  9128. * "Static Class" containing the most commonly used helper while dealing with material for
  9129. * rendering purpose.
  9130. *
  9131. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9132. *
  9133. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9134. */
  9135. export class MaterialHelper {
  9136. /**
  9137. * Bind the current view position to an effect.
  9138. * @param effect The effect to be bound
  9139. * @param scene The scene the eyes position is used from
  9140. */
  9141. static BindEyePosition(effect: Effect, scene: Scene): void;
  9142. /**
  9143. * Helps preparing the defines values about the UVs in used in the effect.
  9144. * UVs are shared as much as we can accross channels in the shaders.
  9145. * @param texture The texture we are preparing the UVs for
  9146. * @param defines The defines to update
  9147. * @param key The channel key "diffuse", "specular"... used in the shader
  9148. */
  9149. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9150. /**
  9151. * Binds a texture matrix value to its corrsponding uniform
  9152. * @param texture The texture to bind the matrix for
  9153. * @param uniformBuffer The uniform buffer receivin the data
  9154. * @param key The channel key "diffuse", "specular"... used in the shader
  9155. */
  9156. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9157. /**
  9158. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9159. * @param mesh defines the current mesh
  9160. * @param scene defines the current scene
  9161. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9162. * @param pointsCloud defines if point cloud rendering has to be turned on
  9163. * @param fogEnabled defines if fog has to be turned on
  9164. * @param alphaTest defines if alpha testing has to be turned on
  9165. * @param defines defines the current list of defines
  9166. */
  9167. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9168. /**
  9169. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9170. * @param scene defines the current scene
  9171. * @param engine defines the current engine
  9172. * @param defines specifies the list of active defines
  9173. * @param useInstances defines if instances have to be turned on
  9174. * @param useClipPlane defines if clip plane have to be turned on
  9175. */
  9176. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9177. /**
  9178. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9179. * @param mesh The mesh containing the geometry data we will draw
  9180. * @param defines The defines to update
  9181. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9182. * @param useBones Precise whether bones should be used or not (override mesh info)
  9183. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9184. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9185. * @returns false if defines are considered not dirty and have not been checked
  9186. */
  9187. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9188. /**
  9189. * Prepares the defines related to the light information passed in parameter
  9190. * @param scene The scene we are intending to draw
  9191. * @param mesh The mesh the effect is compiling for
  9192. * @param defines The defines to update
  9193. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9194. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9195. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9196. * @returns true if normals will be required for the rest of the effect
  9197. */
  9198. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9199. /**
  9200. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9201. * that won t be acctive due to defines being turned off.
  9202. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9203. * @param samplersList The samplers list
  9204. * @param defines The defines helping in the list generation
  9205. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9206. */
  9207. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9208. /**
  9209. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9210. * @param defines The defines to update while falling back
  9211. * @param fallbacks The authorized effect fallbacks
  9212. * @param maxSimultaneousLights The maximum number of lights allowed
  9213. * @param rank the current rank of the Effect
  9214. * @returns The newly affected rank
  9215. */
  9216. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9217. /**
  9218. * Prepares the list of attributes required for morph targets according to the effect defines.
  9219. * @param attribs The current list of supported attribs
  9220. * @param mesh The mesh to prepare the morph targets attributes for
  9221. * @param defines The current Defines of the effect
  9222. */
  9223. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9224. /**
  9225. * Prepares the list of attributes required for bones according to the effect defines.
  9226. * @param attribs The current list of supported attribs
  9227. * @param mesh The mesh to prepare the bones attributes for
  9228. * @param defines The current Defines of the effect
  9229. * @param fallbacks The current efffect fallback strategy
  9230. */
  9231. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9232. /**
  9233. * Prepares the list of attributes required for instances according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param defines The current Defines of the effect
  9236. */
  9237. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9238. /**
  9239. * Binds the light shadow information to the effect for the given mesh.
  9240. * @param light The light containing the generator
  9241. * @param scene The scene the lights belongs to
  9242. * @param mesh The mesh we are binding the information to render
  9243. * @param lightIndex The light index in the effect used to render the mesh
  9244. * @param effect The effect we are binding the data to
  9245. */
  9246. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9247. /**
  9248. * Binds the light information to the effect.
  9249. * @param light The light containing the generator
  9250. * @param effect The effect we are binding the data to
  9251. * @param lightIndex The light index in the effect used to render
  9252. */
  9253. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9254. /**
  9255. * Binds the lights information from the scene to the effect for the given mesh.
  9256. * @param scene The scene the lights belongs to
  9257. * @param mesh The mesh we are binding the information to render
  9258. * @param effect The effect we are binding the data to
  9259. * @param defines The generated defines for the effect
  9260. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9261. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9262. */
  9263. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9264. private static _tempFogColor;
  9265. /**
  9266. * Binds the fog information from the scene to the effect for the given mesh.
  9267. * @param scene The scene the lights belongs to
  9268. * @param mesh The mesh we are binding the information to render
  9269. * @param effect The effect we are binding the data to
  9270. * @param linearSpace Defines if the fog effect is applied in linear space
  9271. */
  9272. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9273. /**
  9274. * Binds the bones information from the mesh to the effect.
  9275. * @param mesh The mesh we are binding the information to render
  9276. * @param effect The effect we are binding the data to
  9277. */
  9278. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9279. /**
  9280. * Binds the morph targets information from the mesh to the effect.
  9281. * @param abstractMesh The mesh we are binding the information to render
  9282. * @param effect The effect we are binding the data to
  9283. */
  9284. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9285. /**
  9286. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9287. * @param defines The generated defines used in the effect
  9288. * @param effect The effect we are binding the data to
  9289. * @param scene The scene we are willing to render with logarithmic scale for
  9290. */
  9291. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9292. /**
  9293. * Binds the clip plane information from the scene to the effect.
  9294. * @param scene The scene the clip plane information are extracted from
  9295. * @param effect The effect we are binding the data to
  9296. */
  9297. static BindClipPlane(effect: Effect, scene: Scene): void;
  9298. }
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var kernelBlurVaryingDeclaration: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var kernelBlurFragment: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var kernelBlurFragment2: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var kernelBlurPixelShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var kernelBlurVertex: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var kernelBlurVertexShader: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * The Blur Post Process which blurs an image based on a kernel and direction.
  9345. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9346. */
  9347. export class BlurPostProcess extends PostProcess {
  9348. /** The direction in which to blur the image. */
  9349. direction: Vector2;
  9350. private blockCompilation;
  9351. protected _kernel: number;
  9352. protected _idealKernel: number;
  9353. protected _packedFloat: boolean;
  9354. private _staticDefines;
  9355. /**
  9356. * Sets the length in pixels of the blur sample region
  9357. */
  9358. /**
  9359. * Gets the length in pixels of the blur sample region
  9360. */
  9361. kernel: number;
  9362. /**
  9363. * Sets wether or not the blur needs to unpack/repack floats
  9364. */
  9365. /**
  9366. * Gets wether or not the blur is unpacking/repacking floats
  9367. */
  9368. packedFloat: boolean;
  9369. /**
  9370. * Creates a new instance BlurPostProcess
  9371. * @param name The name of the effect.
  9372. * @param direction The direction in which to blur the image.
  9373. * @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.
  9374. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9375. * @param camera The camera to apply the render pass to.
  9376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9377. * @param engine The engine which the post process will be applied. (default: current engine)
  9378. * @param reusable If the post process can be reused on the same frame. (default: false)
  9379. * @param textureType Type of textures used when performing the post process. (default: 0)
  9380. * @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)
  9381. */
  9382. constructor(name: string,
  9383. /** The direction in which to blur the image. */
  9384. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9385. /**
  9386. * Updates the effect with the current post process compile time values and recompiles the shader.
  9387. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9388. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9389. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9390. * @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
  9391. * @param onCompiled Called when the shader has been compiled.
  9392. * @param onError Called if there is an error when compiling a shader.
  9393. */
  9394. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9395. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9396. /**
  9397. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9398. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9399. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9400. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9401. * The gaps between physical kernels are compensated for in the weighting of the samples
  9402. * @param idealKernel Ideal blur kernel.
  9403. * @return Nearest best kernel.
  9404. */
  9405. protected _nearestBestKernel(idealKernel: number): number;
  9406. /**
  9407. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9408. * @param x The point on the Gaussian distribution to sample.
  9409. * @return the value of the Gaussian function at x.
  9410. */
  9411. protected _gaussianWeight(x: number): number;
  9412. /**
  9413. * Generates a string that can be used as a floating point number in GLSL.
  9414. * @param x Value to print.
  9415. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9416. * @return GLSL float string.
  9417. */
  9418. protected _glslFloat(x: number, decimalFigures?: number): string;
  9419. }
  9420. }
  9421. declare module BABYLON {
  9422. /** @hidden */
  9423. export var shadowMapPixelShader: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module BABYLON {
  9429. /** @hidden */
  9430. export var bonesDeclaration: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module BABYLON {
  9436. /** @hidden */
  9437. export var morphTargetsVertexGlobalDeclaration: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module BABYLON {
  9443. /** @hidden */
  9444. export var morphTargetsVertexDeclaration: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module BABYLON {
  9450. /** @hidden */
  9451. export var instancesDeclaration: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module BABYLON {
  9457. /** @hidden */
  9458. export var helperFunctions: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module BABYLON {
  9464. /** @hidden */
  9465. export var morphTargetsVertex: {
  9466. name: string;
  9467. shader: string;
  9468. };
  9469. }
  9470. declare module BABYLON {
  9471. /** @hidden */
  9472. export var instancesVertex: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module BABYLON {
  9478. /** @hidden */
  9479. export var bonesVertex: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var shadowMapVertexShader: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var depthBoxBlurPixelShader: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /**
  9500. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9501. */
  9502. export interface ICustomShaderOptions {
  9503. /**
  9504. * Gets or sets the custom shader name to use
  9505. */
  9506. shaderName: string;
  9507. /**
  9508. * The list of attribute names used in the shader
  9509. */
  9510. attributes?: string[];
  9511. /**
  9512. * The list of unifrom names used in the shader
  9513. */
  9514. uniforms?: string[];
  9515. /**
  9516. * The list of sampler names used in the shader
  9517. */
  9518. samplers?: string[];
  9519. /**
  9520. * The list of defines used in the shader
  9521. */
  9522. defines?: string[];
  9523. }
  9524. /**
  9525. * Interface to implement to create a shadow generator compatible with BJS.
  9526. */
  9527. export interface IShadowGenerator {
  9528. /**
  9529. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9530. * @returns The render target texture if present otherwise, null
  9531. */
  9532. getShadowMap(): Nullable<RenderTargetTexture>;
  9533. /**
  9534. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9535. * @returns The render target texture if the shadow map is present otherwise, null
  9536. */
  9537. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9538. /**
  9539. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9540. * @param subMesh The submesh we want to render in the shadow map
  9541. * @param useInstances Defines wether will draw in the map using instances
  9542. * @returns true if ready otherwise, false
  9543. */
  9544. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9545. /**
  9546. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9547. * @param defines Defines of the material we want to update
  9548. * @param lightIndex Index of the light in the enabled light list of the material
  9549. */
  9550. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9551. /**
  9552. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9553. * defined in the generator but impacting the effect).
  9554. * It implies the unifroms available on the materials are the standard BJS ones.
  9555. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9556. * @param effect The effect we are binfing the information for
  9557. */
  9558. bindShadowLight(lightIndex: string, effect: Effect): void;
  9559. /**
  9560. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9561. * (eq to shadow prjection matrix * light transform matrix)
  9562. * @returns The transform matrix used to create the shadow map
  9563. */
  9564. getTransformMatrix(): Matrix;
  9565. /**
  9566. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9567. * Cube and 2D textures for instance.
  9568. */
  9569. recreateShadowMap(): void;
  9570. /**
  9571. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9572. * @param onCompiled Callback triggered at the and of the effects compilation
  9573. * @param options Sets of optional options forcing the compilation with different modes
  9574. */
  9575. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9576. useInstances: boolean;
  9577. }>): void;
  9578. /**
  9579. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9580. * @param options Sets of optional options forcing the compilation with different modes
  9581. * @returns A promise that resolves when the compilation completes
  9582. */
  9583. forceCompilationAsync(options?: Partial<{
  9584. useInstances: boolean;
  9585. }>): Promise<void>;
  9586. /**
  9587. * Serializes the shadow generator setup to a json object.
  9588. * @returns The serialized JSON object
  9589. */
  9590. serialize(): any;
  9591. /**
  9592. * Disposes the Shadow map and related Textures and effects.
  9593. */
  9594. dispose(): void;
  9595. }
  9596. /**
  9597. * Default implementation IShadowGenerator.
  9598. * This is the main object responsible of generating shadows in the framework.
  9599. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9600. */
  9601. export class ShadowGenerator implements IShadowGenerator {
  9602. /**
  9603. * Shadow generator mode None: no filtering applied.
  9604. */
  9605. static readonly FILTER_NONE: number;
  9606. /**
  9607. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9608. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9609. */
  9610. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9611. /**
  9612. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9613. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9614. */
  9615. static readonly FILTER_POISSONSAMPLING: number;
  9616. /**
  9617. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9618. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9619. */
  9620. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9621. /**
  9622. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9623. * edge artifacts on steep falloff.
  9624. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9625. */
  9626. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9627. /**
  9628. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9629. * edge artifacts on steep falloff.
  9630. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9631. */
  9632. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9633. /**
  9634. * Shadow generator mode PCF: Percentage Closer Filtering
  9635. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9636. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9637. */
  9638. static readonly FILTER_PCF: number;
  9639. /**
  9640. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9641. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9642. * Contact Hardening
  9643. */
  9644. static readonly FILTER_PCSS: number;
  9645. /**
  9646. * Reserved for PCF and PCSS
  9647. * Highest Quality.
  9648. *
  9649. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9650. *
  9651. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9652. */
  9653. static readonly QUALITY_HIGH: number;
  9654. /**
  9655. * Reserved for PCF and PCSS
  9656. * Good tradeoff for quality/perf cross devices
  9657. *
  9658. * Execute PCF on a 3*3 kernel.
  9659. *
  9660. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9661. */
  9662. static readonly QUALITY_MEDIUM: number;
  9663. /**
  9664. * Reserved for PCF and PCSS
  9665. * The lowest quality but the fastest.
  9666. *
  9667. * Execute PCF on a 1*1 kernel.
  9668. *
  9669. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9670. */
  9671. static readonly QUALITY_LOW: number;
  9672. /** Gets or sets the custom shader name to use */
  9673. customShaderOptions: ICustomShaderOptions;
  9674. /**
  9675. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9676. */
  9677. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9678. /**
  9679. * Observable triggered before a mesh is rendered in the shadow map.
  9680. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9681. */
  9682. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9683. private _bias;
  9684. /**
  9685. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9686. */
  9687. /**
  9688. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9689. */
  9690. bias: number;
  9691. private _normalBias;
  9692. /**
  9693. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9694. */
  9695. /**
  9696. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9697. */
  9698. normalBias: number;
  9699. private _blurBoxOffset;
  9700. /**
  9701. * Gets the blur box offset: offset applied during the blur pass.
  9702. * Only useful if useKernelBlur = false
  9703. */
  9704. /**
  9705. * Sets the blur box offset: offset applied during the blur pass.
  9706. * Only useful if useKernelBlur = false
  9707. */
  9708. blurBoxOffset: number;
  9709. private _blurScale;
  9710. /**
  9711. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9712. * 2 means half of the size.
  9713. */
  9714. /**
  9715. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9716. * 2 means half of the size.
  9717. */
  9718. blurScale: number;
  9719. private _blurKernel;
  9720. /**
  9721. * Gets the blur kernel: kernel size of the blur pass.
  9722. * Only useful if useKernelBlur = true
  9723. */
  9724. /**
  9725. * Sets the blur kernel: kernel size of the blur pass.
  9726. * Only useful if useKernelBlur = true
  9727. */
  9728. blurKernel: number;
  9729. private _useKernelBlur;
  9730. /**
  9731. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9732. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9733. */
  9734. /**
  9735. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9736. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9737. */
  9738. useKernelBlur: boolean;
  9739. private _depthScale;
  9740. /**
  9741. * Gets the depth scale used in ESM mode.
  9742. */
  9743. /**
  9744. * Sets the depth scale used in ESM mode.
  9745. * This can override the scale stored on the light.
  9746. */
  9747. depthScale: number;
  9748. private _filter;
  9749. /**
  9750. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9751. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9752. */
  9753. /**
  9754. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9755. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9756. */
  9757. filter: number;
  9758. /**
  9759. * Gets if the current filter is set to Poisson Sampling.
  9760. */
  9761. /**
  9762. * Sets the current filter to Poisson Sampling.
  9763. */
  9764. usePoissonSampling: boolean;
  9765. /**
  9766. * Gets if the current filter is set to ESM.
  9767. */
  9768. /**
  9769. * Sets the current filter is to ESM.
  9770. */
  9771. useExponentialShadowMap: boolean;
  9772. /**
  9773. * Gets if the current filter is set to filtered ESM.
  9774. */
  9775. /**
  9776. * Gets if the current filter is set to filtered ESM.
  9777. */
  9778. useBlurExponentialShadowMap: boolean;
  9779. /**
  9780. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9781. * exponential to prevent steep falloff artifacts).
  9782. */
  9783. /**
  9784. * Sets the current filter to "close ESM" (using the inverse of the
  9785. * exponential to prevent steep falloff artifacts).
  9786. */
  9787. useCloseExponentialShadowMap: boolean;
  9788. /**
  9789. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9790. * exponential to prevent steep falloff artifacts).
  9791. */
  9792. /**
  9793. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9794. * exponential to prevent steep falloff artifacts).
  9795. */
  9796. useBlurCloseExponentialShadowMap: boolean;
  9797. /**
  9798. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9799. */
  9800. /**
  9801. * Sets the current filter to "PCF" (percentage closer filtering).
  9802. */
  9803. usePercentageCloserFiltering: boolean;
  9804. private _filteringQuality;
  9805. /**
  9806. * Gets the PCF or PCSS Quality.
  9807. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9808. */
  9809. /**
  9810. * Sets the PCF or PCSS Quality.
  9811. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9812. */
  9813. filteringQuality: number;
  9814. /**
  9815. * Gets if the current filter is set to "PCSS" (contact hardening).
  9816. */
  9817. /**
  9818. * Sets the current filter to "PCSS" (contact hardening).
  9819. */
  9820. useContactHardeningShadow: boolean;
  9821. private _contactHardeningLightSizeUVRatio;
  9822. /**
  9823. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9824. * Using a ratio helps keeping shape stability independently of the map size.
  9825. *
  9826. * It does not account for the light projection as it was having too much
  9827. * instability during the light setup or during light position changes.
  9828. *
  9829. * Only valid if useContactHardeningShadow is true.
  9830. */
  9831. /**
  9832. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9833. * Using a ratio helps keeping shape stability independently of the map size.
  9834. *
  9835. * It does not account for the light projection as it was having too much
  9836. * instability during the light setup or during light position changes.
  9837. *
  9838. * Only valid if useContactHardeningShadow is true.
  9839. */
  9840. contactHardeningLightSizeUVRatio: number;
  9841. private _darkness;
  9842. /**
  9843. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9844. * 0 means strongest and 1 would means no shadow.
  9845. * @returns the darkness.
  9846. */
  9847. getDarkness(): number;
  9848. /**
  9849. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9850. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9851. * @returns the shadow generator allowing fluent coding.
  9852. */
  9853. setDarkness(darkness: number): ShadowGenerator;
  9854. private _transparencyShadow;
  9855. /**
  9856. * Sets the ability to have transparent shadow (boolean).
  9857. * @param transparent True if transparent else False
  9858. * @returns the shadow generator allowing fluent coding
  9859. */
  9860. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9861. private _shadowMap;
  9862. private _shadowMap2;
  9863. /**
  9864. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9865. * @returns The render target texture if present otherwise, null
  9866. */
  9867. getShadowMap(): Nullable<RenderTargetTexture>;
  9868. /**
  9869. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9870. * @returns The render target texture if the shadow map is present otherwise, null
  9871. */
  9872. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9873. /**
  9874. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9875. * @param mesh Mesh to add
  9876. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9877. * @returns the Shadow Generator itself
  9878. */
  9879. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9880. /**
  9881. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9882. * @param mesh Mesh to remove
  9883. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9884. * @returns the Shadow Generator itself
  9885. */
  9886. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9887. /**
  9888. * Controls the extent to which the shadows fade out at the edge of the frustum
  9889. * Used only by directionals and spots
  9890. */
  9891. frustumEdgeFalloff: number;
  9892. private _light;
  9893. /**
  9894. * Returns the associated light object.
  9895. * @returns the light generating the shadow
  9896. */
  9897. getLight(): IShadowLight;
  9898. /**
  9899. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9900. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9901. * It might on the other hand introduce peter panning.
  9902. */
  9903. forceBackFacesOnly: boolean;
  9904. private _scene;
  9905. private _lightDirection;
  9906. private _effect;
  9907. private _viewMatrix;
  9908. private _projectionMatrix;
  9909. private _transformMatrix;
  9910. private _cachedPosition;
  9911. private _cachedDirection;
  9912. private _cachedDefines;
  9913. private _currentRenderID;
  9914. private _boxBlurPostprocess;
  9915. private _kernelBlurXPostprocess;
  9916. private _kernelBlurYPostprocess;
  9917. private _blurPostProcesses;
  9918. private _mapSize;
  9919. private _currentFaceIndex;
  9920. private _currentFaceIndexCache;
  9921. private _textureType;
  9922. private _defaultTextureMatrix;
  9923. /** @hidden */
  9924. static _SceneComponentInitialization: (scene: Scene) => void;
  9925. /**
  9926. * Creates a ShadowGenerator object.
  9927. * A ShadowGenerator is the required tool to use the shadows.
  9928. * Each light casting shadows needs to use its own ShadowGenerator.
  9929. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9930. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9931. * @param light The light object generating the shadows.
  9932. * @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.
  9933. */
  9934. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9935. private _initializeGenerator;
  9936. private _initializeShadowMap;
  9937. private _initializeBlurRTTAndPostProcesses;
  9938. private _renderForShadowMap;
  9939. private _renderSubMeshForShadowMap;
  9940. private _applyFilterValues;
  9941. /**
  9942. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9943. * @param onCompiled Callback triggered at the and of the effects compilation
  9944. * @param options Sets of optional options forcing the compilation with different modes
  9945. */
  9946. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9947. useInstances: boolean;
  9948. }>): void;
  9949. /**
  9950. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9951. * @param options Sets of optional options forcing the compilation with different modes
  9952. * @returns A promise that resolves when the compilation completes
  9953. */
  9954. forceCompilationAsync(options?: Partial<{
  9955. useInstances: boolean;
  9956. }>): Promise<void>;
  9957. /**
  9958. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9959. * @param subMesh The submesh we want to render in the shadow map
  9960. * @param useInstances Defines wether will draw in the map using instances
  9961. * @returns true if ready otherwise, false
  9962. */
  9963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9964. /**
  9965. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9966. * @param defines Defines of the material we want to update
  9967. * @param lightIndex Index of the light in the enabled light list of the material
  9968. */
  9969. prepareDefines(defines: any, lightIndex: number): void;
  9970. /**
  9971. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9972. * defined in the generator but impacting the effect).
  9973. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9974. * @param effect The effect we are binfing the information for
  9975. */
  9976. bindShadowLight(lightIndex: string, effect: Effect): void;
  9977. /**
  9978. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9979. * (eq to shadow prjection matrix * light transform matrix)
  9980. * @returns The transform matrix used to create the shadow map
  9981. */
  9982. getTransformMatrix(): Matrix;
  9983. /**
  9984. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9985. * Cube and 2D textures for instance.
  9986. */
  9987. recreateShadowMap(): void;
  9988. private _disposeBlurPostProcesses;
  9989. private _disposeRTTandPostProcesses;
  9990. /**
  9991. * Disposes the ShadowGenerator.
  9992. * Returns nothing.
  9993. */
  9994. dispose(): void;
  9995. /**
  9996. * Serializes the shadow generator setup to a json object.
  9997. * @returns The serialized JSON object
  9998. */
  9999. serialize(): any;
  10000. /**
  10001. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10002. * @param parsedShadowGenerator The JSON object to parse
  10003. * @param scene The scene to create the shadow map for
  10004. * @returns The parsed shadow generator
  10005. */
  10006. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10007. }
  10008. }
  10009. declare module BABYLON {
  10010. /**
  10011. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10012. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10013. * 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.
  10014. */
  10015. export abstract class Light extends Node {
  10016. /**
  10017. * Falloff Default: light is falling off following the material specification:
  10018. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10019. */
  10020. static readonly FALLOFF_DEFAULT: number;
  10021. /**
  10022. * Falloff Physical: light is falling off following the inverse squared distance law.
  10023. */
  10024. static readonly FALLOFF_PHYSICAL: number;
  10025. /**
  10026. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10027. * to enhance interoperability with other engines.
  10028. */
  10029. static readonly FALLOFF_GLTF: number;
  10030. /**
  10031. * Falloff Standard: light is falling off like in the standard material
  10032. * to enhance interoperability with other materials.
  10033. */
  10034. static readonly FALLOFF_STANDARD: number;
  10035. /**
  10036. * If every light affecting the material is in this lightmapMode,
  10037. * material.lightmapTexture adds or multiplies
  10038. * (depends on material.useLightmapAsShadowmap)
  10039. * after every other light calculations.
  10040. */
  10041. static readonly LIGHTMAP_DEFAULT: number;
  10042. /**
  10043. * material.lightmapTexture as only diffuse lighting from this light
  10044. * adds only specular lighting from this light
  10045. * adds dynamic shadows
  10046. */
  10047. static readonly LIGHTMAP_SPECULAR: number;
  10048. /**
  10049. * material.lightmapTexture as only lighting
  10050. * no light calculation from this light
  10051. * only adds dynamic shadows from this light
  10052. */
  10053. static readonly LIGHTMAP_SHADOWSONLY: number;
  10054. /**
  10055. * Each light type uses the default quantity according to its type:
  10056. * point/spot lights use luminous intensity
  10057. * directional lights use illuminance
  10058. */
  10059. static readonly INTENSITYMODE_AUTOMATIC: number;
  10060. /**
  10061. * lumen (lm)
  10062. */
  10063. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10064. /**
  10065. * candela (lm/sr)
  10066. */
  10067. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10068. /**
  10069. * lux (lm/m^2)
  10070. */
  10071. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10072. /**
  10073. * nit (cd/m^2)
  10074. */
  10075. static readonly INTENSITYMODE_LUMINANCE: number;
  10076. /**
  10077. * Light type const id of the point light.
  10078. */
  10079. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10080. /**
  10081. * Light type const id of the directional light.
  10082. */
  10083. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10084. /**
  10085. * Light type const id of the spot light.
  10086. */
  10087. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10088. /**
  10089. * Light type const id of the hemispheric light.
  10090. */
  10091. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10092. /**
  10093. * Diffuse gives the basic color to an object.
  10094. */
  10095. diffuse: Color3;
  10096. /**
  10097. * Specular produces a highlight color on an object.
  10098. * Note: This is note affecting PBR materials.
  10099. */
  10100. specular: Color3;
  10101. /**
  10102. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10103. * falling off base on range or angle.
  10104. * This can be set to any values in Light.FALLOFF_x.
  10105. *
  10106. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10107. * other types of materials.
  10108. */
  10109. falloffType: number;
  10110. /**
  10111. * Strength of the light.
  10112. * Note: By default it is define in the framework own unit.
  10113. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10114. */
  10115. intensity: number;
  10116. private _range;
  10117. protected _inverseSquaredRange: number;
  10118. /**
  10119. * Defines how far from the source the light is impacting in scene units.
  10120. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10121. */
  10122. /**
  10123. * Defines how far from the source the light is impacting in scene units.
  10124. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10125. */
  10126. range: number;
  10127. /**
  10128. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10129. * of light.
  10130. */
  10131. private _photometricScale;
  10132. private _intensityMode;
  10133. /**
  10134. * Gets the photometric scale used to interpret the intensity.
  10135. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10136. */
  10137. /**
  10138. * Sets the photometric scale used to interpret the intensity.
  10139. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10140. */
  10141. intensityMode: number;
  10142. private _radius;
  10143. /**
  10144. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10145. */
  10146. /**
  10147. * sets the light radius used by PBR Materials to simulate soft area lights.
  10148. */
  10149. radius: number;
  10150. private _renderPriority;
  10151. /**
  10152. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10153. * exceeding the number allowed of the materials.
  10154. */
  10155. renderPriority: number;
  10156. private _shadowEnabled;
  10157. /**
  10158. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10159. * the current shadow generator.
  10160. */
  10161. /**
  10162. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10163. * the current shadow generator.
  10164. */
  10165. shadowEnabled: boolean;
  10166. private _includedOnlyMeshes;
  10167. /**
  10168. * Gets the only meshes impacted by this light.
  10169. */
  10170. /**
  10171. * Sets the only meshes impacted by this light.
  10172. */
  10173. includedOnlyMeshes: AbstractMesh[];
  10174. private _excludedMeshes;
  10175. /**
  10176. * Gets the meshes not impacted by this light.
  10177. */
  10178. /**
  10179. * Sets the meshes not impacted by this light.
  10180. */
  10181. excludedMeshes: AbstractMesh[];
  10182. private _excludeWithLayerMask;
  10183. /**
  10184. * Gets the layer id use to find what meshes are not impacted by the light.
  10185. * Inactive if 0
  10186. */
  10187. /**
  10188. * Sets the layer id use to find what meshes are not impacted by the light.
  10189. * Inactive if 0
  10190. */
  10191. excludeWithLayerMask: number;
  10192. private _includeOnlyWithLayerMask;
  10193. /**
  10194. * Gets the layer id use to find what meshes are impacted by the light.
  10195. * Inactive if 0
  10196. */
  10197. /**
  10198. * Sets the layer id use to find what meshes are impacted by the light.
  10199. * Inactive if 0
  10200. */
  10201. includeOnlyWithLayerMask: number;
  10202. private _lightmapMode;
  10203. /**
  10204. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10205. */
  10206. /**
  10207. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10208. */
  10209. lightmapMode: number;
  10210. /**
  10211. * Shadow generator associted to the light.
  10212. * @hidden Internal use only.
  10213. */
  10214. _shadowGenerator: Nullable<IShadowGenerator>;
  10215. /**
  10216. * @hidden Internal use only.
  10217. */
  10218. _excludedMeshesIds: string[];
  10219. /**
  10220. * @hidden Internal use only.
  10221. */
  10222. _includedOnlyMeshesIds: string[];
  10223. /**
  10224. * The current light unifom buffer.
  10225. * @hidden Internal use only.
  10226. */
  10227. _uniformBuffer: UniformBuffer;
  10228. /**
  10229. * Creates a Light object in the scene.
  10230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10231. * @param name The firendly name of the light
  10232. * @param scene The scene the light belongs too
  10233. */
  10234. constructor(name: string, scene: Scene);
  10235. protected abstract _buildUniformLayout(): void;
  10236. /**
  10237. * Sets the passed Effect "effect" with the Light information.
  10238. * @param effect The effect to update
  10239. * @param lightIndex The index of the light in the effect to update
  10240. * @returns The light
  10241. */
  10242. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10243. /**
  10244. * Returns the string "Light".
  10245. * @returns the class name
  10246. */
  10247. getClassName(): string;
  10248. /** @hidden */
  10249. readonly _isLight: boolean;
  10250. /**
  10251. * Converts the light information to a readable string for debug purpose.
  10252. * @param fullDetails Supports for multiple levels of logging within scene loading
  10253. * @returns the human readable light info
  10254. */
  10255. toString(fullDetails?: boolean): string;
  10256. /** @hidden */
  10257. protected _syncParentEnabledState(): void;
  10258. /**
  10259. * Set the enabled state of this node.
  10260. * @param value - the new enabled state
  10261. */
  10262. setEnabled(value: boolean): void;
  10263. /**
  10264. * Returns the Light associated shadow generator if any.
  10265. * @return the associated shadow generator.
  10266. */
  10267. getShadowGenerator(): Nullable<IShadowGenerator>;
  10268. /**
  10269. * Returns a Vector3, the absolute light position in the World.
  10270. * @returns the world space position of the light
  10271. */
  10272. getAbsolutePosition(): Vector3;
  10273. /**
  10274. * Specifies if the light will affect the passed mesh.
  10275. * @param mesh The mesh to test against the light
  10276. * @return true the mesh is affected otherwise, false.
  10277. */
  10278. canAffectMesh(mesh: AbstractMesh): boolean;
  10279. /**
  10280. * Sort function to order lights for rendering.
  10281. * @param a First Light object to compare to second.
  10282. * @param b Second Light object to compare first.
  10283. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10284. */
  10285. static CompareLightsPriority(a: Light, b: Light): number;
  10286. /**
  10287. * Releases resources associated with this node.
  10288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10290. */
  10291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10292. /**
  10293. * Returns the light type ID (integer).
  10294. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10295. */
  10296. getTypeID(): number;
  10297. /**
  10298. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10299. * @returns the scaled intensity in intensity mode unit
  10300. */
  10301. getScaledIntensity(): number;
  10302. /**
  10303. * Returns a new Light object, named "name", from the current one.
  10304. * @param name The name of the cloned light
  10305. * @returns the new created light
  10306. */
  10307. clone(name: string): Nullable<Light>;
  10308. /**
  10309. * Serializes the current light into a Serialization object.
  10310. * @returns the serialized object.
  10311. */
  10312. serialize(): any;
  10313. /**
  10314. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10315. * This new light is named "name" and added to the passed scene.
  10316. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10317. * @param name The friendly name of the light
  10318. * @param scene The scene the new light will belong to
  10319. * @returns the constructor function
  10320. */
  10321. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10322. /**
  10323. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10324. * @param parsedLight The JSON representation of the light
  10325. * @param scene The scene to create the parsed light in
  10326. * @returns the created light after parsing
  10327. */
  10328. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10329. private _hookArrayForExcluded;
  10330. private _hookArrayForIncludedOnly;
  10331. private _resyncMeshes;
  10332. /**
  10333. * Forces the meshes to update their light related information in their rendering used effects
  10334. * @hidden Internal Use Only
  10335. */
  10336. _markMeshesAsLightDirty(): void;
  10337. /**
  10338. * Recomputes the cached photometric scale if needed.
  10339. */
  10340. private _computePhotometricScale;
  10341. /**
  10342. * Returns the Photometric Scale according to the light type and intensity mode.
  10343. */
  10344. private _getPhotometricScale;
  10345. /**
  10346. * Reorder the light in the scene according to their defined priority.
  10347. * @hidden Internal Use Only
  10348. */
  10349. _reorderLightsInScene(): void;
  10350. /**
  10351. * Prepares the list of defines specific to the light type.
  10352. * @param defines the list of defines
  10353. * @param lightIndex defines the index of the light for the effect
  10354. */
  10355. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10356. }
  10357. }
  10358. declare module BABYLON {
  10359. /**
  10360. * Interface used to define Action
  10361. */
  10362. export interface IAction {
  10363. /**
  10364. * Trigger for the action
  10365. */
  10366. trigger: number;
  10367. /** Options of the trigger */
  10368. triggerOptions: any;
  10369. /**
  10370. * Gets the trigger parameters
  10371. * @returns the trigger parameters
  10372. */
  10373. getTriggerParameter(): any;
  10374. /**
  10375. * Internal only - executes current action event
  10376. * @hidden
  10377. */
  10378. _executeCurrent(evt?: ActionEvent): void;
  10379. /**
  10380. * Serialize placeholder for child classes
  10381. * @param parent of child
  10382. * @returns the serialized object
  10383. */
  10384. serialize(parent: any): any;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. _prepare(): void;
  10390. /**
  10391. * Internal only - manager for action
  10392. * @hidden
  10393. */
  10394. _actionManager: AbstractActionManager;
  10395. }
  10396. /**
  10397. * The action to be carried out following a trigger
  10398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10399. */
  10400. export class Action implements IAction {
  10401. /** the trigger, with or without parameters, for the action */
  10402. triggerOptions: any;
  10403. /**
  10404. * Trigger for the action
  10405. */
  10406. trigger: number;
  10407. /**
  10408. * Internal only - manager for action
  10409. * @hidden
  10410. */
  10411. _actionManager: ActionManager;
  10412. private _nextActiveAction;
  10413. private _child;
  10414. private _condition?;
  10415. private _triggerParameter;
  10416. /**
  10417. * An event triggered prior to action being executed.
  10418. */
  10419. onBeforeExecuteObservable: Observable<Action>;
  10420. /**
  10421. * Creates a new Action
  10422. * @param triggerOptions the trigger, with or without parameters, for the action
  10423. * @param condition an optional determinant of action
  10424. */
  10425. constructor(
  10426. /** the trigger, with or without parameters, for the action */
  10427. triggerOptions: any, condition?: Condition);
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. _prepare(): void;
  10433. /**
  10434. * Gets the trigger parameters
  10435. * @returns the trigger parameters
  10436. */
  10437. getTriggerParameter(): any;
  10438. /**
  10439. * Internal only - executes current action event
  10440. * @hidden
  10441. */
  10442. _executeCurrent(evt?: ActionEvent): void;
  10443. /**
  10444. * Execute placeholder for child classes
  10445. * @param evt optional action event
  10446. */
  10447. execute(evt?: ActionEvent): void;
  10448. /**
  10449. * Skips to next active action
  10450. */
  10451. skipToNextActiveAction(): void;
  10452. /**
  10453. * Adds action to chain of actions, may be a DoNothingAction
  10454. * @param action defines the next action to execute
  10455. * @returns The action passed in
  10456. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10457. */
  10458. then(action: Action): Action;
  10459. /**
  10460. * Internal only
  10461. * @hidden
  10462. */
  10463. _getProperty(propertyPath: string): string;
  10464. /**
  10465. * Internal only
  10466. * @hidden
  10467. */
  10468. _getEffectiveTarget(target: any, propertyPath: string): any;
  10469. /**
  10470. * Serialize placeholder for child classes
  10471. * @param parent of child
  10472. * @returns the serialized object
  10473. */
  10474. serialize(parent: any): any;
  10475. /**
  10476. * Internal only called by serialize
  10477. * @hidden
  10478. */
  10479. protected _serialize(serializedAction: any, parent?: any): any;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. static _SerializeValueAsString: (value: any) => string;
  10485. /**
  10486. * Internal only
  10487. * @hidden
  10488. */
  10489. static _GetTargetProperty: (target: Scene | Node) => {
  10490. name: string;
  10491. targetType: string;
  10492. value: string;
  10493. };
  10494. }
  10495. }
  10496. declare module BABYLON {
  10497. /**
  10498. * A Condition applied to an Action
  10499. */
  10500. export class Condition {
  10501. /**
  10502. * Internal only - manager for action
  10503. * @hidden
  10504. */
  10505. _actionManager: ActionManager;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. _evaluationId: number;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. _currentResult: boolean;
  10516. /**
  10517. * Creates a new Condition
  10518. * @param actionManager the manager of the action the condition is applied to
  10519. */
  10520. constructor(actionManager: ActionManager);
  10521. /**
  10522. * Check if the current condition is valid
  10523. * @returns a boolean
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Internal only
  10528. * @hidden
  10529. */
  10530. _getProperty(propertyPath: string): string;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */
  10535. _getEffectiveTarget(target: any, propertyPath: string): any;
  10536. /**
  10537. * Serialize placeholder for child classes
  10538. * @returns the serialized object
  10539. */
  10540. serialize(): any;
  10541. /**
  10542. * Internal only
  10543. * @hidden
  10544. */
  10545. protected _serialize(serializedCondition: any): any;
  10546. }
  10547. /**
  10548. * Defines specific conditional operators as extensions of Condition
  10549. */
  10550. export class ValueCondition extends Condition {
  10551. /** path to specify the property of the target the conditional operator uses */
  10552. propertyPath: string;
  10553. /** the value compared by the conditional operator against the current value of the property */
  10554. value: any;
  10555. /** the conditional operator, default ValueCondition.IsEqual */
  10556. operator: number;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private static _IsEqual;
  10562. /**
  10563. * Internal only
  10564. * @hidden
  10565. */
  10566. private static _IsDifferent;
  10567. /**
  10568. * Internal only
  10569. * @hidden
  10570. */
  10571. private static _IsGreater;
  10572. /**
  10573. * Internal only
  10574. * @hidden
  10575. */
  10576. private static _IsLesser;
  10577. /**
  10578. * returns the number for IsEqual
  10579. */
  10580. static readonly IsEqual: number;
  10581. /**
  10582. * Returns the number for IsDifferent
  10583. */
  10584. static readonly IsDifferent: number;
  10585. /**
  10586. * Returns the number for IsGreater
  10587. */
  10588. static readonly IsGreater: number;
  10589. /**
  10590. * Returns the number for IsLesser
  10591. */
  10592. static readonly IsLesser: number;
  10593. /**
  10594. * Internal only The action manager for the condition
  10595. * @hidden
  10596. */
  10597. _actionManager: ActionManager;
  10598. /**
  10599. * Internal only
  10600. * @hidden
  10601. */
  10602. private _target;
  10603. /**
  10604. * Internal only
  10605. * @hidden
  10606. */
  10607. private _effectiveTarget;
  10608. /**
  10609. * Internal only
  10610. * @hidden
  10611. */
  10612. private _property;
  10613. /**
  10614. * Creates a new ValueCondition
  10615. * @param actionManager manager for the action the condition applies to
  10616. * @param target for the action
  10617. * @param propertyPath path to specify the property of the target the conditional operator uses
  10618. * @param value the value compared by the conditional operator against the current value of the property
  10619. * @param operator the conditional operator, default ValueCondition.IsEqual
  10620. */
  10621. constructor(actionManager: ActionManager, target: any,
  10622. /** path to specify the property of the target the conditional operator uses */
  10623. propertyPath: string,
  10624. /** the value compared by the conditional operator against the current value of the property */
  10625. value: any,
  10626. /** the conditional operator, default ValueCondition.IsEqual */
  10627. operator?: number);
  10628. /**
  10629. * Compares the given value with the property value for the specified conditional operator
  10630. * @returns the result of the comparison
  10631. */
  10632. isValid(): boolean;
  10633. /**
  10634. * Serialize the ValueCondition into a JSON compatible object
  10635. * @returns serialization object
  10636. */
  10637. serialize(): any;
  10638. /**
  10639. * Gets the name of the conditional operator for the ValueCondition
  10640. * @param operator the conditional operator
  10641. * @returns the name
  10642. */
  10643. static GetOperatorName(operator: number): string;
  10644. }
  10645. /**
  10646. * Defines a predicate condition as an extension of Condition
  10647. */
  10648. export class PredicateCondition extends Condition {
  10649. /** defines the predicate function used to validate the condition */
  10650. predicate: () => boolean;
  10651. /**
  10652. * Internal only - manager for action
  10653. * @hidden
  10654. */
  10655. _actionManager: ActionManager;
  10656. /**
  10657. * Creates a new PredicateCondition
  10658. * @param actionManager manager for the action the condition applies to
  10659. * @param predicate defines the predicate function used to validate the condition
  10660. */
  10661. constructor(actionManager: ActionManager,
  10662. /** defines the predicate function used to validate the condition */
  10663. predicate: () => boolean);
  10664. /**
  10665. * @returns the validity of the predicate condition
  10666. */
  10667. isValid(): boolean;
  10668. }
  10669. /**
  10670. * Defines a state condition as an extension of Condition
  10671. */
  10672. export class StateCondition extends Condition {
  10673. /** Value to compare with target state */
  10674. value: string;
  10675. /**
  10676. * Internal only - manager for action
  10677. * @hidden
  10678. */
  10679. _actionManager: ActionManager;
  10680. /**
  10681. * Internal only
  10682. * @hidden
  10683. */
  10684. private _target;
  10685. /**
  10686. * Creates a new StateCondition
  10687. * @param actionManager manager for the action the condition applies to
  10688. * @param target of the condition
  10689. * @param value to compare with target state
  10690. */
  10691. constructor(actionManager: ActionManager, target: any,
  10692. /** Value to compare with target state */
  10693. value: string);
  10694. /**
  10695. * Gets a boolean indicating if the current condition is met
  10696. * @returns the validity of the state
  10697. */
  10698. isValid(): boolean;
  10699. /**
  10700. * Serialize the StateCondition into a JSON compatible object
  10701. * @returns serialization object
  10702. */
  10703. serialize(): any;
  10704. }
  10705. }
  10706. declare module BABYLON {
  10707. /**
  10708. * This defines an action responsible to toggle a boolean once triggered.
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10710. */
  10711. export class SwitchBooleanAction extends Action {
  10712. /**
  10713. * The path to the boolean property in the target object
  10714. */
  10715. propertyPath: string;
  10716. private _target;
  10717. private _effectiveTarget;
  10718. private _property;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the boolean
  10723. * @param propertyPath defines the path to the boolean property in the target object
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10727. /** @hidden */
  10728. _prepare(): void;
  10729. /**
  10730. * Execute the action toggle the boolean value.
  10731. */
  10732. execute(): void;
  10733. /**
  10734. * Serializes the actions and its related information.
  10735. * @param parent defines the object to serialize in
  10736. * @returns the serialized object
  10737. */
  10738. serialize(parent: any): any;
  10739. }
  10740. /**
  10741. * This defines an action responsible to set a the state field of the target
  10742. * to a desired value once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class SetStateAction extends Action {
  10746. /**
  10747. * The value to store in the state field.
  10748. */
  10749. value: string;
  10750. private _target;
  10751. /**
  10752. * Instantiate the action
  10753. * @param triggerOptions defines the trigger options
  10754. * @param target defines the object containing the state property
  10755. * @param value defines the value to store in the state field
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10759. /**
  10760. * Execute the action and store the value on the target state property.
  10761. */
  10762. execute(): void;
  10763. /**
  10764. * Serializes the actions and its related information.
  10765. * @param parent defines the object to serialize in
  10766. * @returns the serialized object
  10767. */
  10768. serialize(parent: any): any;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set a property of the target
  10772. * to a desired value once triggered.
  10773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10774. */
  10775. export class SetValueAction extends Action {
  10776. /**
  10777. * The path of the property to set in the target.
  10778. */
  10779. propertyPath: string;
  10780. /**
  10781. * The value to set in the property
  10782. */
  10783. value: any;
  10784. private _target;
  10785. private _effectiveTarget;
  10786. private _property;
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param target defines the object containing the property
  10791. * @param propertyPath defines the path of the property to set in the target
  10792. * @param value defines the value to set in the property
  10793. * @param condition defines the trigger related conditions
  10794. */
  10795. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10796. /** @hidden */
  10797. _prepare(): void;
  10798. /**
  10799. * Execute the action and set the targetted property to the desired value.
  10800. */
  10801. execute(): void;
  10802. /**
  10803. * Serializes the actions and its related information.
  10804. * @param parent defines the object to serialize in
  10805. * @returns the serialized object
  10806. */
  10807. serialize(parent: any): any;
  10808. }
  10809. /**
  10810. * This defines an action responsible to increment the target value
  10811. * to a desired value once triggered.
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10813. */
  10814. export class IncrementValueAction extends Action {
  10815. /**
  10816. * The path of the property to increment in the target.
  10817. */
  10818. propertyPath: string;
  10819. /**
  10820. * The value we should increment the property by.
  10821. */
  10822. value: any;
  10823. private _target;
  10824. private _effectiveTarget;
  10825. private _property;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the object containing the property
  10830. * @param propertyPath defines the path of the property to increment in the target
  10831. * @param value defines the value value we should increment the property by
  10832. * @param condition defines the trigger related conditions
  10833. */
  10834. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10835. /** @hidden */
  10836. _prepare(): void;
  10837. /**
  10838. * Execute the action and increment the target of the value amount.
  10839. */
  10840. execute(): void;
  10841. /**
  10842. * Serializes the actions and its related information.
  10843. * @param parent defines the object to serialize in
  10844. * @returns the serialized object
  10845. */
  10846. serialize(parent: any): any;
  10847. }
  10848. /**
  10849. * This defines an action responsible to start an animation once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class PlayAnimationAction extends Action {
  10853. /**
  10854. * Where the animation should start (animation frame)
  10855. */
  10856. from: number;
  10857. /**
  10858. * Where the animation should stop (animation frame)
  10859. */
  10860. to: number;
  10861. /**
  10862. * Define if the animation should loop or stop after the first play.
  10863. */
  10864. loop?: boolean;
  10865. private _target;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the target animation or animation name
  10870. * @param from defines from where the animation should start (animation frame)
  10871. * @param end defines where the animation should stop (animation frame)
  10872. * @param loop defines if the animation should loop or stop after the first play
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action and play the animation.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to stop an animation once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class StopAnimationAction extends Action {
  10894. private _target;
  10895. /**
  10896. * Instantiate the action
  10897. * @param triggerOptions defines the trigger options
  10898. * @param target defines the target animation or animation name
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, target: any, condition?: Condition);
  10902. /** @hidden */
  10903. _prepare(): void;
  10904. /**
  10905. * Execute the action and stop the animation.
  10906. */
  10907. execute(): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible that does nothing once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class DoNothingAction extends Action {
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param condition defines the trigger related conditions
  10924. */
  10925. constructor(triggerOptions?: any, condition?: Condition);
  10926. /**
  10927. * Execute the action and do nothing.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible to trigger several actions once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class CombineAction extends Action {
  10942. /**
  10943. * The list of aggregated animations to run.
  10944. */
  10945. children: Action[];
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param children defines the list of aggregated animations to run
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10953. /** @hidden */
  10954. _prepare(): void;
  10955. /**
  10956. * Execute the action and executes all the aggregated actions.
  10957. */
  10958. execute(evt: ActionEvent): void;
  10959. /**
  10960. * Serializes the actions and its related information.
  10961. * @param parent defines the object to serialize in
  10962. * @returns the serialized object
  10963. */
  10964. serialize(parent: any): any;
  10965. }
  10966. /**
  10967. * This defines an action responsible to run code (external event) once triggered.
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10969. */
  10970. export class ExecuteCodeAction extends Action {
  10971. /**
  10972. * The callback function to run.
  10973. */
  10974. func: (evt: ActionEvent) => void;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param func defines the callback function to run
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10982. /**
  10983. * Execute the action and run the attached code.
  10984. */
  10985. execute(evt: ActionEvent): void;
  10986. }
  10987. /**
  10988. * This defines an action responsible to set the parent property of the target once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class SetParentAction extends Action {
  10992. private _parent;
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target containing the parent property
  10998. * @param parent defines from where the animation should start (animation frame)
  10999. * @param condition defines the trigger related conditions
  11000. */
  11001. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11002. /** @hidden */
  11003. _prepare(): void;
  11004. /**
  11005. * Execute the action and set the parent property.
  11006. */
  11007. execute(): void;
  11008. /**
  11009. * Serializes the actions and its related information.
  11010. * @param parent defines the object to serialize in
  11011. * @returns the serialized object
  11012. */
  11013. serialize(parent: any): any;
  11014. }
  11015. }
  11016. declare module BABYLON {
  11017. /**
  11018. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11019. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11021. */
  11022. export class ActionManager extends AbstractActionManager {
  11023. /**
  11024. * Nothing
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly NothingTrigger: number;
  11028. /**
  11029. * On pick
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnPickTrigger: number;
  11033. /**
  11034. * On left pick
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnLeftPickTrigger: number;
  11038. /**
  11039. * On right pick
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnRightPickTrigger: number;
  11043. /**
  11044. * On center pick
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnCenterPickTrigger: number;
  11048. /**
  11049. * On pick down
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnPickDownTrigger: number;
  11053. /**
  11054. * On double pick
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnDoublePickTrigger: number;
  11058. /**
  11059. * On pick up
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnPickUpTrigger: number;
  11063. /**
  11064. * On pick out.
  11065. * This trigger will only be raised if you also declared a OnPickDown
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnPickOutTrigger: number;
  11069. /**
  11070. * On long press
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnLongPressTrigger: number;
  11074. /**
  11075. * On pointer over
  11076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11077. */
  11078. static readonly OnPointerOverTrigger: number;
  11079. /**
  11080. * On pointer out
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11082. */
  11083. static readonly OnPointerOutTrigger: number;
  11084. /**
  11085. * On every frame
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11087. */
  11088. static readonly OnEveryFrameTrigger: number;
  11089. /**
  11090. * On intersection enter
  11091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11092. */
  11093. static readonly OnIntersectionEnterTrigger: number;
  11094. /**
  11095. * On intersection exit
  11096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11097. */
  11098. static readonly OnIntersectionExitTrigger: number;
  11099. /**
  11100. * On key down
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11102. */
  11103. static readonly OnKeyDownTrigger: number;
  11104. /**
  11105. * On key up
  11106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11107. */
  11108. static readonly OnKeyUpTrigger: number;
  11109. private _scene;
  11110. /**
  11111. * Creates a new action manager
  11112. * @param scene defines the hosting scene
  11113. */
  11114. constructor(scene: Scene);
  11115. /**
  11116. * Releases all associated resources
  11117. */
  11118. dispose(): void;
  11119. /**
  11120. * Gets hosting scene
  11121. * @returns the hosting scene
  11122. */
  11123. getScene(): Scene;
  11124. /**
  11125. * Does this action manager handles actions of any of the given triggers
  11126. * @param triggers defines the triggers to be tested
  11127. * @return a boolean indicating whether one (or more) of the triggers is handled
  11128. */
  11129. hasSpecificTriggers(triggers: number[]): boolean;
  11130. /**
  11131. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11132. * speed.
  11133. * @param triggerA defines the trigger to be tested
  11134. * @param triggerB defines the trigger to be tested
  11135. * @return a boolean indicating whether one (or more) of the triggers is handled
  11136. */
  11137. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11138. /**
  11139. * Does this action manager handles actions of a given trigger
  11140. * @param trigger defines the trigger to be tested
  11141. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11142. * @return whether the trigger is handled
  11143. */
  11144. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11145. /**
  11146. * Does this action manager has pointer triggers
  11147. */
  11148. readonly hasPointerTriggers: boolean;
  11149. /**
  11150. * Does this action manager has pick triggers
  11151. */
  11152. readonly hasPickTriggers: boolean;
  11153. /**
  11154. * Registers an action to this action manager
  11155. * @param action defines the action to be registered
  11156. * @return the action amended (prepared) after registration
  11157. */
  11158. registerAction(action: IAction): Nullable<IAction>;
  11159. /**
  11160. * Unregisters an action to this action manager
  11161. * @param action defines the action to be unregistered
  11162. * @return a boolean indicating whether the action has been unregistered
  11163. */
  11164. unregisterAction(action: IAction): Boolean;
  11165. /**
  11166. * Process a specific trigger
  11167. * @param trigger defines the trigger to process
  11168. * @param evt defines the event details to be processed
  11169. */
  11170. processTrigger(trigger: number, evt?: IActionEvent): void;
  11171. /** @hidden */
  11172. _getEffectiveTarget(target: any, propertyPath: string): any;
  11173. /** @hidden */
  11174. _getProperty(propertyPath: string): string;
  11175. /**
  11176. * Serialize this manager to a JSON object
  11177. * @param name defines the property name to store this manager
  11178. * @returns a JSON representation of this manager
  11179. */
  11180. serialize(name: string): any;
  11181. /**
  11182. * Creates a new ActionManager from a JSON data
  11183. * @param parsedActions defines the JSON data to read from
  11184. * @param object defines the hosting mesh
  11185. * @param scene defines the hosting scene
  11186. */
  11187. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11188. /**
  11189. * Get a trigger name by index
  11190. * @param trigger defines the trigger index
  11191. * @returns a trigger name
  11192. */
  11193. static GetTriggerName(trigger: number): string;
  11194. }
  11195. }
  11196. declare module BABYLON {
  11197. /**
  11198. * Class representing a ray with position and direction
  11199. */
  11200. export class Ray {
  11201. /** origin point */
  11202. origin: Vector3;
  11203. /** direction */
  11204. direction: Vector3;
  11205. /** length of the ray */
  11206. length: number;
  11207. private static readonly TmpVector3;
  11208. private _tmpRay;
  11209. /**
  11210. * Creates a new ray
  11211. * @param origin origin point
  11212. * @param direction direction
  11213. * @param length length of the ray
  11214. */
  11215. constructor(
  11216. /** origin point */
  11217. origin: Vector3,
  11218. /** direction */
  11219. direction: Vector3,
  11220. /** length of the ray */
  11221. length?: number);
  11222. /**
  11223. * Checks if the ray intersects a box
  11224. * @param minimum bound of the box
  11225. * @param maximum bound of the box
  11226. * @param intersectionTreshold extra extend to be added to the box in all direction
  11227. * @returns if the box was hit
  11228. */
  11229. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11230. /**
  11231. * Checks if the ray intersects a box
  11232. * @param box the bounding box to check
  11233. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11234. * @returns if the box was hit
  11235. */
  11236. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11237. /**
  11238. * If the ray hits a sphere
  11239. * @param sphere the bounding sphere to check
  11240. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11241. * @returns true if it hits the sphere
  11242. */
  11243. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11244. /**
  11245. * If the ray hits a triange
  11246. * @param vertex0 triangle vertex
  11247. * @param vertex1 triangle vertex
  11248. * @param vertex2 triangle vertex
  11249. * @returns intersection information if hit
  11250. */
  11251. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11252. /**
  11253. * Checks if ray intersects a plane
  11254. * @param plane the plane to check
  11255. * @returns the distance away it was hit
  11256. */
  11257. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11258. /**
  11259. * Checks if ray intersects a mesh
  11260. * @param mesh the mesh to check
  11261. * @param fastCheck if only the bounding box should checked
  11262. * @returns picking info of the intersecton
  11263. */
  11264. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11265. /**
  11266. * Checks if ray intersects a mesh
  11267. * @param meshes the meshes to check
  11268. * @param fastCheck if only the bounding box should checked
  11269. * @param results array to store result in
  11270. * @returns Array of picking infos
  11271. */
  11272. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11273. private _comparePickingInfo;
  11274. private static smallnum;
  11275. private static rayl;
  11276. /**
  11277. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11278. * @param sega the first point of the segment to test the intersection against
  11279. * @param segb the second point of the segment to test the intersection against
  11280. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11281. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11282. */
  11283. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11284. /**
  11285. * Update the ray from viewport position
  11286. * @param x position
  11287. * @param y y position
  11288. * @param viewportWidth viewport width
  11289. * @param viewportHeight viewport height
  11290. * @param world world matrix
  11291. * @param view view matrix
  11292. * @param projection projection matrix
  11293. * @returns this ray updated
  11294. */
  11295. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11296. /**
  11297. * Creates a ray with origin and direction of 0,0,0
  11298. * @returns the new ray
  11299. */
  11300. static Zero(): Ray;
  11301. /**
  11302. * Creates a new ray from screen space and viewport
  11303. * @param x position
  11304. * @param y y position
  11305. * @param viewportWidth viewport width
  11306. * @param viewportHeight viewport height
  11307. * @param world world matrix
  11308. * @param view view matrix
  11309. * @param projection projection matrix
  11310. * @returns new ray
  11311. */
  11312. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11313. /**
  11314. * 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
  11315. * transformed to the given world matrix.
  11316. * @param origin The origin point
  11317. * @param end The end point
  11318. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11319. * @returns the new ray
  11320. */
  11321. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * Transforms a ray by a matrix
  11324. * @param ray ray to transform
  11325. * @param matrix matrix to apply
  11326. * @returns the resulting new ray
  11327. */
  11328. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11329. /**
  11330. * Transforms a ray by a matrix
  11331. * @param ray ray to transform
  11332. * @param matrix matrix to apply
  11333. * @param result ray to store result in
  11334. */
  11335. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11336. /**
  11337. * Unproject a ray from screen space to object space
  11338. * @param sourceX defines the screen space x coordinate to use
  11339. * @param sourceY defines the screen space y coordinate to use
  11340. * @param viewportWidth defines the current width of the viewport
  11341. * @param viewportHeight defines the current height of the viewport
  11342. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11343. * @param view defines the view matrix to use
  11344. * @param projection defines the projection matrix to use
  11345. */
  11346. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11347. }
  11348. /**
  11349. * Type used to define predicate used to select faces when a mesh intersection is detected
  11350. */
  11351. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11352. interface Scene {
  11353. /** @hidden */
  11354. _tempPickingRay: Nullable<Ray>;
  11355. /** @hidden */
  11356. _cachedRayForTransform: Ray;
  11357. /** @hidden */
  11358. _pickWithRayInverseMatrix: Matrix;
  11359. /** @hidden */
  11360. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11361. /** @hidden */
  11362. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11363. }
  11364. }
  11365. declare module BABYLON {
  11366. /**
  11367. * Groups all the scene component constants in one place to ease maintenance.
  11368. * @hidden
  11369. */
  11370. export class SceneComponentConstants {
  11371. static readonly NAME_EFFECTLAYER: string;
  11372. static readonly NAME_LAYER: string;
  11373. static readonly NAME_LENSFLARESYSTEM: string;
  11374. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11375. static readonly NAME_PARTICLESYSTEM: string;
  11376. static readonly NAME_GAMEPAD: string;
  11377. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11378. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11379. static readonly NAME_DEPTHRENDERER: string;
  11380. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11381. static readonly NAME_SPRITE: string;
  11382. static readonly NAME_OUTLINERENDERER: string;
  11383. static readonly NAME_PROCEDURALTEXTURE: string;
  11384. static readonly NAME_SHADOWGENERATOR: string;
  11385. static readonly NAME_OCTREE: string;
  11386. static readonly NAME_PHYSICSENGINE: string;
  11387. static readonly NAME_AUDIO: string;
  11388. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11389. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11390. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11391. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11392. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11393. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11394. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11395. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11396. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11397. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11398. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11399. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11400. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11401. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11402. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11403. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11404. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11405. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11406. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11407. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11408. static readonly STEP_AFTERRENDER_AUDIO: number;
  11409. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11410. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11411. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11412. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11413. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11414. static readonly STEP_POINTERMOVE_SPRITE: number;
  11415. static readonly STEP_POINTERDOWN_SPRITE: number;
  11416. static readonly STEP_POINTERUP_SPRITE: number;
  11417. }
  11418. /**
  11419. * This represents a scene component.
  11420. *
  11421. * This is used to decouple the dependency the scene is having on the different workloads like
  11422. * layers, post processes...
  11423. */
  11424. export interface ISceneComponent {
  11425. /**
  11426. * The name of the component. Each component must have a unique name.
  11427. */
  11428. name: string;
  11429. /**
  11430. * The scene the component belongs to.
  11431. */
  11432. scene: Scene;
  11433. /**
  11434. * Register the component to one instance of a scene.
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. }
  11447. /**
  11448. * This represents a SERIALIZABLE scene component.
  11449. *
  11450. * This extends Scene Component to add Serialization methods on top.
  11451. */
  11452. export interface ISceneSerializableComponent extends ISceneComponent {
  11453. /**
  11454. * Adds all the element from the container to the scene
  11455. * @param container the container holding the elements
  11456. */
  11457. addFromContainer(container: AbstractScene): void;
  11458. /**
  11459. * Removes all the elements in the container from the scene
  11460. * @param container contains the elements to remove
  11461. */
  11462. removeFromContainer(container: AbstractScene): void;
  11463. /**
  11464. * Serializes the component data to the specified json object
  11465. * @param serializationObject The object to serialize to
  11466. */
  11467. serialize(serializationObject: any): void;
  11468. }
  11469. /**
  11470. * Strong typing of a Mesh related stage step action
  11471. */
  11472. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11473. /**
  11474. * Strong typing of a Evaluate Sub Mesh related stage step action
  11475. */
  11476. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11477. /**
  11478. * Strong typing of a Active Mesh related stage step action
  11479. */
  11480. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11481. /**
  11482. * Strong typing of a Camera related stage step action
  11483. */
  11484. export type CameraStageAction = (camera: Camera) => void;
  11485. /**
  11486. * Strong typing of a Render Target related stage step action
  11487. */
  11488. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11489. /**
  11490. * Strong typing of a RenderingGroup related stage step action
  11491. */
  11492. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11493. /**
  11494. * Strong typing of a Mesh Render related stage step action
  11495. */
  11496. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11497. /**
  11498. * Strong typing of a simple stage step action
  11499. */
  11500. export type SimpleStageAction = () => void;
  11501. /**
  11502. * Strong typing of a render target action.
  11503. */
  11504. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11505. /**
  11506. * Strong typing of a pointer move action.
  11507. */
  11508. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11509. /**
  11510. * Strong typing of a pointer up/down action.
  11511. */
  11512. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11513. /**
  11514. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11515. * @hidden
  11516. */
  11517. export class Stage<T extends Function> extends Array<{
  11518. index: number;
  11519. component: ISceneComponent;
  11520. action: T;
  11521. }> {
  11522. /**
  11523. * Hide ctor from the rest of the world.
  11524. * @param items The items to add.
  11525. */
  11526. private constructor();
  11527. /**
  11528. * Creates a new Stage.
  11529. * @returns A new instance of a Stage
  11530. */
  11531. static Create<T extends Function>(): Stage<T>;
  11532. /**
  11533. * Registers a step in an ordered way in the targeted stage.
  11534. * @param index Defines the position to register the step in
  11535. * @param component Defines the component attached to the step
  11536. * @param action Defines the action to launch during the step
  11537. */
  11538. registerStep(index: number, component: ISceneComponent, action: T): void;
  11539. /**
  11540. * Clears all the steps from the stage.
  11541. */
  11542. clear(): void;
  11543. }
  11544. }
  11545. declare module BABYLON {
  11546. interface Scene {
  11547. /** @hidden */
  11548. _pointerOverSprite: Nullable<Sprite>;
  11549. /** @hidden */
  11550. _pickedDownSprite: Nullable<Sprite>;
  11551. /** @hidden */
  11552. _tempSpritePickingRay: Nullable<Ray>;
  11553. /**
  11554. * All of the sprite managers added to this scene
  11555. * @see http://doc.babylonjs.com/babylon101/sprites
  11556. */
  11557. spriteManagers: Array<ISpriteManager>;
  11558. /**
  11559. * An event triggered when sprites rendering is about to start
  11560. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11561. */
  11562. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11563. /**
  11564. * An event triggered when sprites rendering is done
  11565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11566. */
  11567. onAfterSpritesRenderingObservable: Observable<Scene>;
  11568. /** @hidden */
  11569. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11570. /** Launch a ray to try to pick a sprite in the scene
  11571. * @param x position on screen
  11572. * @param y position on screen
  11573. * @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
  11574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11576. * @returns a PickingInfo
  11577. */
  11578. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Use the given ray to pick a sprite in the scene
  11580. * @param ray The ray (in world space) to use to pick meshes
  11581. * @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
  11582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11583. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11584. * @returns a PickingInfo
  11585. */
  11586. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11587. /**
  11588. * Force the sprite under the pointer
  11589. * @param sprite defines the sprite to use
  11590. */
  11591. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11592. /**
  11593. * Gets the sprite under the pointer
  11594. * @returns a Sprite or null if no sprite is under the pointer
  11595. */
  11596. getPointerOverSprite(): Nullable<Sprite>;
  11597. }
  11598. /**
  11599. * Defines the sprite scene component responsible to manage sprites
  11600. * in a given scene.
  11601. */
  11602. export class SpriteSceneComponent implements ISceneComponent {
  11603. /**
  11604. * The component name helpfull to identify the component in the list of scene components.
  11605. */
  11606. readonly name: string;
  11607. /**
  11608. * The scene the component belongs to.
  11609. */
  11610. scene: Scene;
  11611. /** @hidden */
  11612. private _spritePredicate;
  11613. /**
  11614. * Creates a new instance of the component for the given scene
  11615. * @param scene Defines the scene to register the component in
  11616. */
  11617. constructor(scene: Scene);
  11618. /**
  11619. * Registers the component in a given scene
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. private _pickSpriteButKeepRay;
  11632. private _pointerMove;
  11633. private _pointerDown;
  11634. private _pointerUp;
  11635. }
  11636. }
  11637. declare module BABYLON {
  11638. /** @hidden */
  11639. export var fogFragmentDeclaration: {
  11640. name: string;
  11641. shader: string;
  11642. };
  11643. }
  11644. declare module BABYLON {
  11645. /** @hidden */
  11646. export var fogFragment: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module BABYLON {
  11652. /** @hidden */
  11653. export var spritesPixelShader: {
  11654. name: string;
  11655. shader: string;
  11656. };
  11657. }
  11658. declare module BABYLON {
  11659. /** @hidden */
  11660. export var fogVertexDeclaration: {
  11661. name: string;
  11662. shader: string;
  11663. };
  11664. }
  11665. declare module BABYLON {
  11666. /** @hidden */
  11667. export var spritesVertexShader: {
  11668. name: string;
  11669. shader: string;
  11670. };
  11671. }
  11672. declare module BABYLON {
  11673. /**
  11674. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11675. */
  11676. export interface ISpriteManager extends IDisposable {
  11677. /**
  11678. * Restricts the camera to viewing objects with the same layerMask.
  11679. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11680. */
  11681. layerMask: number;
  11682. /**
  11683. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11684. */
  11685. isPickable: boolean;
  11686. /**
  11687. * Specifies the rendering group id for this mesh (0 by default)
  11688. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11689. */
  11690. renderingGroupId: number;
  11691. /**
  11692. * Defines the list of sprites managed by the manager.
  11693. */
  11694. sprites: Array<Sprite>;
  11695. /**
  11696. * Tests the intersection of a sprite with a specific ray.
  11697. * @param ray The ray we are sending to test the collision
  11698. * @param camera The camera space we are sending rays in
  11699. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11700. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11701. * @returns picking info or null.
  11702. */
  11703. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11704. /**
  11705. * Renders the list of sprites on screen.
  11706. */
  11707. render(): void;
  11708. }
  11709. /**
  11710. * Class used to manage multiple sprites on the same spritesheet
  11711. * @see http://doc.babylonjs.com/babylon101/sprites
  11712. */
  11713. export class SpriteManager implements ISpriteManager {
  11714. /** defines the manager's name */
  11715. name: string;
  11716. /** Gets the list of sprites */
  11717. sprites: Sprite[];
  11718. /** Gets or sets the rendering group id (0 by default) */
  11719. renderingGroupId: number;
  11720. /** Gets or sets camera layer mask */
  11721. layerMask: number;
  11722. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11723. fogEnabled: boolean;
  11724. /** Gets or sets a boolean indicating if the sprites are pickable */
  11725. isPickable: boolean;
  11726. /** Defines the default width of a cell in the spritesheet */
  11727. cellWidth: number;
  11728. /** Defines the default height of a cell in the spritesheet */
  11729. cellHeight: number;
  11730. /**
  11731. * An event triggered when the manager is disposed.
  11732. */
  11733. onDisposeObservable: Observable<SpriteManager>;
  11734. private _onDisposeObserver;
  11735. /**
  11736. * Callback called when the manager is disposed
  11737. */
  11738. onDispose: () => void;
  11739. private _capacity;
  11740. private _spriteTexture;
  11741. private _epsilon;
  11742. private _scene;
  11743. private _vertexData;
  11744. private _buffer;
  11745. private _vertexBuffers;
  11746. private _indexBuffer;
  11747. private _effectBase;
  11748. private _effectFog;
  11749. /**
  11750. * Gets or sets the spritesheet texture
  11751. */
  11752. texture: Texture;
  11753. /**
  11754. * Creates a new sprite manager
  11755. * @param name defines the manager's name
  11756. * @param imgUrl defines the sprite sheet url
  11757. * @param capacity defines the maximum allowed number of sprites
  11758. * @param cellSize defines the size of a sprite cell
  11759. * @param scene defines the hosting scene
  11760. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11761. * @param samplingMode defines the smapling mode to use with spritesheet
  11762. */
  11763. constructor(
  11764. /** defines the manager's name */
  11765. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11766. private _appendSpriteVertex;
  11767. /**
  11768. * Intersects the sprites with a ray
  11769. * @param ray defines the ray to intersect with
  11770. * @param camera defines the current active camera
  11771. * @param predicate defines a predicate used to select candidate sprites
  11772. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11773. * @returns null if no hit or a PickingInfo
  11774. */
  11775. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11776. /**
  11777. * Render all child sprites
  11778. */
  11779. render(): void;
  11780. /**
  11781. * Release associated resources
  11782. */
  11783. dispose(): void;
  11784. }
  11785. }
  11786. declare module BABYLON {
  11787. /**
  11788. * Class used to represent a sprite
  11789. * @see http://doc.babylonjs.com/babylon101/sprites
  11790. */
  11791. export class Sprite {
  11792. /** defines the name */
  11793. name: string;
  11794. /** Gets or sets the current world position */
  11795. position: Vector3;
  11796. /** Gets or sets the main color */
  11797. color: Color4;
  11798. /** Gets or sets the width */
  11799. width: number;
  11800. /** Gets or sets the height */
  11801. height: number;
  11802. /** Gets or sets rotation angle */
  11803. angle: number;
  11804. /** Gets or sets the cell index in the sprite sheet */
  11805. cellIndex: number;
  11806. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11807. invertU: number;
  11808. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11809. invertV: number;
  11810. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11811. disposeWhenFinishedAnimating: boolean;
  11812. /** Gets the list of attached animations */
  11813. animations: Animation[];
  11814. /** Gets or sets a boolean indicating if the sprite can be picked */
  11815. isPickable: boolean;
  11816. /**
  11817. * Gets or sets the associated action manager
  11818. */
  11819. actionManager: Nullable<ActionManager>;
  11820. private _animationStarted;
  11821. private _loopAnimation;
  11822. private _fromIndex;
  11823. private _toIndex;
  11824. private _delay;
  11825. private _direction;
  11826. private _manager;
  11827. private _time;
  11828. private _onAnimationEnd;
  11829. /**
  11830. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11831. */
  11832. isVisible: boolean;
  11833. /**
  11834. * Gets or sets the sprite size
  11835. */
  11836. size: number;
  11837. /**
  11838. * Creates a new Sprite
  11839. * @param name defines the name
  11840. * @param manager defines the manager
  11841. */
  11842. constructor(
  11843. /** defines the name */
  11844. name: string, manager: ISpriteManager);
  11845. /**
  11846. * Starts an animation
  11847. * @param from defines the initial key
  11848. * @param to defines the end key
  11849. * @param loop defines if the animation must loop
  11850. * @param delay defines the start delay (in ms)
  11851. * @param onAnimationEnd defines a callback to call when animation ends
  11852. */
  11853. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11854. /** Stops current animation (if any) */
  11855. stopAnimation(): void;
  11856. /** @hidden */
  11857. _animate(deltaTime: number): void;
  11858. /** Release associated resources */
  11859. dispose(): void;
  11860. }
  11861. }
  11862. declare module BABYLON {
  11863. /**
  11864. * Information about the result of picking within a scene
  11865. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11866. */
  11867. export class PickingInfo {
  11868. /** @hidden */
  11869. _pickingUnavailable: boolean;
  11870. /**
  11871. * If the pick collided with an object
  11872. */
  11873. hit: boolean;
  11874. /**
  11875. * Distance away where the pick collided
  11876. */
  11877. distance: number;
  11878. /**
  11879. * The location of pick collision
  11880. */
  11881. pickedPoint: Nullable<Vector3>;
  11882. /**
  11883. * The mesh corresponding the the pick collision
  11884. */
  11885. pickedMesh: Nullable<AbstractMesh>;
  11886. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11887. bu: number;
  11888. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11889. bv: number;
  11890. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11891. faceId: number;
  11892. /** Id of the the submesh that was picked */
  11893. subMeshId: number;
  11894. /** If a sprite was picked, this will be the sprite the pick collided with */
  11895. pickedSprite: Nullable<Sprite>;
  11896. /**
  11897. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11898. */
  11899. originMesh: Nullable<AbstractMesh>;
  11900. /**
  11901. * The ray that was used to perform the picking.
  11902. */
  11903. ray: Nullable<Ray>;
  11904. /**
  11905. * Gets the normal correspodning to the face the pick collided with
  11906. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11907. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11908. * @returns The normal correspodning to the face the pick collided with
  11909. */
  11910. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11911. /**
  11912. * Gets the texture coordinates of where the pick occured
  11913. * @returns the vector containing the coordnates of the texture
  11914. */
  11915. getTextureCoordinates(): Nullable<Vector2>;
  11916. }
  11917. }
  11918. declare module BABYLON {
  11919. /**
  11920. * Gather the list of pointer event types as constants.
  11921. */
  11922. export class PointerEventTypes {
  11923. /**
  11924. * 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.
  11925. */
  11926. static readonly POINTERDOWN: number;
  11927. /**
  11928. * The pointerup event is fired when a pointer is no longer active.
  11929. */
  11930. static readonly POINTERUP: number;
  11931. /**
  11932. * The pointermove event is fired when a pointer changes coordinates.
  11933. */
  11934. static readonly POINTERMOVE: number;
  11935. /**
  11936. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11937. */
  11938. static readonly POINTERWHEEL: number;
  11939. /**
  11940. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11941. */
  11942. static readonly POINTERPICK: number;
  11943. /**
  11944. * The pointertap event is fired when a the object has been touched and released without drag.
  11945. */
  11946. static readonly POINTERTAP: number;
  11947. /**
  11948. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11949. */
  11950. static readonly POINTERDOUBLETAP: number;
  11951. }
  11952. /**
  11953. * Base class of pointer info types.
  11954. */
  11955. export class PointerInfoBase {
  11956. /**
  11957. * Defines the type of event (PointerEventTypes)
  11958. */
  11959. type: number;
  11960. /**
  11961. * Defines the related dom event
  11962. */
  11963. event: PointerEvent | MouseWheelEvent;
  11964. /**
  11965. * Instantiates the base class of pointers info.
  11966. * @param type Defines the type of event (PointerEventTypes)
  11967. * @param event Defines the related dom event
  11968. */
  11969. constructor(
  11970. /**
  11971. * Defines the type of event (PointerEventTypes)
  11972. */
  11973. type: number,
  11974. /**
  11975. * Defines the related dom event
  11976. */
  11977. event: PointerEvent | MouseWheelEvent);
  11978. }
  11979. /**
  11980. * This class is used to store pointer related info for the onPrePointerObservable event.
  11981. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11982. */
  11983. export class PointerInfoPre extends PointerInfoBase {
  11984. /**
  11985. * Ray from a pointer if availible (eg. 6dof controller)
  11986. */
  11987. ray: Nullable<Ray>;
  11988. /**
  11989. * Defines the local position of the pointer on the canvas.
  11990. */
  11991. localPosition: Vector2;
  11992. /**
  11993. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11994. */
  11995. skipOnPointerObservable: boolean;
  11996. /**
  11997. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11998. * @param type Defines the type of event (PointerEventTypes)
  11999. * @param event Defines the related dom event
  12000. * @param localX Defines the local x coordinates of the pointer when the event occured
  12001. * @param localY Defines the local y coordinates of the pointer when the event occured
  12002. */
  12003. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12004. }
  12005. /**
  12006. * This type contains all the data related to a pointer event in Babylon.js.
  12007. * 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.
  12008. */
  12009. export class PointerInfo extends PointerInfoBase {
  12010. /**
  12011. * Defines the picking info associated to the info (if any)\
  12012. */
  12013. pickInfo: Nullable<PickingInfo>;
  12014. /**
  12015. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param pickInfo Defines the picking info associated to the info (if any)\
  12019. */
  12020. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12021. /**
  12022. * Defines the picking info associated to the info (if any)\
  12023. */
  12024. pickInfo: Nullable<PickingInfo>);
  12025. }
  12026. /**
  12027. * Data relating to a touch event on the screen.
  12028. */
  12029. export interface PointerTouch {
  12030. /**
  12031. * X coordinate of touch.
  12032. */
  12033. x: number;
  12034. /**
  12035. * Y coordinate of touch.
  12036. */
  12037. y: number;
  12038. /**
  12039. * Id of touch. Unique for each finger.
  12040. */
  12041. pointerId: number;
  12042. /**
  12043. * Event type passed from DOM.
  12044. */
  12045. type: any;
  12046. }
  12047. }
  12048. declare module BABYLON {
  12049. /**
  12050. * Manage the mouse inputs to control the movement of a free camera.
  12051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12052. */
  12053. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12054. /**
  12055. * Define if touch is enabled in the mouse input
  12056. */
  12057. touchEnabled: boolean;
  12058. /**
  12059. * Defines the camera the input is attached to.
  12060. */
  12061. camera: FreeCamera;
  12062. /**
  12063. * Defines the buttons associated with the input to handle camera move.
  12064. */
  12065. buttons: number[];
  12066. /**
  12067. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12068. */
  12069. angularSensibility: number;
  12070. private _pointerInput;
  12071. private _onMouseMove;
  12072. private _observer;
  12073. private previousPosition;
  12074. /**
  12075. * Manage the mouse inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. * @param touchEnabled Defines if touch is enabled or not
  12078. */
  12079. constructor(
  12080. /**
  12081. * Define if touch is enabled in the mouse input
  12082. */
  12083. touchEnabled?: boolean);
  12084. /**
  12085. * Attach the input controls to a specific dom element to get the input from.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Called on JS contextmenu event.
  12092. * Override this method to provide functionality.
  12093. */
  12094. protected onContextMenu(evt: PointerEvent): void;
  12095. /**
  12096. * Detach the current controls from the specified dom element.
  12097. * @param element Defines the element to stop listening the inputs from
  12098. */
  12099. detachControl(element: Nullable<HTMLElement>): void;
  12100. /**
  12101. * Gets the class name of the current intput.
  12102. * @returns the class name
  12103. */
  12104. getClassName(): string;
  12105. /**
  12106. * Get the friendly name associated with the input class.
  12107. * @returns the input friendly name
  12108. */
  12109. getSimpleName(): string;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. /**
  12114. * Manage the touch inputs to control the movement of a free camera.
  12115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12116. */
  12117. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12118. /**
  12119. * Defines the camera the input is attached to.
  12120. */
  12121. camera: FreeCamera;
  12122. /**
  12123. * Defines the touch sensibility for rotation.
  12124. * The higher the faster.
  12125. */
  12126. touchAngularSensibility: number;
  12127. /**
  12128. * Defines the touch sensibility for move.
  12129. * The higher the faster.
  12130. */
  12131. touchMoveSensibility: number;
  12132. private _offsetX;
  12133. private _offsetY;
  12134. private _pointerPressed;
  12135. private _pointerInput;
  12136. private _observer;
  12137. private _onLostFocus;
  12138. /**
  12139. * Attach the input controls to a specific dom element to get the input from.
  12140. * @param element Defines the element the controls should be listened from
  12141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12142. */
  12143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12144. /**
  12145. * Detach the current controls from the specified dom element.
  12146. * @param element Defines the element to stop listening the inputs from
  12147. */
  12148. detachControl(element: Nullable<HTMLElement>): void;
  12149. /**
  12150. * Update the current camera state depending on the inputs that have been used this frame.
  12151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12152. */
  12153. checkInputs(): void;
  12154. /**
  12155. * Gets the class name of the current intput.
  12156. * @returns the class name
  12157. */
  12158. getClassName(): string;
  12159. /**
  12160. * Get the friendly name associated with the input class.
  12161. * @returns the input friendly name
  12162. */
  12163. getSimpleName(): string;
  12164. }
  12165. }
  12166. declare module BABYLON {
  12167. /**
  12168. * Default Inputs manager for the FreeCamera.
  12169. * It groups all the default supported inputs for ease of use.
  12170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12171. */
  12172. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12173. /**
  12174. * Instantiates a new FreeCameraInputsManager.
  12175. * @param camera Defines the camera the inputs belong to
  12176. */
  12177. constructor(camera: FreeCamera);
  12178. /**
  12179. * Add keyboard input support to the input manager.
  12180. * @returns the current input manager
  12181. */
  12182. addKeyboard(): FreeCameraInputsManager;
  12183. /**
  12184. * Add mouse input support to the input manager.
  12185. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12186. * @returns the current input manager
  12187. */
  12188. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12189. /**
  12190. * Add touch input support to the input manager.
  12191. * @returns the current input manager
  12192. */
  12193. addTouch(): FreeCameraInputsManager;
  12194. }
  12195. }
  12196. declare module BABYLON {
  12197. /**
  12198. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12199. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12201. */
  12202. export class FreeCamera extends TargetCamera {
  12203. /**
  12204. * Define the collision ellipsoid of the camera.
  12205. * This is helpful to simulate a camera body like the player body around the camera
  12206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12207. */
  12208. ellipsoid: Vector3;
  12209. /**
  12210. * Define an offset for the position of the ellipsoid around the camera.
  12211. * This can be helpful to determine the center of the body near the gravity center of the body
  12212. * instead of its head.
  12213. */
  12214. ellipsoidOffset: Vector3;
  12215. /**
  12216. * Enable or disable collisions of the camera with the rest of the scene objects.
  12217. */
  12218. checkCollisions: boolean;
  12219. /**
  12220. * Enable or disable gravity on the camera.
  12221. */
  12222. applyGravity: boolean;
  12223. /**
  12224. * Define the input manager associated to the camera.
  12225. */
  12226. inputs: FreeCameraInputsManager;
  12227. /**
  12228. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12229. * Higher values reduce sensitivity.
  12230. */
  12231. /**
  12232. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12233. * Higher values reduce sensitivity.
  12234. */
  12235. angularSensibility: number;
  12236. /**
  12237. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12238. */
  12239. keysUp: number[];
  12240. /**
  12241. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12242. */
  12243. keysDown: number[];
  12244. /**
  12245. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12246. */
  12247. keysLeft: number[];
  12248. /**
  12249. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12250. */
  12251. keysRight: number[];
  12252. /**
  12253. * Event raised when the camera collide with a mesh in the scene.
  12254. */
  12255. onCollide: (collidedMesh: AbstractMesh) => void;
  12256. private _collider;
  12257. private _needMoveForGravity;
  12258. private _oldPosition;
  12259. private _diffPosition;
  12260. private _newPosition;
  12261. /** @hidden */
  12262. _localDirection: Vector3;
  12263. /** @hidden */
  12264. _transformedDirection: Vector3;
  12265. /**
  12266. * Instantiates a Free Camera.
  12267. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12268. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12270. * @param name Define the name of the camera in the scene
  12271. * @param position Define the start position of the camera in the scene
  12272. * @param scene Define the scene the camera belongs to
  12273. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12274. */
  12275. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12276. /**
  12277. * Attached controls to the current camera.
  12278. * @param element Defines the element the controls should be listened from
  12279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12280. */
  12281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12282. /**
  12283. * Detach the current controls from the camera.
  12284. * The camera will stop reacting to inputs.
  12285. * @param element Defines the element to stop listening the inputs from
  12286. */
  12287. detachControl(element: HTMLElement): void;
  12288. private _collisionMask;
  12289. /**
  12290. * Define a collision mask to limit the list of object the camera can collide with
  12291. */
  12292. collisionMask: number;
  12293. /** @hidden */
  12294. _collideWithWorld(displacement: Vector3): void;
  12295. private _onCollisionPositionChange;
  12296. /** @hidden */
  12297. _checkInputs(): void;
  12298. /** @hidden */
  12299. _decideIfNeedsToMove(): boolean;
  12300. /** @hidden */
  12301. _updatePosition(): void;
  12302. /**
  12303. * Destroy the camera and release the current resources hold by it.
  12304. */
  12305. dispose(): void;
  12306. /**
  12307. * Gets the current object class name.
  12308. * @return the class name
  12309. */
  12310. getClassName(): string;
  12311. }
  12312. }
  12313. declare module BABYLON {
  12314. /**
  12315. * Represents a gamepad control stick position
  12316. */
  12317. export class StickValues {
  12318. /**
  12319. * The x component of the control stick
  12320. */
  12321. x: number;
  12322. /**
  12323. * The y component of the control stick
  12324. */
  12325. y: number;
  12326. /**
  12327. * Initializes the gamepad x and y control stick values
  12328. * @param x The x component of the gamepad control stick value
  12329. * @param y The y component of the gamepad control stick value
  12330. */
  12331. constructor(
  12332. /**
  12333. * The x component of the control stick
  12334. */
  12335. x: number,
  12336. /**
  12337. * The y component of the control stick
  12338. */
  12339. y: number);
  12340. }
  12341. /**
  12342. * An interface which manages callbacks for gamepad button changes
  12343. */
  12344. export interface GamepadButtonChanges {
  12345. /**
  12346. * Called when a gamepad has been changed
  12347. */
  12348. changed: boolean;
  12349. /**
  12350. * Called when a gamepad press event has been triggered
  12351. */
  12352. pressChanged: boolean;
  12353. /**
  12354. * Called when a touch event has been triggered
  12355. */
  12356. touchChanged: boolean;
  12357. /**
  12358. * Called when a value has changed
  12359. */
  12360. valueChanged: boolean;
  12361. }
  12362. /**
  12363. * Represents a gamepad
  12364. */
  12365. export class Gamepad {
  12366. /**
  12367. * The id of the gamepad
  12368. */
  12369. id: string;
  12370. /**
  12371. * The index of the gamepad
  12372. */
  12373. index: number;
  12374. /**
  12375. * The browser gamepad
  12376. */
  12377. browserGamepad: any;
  12378. /**
  12379. * Specifies what type of gamepad this represents
  12380. */
  12381. type: number;
  12382. private _leftStick;
  12383. private _rightStick;
  12384. /** @hidden */
  12385. _isConnected: boolean;
  12386. private _leftStickAxisX;
  12387. private _leftStickAxisY;
  12388. private _rightStickAxisX;
  12389. private _rightStickAxisY;
  12390. /**
  12391. * Triggered when the left control stick has been changed
  12392. */
  12393. private _onleftstickchanged;
  12394. /**
  12395. * Triggered when the right control stick has been changed
  12396. */
  12397. private _onrightstickchanged;
  12398. /**
  12399. * Represents a gamepad controller
  12400. */
  12401. static GAMEPAD: number;
  12402. /**
  12403. * Represents a generic controller
  12404. */
  12405. static GENERIC: number;
  12406. /**
  12407. * Represents an XBox controller
  12408. */
  12409. static XBOX: number;
  12410. /**
  12411. * Represents a pose-enabled controller
  12412. */
  12413. static POSE_ENABLED: number;
  12414. /**
  12415. * Specifies whether the left control stick should be Y-inverted
  12416. */
  12417. protected _invertLeftStickY: boolean;
  12418. /**
  12419. * Specifies if the gamepad has been connected
  12420. */
  12421. readonly isConnected: boolean;
  12422. /**
  12423. * Initializes the gamepad
  12424. * @param id The id of the gamepad
  12425. * @param index The index of the gamepad
  12426. * @param browserGamepad The browser gamepad
  12427. * @param leftStickX The x component of the left joystick
  12428. * @param leftStickY The y component of the left joystick
  12429. * @param rightStickX The x component of the right joystick
  12430. * @param rightStickY The y component of the right joystick
  12431. */
  12432. constructor(
  12433. /**
  12434. * The id of the gamepad
  12435. */
  12436. id: string,
  12437. /**
  12438. * The index of the gamepad
  12439. */
  12440. index: number,
  12441. /**
  12442. * The browser gamepad
  12443. */
  12444. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12445. /**
  12446. * Callback triggered when the left joystick has changed
  12447. * @param callback
  12448. */
  12449. onleftstickchanged(callback: (values: StickValues) => void): void;
  12450. /**
  12451. * Callback triggered when the right joystick has changed
  12452. * @param callback
  12453. */
  12454. onrightstickchanged(callback: (values: StickValues) => void): void;
  12455. /**
  12456. * Gets the left joystick
  12457. */
  12458. /**
  12459. * Sets the left joystick values
  12460. */
  12461. leftStick: StickValues;
  12462. /**
  12463. * Gets the right joystick
  12464. */
  12465. /**
  12466. * Sets the right joystick value
  12467. */
  12468. rightStick: StickValues;
  12469. /**
  12470. * Updates the gamepad joystick positions
  12471. */
  12472. update(): void;
  12473. /**
  12474. * Disposes the gamepad
  12475. */
  12476. dispose(): void;
  12477. }
  12478. /**
  12479. * Represents a generic gamepad
  12480. */
  12481. export class GenericPad extends Gamepad {
  12482. private _buttons;
  12483. private _onbuttondown;
  12484. private _onbuttonup;
  12485. /**
  12486. * Observable triggered when a button has been pressed
  12487. */
  12488. onButtonDownObservable: Observable<number>;
  12489. /**
  12490. * Observable triggered when a button has been released
  12491. */
  12492. onButtonUpObservable: Observable<number>;
  12493. /**
  12494. * Callback triggered when a button has been pressed
  12495. * @param callback Called when a button has been pressed
  12496. */
  12497. onbuttondown(callback: (buttonPressed: number) => void): void;
  12498. /**
  12499. * Callback triggered when a button has been released
  12500. * @param callback Called when a button has been released
  12501. */
  12502. onbuttonup(callback: (buttonReleased: number) => void): void;
  12503. /**
  12504. * Initializes the generic gamepad
  12505. * @param id The id of the generic gamepad
  12506. * @param index The index of the generic gamepad
  12507. * @param browserGamepad The browser gamepad
  12508. */
  12509. constructor(id: string, index: number, browserGamepad: any);
  12510. private _setButtonValue;
  12511. /**
  12512. * Updates the generic gamepad
  12513. */
  12514. update(): void;
  12515. /**
  12516. * Disposes the generic gamepad
  12517. */
  12518. dispose(): void;
  12519. }
  12520. }
  12521. declare module BABYLON {
  12522. /**
  12523. * Defines the types of pose enabled controllers that are supported
  12524. */
  12525. export enum PoseEnabledControllerType {
  12526. /**
  12527. * HTC Vive
  12528. */
  12529. VIVE = 0,
  12530. /**
  12531. * Oculus Rift
  12532. */
  12533. OCULUS = 1,
  12534. /**
  12535. * Windows mixed reality
  12536. */
  12537. WINDOWS = 2,
  12538. /**
  12539. * Samsung gear VR
  12540. */
  12541. GEAR_VR = 3,
  12542. /**
  12543. * Google Daydream
  12544. */
  12545. DAYDREAM = 4,
  12546. /**
  12547. * Generic
  12548. */
  12549. GENERIC = 5
  12550. }
  12551. /**
  12552. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12553. */
  12554. export interface MutableGamepadButton {
  12555. /**
  12556. * Value of the button/trigger
  12557. */
  12558. value: number;
  12559. /**
  12560. * If the button/trigger is currently touched
  12561. */
  12562. touched: boolean;
  12563. /**
  12564. * If the button/trigger is currently pressed
  12565. */
  12566. pressed: boolean;
  12567. }
  12568. /**
  12569. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12570. * @hidden
  12571. */
  12572. export interface ExtendedGamepadButton extends GamepadButton {
  12573. /**
  12574. * If the button/trigger is currently pressed
  12575. */
  12576. readonly pressed: boolean;
  12577. /**
  12578. * If the button/trigger is currently touched
  12579. */
  12580. readonly touched: boolean;
  12581. /**
  12582. * Value of the button/trigger
  12583. */
  12584. readonly value: number;
  12585. }
  12586. /** @hidden */
  12587. export interface _GamePadFactory {
  12588. /**
  12589. * Returns wether or not the current gamepad can be created for this type of controller.
  12590. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12591. * @returns true if it can be created, otherwise false
  12592. */
  12593. canCreate(gamepadInfo: any): boolean;
  12594. /**
  12595. * Creates a new instance of the Gamepad.
  12596. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12597. * @returns the new gamepad instance
  12598. */
  12599. create(gamepadInfo: any): Gamepad;
  12600. }
  12601. /**
  12602. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12603. */
  12604. export class PoseEnabledControllerHelper {
  12605. /** @hidden */
  12606. static _ControllerFactories: _GamePadFactory[];
  12607. /** @hidden */
  12608. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12609. /**
  12610. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12611. * @param vrGamepad the gamepad to initialized
  12612. * @returns a vr controller of the type the gamepad identified as
  12613. */
  12614. static InitiateController(vrGamepad: any): Gamepad;
  12615. }
  12616. /**
  12617. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12618. */
  12619. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12620. private _deviceRoomPosition;
  12621. private _deviceRoomRotationQuaternion;
  12622. /**
  12623. * The device position in babylon space
  12624. */
  12625. devicePosition: Vector3;
  12626. /**
  12627. * The device rotation in babylon space
  12628. */
  12629. deviceRotationQuaternion: Quaternion;
  12630. /**
  12631. * The scale factor of the device in babylon space
  12632. */
  12633. deviceScaleFactor: number;
  12634. /**
  12635. * (Likely devicePosition should be used instead) The device position in its room space
  12636. */
  12637. position: Vector3;
  12638. /**
  12639. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12640. */
  12641. rotationQuaternion: Quaternion;
  12642. /**
  12643. * The type of controller (Eg. Windows mixed reality)
  12644. */
  12645. controllerType: PoseEnabledControllerType;
  12646. protected _calculatedPosition: Vector3;
  12647. private _calculatedRotation;
  12648. /**
  12649. * The raw pose from the device
  12650. */
  12651. rawPose: DevicePose;
  12652. private _trackPosition;
  12653. private _maxRotationDistFromHeadset;
  12654. private _draggedRoomRotation;
  12655. /**
  12656. * @hidden
  12657. */
  12658. _disableTrackPosition(fixedPosition: Vector3): void;
  12659. /**
  12660. * Internal, the mesh attached to the controller
  12661. * @hidden
  12662. */
  12663. _mesh: Nullable<AbstractMesh>;
  12664. private _poseControlledCamera;
  12665. private _leftHandSystemQuaternion;
  12666. /**
  12667. * Internal, matrix used to convert room space to babylon space
  12668. * @hidden
  12669. */
  12670. _deviceToWorld: Matrix;
  12671. /**
  12672. * Node to be used when casting a ray from the controller
  12673. * @hidden
  12674. */
  12675. _pointingPoseNode: Nullable<TransformNode>;
  12676. /**
  12677. * Name of the child mesh that can be used to cast a ray from the controller
  12678. */
  12679. static readonly POINTING_POSE: string;
  12680. /**
  12681. * Creates a new PoseEnabledController from a gamepad
  12682. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12683. */
  12684. constructor(browserGamepad: any);
  12685. private _workingMatrix;
  12686. /**
  12687. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12688. */
  12689. update(): void;
  12690. /**
  12691. * Updates only the pose device and mesh without doing any button event checking
  12692. */
  12693. protected _updatePoseAndMesh(): void;
  12694. /**
  12695. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12696. * @param poseData raw pose fromthe device
  12697. */
  12698. updateFromDevice(poseData: DevicePose): void;
  12699. /**
  12700. * @hidden
  12701. */
  12702. _meshAttachedObservable: Observable<AbstractMesh>;
  12703. /**
  12704. * Attaches a mesh to the controller
  12705. * @param mesh the mesh to be attached
  12706. */
  12707. attachToMesh(mesh: AbstractMesh): void;
  12708. /**
  12709. * Attaches the controllers mesh to a camera
  12710. * @param camera the camera the mesh should be attached to
  12711. */
  12712. attachToPoseControlledCamera(camera: TargetCamera): void;
  12713. /**
  12714. * Disposes of the controller
  12715. */
  12716. dispose(): void;
  12717. /**
  12718. * The mesh that is attached to the controller
  12719. */
  12720. readonly mesh: Nullable<AbstractMesh>;
  12721. /**
  12722. * Gets the ray of the controller in the direction the controller is pointing
  12723. * @param length the length the resulting ray should be
  12724. * @returns a ray in the direction the controller is pointing
  12725. */
  12726. getForwardRay(length?: number): Ray;
  12727. }
  12728. }
  12729. declare module BABYLON {
  12730. /**
  12731. * Defines the WebVRController object that represents controllers tracked in 3D space
  12732. */
  12733. export abstract class WebVRController extends PoseEnabledController {
  12734. /**
  12735. * Internal, the default controller model for the controller
  12736. */
  12737. protected _defaultModel: AbstractMesh;
  12738. /**
  12739. * Fired when the trigger state has changed
  12740. */
  12741. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12742. /**
  12743. * Fired when the main button state has changed
  12744. */
  12745. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12746. /**
  12747. * Fired when the secondary button state has changed
  12748. */
  12749. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12750. /**
  12751. * Fired when the pad state has changed
  12752. */
  12753. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12754. /**
  12755. * Fired when controllers stick values have changed
  12756. */
  12757. onPadValuesChangedObservable: Observable<StickValues>;
  12758. /**
  12759. * Array of button availible on the controller
  12760. */
  12761. protected _buttons: Array<MutableGamepadButton>;
  12762. private _onButtonStateChange;
  12763. /**
  12764. * Fired when a controller button's state has changed
  12765. * @param callback the callback containing the button that was modified
  12766. */
  12767. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12768. /**
  12769. * X and Y axis corrisponding to the controllers joystick
  12770. */
  12771. pad: StickValues;
  12772. /**
  12773. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12774. */
  12775. hand: string;
  12776. /**
  12777. * The default controller model for the controller
  12778. */
  12779. readonly defaultModel: AbstractMesh;
  12780. /**
  12781. * Creates a new WebVRController from a gamepad
  12782. * @param vrGamepad the gamepad that the WebVRController should be created from
  12783. */
  12784. constructor(vrGamepad: any);
  12785. /**
  12786. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12787. */
  12788. update(): void;
  12789. /**
  12790. * Function to be called when a button is modified
  12791. */
  12792. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12793. /**
  12794. * Loads a mesh and attaches it to the controller
  12795. * @param scene the scene the mesh should be added to
  12796. * @param meshLoaded callback for when the mesh has been loaded
  12797. */
  12798. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12799. private _setButtonValue;
  12800. private _changes;
  12801. private _checkChanges;
  12802. /**
  12803. * Disposes of th webVRCOntroller
  12804. */
  12805. dispose(): void;
  12806. }
  12807. }
  12808. declare module BABYLON {
  12809. /**
  12810. * The HemisphericLight simulates the ambient environment light,
  12811. * so the passed direction is the light reflection direction, not the incoming direction.
  12812. */
  12813. export class HemisphericLight extends Light {
  12814. /**
  12815. * The groundColor is the light in the opposite direction to the one specified during creation.
  12816. * 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.
  12817. */
  12818. groundColor: Color3;
  12819. /**
  12820. * The light reflection direction, not the incoming direction.
  12821. */
  12822. direction: Vector3;
  12823. /**
  12824. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12825. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12826. * The HemisphericLight can't cast shadows.
  12827. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12828. * @param name The friendly name of the light
  12829. * @param direction The direction of the light reflection
  12830. * @param scene The scene the light belongs to
  12831. */
  12832. constructor(name: string, direction: Vector3, scene: Scene);
  12833. protected _buildUniformLayout(): void;
  12834. /**
  12835. * Returns the string "HemisphericLight".
  12836. * @return The class name
  12837. */
  12838. getClassName(): string;
  12839. /**
  12840. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12841. * Returns the updated direction.
  12842. * @param target The target the direction should point to
  12843. * @return The computed direction
  12844. */
  12845. setDirectionToTarget(target: Vector3): Vector3;
  12846. /**
  12847. * Returns the shadow generator associated to the light.
  12848. * @returns Always null for hemispheric lights because it does not support shadows.
  12849. */
  12850. getShadowGenerator(): Nullable<IShadowGenerator>;
  12851. /**
  12852. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12853. * @param effect The effect to update
  12854. * @param lightIndex The index of the light in the effect to update
  12855. * @returns The hemispheric light
  12856. */
  12857. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12858. /**
  12859. * Computes the world matrix of the node
  12860. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12861. * @param useWasUpdatedFlag defines a reserved property
  12862. * @returns the world matrix
  12863. */
  12864. computeWorldMatrix(): Matrix;
  12865. /**
  12866. * Returns the integer 3.
  12867. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12868. */
  12869. getTypeID(): number;
  12870. /**
  12871. * Prepares the list of defines specific to the light type.
  12872. * @param defines the list of defines
  12873. * @param lightIndex defines the index of the light for the effect
  12874. */
  12875. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12876. }
  12877. }
  12878. declare module BABYLON {
  12879. /**
  12880. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12881. * IMPORTANT!! The data is right-hand data.
  12882. * @export
  12883. * @interface DevicePose
  12884. */
  12885. export interface DevicePose {
  12886. /**
  12887. * The position of the device, values in array are [x,y,z].
  12888. */
  12889. readonly position: Nullable<Float32Array>;
  12890. /**
  12891. * The linearVelocity of the device, values in array are [x,y,z].
  12892. */
  12893. readonly linearVelocity: Nullable<Float32Array>;
  12894. /**
  12895. * The linearAcceleration of the device, values in array are [x,y,z].
  12896. */
  12897. readonly linearAcceleration: Nullable<Float32Array>;
  12898. /**
  12899. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12900. */
  12901. readonly orientation: Nullable<Float32Array>;
  12902. /**
  12903. * The angularVelocity of the device, values in array are [x,y,z].
  12904. */
  12905. readonly angularVelocity: Nullable<Float32Array>;
  12906. /**
  12907. * The angularAcceleration of the device, values in array are [x,y,z].
  12908. */
  12909. readonly angularAcceleration: Nullable<Float32Array>;
  12910. }
  12911. /**
  12912. * Interface representing a pose controlled object in Babylon.
  12913. * A pose controlled object has both regular pose values as well as pose values
  12914. * from an external device such as a VR head mounted display
  12915. */
  12916. export interface PoseControlled {
  12917. /**
  12918. * The position of the object in babylon space.
  12919. */
  12920. position: Vector3;
  12921. /**
  12922. * The rotation quaternion of the object in babylon space.
  12923. */
  12924. rotationQuaternion: Quaternion;
  12925. /**
  12926. * The position of the device in babylon space.
  12927. */
  12928. devicePosition?: Vector3;
  12929. /**
  12930. * The rotation quaternion of the device in babylon space.
  12931. */
  12932. deviceRotationQuaternion: Quaternion;
  12933. /**
  12934. * The raw pose coming from the device.
  12935. */
  12936. rawPose: Nullable<DevicePose>;
  12937. /**
  12938. * The scale of the device to be used when translating from device space to babylon space.
  12939. */
  12940. deviceScaleFactor: number;
  12941. /**
  12942. * Updates the poseControlled values based on the input device pose.
  12943. * @param poseData the pose data to update the object with
  12944. */
  12945. updateFromDevice(poseData: DevicePose): void;
  12946. }
  12947. /**
  12948. * Set of options to customize the webVRCamera
  12949. */
  12950. export interface WebVROptions {
  12951. /**
  12952. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12953. */
  12954. trackPosition?: boolean;
  12955. /**
  12956. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12957. */
  12958. positionScale?: number;
  12959. /**
  12960. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12961. */
  12962. displayName?: string;
  12963. /**
  12964. * Should the native controller meshes be initialized. (default: true)
  12965. */
  12966. controllerMeshes?: boolean;
  12967. /**
  12968. * Creating a default HemiLight only on controllers. (default: true)
  12969. */
  12970. defaultLightingOnControllers?: boolean;
  12971. /**
  12972. * If you don't want to use the default VR button of the helper. (default: false)
  12973. */
  12974. useCustomVRButton?: boolean;
  12975. /**
  12976. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12977. */
  12978. customVRButton?: HTMLButtonElement;
  12979. /**
  12980. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12981. */
  12982. rayLength?: number;
  12983. /**
  12984. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12985. */
  12986. defaultHeight?: number;
  12987. }
  12988. /**
  12989. * This represents a WebVR camera.
  12990. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12991. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12992. */
  12993. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12994. private webVROptions;
  12995. /**
  12996. * @hidden
  12997. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12998. */
  12999. _vrDevice: any;
  13000. /**
  13001. * The rawPose of the vrDevice.
  13002. */
  13003. rawPose: Nullable<DevicePose>;
  13004. private _onVREnabled;
  13005. private _specsVersion;
  13006. private _attached;
  13007. private _frameData;
  13008. protected _descendants: Array<Node>;
  13009. private _deviceRoomPosition;
  13010. /** @hidden */
  13011. _deviceRoomRotationQuaternion: Quaternion;
  13012. private _standingMatrix;
  13013. /**
  13014. * Represents device position in babylon space.
  13015. */
  13016. devicePosition: Vector3;
  13017. /**
  13018. * Represents device rotation in babylon space.
  13019. */
  13020. deviceRotationQuaternion: Quaternion;
  13021. /**
  13022. * The scale of the device to be used when translating from device space to babylon space.
  13023. */
  13024. deviceScaleFactor: number;
  13025. private _deviceToWorld;
  13026. private _worldToDevice;
  13027. /**
  13028. * References to the webVR controllers for the vrDevice.
  13029. */
  13030. controllers: Array<WebVRController>;
  13031. /**
  13032. * Emits an event when a controller is attached.
  13033. */
  13034. onControllersAttachedObservable: Observable<WebVRController[]>;
  13035. /**
  13036. * Emits an event when a controller's mesh has been loaded;
  13037. */
  13038. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13039. /**
  13040. * Emits an event when the HMD's pose has been updated.
  13041. */
  13042. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13043. private _poseSet;
  13044. /**
  13045. * If the rig cameras be used as parent instead of this camera.
  13046. */
  13047. rigParenting: boolean;
  13048. private _lightOnControllers;
  13049. private _defaultHeight?;
  13050. /**
  13051. * Instantiates a WebVRFreeCamera.
  13052. * @param name The name of the WebVRFreeCamera
  13053. * @param position The starting anchor position for the camera
  13054. * @param scene The scene the camera belongs to
  13055. * @param webVROptions a set of customizable options for the webVRCamera
  13056. */
  13057. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13058. /**
  13059. * Gets the device distance from the ground in meters.
  13060. * @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.
  13061. */
  13062. deviceDistanceToRoomGround(): number;
  13063. /**
  13064. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13065. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13066. */
  13067. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13068. /**
  13069. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13070. * @returns A promise with a boolean set to if the standing matrix is supported.
  13071. */
  13072. useStandingMatrixAsync(): Promise<boolean>;
  13073. /**
  13074. * Disposes the camera
  13075. */
  13076. dispose(): void;
  13077. /**
  13078. * Gets a vrController by name.
  13079. * @param name The name of the controller to retreive
  13080. * @returns the controller matching the name specified or null if not found
  13081. */
  13082. getControllerByName(name: string): Nullable<WebVRController>;
  13083. private _leftController;
  13084. /**
  13085. * The controller corrisponding to the users left hand.
  13086. */
  13087. readonly leftController: Nullable<WebVRController>;
  13088. private _rightController;
  13089. /**
  13090. * The controller corrisponding to the users right hand.
  13091. */
  13092. readonly rightController: Nullable<WebVRController>;
  13093. /**
  13094. * Casts a ray forward from the vrCamera's gaze.
  13095. * @param length Length of the ray (default: 100)
  13096. * @returns the ray corrisponding to the gaze
  13097. */
  13098. getForwardRay(length?: number): Ray;
  13099. /**
  13100. * @hidden
  13101. * Updates the camera based on device's frame data
  13102. */
  13103. _checkInputs(): void;
  13104. /**
  13105. * Updates the poseControlled values based on the input device pose.
  13106. * @param poseData Pose coming from the device
  13107. */
  13108. updateFromDevice(poseData: DevicePose): void;
  13109. private _htmlElementAttached;
  13110. private _detachIfAttached;
  13111. /**
  13112. * WebVR's attach control will start broadcasting frames to the device.
  13113. * Note that in certain browsers (chrome for example) this function must be called
  13114. * within a user-interaction callback. Example:
  13115. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13116. *
  13117. * @param element html element to attach the vrDevice to
  13118. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13119. */
  13120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13121. /**
  13122. * Detaches the camera from the html element and disables VR
  13123. *
  13124. * @param element html element to detach from
  13125. */
  13126. detachControl(element: HTMLElement): void;
  13127. /**
  13128. * @returns the name of this class
  13129. */
  13130. getClassName(): string;
  13131. /**
  13132. * Calls resetPose on the vrDisplay
  13133. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13134. */
  13135. resetToCurrentRotation(): void;
  13136. /**
  13137. * @hidden
  13138. * Updates the rig cameras (left and right eye)
  13139. */
  13140. _updateRigCameras(): void;
  13141. private _workingVector;
  13142. private _oneVector;
  13143. private _workingMatrix;
  13144. private updateCacheCalled;
  13145. private _correctPositionIfNotTrackPosition;
  13146. /**
  13147. * @hidden
  13148. * Updates the cached values of the camera
  13149. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13150. */
  13151. _updateCache(ignoreParentClass?: boolean): void;
  13152. /**
  13153. * @hidden
  13154. * Get current device position in babylon world
  13155. */
  13156. _computeDevicePosition(): void;
  13157. /**
  13158. * Updates the current device position and rotation in the babylon world
  13159. */
  13160. update(): void;
  13161. /**
  13162. * @hidden
  13163. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13164. * @returns an identity matrix
  13165. */
  13166. _getViewMatrix(): Matrix;
  13167. private _tmpMatrix;
  13168. /**
  13169. * This function is called by the two RIG cameras.
  13170. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13171. * @hidden
  13172. */
  13173. _getWebVRViewMatrix(): Matrix;
  13174. /** @hidden */
  13175. _getWebVRProjectionMatrix(): Matrix;
  13176. private _onGamepadConnectedObserver;
  13177. private _onGamepadDisconnectedObserver;
  13178. private _updateCacheWhenTrackingDisabledObserver;
  13179. /**
  13180. * Initializes the controllers and their meshes
  13181. */
  13182. initControllers(): void;
  13183. }
  13184. }
  13185. declare module BABYLON {
  13186. /**
  13187. * Size options for a post process
  13188. */
  13189. export type PostProcessOptions = {
  13190. width: number;
  13191. height: number;
  13192. };
  13193. /**
  13194. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13195. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13196. */
  13197. export class PostProcess {
  13198. /** Name of the PostProcess. */
  13199. name: string;
  13200. /**
  13201. * Gets or sets the unique id of the post process
  13202. */
  13203. uniqueId: number;
  13204. /**
  13205. * Width of the texture to apply the post process on
  13206. */
  13207. width: number;
  13208. /**
  13209. * Height of the texture to apply the post process on
  13210. */
  13211. height: number;
  13212. /**
  13213. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13214. * @hidden
  13215. */
  13216. _outputTexture: Nullable<InternalTexture>;
  13217. /**
  13218. * Sampling mode used by the shader
  13219. * See https://doc.babylonjs.com/classes/3.1/texture
  13220. */
  13221. renderTargetSamplingMode: number;
  13222. /**
  13223. * Clear color to use when screen clearing
  13224. */
  13225. clearColor: Color4;
  13226. /**
  13227. * If the buffer needs to be cleared before applying the post process. (default: true)
  13228. * Should be set to false if shader will overwrite all previous pixels.
  13229. */
  13230. autoClear: boolean;
  13231. /**
  13232. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13233. */
  13234. alphaMode: number;
  13235. /**
  13236. * Sets the setAlphaBlendConstants of the babylon engine
  13237. */
  13238. alphaConstants: Color4;
  13239. /**
  13240. * Animations to be used for the post processing
  13241. */
  13242. animations: Animation[];
  13243. /**
  13244. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13245. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13246. */
  13247. enablePixelPerfectMode: boolean;
  13248. /**
  13249. * Force the postprocess to be applied without taking in account viewport
  13250. */
  13251. forceFullscreenViewport: boolean;
  13252. /**
  13253. * List of inspectable custom properties (used by the Inspector)
  13254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13255. */
  13256. inspectableCustomProperties: IInspectable[];
  13257. /**
  13258. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13259. *
  13260. * | Value | Type | Description |
  13261. * | ----- | ----------------------------------- | ----------- |
  13262. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13263. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13264. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13265. *
  13266. */
  13267. scaleMode: number;
  13268. /**
  13269. * Force textures to be a power of two (default: false)
  13270. */
  13271. alwaysForcePOT: boolean;
  13272. private _samples;
  13273. /**
  13274. * Number of sample textures (default: 1)
  13275. */
  13276. samples: number;
  13277. /**
  13278. * Modify the scale of the post process to be the same as the viewport (default: false)
  13279. */
  13280. adaptScaleToCurrentViewport: boolean;
  13281. private _camera;
  13282. private _scene;
  13283. private _engine;
  13284. private _options;
  13285. private _reusable;
  13286. private _textureType;
  13287. /**
  13288. * Smart array of input and output textures for the post process.
  13289. * @hidden
  13290. */
  13291. _textures: SmartArray<InternalTexture>;
  13292. /**
  13293. * The index in _textures that corresponds to the output texture.
  13294. * @hidden
  13295. */
  13296. _currentRenderTextureInd: number;
  13297. private _effect;
  13298. private _samplers;
  13299. private _fragmentUrl;
  13300. private _vertexUrl;
  13301. private _parameters;
  13302. private _scaleRatio;
  13303. protected _indexParameters: any;
  13304. private _shareOutputWithPostProcess;
  13305. private _texelSize;
  13306. private _forcedOutputTexture;
  13307. /**
  13308. * Returns the fragment url or shader name used in the post process.
  13309. * @returns the fragment url or name in the shader store.
  13310. */
  13311. getEffectName(): string;
  13312. /**
  13313. * An event triggered when the postprocess is activated.
  13314. */
  13315. onActivateObservable: Observable<Camera>;
  13316. private _onActivateObserver;
  13317. /**
  13318. * A function that is added to the onActivateObservable
  13319. */
  13320. onActivate: Nullable<(camera: Camera) => void>;
  13321. /**
  13322. * An event triggered when the postprocess changes its size.
  13323. */
  13324. onSizeChangedObservable: Observable<PostProcess>;
  13325. private _onSizeChangedObserver;
  13326. /**
  13327. * A function that is added to the onSizeChangedObservable
  13328. */
  13329. onSizeChanged: (postProcess: PostProcess) => void;
  13330. /**
  13331. * An event triggered when the postprocess applies its effect.
  13332. */
  13333. onApplyObservable: Observable<Effect>;
  13334. private _onApplyObserver;
  13335. /**
  13336. * A function that is added to the onApplyObservable
  13337. */
  13338. onApply: (effect: Effect) => void;
  13339. /**
  13340. * An event triggered before rendering the postprocess
  13341. */
  13342. onBeforeRenderObservable: Observable<Effect>;
  13343. private _onBeforeRenderObserver;
  13344. /**
  13345. * A function that is added to the onBeforeRenderObservable
  13346. */
  13347. onBeforeRender: (effect: Effect) => void;
  13348. /**
  13349. * An event triggered after rendering the postprocess
  13350. */
  13351. onAfterRenderObservable: Observable<Effect>;
  13352. private _onAfterRenderObserver;
  13353. /**
  13354. * A function that is added to the onAfterRenderObservable
  13355. */
  13356. onAfterRender: (efect: Effect) => void;
  13357. /**
  13358. * 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
  13359. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13360. */
  13361. inputTexture: InternalTexture;
  13362. /**
  13363. * Gets the camera which post process is applied to.
  13364. * @returns The camera the post process is applied to.
  13365. */
  13366. getCamera(): Camera;
  13367. /**
  13368. * Gets the texel size of the postprocess.
  13369. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13370. */
  13371. readonly texelSize: Vector2;
  13372. /**
  13373. * Creates a new instance PostProcess
  13374. * @param name The name of the PostProcess.
  13375. * @param fragmentUrl The url of the fragment shader to be used.
  13376. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13377. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13378. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13379. * @param camera The camera to apply the render pass to.
  13380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13381. * @param engine The engine which the post process will be applied. (default: current engine)
  13382. * @param reusable If the post process can be reused on the same frame. (default: false)
  13383. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13384. * @param textureType Type of textures used when performing the post process. (default: 0)
  13385. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13386. * @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
  13387. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13388. */
  13389. constructor(
  13390. /** Name of the PostProcess. */
  13391. 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);
  13392. /**
  13393. * Gets a string idenfifying the name of the class
  13394. * @returns "PostProcess" string
  13395. */
  13396. getClassName(): string;
  13397. /**
  13398. * Gets the engine which this post process belongs to.
  13399. * @returns The engine the post process was enabled with.
  13400. */
  13401. getEngine(): Engine;
  13402. /**
  13403. * The effect that is created when initializing the post process.
  13404. * @returns The created effect corrisponding the the postprocess.
  13405. */
  13406. getEffect(): Effect;
  13407. /**
  13408. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13409. * @param postProcess The post process to share the output with.
  13410. * @returns This post process.
  13411. */
  13412. shareOutputWith(postProcess: PostProcess): PostProcess;
  13413. /**
  13414. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13415. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13416. */
  13417. useOwnOutput(): void;
  13418. /**
  13419. * Updates the effect with the current post process compile time values and recompiles the shader.
  13420. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13421. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13422. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13423. * @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
  13424. * @param onCompiled Called when the shader has been compiled.
  13425. * @param onError Called if there is an error when compiling a shader.
  13426. */
  13427. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13428. /**
  13429. * The post process is reusable if it can be used multiple times within one frame.
  13430. * @returns If the post process is reusable
  13431. */
  13432. isReusable(): boolean;
  13433. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13434. markTextureDirty(): void;
  13435. /**
  13436. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13437. * 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.
  13438. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13439. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13440. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13441. * @returns The target texture that was bound to be written to.
  13442. */
  13443. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13444. /**
  13445. * If the post process is supported.
  13446. */
  13447. readonly isSupported: boolean;
  13448. /**
  13449. * The aspect ratio of the output texture.
  13450. */
  13451. readonly aspectRatio: number;
  13452. /**
  13453. * Get a value indicating if the post-process is ready to be used
  13454. * @returns true if the post-process is ready (shader is compiled)
  13455. */
  13456. isReady(): boolean;
  13457. /**
  13458. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13459. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13460. */
  13461. apply(): Nullable<Effect>;
  13462. private _disposeTextures;
  13463. /**
  13464. * Disposes the post process.
  13465. * @param camera The camera to dispose the post process on.
  13466. */
  13467. dispose(camera?: Camera): void;
  13468. }
  13469. }
  13470. declare module BABYLON {
  13471. /**
  13472. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13473. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13474. */
  13475. export class PostProcessManager {
  13476. private _scene;
  13477. private _indexBuffer;
  13478. private _vertexBuffers;
  13479. /**
  13480. * Creates a new instance PostProcess
  13481. * @param scene The scene that the post process is associated with.
  13482. */
  13483. constructor(scene: Scene);
  13484. private _prepareBuffers;
  13485. private _buildIndexBuffer;
  13486. /**
  13487. * Rebuilds the vertex buffers of the manager.
  13488. * @hidden
  13489. */
  13490. _rebuild(): void;
  13491. /**
  13492. * Prepares a frame to be run through a post process.
  13493. * @param sourceTexture The input texture to the post procesess. (default: null)
  13494. * @param postProcesses An array of post processes to be run. (default: null)
  13495. * @returns True if the post processes were able to be run.
  13496. * @hidden
  13497. */
  13498. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13499. /**
  13500. * Manually render a set of post processes to a texture.
  13501. * @param postProcesses An array of post processes to be run.
  13502. * @param targetTexture The target texture to render to.
  13503. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13504. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13505. * @param lodLevel defines which lod of the texture to render to
  13506. */
  13507. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13508. /**
  13509. * Finalize the result of the output of the postprocesses.
  13510. * @param doNotPresent If true the result will not be displayed to the screen.
  13511. * @param targetTexture The target texture to render to.
  13512. * @param faceIndex The index of the face to bind the target texture to.
  13513. * @param postProcesses The array of post processes to render.
  13514. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13515. * @hidden
  13516. */
  13517. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13518. /**
  13519. * Disposes of the post process manager.
  13520. */
  13521. dispose(): void;
  13522. }
  13523. }
  13524. declare module BABYLON {
  13525. interface AbstractScene {
  13526. /**
  13527. * The list of layers (background and foreground) of the scene
  13528. */
  13529. layers: Array<Layer>;
  13530. }
  13531. /**
  13532. * Defines the layer scene component responsible to manage any layers
  13533. * in a given scene.
  13534. */
  13535. export class LayerSceneComponent implements ISceneComponent {
  13536. /**
  13537. * The component name helpfull to identify the component in the list of scene components.
  13538. */
  13539. readonly name: string;
  13540. /**
  13541. * The scene the component belongs to.
  13542. */
  13543. scene: Scene;
  13544. private _engine;
  13545. /**
  13546. * Creates a new instance of the component for the given scene
  13547. * @param scene Defines the scene to register the component in
  13548. */
  13549. constructor(scene: Scene);
  13550. /**
  13551. * Registers the component in a given scene
  13552. */
  13553. register(): void;
  13554. /**
  13555. * Rebuilds the elements related to this component in case of
  13556. * context lost for instance.
  13557. */
  13558. rebuild(): void;
  13559. /**
  13560. * Disposes the component and the associated ressources.
  13561. */
  13562. dispose(): void;
  13563. private _draw;
  13564. private _drawCameraPredicate;
  13565. private _drawCameraBackground;
  13566. private _drawCameraForeground;
  13567. private _drawRenderTargetPredicate;
  13568. private _drawRenderTargetBackground;
  13569. private _drawRenderTargetForeground;
  13570. }
  13571. }
  13572. declare module BABYLON {
  13573. /** @hidden */
  13574. export var layerPixelShader: {
  13575. name: string;
  13576. shader: string;
  13577. };
  13578. }
  13579. declare module BABYLON {
  13580. /** @hidden */
  13581. export var layerVertexShader: {
  13582. name: string;
  13583. shader: string;
  13584. };
  13585. }
  13586. declare module BABYLON {
  13587. /**
  13588. * This represents a full screen 2d layer.
  13589. * This can be useful to display a picture in the background of your scene for instance.
  13590. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13591. */
  13592. export class Layer {
  13593. /**
  13594. * Define the name of the layer.
  13595. */
  13596. name: string;
  13597. /**
  13598. * Define the texture the layer should display.
  13599. */
  13600. texture: Nullable<Texture>;
  13601. /**
  13602. * Is the layer in background or foreground.
  13603. */
  13604. isBackground: boolean;
  13605. /**
  13606. * Define the color of the layer (instead of texture).
  13607. */
  13608. color: Color4;
  13609. /**
  13610. * Define the scale of the layer in order to zoom in out of the texture.
  13611. */
  13612. scale: Vector2;
  13613. /**
  13614. * Define an offset for the layer in order to shift the texture.
  13615. */
  13616. offset: Vector2;
  13617. /**
  13618. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13619. */
  13620. alphaBlendingMode: number;
  13621. /**
  13622. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13623. * Alpha test will not mix with the background color in case of transparency.
  13624. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13625. */
  13626. alphaTest: boolean;
  13627. /**
  13628. * Define a mask to restrict the layer to only some of the scene cameras.
  13629. */
  13630. layerMask: number;
  13631. /**
  13632. * Define the list of render target the layer is visible into.
  13633. */
  13634. renderTargetTextures: RenderTargetTexture[];
  13635. /**
  13636. * Define if the layer is only used in renderTarget or if it also
  13637. * renders in the main frame buffer of the canvas.
  13638. */
  13639. renderOnlyInRenderTargetTextures: boolean;
  13640. private _scene;
  13641. private _vertexBuffers;
  13642. private _indexBuffer;
  13643. private _effect;
  13644. private _alphaTestEffect;
  13645. /**
  13646. * An event triggered when the layer is disposed.
  13647. */
  13648. onDisposeObservable: Observable<Layer>;
  13649. private _onDisposeObserver;
  13650. /**
  13651. * Back compatibility with callback before the onDisposeObservable existed.
  13652. * The set callback will be triggered when the layer has been disposed.
  13653. */
  13654. onDispose: () => void;
  13655. /**
  13656. * An event triggered before rendering the scene
  13657. */
  13658. onBeforeRenderObservable: Observable<Layer>;
  13659. private _onBeforeRenderObserver;
  13660. /**
  13661. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13662. * The set callback will be triggered just before rendering the layer.
  13663. */
  13664. onBeforeRender: () => void;
  13665. /**
  13666. * An event triggered after rendering the scene
  13667. */
  13668. onAfterRenderObservable: Observable<Layer>;
  13669. private _onAfterRenderObserver;
  13670. /**
  13671. * Back compatibility with callback before the onAfterRenderObservable existed.
  13672. * The set callback will be triggered just after rendering the layer.
  13673. */
  13674. onAfterRender: () => void;
  13675. /**
  13676. * Instantiates a new layer.
  13677. * This represents a full screen 2d layer.
  13678. * This can be useful to display a picture in the background of your scene for instance.
  13679. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13680. * @param name Define the name of the layer in the scene
  13681. * @param imgUrl Define the url of the texture to display in the layer
  13682. * @param scene Define the scene the layer belongs to
  13683. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13684. * @param color Defines a color for the layer
  13685. */
  13686. constructor(
  13687. /**
  13688. * Define the name of the layer.
  13689. */
  13690. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13691. private _createIndexBuffer;
  13692. /** @hidden */
  13693. _rebuild(): void;
  13694. /**
  13695. * Renders the layer in the scene.
  13696. */
  13697. render(): void;
  13698. /**
  13699. * Disposes and releases the associated ressources.
  13700. */
  13701. dispose(): void;
  13702. }
  13703. }
  13704. declare module BABYLON {
  13705. interface AbstractScene {
  13706. /**
  13707. * The list of procedural textures added to the scene
  13708. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13709. */
  13710. proceduralTextures: Array<ProceduralTexture>;
  13711. }
  13712. /**
  13713. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13714. * in a given scene.
  13715. */
  13716. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13717. /**
  13718. * The component name helpfull to identify the component in the list of scene components.
  13719. */
  13720. readonly name: string;
  13721. /**
  13722. * The scene the component belongs to.
  13723. */
  13724. scene: Scene;
  13725. /**
  13726. * Creates a new instance of the component for the given scene
  13727. * @param scene Defines the scene to register the component in
  13728. */
  13729. constructor(scene: Scene);
  13730. /**
  13731. * Registers the component in a given scene
  13732. */
  13733. register(): void;
  13734. /**
  13735. * Rebuilds the elements related to this component in case of
  13736. * context lost for instance.
  13737. */
  13738. rebuild(): void;
  13739. /**
  13740. * Disposes the component and the associated ressources.
  13741. */
  13742. dispose(): void;
  13743. private _beforeClear;
  13744. }
  13745. }
  13746. declare module BABYLON {
  13747. /** @hidden */
  13748. export var proceduralVertexShader: {
  13749. name: string;
  13750. shader: string;
  13751. };
  13752. }
  13753. declare module BABYLON {
  13754. /**
  13755. * 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.
  13756. * This is the base class of any Procedural texture and contains most of the shareable code.
  13757. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13758. */
  13759. export class ProceduralTexture extends Texture {
  13760. isCube: boolean;
  13761. /**
  13762. * Define if the texture is enabled or not (disabled texture will not render)
  13763. */
  13764. isEnabled: boolean;
  13765. /**
  13766. * Define if the texture must be cleared before rendering (default is true)
  13767. */
  13768. autoClear: boolean;
  13769. /**
  13770. * Callback called when the texture is generated
  13771. */
  13772. onGenerated: () => void;
  13773. /**
  13774. * Event raised when the texture is generated
  13775. */
  13776. onGeneratedObservable: Observable<ProceduralTexture>;
  13777. /** @hidden */
  13778. _generateMipMaps: boolean;
  13779. /** @hidden **/
  13780. _effect: Effect;
  13781. /** @hidden */
  13782. _textures: {
  13783. [key: string]: Texture;
  13784. };
  13785. private _size;
  13786. private _currentRefreshId;
  13787. private _refreshRate;
  13788. private _vertexBuffers;
  13789. private _indexBuffer;
  13790. private _uniforms;
  13791. private _samplers;
  13792. private _fragment;
  13793. private _floats;
  13794. private _ints;
  13795. private _floatsArrays;
  13796. private _colors3;
  13797. private _colors4;
  13798. private _vectors2;
  13799. private _vectors3;
  13800. private _matrices;
  13801. private _fallbackTexture;
  13802. private _fallbackTextureUsed;
  13803. private _engine;
  13804. private _cachedDefines;
  13805. private _contentUpdateId;
  13806. private _contentData;
  13807. /**
  13808. * Instantiates a new procedural texture.
  13809. * 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.
  13810. * This is the base class of any Procedural texture and contains most of the shareable code.
  13811. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13812. * @param name Define the name of the texture
  13813. * @param size Define the size of the texture to create
  13814. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13815. * @param scene Define the scene the texture belongs to
  13816. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13817. * @param generateMipMaps Define if the texture should creates mip maps or not
  13818. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13819. */
  13820. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13821. /**
  13822. * The effect that is created when initializing the post process.
  13823. * @returns The created effect corrisponding the the postprocess.
  13824. */
  13825. getEffect(): Effect;
  13826. /**
  13827. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13828. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13829. */
  13830. getContent(): Nullable<ArrayBufferView>;
  13831. private _createIndexBuffer;
  13832. /** @hidden */
  13833. _rebuild(): void;
  13834. /**
  13835. * Resets the texture in order to recreate its associated resources.
  13836. * This can be called in case of context loss
  13837. */
  13838. reset(): void;
  13839. protected _getDefines(): string;
  13840. /**
  13841. * Is the texture ready to be used ? (rendered at least once)
  13842. * @returns true if ready, otherwise, false.
  13843. */
  13844. isReady(): boolean;
  13845. /**
  13846. * Resets the refresh counter of the texture and start bak from scratch.
  13847. * Could be useful to regenerate the texture if it is setup to render only once.
  13848. */
  13849. resetRefreshCounter(): void;
  13850. /**
  13851. * Set the fragment shader to use in order to render the texture.
  13852. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13853. */
  13854. setFragment(fragment: any): void;
  13855. /**
  13856. * Define the refresh rate of the texture or the rendering frequency.
  13857. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13858. */
  13859. refreshRate: number;
  13860. /** @hidden */
  13861. _shouldRender(): boolean;
  13862. /**
  13863. * Get the size the texture is rendering at.
  13864. * @returns the size (texture is always squared)
  13865. */
  13866. getRenderSize(): number;
  13867. /**
  13868. * Resize the texture to new value.
  13869. * @param size Define the new size the texture should have
  13870. * @param generateMipMaps Define whether the new texture should create mip maps
  13871. */
  13872. resize(size: number, generateMipMaps: boolean): void;
  13873. private _checkUniform;
  13874. /**
  13875. * Set a texture in the shader program used to render.
  13876. * @param name Define the name of the uniform samplers as defined in the shader
  13877. * @param texture Define the texture to bind to this sampler
  13878. * @return the texture itself allowing "fluent" like uniform updates
  13879. */
  13880. setTexture(name: string, texture: Texture): ProceduralTexture;
  13881. /**
  13882. * Set a float in the shader.
  13883. * @param name Define the name of the uniform as defined in the shader
  13884. * @param value Define the value to give to the uniform
  13885. * @return the texture itself allowing "fluent" like uniform updates
  13886. */
  13887. setFloat(name: string, value: number): ProceduralTexture;
  13888. /**
  13889. * Set a int in the shader.
  13890. * @param name Define the name of the uniform as defined in the shader
  13891. * @param value Define the value to give to the uniform
  13892. * @return the texture itself allowing "fluent" like uniform updates
  13893. */
  13894. setInt(name: string, value: number): ProceduralTexture;
  13895. /**
  13896. * Set an array of floats in the shader.
  13897. * @param name Define the name of the uniform as defined in the shader
  13898. * @param value Define the value to give to the uniform
  13899. * @return the texture itself allowing "fluent" like uniform updates
  13900. */
  13901. setFloats(name: string, value: number[]): ProceduralTexture;
  13902. /**
  13903. * Set a vec3 in the shader from a Color3.
  13904. * @param name Define the name of the uniform as defined in the shader
  13905. * @param value Define the value to give to the uniform
  13906. * @return the texture itself allowing "fluent" like uniform updates
  13907. */
  13908. setColor3(name: string, value: Color3): ProceduralTexture;
  13909. /**
  13910. * Set a vec4 in the shader from a Color4.
  13911. * @param name Define the name of the uniform as defined in the shader
  13912. * @param value Define the value to give to the uniform
  13913. * @return the texture itself allowing "fluent" like uniform updates
  13914. */
  13915. setColor4(name: string, value: Color4): ProceduralTexture;
  13916. /**
  13917. * Set a vec2 in the shader from a Vector2.
  13918. * @param name Define the name of the uniform as defined in the shader
  13919. * @param value Define the value to give to the uniform
  13920. * @return the texture itself allowing "fluent" like uniform updates
  13921. */
  13922. setVector2(name: string, value: Vector2): ProceduralTexture;
  13923. /**
  13924. * Set a vec3 in the shader from a Vector3.
  13925. * @param name Define the name of the uniform as defined in the shader
  13926. * @param value Define the value to give to the uniform
  13927. * @return the texture itself allowing "fluent" like uniform updates
  13928. */
  13929. setVector3(name: string, value: Vector3): ProceduralTexture;
  13930. /**
  13931. * Set a mat4 in the shader from a MAtrix.
  13932. * @param name Define the name of the uniform as defined in the shader
  13933. * @param value Define the value to give to the uniform
  13934. * @return the texture itself allowing "fluent" like uniform updates
  13935. */
  13936. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13937. /**
  13938. * Render the texture to its associated render target.
  13939. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13940. */
  13941. render(useCameraPostProcess?: boolean): void;
  13942. /**
  13943. * Clone the texture.
  13944. * @returns the cloned texture
  13945. */
  13946. clone(): ProceduralTexture;
  13947. /**
  13948. * Dispose the texture and release its asoociated resources.
  13949. */
  13950. dispose(): void;
  13951. }
  13952. }
  13953. declare module BABYLON {
  13954. /**
  13955. * This represents the base class for particle system in Babylon.
  13956. * 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.
  13957. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13958. * @example https://doc.babylonjs.com/babylon101/particles
  13959. */
  13960. export class BaseParticleSystem {
  13961. /**
  13962. * Source color is added to the destination color without alpha affecting the result
  13963. */
  13964. static BLENDMODE_ONEONE: number;
  13965. /**
  13966. * Blend current color and particle color using particle’s alpha
  13967. */
  13968. static BLENDMODE_STANDARD: number;
  13969. /**
  13970. * Add current color and particle color multiplied by particle’s alpha
  13971. */
  13972. static BLENDMODE_ADD: number;
  13973. /**
  13974. * Multiply current color with particle color
  13975. */
  13976. static BLENDMODE_MULTIPLY: number;
  13977. /**
  13978. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13979. */
  13980. static BLENDMODE_MULTIPLYADD: number;
  13981. /**
  13982. * List of animations used by the particle system.
  13983. */
  13984. animations: Animation[];
  13985. /**
  13986. * The id of the Particle system.
  13987. */
  13988. id: string;
  13989. /**
  13990. * The friendly name of the Particle system.
  13991. */
  13992. name: string;
  13993. /**
  13994. * The rendering group used by the Particle system to chose when to render.
  13995. */
  13996. renderingGroupId: number;
  13997. /**
  13998. * The emitter represents the Mesh or position we are attaching the particle system to.
  13999. */
  14000. emitter: Nullable<AbstractMesh | Vector3>;
  14001. /**
  14002. * The maximum number of particles to emit per frame
  14003. */
  14004. emitRate: number;
  14005. /**
  14006. * If you want to launch only a few particles at once, that can be done, as well.
  14007. */
  14008. manualEmitCount: number;
  14009. /**
  14010. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14011. */
  14012. updateSpeed: number;
  14013. /**
  14014. * The amount of time the particle system is running (depends of the overall update speed).
  14015. */
  14016. targetStopDuration: number;
  14017. /**
  14018. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14019. */
  14020. disposeOnStop: boolean;
  14021. /**
  14022. * Minimum power of emitting particles.
  14023. */
  14024. minEmitPower: number;
  14025. /**
  14026. * Maximum power of emitting particles.
  14027. */
  14028. maxEmitPower: number;
  14029. /**
  14030. * Minimum life time of emitting particles.
  14031. */
  14032. minLifeTime: number;
  14033. /**
  14034. * Maximum life time of emitting particles.
  14035. */
  14036. maxLifeTime: number;
  14037. /**
  14038. * Minimum Size of emitting particles.
  14039. */
  14040. minSize: number;
  14041. /**
  14042. * Maximum Size of emitting particles.
  14043. */
  14044. maxSize: number;
  14045. /**
  14046. * Minimum scale of emitting particles on X axis.
  14047. */
  14048. minScaleX: number;
  14049. /**
  14050. * Maximum scale of emitting particles on X axis.
  14051. */
  14052. maxScaleX: number;
  14053. /**
  14054. * Minimum scale of emitting particles on Y axis.
  14055. */
  14056. minScaleY: number;
  14057. /**
  14058. * Maximum scale of emitting particles on Y axis.
  14059. */
  14060. maxScaleY: number;
  14061. /**
  14062. * Gets or sets the minimal initial rotation in radians.
  14063. */
  14064. minInitialRotation: number;
  14065. /**
  14066. * Gets or sets the maximal initial rotation in radians.
  14067. */
  14068. maxInitialRotation: number;
  14069. /**
  14070. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14071. */
  14072. minAngularSpeed: number;
  14073. /**
  14074. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14075. */
  14076. maxAngularSpeed: number;
  14077. /**
  14078. * The texture used to render each particle. (this can be a spritesheet)
  14079. */
  14080. particleTexture: Nullable<Texture>;
  14081. /**
  14082. * The layer mask we are rendering the particles through.
  14083. */
  14084. layerMask: number;
  14085. /**
  14086. * This can help using your own shader to render the particle system.
  14087. * The according effect will be created
  14088. */
  14089. customShader: any;
  14090. /**
  14091. * By default particle system starts as soon as they are created. This prevents the
  14092. * automatic start to happen and let you decide when to start emitting particles.
  14093. */
  14094. preventAutoStart: boolean;
  14095. private _noiseTexture;
  14096. /**
  14097. * Gets or sets a texture used to add random noise to particle positions
  14098. */
  14099. noiseTexture: Nullable<ProceduralTexture>;
  14100. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14101. noiseStrength: Vector3;
  14102. /**
  14103. * Callback triggered when the particle animation is ending.
  14104. */
  14105. onAnimationEnd: Nullable<() => void>;
  14106. /**
  14107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14108. */
  14109. blendMode: number;
  14110. /**
  14111. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14112. * to override the particles.
  14113. */
  14114. forceDepthWrite: boolean;
  14115. /** 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 */
  14116. preWarmCycles: number;
  14117. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14118. preWarmStepOffset: number;
  14119. /**
  14120. * 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)
  14121. */
  14122. spriteCellChangeSpeed: number;
  14123. /**
  14124. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14125. */
  14126. startSpriteCellID: number;
  14127. /**
  14128. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14129. */
  14130. endSpriteCellID: number;
  14131. /**
  14132. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14133. */
  14134. spriteCellWidth: number;
  14135. /**
  14136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14137. */
  14138. spriteCellHeight: number;
  14139. /**
  14140. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14141. */
  14142. spriteRandomStartCell: boolean;
  14143. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14144. translationPivot: Vector2;
  14145. /** @hidden */
  14146. protected _isAnimationSheetEnabled: boolean;
  14147. /**
  14148. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14149. */
  14150. beginAnimationOnStart: boolean;
  14151. /**
  14152. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14153. */
  14154. beginAnimationFrom: number;
  14155. /**
  14156. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14157. */
  14158. beginAnimationTo: number;
  14159. /**
  14160. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14161. */
  14162. beginAnimationLoop: boolean;
  14163. /**
  14164. * Gets or sets a world offset applied to all particles
  14165. */
  14166. worldOffset: Vector3;
  14167. /**
  14168. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14169. */
  14170. isAnimationSheetEnabled: boolean;
  14171. /**
  14172. * Get hosting scene
  14173. * @returns the scene
  14174. */
  14175. getScene(): Scene;
  14176. /**
  14177. * You can use gravity if you want to give an orientation to your particles.
  14178. */
  14179. gravity: Vector3;
  14180. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14181. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14182. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14183. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14184. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14185. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14186. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14187. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14188. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14189. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14190. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14191. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14192. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14193. /**
  14194. * Defines the delay in milliseconds before starting the system (0 by default)
  14195. */
  14196. startDelay: number;
  14197. /**
  14198. * Gets the current list of drag gradients.
  14199. * You must use addDragGradient and removeDragGradient to udpate this list
  14200. * @returns the list of drag gradients
  14201. */
  14202. getDragGradients(): Nullable<Array<FactorGradient>>;
  14203. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14204. limitVelocityDamping: number;
  14205. /**
  14206. * Gets the current list of limit velocity gradients.
  14207. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14208. * @returns the list of limit velocity gradients
  14209. */
  14210. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14211. /**
  14212. * Gets the current list of color gradients.
  14213. * You must use addColorGradient and removeColorGradient to udpate this list
  14214. * @returns the list of color gradients
  14215. */
  14216. getColorGradients(): Nullable<Array<ColorGradient>>;
  14217. /**
  14218. * Gets the current list of size gradients.
  14219. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14220. * @returns the list of size gradients
  14221. */
  14222. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14223. /**
  14224. * Gets the current list of color remap gradients.
  14225. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14226. * @returns the list of color remap gradients
  14227. */
  14228. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14229. /**
  14230. * Gets the current list of alpha remap gradients.
  14231. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14232. * @returns the list of alpha remap gradients
  14233. */
  14234. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14235. /**
  14236. * Gets the current list of life time gradients.
  14237. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14238. * @returns the list of life time gradients
  14239. */
  14240. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14241. /**
  14242. * Gets the current list of angular speed gradients.
  14243. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14244. * @returns the list of angular speed gradients
  14245. */
  14246. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14247. /**
  14248. * Gets the current list of velocity gradients.
  14249. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14250. * @returns the list of velocity gradients
  14251. */
  14252. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Gets the current list of start size gradients.
  14255. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14256. * @returns the list of start size gradients
  14257. */
  14258. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Gets the current list of emit rate gradients.
  14261. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14262. * @returns the list of emit rate gradients
  14263. */
  14264. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14265. /**
  14266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14267. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14268. */
  14269. direction1: Vector3;
  14270. /**
  14271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14273. */
  14274. direction2: Vector3;
  14275. /**
  14276. * 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.
  14277. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14278. */
  14279. minEmitBox: Vector3;
  14280. /**
  14281. * 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.
  14282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14283. */
  14284. maxEmitBox: Vector3;
  14285. /**
  14286. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14287. */
  14288. color1: Color4;
  14289. /**
  14290. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14291. */
  14292. color2: Color4;
  14293. /**
  14294. * Color the particle will have at the end of its lifetime
  14295. */
  14296. colorDead: Color4;
  14297. /**
  14298. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14299. */
  14300. textureMask: Color4;
  14301. /**
  14302. * The particle emitter type defines the emitter used by the particle system.
  14303. * It can be for example box, sphere, or cone...
  14304. */
  14305. particleEmitterType: IParticleEmitterType;
  14306. /** @hidden */
  14307. _isSubEmitter: boolean;
  14308. /**
  14309. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14310. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14311. */
  14312. billboardMode: number;
  14313. protected _isBillboardBased: boolean;
  14314. /**
  14315. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14316. */
  14317. isBillboardBased: boolean;
  14318. /**
  14319. * The scene the particle system belongs to.
  14320. */
  14321. protected _scene: Scene;
  14322. /**
  14323. * Local cache of defines for image processing.
  14324. */
  14325. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14326. /**
  14327. * Default configuration related to image processing available in the standard Material.
  14328. */
  14329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14330. /**
  14331. * Gets the image processing configuration used either in this material.
  14332. */
  14333. /**
  14334. * Sets the Default image processing configuration used either in the this material.
  14335. *
  14336. * If sets to null, the scene one is in use.
  14337. */
  14338. imageProcessingConfiguration: ImageProcessingConfiguration;
  14339. /**
  14340. * Attaches a new image processing configuration to the Standard Material.
  14341. * @param configuration
  14342. */
  14343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14344. /** @hidden */
  14345. protected _reset(): void;
  14346. /** @hidden */
  14347. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14348. /**
  14349. * Instantiates a particle system.
  14350. * 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.
  14351. * @param name The name of the particle system
  14352. */
  14353. constructor(name: string);
  14354. /**
  14355. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14358. * @returns the emitter
  14359. */
  14360. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14361. /**
  14362. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14363. * @param radius The radius of the hemisphere to emit from
  14364. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14365. * @returns the emitter
  14366. */
  14367. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14368. /**
  14369. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14370. * @param radius The radius of the sphere to emit from
  14371. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14372. * @returns the emitter
  14373. */
  14374. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14375. /**
  14376. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14377. * @param radius The radius of the sphere to emit from
  14378. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14379. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14380. * @returns the emitter
  14381. */
  14382. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14383. /**
  14384. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14385. * @param radius The radius of the emission cylinder
  14386. * @param height The height of the emission cylinder
  14387. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14388. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14389. * @returns the emitter
  14390. */
  14391. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14392. /**
  14393. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14394. * @param radius The radius of the cylinder to emit from
  14395. * @param height The height of the emission cylinder
  14396. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14397. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14398. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14399. * @returns the emitter
  14400. */
  14401. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14402. /**
  14403. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14404. * @param radius The radius of the cone to emit from
  14405. * @param angle The base angle of the cone
  14406. * @returns the emitter
  14407. */
  14408. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14409. /**
  14410. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14413. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14414. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14415. * @returns the emitter
  14416. */
  14417. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14418. }
  14419. }
  14420. declare module BABYLON {
  14421. /**
  14422. * Type of sub emitter
  14423. */
  14424. export enum SubEmitterType {
  14425. /**
  14426. * Attached to the particle over it's lifetime
  14427. */
  14428. ATTACHED = 0,
  14429. /**
  14430. * Created when the particle dies
  14431. */
  14432. END = 1
  14433. }
  14434. /**
  14435. * Sub emitter class used to emit particles from an existing particle
  14436. */
  14437. export class SubEmitter {
  14438. /**
  14439. * the particle system to be used by the sub emitter
  14440. */
  14441. particleSystem: ParticleSystem;
  14442. /**
  14443. * Type of the submitter (Default: END)
  14444. */
  14445. type: SubEmitterType;
  14446. /**
  14447. * 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)
  14448. * Note: This only is supported when using an emitter of type Mesh
  14449. */
  14450. inheritDirection: boolean;
  14451. /**
  14452. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14453. */
  14454. inheritedVelocityAmount: number;
  14455. /**
  14456. * Creates a sub emitter
  14457. * @param particleSystem the particle system to be used by the sub emitter
  14458. */
  14459. constructor(
  14460. /**
  14461. * the particle system to be used by the sub emitter
  14462. */
  14463. particleSystem: ParticleSystem);
  14464. /**
  14465. * Clones the sub emitter
  14466. * @returns the cloned sub emitter
  14467. */
  14468. clone(): SubEmitter;
  14469. /**
  14470. * Serialize current object to a JSON object
  14471. * @returns the serialized object
  14472. */
  14473. serialize(): any;
  14474. /** @hidden */
  14475. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14476. /**
  14477. * Creates a new SubEmitter from a serialized JSON version
  14478. * @param serializationObject defines the JSON object to read from
  14479. * @param scene defines the hosting scene
  14480. * @param rootUrl defines the rootUrl for data loading
  14481. * @returns a new SubEmitter
  14482. */
  14483. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14484. /** Release associated resources */
  14485. dispose(): void;
  14486. }
  14487. }
  14488. declare module BABYLON {
  14489. /** @hidden */
  14490. export var clipPlaneFragmentDeclaration: {
  14491. name: string;
  14492. shader: string;
  14493. };
  14494. }
  14495. declare module BABYLON {
  14496. /** @hidden */
  14497. export var imageProcessingDeclaration: {
  14498. name: string;
  14499. shader: string;
  14500. };
  14501. }
  14502. declare module BABYLON {
  14503. /** @hidden */
  14504. export var imageProcessingFunctions: {
  14505. name: string;
  14506. shader: string;
  14507. };
  14508. }
  14509. declare module BABYLON {
  14510. /** @hidden */
  14511. export var clipPlaneFragment: {
  14512. name: string;
  14513. shader: string;
  14514. };
  14515. }
  14516. declare module BABYLON {
  14517. /** @hidden */
  14518. export var particlesPixelShader: {
  14519. name: string;
  14520. shader: string;
  14521. };
  14522. }
  14523. declare module BABYLON {
  14524. /** @hidden */
  14525. export var clipPlaneVertexDeclaration: {
  14526. name: string;
  14527. shader: string;
  14528. };
  14529. }
  14530. declare module BABYLON {
  14531. /** @hidden */
  14532. export var clipPlaneVertex: {
  14533. name: string;
  14534. shader: string;
  14535. };
  14536. }
  14537. declare module BABYLON {
  14538. /** @hidden */
  14539. export var particlesVertexShader: {
  14540. name: string;
  14541. shader: string;
  14542. };
  14543. }
  14544. declare module BABYLON {
  14545. /**
  14546. * This represents a particle system in Babylon.
  14547. * 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.
  14548. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14549. * @example https://doc.babylonjs.com/babylon101/particles
  14550. */
  14551. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14552. /**
  14553. * Billboard mode will only apply to Y axis
  14554. */
  14555. static readonly BILLBOARDMODE_Y: number;
  14556. /**
  14557. * Billboard mode will apply to all axes
  14558. */
  14559. static readonly BILLBOARDMODE_ALL: number;
  14560. /**
  14561. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14562. */
  14563. static readonly BILLBOARDMODE_STRETCHED: number;
  14564. /**
  14565. * This function can be defined to provide custom update for active particles.
  14566. * This function will be called instead of regular update (age, position, color, etc.).
  14567. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14568. */
  14569. updateFunction: (particles: Particle[]) => void;
  14570. private _emitterWorldMatrix;
  14571. /**
  14572. * This function can be defined to specify initial direction for every new particle.
  14573. * It by default use the emitterType defined function
  14574. */
  14575. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14576. /**
  14577. * This function can be defined to specify initial position for every new particle.
  14578. * It by default use the emitterType defined function
  14579. */
  14580. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14581. /**
  14582. * @hidden
  14583. */
  14584. _inheritedVelocityOffset: Vector3;
  14585. /**
  14586. * An event triggered when the system is disposed
  14587. */
  14588. onDisposeObservable: Observable<ParticleSystem>;
  14589. private _onDisposeObserver;
  14590. /**
  14591. * Sets a callback that will be triggered when the system is disposed
  14592. */
  14593. onDispose: () => void;
  14594. private _particles;
  14595. private _epsilon;
  14596. private _capacity;
  14597. private _stockParticles;
  14598. private _newPartsExcess;
  14599. private _vertexData;
  14600. private _vertexBuffer;
  14601. private _vertexBuffers;
  14602. private _spriteBuffer;
  14603. private _indexBuffer;
  14604. private _effect;
  14605. private _customEffect;
  14606. private _cachedDefines;
  14607. private _scaledColorStep;
  14608. private _colorDiff;
  14609. private _scaledDirection;
  14610. private _scaledGravity;
  14611. private _currentRenderId;
  14612. private _alive;
  14613. private _useInstancing;
  14614. private _started;
  14615. private _stopped;
  14616. private _actualFrame;
  14617. private _scaledUpdateSpeed;
  14618. private _vertexBufferSize;
  14619. /** @hidden */
  14620. _currentEmitRateGradient: Nullable<FactorGradient>;
  14621. /** @hidden */
  14622. _currentEmitRate1: number;
  14623. /** @hidden */
  14624. _currentEmitRate2: number;
  14625. /** @hidden */
  14626. _currentStartSizeGradient: Nullable<FactorGradient>;
  14627. /** @hidden */
  14628. _currentStartSize1: number;
  14629. /** @hidden */
  14630. _currentStartSize2: number;
  14631. private readonly _rawTextureWidth;
  14632. private _rampGradientsTexture;
  14633. private _useRampGradients;
  14634. /** Gets or sets a boolean indicating that ramp gradients must be used
  14635. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14636. */
  14637. useRampGradients: boolean;
  14638. /**
  14639. * 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.
  14640. * 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: [])
  14641. */
  14642. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14643. private _subEmitters;
  14644. /**
  14645. * @hidden
  14646. * If the particle systems emitter should be disposed when the particle system is disposed
  14647. */
  14648. _disposeEmitterOnDispose: boolean;
  14649. /**
  14650. * The current active Sub-systems, this property is used by the root particle system only.
  14651. */
  14652. activeSubSystems: Array<ParticleSystem>;
  14653. private _rootParticleSystem;
  14654. /**
  14655. * Gets the current list of active particles
  14656. */
  14657. readonly particles: Particle[];
  14658. /**
  14659. * Returns the string "ParticleSystem"
  14660. * @returns a string containing the class name
  14661. */
  14662. getClassName(): string;
  14663. /**
  14664. * Instantiates a particle system.
  14665. * 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.
  14666. * @param name The name of the particle system
  14667. * @param capacity The max number of particles alive at the same time
  14668. * @param scene The scene the particle system belongs to
  14669. * @param customEffect a custom effect used to change the way particles are rendered by default
  14670. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14671. * @param epsilon Offset used to render the particles
  14672. */
  14673. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14674. private _addFactorGradient;
  14675. private _removeFactorGradient;
  14676. /**
  14677. * Adds a new life time gradient
  14678. * @param gradient defines the gradient to use (between 0 and 1)
  14679. * @param factor defines the life time factor to affect to the specified gradient
  14680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14681. * @returns the current particle system
  14682. */
  14683. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14684. /**
  14685. * Remove a specific life time gradient
  14686. * @param gradient defines the gradient to remove
  14687. * @returns the current particle system
  14688. */
  14689. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14690. /**
  14691. * Adds a new size gradient
  14692. * @param gradient defines the gradient to use (between 0 and 1)
  14693. * @param factor defines the size factor to affect to the specified gradient
  14694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14695. * @returns the current particle system
  14696. */
  14697. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14698. /**
  14699. * Remove a specific size gradient
  14700. * @param gradient defines the gradient to remove
  14701. * @returns the current particle system
  14702. */
  14703. removeSizeGradient(gradient: number): IParticleSystem;
  14704. /**
  14705. * Adds a new color remap gradient
  14706. * @param gradient defines the gradient to use (between 0 and 1)
  14707. * @param min defines the color remap minimal range
  14708. * @param max defines the color remap maximal range
  14709. * @returns the current particle system
  14710. */
  14711. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14712. /**
  14713. * Remove a specific color remap gradient
  14714. * @param gradient defines the gradient to remove
  14715. * @returns the current particle system
  14716. */
  14717. removeColorRemapGradient(gradient: number): IParticleSystem;
  14718. /**
  14719. * Adds a new alpha remap gradient
  14720. * @param gradient defines the gradient to use (between 0 and 1)
  14721. * @param min defines the alpha remap minimal range
  14722. * @param max defines the alpha remap maximal range
  14723. * @returns the current particle system
  14724. */
  14725. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14726. /**
  14727. * Remove a specific alpha remap gradient
  14728. * @param gradient defines the gradient to remove
  14729. * @returns the current particle system
  14730. */
  14731. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14732. /**
  14733. * Adds a new angular speed gradient
  14734. * @param gradient defines the gradient to use (between 0 and 1)
  14735. * @param factor defines the angular speed to affect to the specified gradient
  14736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14737. * @returns the current particle system
  14738. */
  14739. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14740. /**
  14741. * Remove a specific angular speed gradient
  14742. * @param gradient defines the gradient to remove
  14743. * @returns the current particle system
  14744. */
  14745. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14746. /**
  14747. * Adds a new velocity gradient
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param factor defines the velocity to affect to the specified gradient
  14750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14751. * @returns the current particle system
  14752. */
  14753. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14754. /**
  14755. * Remove a specific velocity gradient
  14756. * @param gradient defines the gradient to remove
  14757. * @returns the current particle system
  14758. */
  14759. removeVelocityGradient(gradient: number): IParticleSystem;
  14760. /**
  14761. * Adds a new limit velocity gradient
  14762. * @param gradient defines the gradient to use (between 0 and 1)
  14763. * @param factor defines the limit velocity value to affect to the specified gradient
  14764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14765. * @returns the current particle system
  14766. */
  14767. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14768. /**
  14769. * Remove a specific limit velocity gradient
  14770. * @param gradient defines the gradient to remove
  14771. * @returns the current particle system
  14772. */
  14773. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14774. /**
  14775. * Adds a new drag gradient
  14776. * @param gradient defines the gradient to use (between 0 and 1)
  14777. * @param factor defines the drag value to affect to the specified gradient
  14778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14779. * @returns the current particle system
  14780. */
  14781. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14782. /**
  14783. * Remove a specific drag gradient
  14784. * @param gradient defines the gradient to remove
  14785. * @returns the current particle system
  14786. */
  14787. removeDragGradient(gradient: number): IParticleSystem;
  14788. /**
  14789. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14790. * @param gradient defines the gradient to use (between 0 and 1)
  14791. * @param factor defines the emit rate value to affect to the specified gradient
  14792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14793. * @returns the current particle system
  14794. */
  14795. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14796. /**
  14797. * Remove a specific emit rate gradient
  14798. * @param gradient defines the gradient to remove
  14799. * @returns the current particle system
  14800. */
  14801. removeEmitRateGradient(gradient: number): IParticleSystem;
  14802. /**
  14803. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14804. * @param gradient defines the gradient to use (between 0 and 1)
  14805. * @param factor defines the start size value to affect to the specified gradient
  14806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14807. * @returns the current particle system
  14808. */
  14809. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14810. /**
  14811. * Remove a specific start size gradient
  14812. * @param gradient defines the gradient to remove
  14813. * @returns the current particle system
  14814. */
  14815. removeStartSizeGradient(gradient: number): IParticleSystem;
  14816. private _createRampGradientTexture;
  14817. /**
  14818. * Gets the current list of ramp gradients.
  14819. * You must use addRampGradient and removeRampGradient to udpate this list
  14820. * @returns the list of ramp gradients
  14821. */
  14822. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14823. /**
  14824. * Adds a new ramp gradient used to remap particle colors
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param color defines the color to affect to the specified gradient
  14827. * @returns the current particle system
  14828. */
  14829. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14830. /**
  14831. * Remove a specific ramp gradient
  14832. * @param gradient defines the gradient to remove
  14833. * @returns the current particle system
  14834. */
  14835. removeRampGradient(gradient: number): ParticleSystem;
  14836. /**
  14837. * Adds a new color gradient
  14838. * @param gradient defines the gradient to use (between 0 and 1)
  14839. * @param color1 defines the color to affect to the specified gradient
  14840. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14841. * @returns this particle system
  14842. */
  14843. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14844. /**
  14845. * Remove a specific color gradient
  14846. * @param gradient defines the gradient to remove
  14847. * @returns this particle system
  14848. */
  14849. removeColorGradient(gradient: number): IParticleSystem;
  14850. private _fetchR;
  14851. protected _reset(): void;
  14852. private _resetEffect;
  14853. private _createVertexBuffers;
  14854. private _createIndexBuffer;
  14855. /**
  14856. * Gets the maximum number of particles active at the same time.
  14857. * @returns The max number of active particles.
  14858. */
  14859. getCapacity(): number;
  14860. /**
  14861. * Gets whether there are still active particles in the system.
  14862. * @returns True if it is alive, otherwise false.
  14863. */
  14864. isAlive(): boolean;
  14865. /**
  14866. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14867. * @returns True if it has been started, otherwise false.
  14868. */
  14869. isStarted(): boolean;
  14870. private _prepareSubEmitterInternalArray;
  14871. /**
  14872. * Starts the particle system and begins to emit
  14873. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14874. */
  14875. start(delay?: number): void;
  14876. /**
  14877. * Stops the particle system.
  14878. * @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.
  14879. */
  14880. stop(stopSubEmitters?: boolean): void;
  14881. /**
  14882. * Remove all active particles
  14883. */
  14884. reset(): void;
  14885. /**
  14886. * @hidden (for internal use only)
  14887. */
  14888. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14889. /**
  14890. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14891. * Its lifetime will start back at 0.
  14892. */
  14893. recycleParticle: (particle: Particle) => void;
  14894. private _stopSubEmitters;
  14895. private _createParticle;
  14896. private _removeFromRoot;
  14897. private _emitFromParticle;
  14898. private _update;
  14899. /** @hidden */
  14900. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14901. /** @hidden */
  14902. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14903. /** @hidden */
  14904. private _getEffect;
  14905. /**
  14906. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14907. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14908. */
  14909. animate(preWarmOnly?: boolean): void;
  14910. private _appendParticleVertices;
  14911. /**
  14912. * Rebuilds the particle system.
  14913. */
  14914. rebuild(): void;
  14915. /**
  14916. * Is this system ready to be used/rendered
  14917. * @return true if the system is ready
  14918. */
  14919. isReady(): boolean;
  14920. private _render;
  14921. /**
  14922. * Renders the particle system in its current state.
  14923. * @returns the current number of particles
  14924. */
  14925. render(): number;
  14926. /**
  14927. * Disposes the particle system and free the associated resources
  14928. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14929. */
  14930. dispose(disposeTexture?: boolean): void;
  14931. /**
  14932. * Clones the particle system.
  14933. * @param name The name of the cloned object
  14934. * @param newEmitter The new emitter to use
  14935. * @returns the cloned particle system
  14936. */
  14937. clone(name: string, newEmitter: any): ParticleSystem;
  14938. /**
  14939. * Serializes the particle system to a JSON object.
  14940. * @returns the JSON object
  14941. */
  14942. serialize(): any;
  14943. /** @hidden */
  14944. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14945. /** @hidden */
  14946. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14947. /**
  14948. * Parses a JSON object to create a particle system.
  14949. * @param parsedParticleSystem The JSON object to parse
  14950. * @param scene The scene to create the particle system in
  14951. * @param rootUrl The root url to use to load external dependencies like texture
  14952. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14953. * @returns the Parsed particle system
  14954. */
  14955. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14956. }
  14957. }
  14958. declare module BABYLON {
  14959. /**
  14960. * A particle represents one of the element emitted by a particle system.
  14961. * This is mainly define by its coordinates, direction, velocity and age.
  14962. */
  14963. export class Particle {
  14964. /**
  14965. * The particle system the particle belongs to.
  14966. */
  14967. particleSystem: ParticleSystem;
  14968. private static _Count;
  14969. /**
  14970. * Unique ID of the particle
  14971. */
  14972. id: number;
  14973. /**
  14974. * The world position of the particle in the scene.
  14975. */
  14976. position: Vector3;
  14977. /**
  14978. * The world direction of the particle in the scene.
  14979. */
  14980. direction: Vector3;
  14981. /**
  14982. * The color of the particle.
  14983. */
  14984. color: Color4;
  14985. /**
  14986. * The color change of the particle per step.
  14987. */
  14988. colorStep: Color4;
  14989. /**
  14990. * Defines how long will the life of the particle be.
  14991. */
  14992. lifeTime: number;
  14993. /**
  14994. * The current age of the particle.
  14995. */
  14996. age: number;
  14997. /**
  14998. * The current size of the particle.
  14999. */
  15000. size: number;
  15001. /**
  15002. * The current scale of the particle.
  15003. */
  15004. scale: Vector2;
  15005. /**
  15006. * The current angle of the particle.
  15007. */
  15008. angle: number;
  15009. /**
  15010. * Defines how fast is the angle changing.
  15011. */
  15012. angularSpeed: number;
  15013. /**
  15014. * Defines the cell index used by the particle to be rendered from a sprite.
  15015. */
  15016. cellIndex: number;
  15017. /**
  15018. * The information required to support color remapping
  15019. */
  15020. remapData: Vector4;
  15021. /** @hidden */
  15022. _randomCellOffset?: number;
  15023. /** @hidden */
  15024. _initialDirection: Nullable<Vector3>;
  15025. /** @hidden */
  15026. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15027. /** @hidden */
  15028. _initialStartSpriteCellID: number;
  15029. /** @hidden */
  15030. _initialEndSpriteCellID: number;
  15031. /** @hidden */
  15032. _currentColorGradient: Nullable<ColorGradient>;
  15033. /** @hidden */
  15034. _currentColor1: Color4;
  15035. /** @hidden */
  15036. _currentColor2: Color4;
  15037. /** @hidden */
  15038. _currentSizeGradient: Nullable<FactorGradient>;
  15039. /** @hidden */
  15040. _currentSize1: number;
  15041. /** @hidden */
  15042. _currentSize2: number;
  15043. /** @hidden */
  15044. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15045. /** @hidden */
  15046. _currentAngularSpeed1: number;
  15047. /** @hidden */
  15048. _currentAngularSpeed2: number;
  15049. /** @hidden */
  15050. _currentVelocityGradient: Nullable<FactorGradient>;
  15051. /** @hidden */
  15052. _currentVelocity1: number;
  15053. /** @hidden */
  15054. _currentVelocity2: number;
  15055. /** @hidden */
  15056. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15057. /** @hidden */
  15058. _currentLimitVelocity1: number;
  15059. /** @hidden */
  15060. _currentLimitVelocity2: number;
  15061. /** @hidden */
  15062. _currentDragGradient: Nullable<FactorGradient>;
  15063. /** @hidden */
  15064. _currentDrag1: number;
  15065. /** @hidden */
  15066. _currentDrag2: number;
  15067. /** @hidden */
  15068. _randomNoiseCoordinates1: Vector3;
  15069. /** @hidden */
  15070. _randomNoiseCoordinates2: Vector3;
  15071. /**
  15072. * Creates a new instance Particle
  15073. * @param particleSystem the particle system the particle belongs to
  15074. */
  15075. constructor(
  15076. /**
  15077. * The particle system the particle belongs to.
  15078. */
  15079. particleSystem: ParticleSystem);
  15080. private updateCellInfoFromSystem;
  15081. /**
  15082. * Defines how the sprite cell index is updated for the particle
  15083. */
  15084. updateCellIndex(): void;
  15085. /** @hidden */
  15086. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15087. /** @hidden */
  15088. _inheritParticleInfoToSubEmitters(): void;
  15089. /** @hidden */
  15090. _reset(): void;
  15091. /**
  15092. * Copy the properties of particle to another one.
  15093. * @param other the particle to copy the information to.
  15094. */
  15095. copyTo(other: Particle): void;
  15096. }
  15097. }
  15098. declare module BABYLON {
  15099. /**
  15100. * Particle emitter represents a volume emitting particles.
  15101. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15102. */
  15103. export interface IParticleEmitterType {
  15104. /**
  15105. * Called by the particle System when the direction is computed for the created particle.
  15106. * @param worldMatrix is the world matrix of the particle system
  15107. * @param directionToUpdate is the direction vector to update with the result
  15108. * @param particle is the particle we are computed the direction for
  15109. */
  15110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15111. /**
  15112. * Called by the particle System when the position is computed for the created particle.
  15113. * @param worldMatrix is the world matrix of the particle system
  15114. * @param positionToUpdate is the position vector to update with the result
  15115. * @param particle is the particle we are computed the position for
  15116. */
  15117. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15118. /**
  15119. * Clones the current emitter and returns a copy of it
  15120. * @returns the new emitter
  15121. */
  15122. clone(): IParticleEmitterType;
  15123. /**
  15124. * Called by the GPUParticleSystem to setup the update shader
  15125. * @param effect defines the update shader
  15126. */
  15127. applyToShader(effect: Effect): void;
  15128. /**
  15129. * Returns a string to use to update the GPU particles update shader
  15130. * @returns the effect defines string
  15131. */
  15132. getEffectDefines(): string;
  15133. /**
  15134. * Returns a string representing the class name
  15135. * @returns a string containing the class name
  15136. */
  15137. getClassName(): string;
  15138. /**
  15139. * Serializes the particle system to a JSON object.
  15140. * @returns the JSON object
  15141. */
  15142. serialize(): any;
  15143. /**
  15144. * Parse properties from a JSON object
  15145. * @param serializationObject defines the JSON object
  15146. */
  15147. parse(serializationObject: any): void;
  15148. }
  15149. }
  15150. declare module BABYLON {
  15151. /**
  15152. * Particle emitter emitting particles from the inside of a box.
  15153. * It emits the particles randomly between 2 given directions.
  15154. */
  15155. export class BoxParticleEmitter implements IParticleEmitterType {
  15156. /**
  15157. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15158. */
  15159. direction1: Vector3;
  15160. /**
  15161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15162. */
  15163. direction2: Vector3;
  15164. /**
  15165. * 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.
  15166. */
  15167. minEmitBox: Vector3;
  15168. /**
  15169. * 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.
  15170. */
  15171. maxEmitBox: Vector3;
  15172. /**
  15173. * Creates a new instance BoxParticleEmitter
  15174. */
  15175. constructor();
  15176. /**
  15177. * Called by the particle System when the direction is computed for the created particle.
  15178. * @param worldMatrix is the world matrix of the particle system
  15179. * @param directionToUpdate is the direction vector to update with the result
  15180. * @param particle is the particle we are computed the direction for
  15181. */
  15182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15183. /**
  15184. * Called by the particle System when the position is computed for the created particle.
  15185. * @param worldMatrix is the world matrix of the particle system
  15186. * @param positionToUpdate is the position vector to update with the result
  15187. * @param particle is the particle we are computed the position for
  15188. */
  15189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15190. /**
  15191. * Clones the current emitter and returns a copy of it
  15192. * @returns the new emitter
  15193. */
  15194. clone(): BoxParticleEmitter;
  15195. /**
  15196. * Called by the GPUParticleSystem to setup the update shader
  15197. * @param effect defines the update shader
  15198. */
  15199. applyToShader(effect: Effect): void;
  15200. /**
  15201. * Returns a string to use to update the GPU particles update shader
  15202. * @returns a string containng the defines string
  15203. */
  15204. getEffectDefines(): string;
  15205. /**
  15206. * Returns the string "BoxParticleEmitter"
  15207. * @returns a string containing the class name
  15208. */
  15209. getClassName(): string;
  15210. /**
  15211. * Serializes the particle system to a JSON object.
  15212. * @returns the JSON object
  15213. */
  15214. serialize(): any;
  15215. /**
  15216. * Parse properties from a JSON object
  15217. * @param serializationObject defines the JSON object
  15218. */
  15219. parse(serializationObject: any): void;
  15220. }
  15221. }
  15222. declare module BABYLON {
  15223. /**
  15224. * Particle emitter emitting particles from the inside of a cone.
  15225. * It emits the particles alongside the cone volume from the base to the particle.
  15226. * The emission direction might be randomized.
  15227. */
  15228. export class ConeParticleEmitter implements IParticleEmitterType {
  15229. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15230. directionRandomizer: number;
  15231. private _radius;
  15232. private _angle;
  15233. private _height;
  15234. /**
  15235. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15236. */
  15237. radiusRange: number;
  15238. /**
  15239. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15240. */
  15241. heightRange: number;
  15242. /**
  15243. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15244. */
  15245. emitFromSpawnPointOnly: boolean;
  15246. /**
  15247. * Gets or sets the radius of the emission cone
  15248. */
  15249. radius: number;
  15250. /**
  15251. * Gets or sets the angle of the emission cone
  15252. */
  15253. angle: number;
  15254. private _buildHeight;
  15255. /**
  15256. * Creates a new instance ConeParticleEmitter
  15257. * @param radius the radius of the emission cone (1 by default)
  15258. * @param angle the cone base angle (PI by default)
  15259. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15260. */
  15261. constructor(radius?: number, angle?: number,
  15262. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15263. directionRandomizer?: number);
  15264. /**
  15265. * Called by the particle System when the direction is computed for the created particle.
  15266. * @param worldMatrix is the world matrix of the particle system
  15267. * @param directionToUpdate is the direction vector to update with the result
  15268. * @param particle is the particle we are computed the direction for
  15269. */
  15270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15271. /**
  15272. * Called by the particle System when the position is computed for the created particle.
  15273. * @param worldMatrix is the world matrix of the particle system
  15274. * @param positionToUpdate is the position vector to update with the result
  15275. * @param particle is the particle we are computed the position for
  15276. */
  15277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15278. /**
  15279. * Clones the current emitter and returns a copy of it
  15280. * @returns the new emitter
  15281. */
  15282. clone(): ConeParticleEmitter;
  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 "ConeParticleEmitter"
  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. * Particle emitter emitting particles from the inside of a cylinder.
  15313. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15314. */
  15315. export class CylinderParticleEmitter implements IParticleEmitterType {
  15316. /**
  15317. * The radius of the emission cylinder.
  15318. */
  15319. radius: number;
  15320. /**
  15321. * The height of the emission cylinder.
  15322. */
  15323. height: number;
  15324. /**
  15325. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15326. */
  15327. radiusRange: number;
  15328. /**
  15329. * How much to randomize the particle direction [0-1].
  15330. */
  15331. directionRandomizer: number;
  15332. /**
  15333. * Creates a new instance CylinderParticleEmitter
  15334. * @param radius the radius of the emission cylinder (1 by default)
  15335. * @param height the height of the emission cylinder (1 by default)
  15336. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15337. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15338. */
  15339. constructor(
  15340. /**
  15341. * The radius of the emission cylinder.
  15342. */
  15343. radius?: number,
  15344. /**
  15345. * The height of the emission cylinder.
  15346. */
  15347. height?: number,
  15348. /**
  15349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15350. */
  15351. radiusRange?: number,
  15352. /**
  15353. * How much to randomize the particle direction [0-1].
  15354. */
  15355. directionRandomizer?: number);
  15356. /**
  15357. * Called by the particle System when the direction is computed for the created particle.
  15358. * @param worldMatrix is the world matrix of the particle system
  15359. * @param directionToUpdate is the direction vector to update with the result
  15360. * @param particle is the particle we are computed the direction for
  15361. */
  15362. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15363. /**
  15364. * Called by the particle System when the position is computed for the created particle.
  15365. * @param worldMatrix is the world matrix of the particle system
  15366. * @param positionToUpdate is the position vector to update with the result
  15367. * @param particle is the particle we are computed the position for
  15368. */
  15369. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15370. /**
  15371. * Clones the current emitter and returns a copy of it
  15372. * @returns the new emitter
  15373. */
  15374. clone(): CylinderParticleEmitter;
  15375. /**
  15376. * Called by the GPUParticleSystem to setup the update shader
  15377. * @param effect defines the update shader
  15378. */
  15379. applyToShader(effect: Effect): void;
  15380. /**
  15381. * Returns a string to use to update the GPU particles update shader
  15382. * @returns a string containng the defines string
  15383. */
  15384. getEffectDefines(): string;
  15385. /**
  15386. * Returns the string "CylinderParticleEmitter"
  15387. * @returns a string containing the class name
  15388. */
  15389. getClassName(): string;
  15390. /**
  15391. * Serializes the particle system to a JSON object.
  15392. * @returns the JSON object
  15393. */
  15394. serialize(): any;
  15395. /**
  15396. * Parse properties from a JSON object
  15397. * @param serializationObject defines the JSON object
  15398. */
  15399. parse(serializationObject: any): void;
  15400. }
  15401. /**
  15402. * Particle emitter emitting particles from the inside of a cylinder.
  15403. * It emits the particles randomly between two vectors.
  15404. */
  15405. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15406. /**
  15407. * The min limit of the emission direction.
  15408. */
  15409. direction1: Vector3;
  15410. /**
  15411. * The max limit of the emission direction.
  15412. */
  15413. direction2: Vector3;
  15414. /**
  15415. * Creates a new instance CylinderDirectedParticleEmitter
  15416. * @param radius the radius of the emission cylinder (1 by default)
  15417. * @param height the height of the emission cylinder (1 by default)
  15418. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15419. * @param direction1 the min limit of the emission direction (up vector by default)
  15420. * @param direction2 the max limit of the emission direction (up vector by default)
  15421. */
  15422. constructor(radius?: number, height?: number, radiusRange?: number,
  15423. /**
  15424. * The min limit of the emission direction.
  15425. */
  15426. direction1?: Vector3,
  15427. /**
  15428. * The max limit of the emission direction.
  15429. */
  15430. direction2?: Vector3);
  15431. /**
  15432. * Called by the particle System when the direction is computed for the created particle.
  15433. * @param worldMatrix is the world matrix of the particle system
  15434. * @param directionToUpdate is the direction vector to update with the result
  15435. * @param particle is the particle we are computed the direction for
  15436. */
  15437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15438. /**
  15439. * Clones the current emitter and returns a copy of it
  15440. * @returns the new emitter
  15441. */
  15442. clone(): CylinderDirectedParticleEmitter;
  15443. /**
  15444. * Called by the GPUParticleSystem to setup the update shader
  15445. * @param effect defines the update shader
  15446. */
  15447. applyToShader(effect: Effect): void;
  15448. /**
  15449. * Returns a string to use to update the GPU particles update shader
  15450. * @returns a string containng the defines string
  15451. */
  15452. getEffectDefines(): string;
  15453. /**
  15454. * Returns the string "CylinderDirectedParticleEmitter"
  15455. * @returns a string containing the class name
  15456. */
  15457. getClassName(): string;
  15458. /**
  15459. * Serializes the particle system to a JSON object.
  15460. * @returns the JSON object
  15461. */
  15462. serialize(): any;
  15463. /**
  15464. * Parse properties from a JSON object
  15465. * @param serializationObject defines the JSON object
  15466. */
  15467. parse(serializationObject: any): void;
  15468. }
  15469. }
  15470. declare module BABYLON {
  15471. /**
  15472. * Particle emitter emitting particles from the inside of a hemisphere.
  15473. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15474. */
  15475. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15476. /**
  15477. * The radius of the emission hemisphere.
  15478. */
  15479. radius: number;
  15480. /**
  15481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15482. */
  15483. radiusRange: number;
  15484. /**
  15485. * How much to randomize the particle direction [0-1].
  15486. */
  15487. directionRandomizer: number;
  15488. /**
  15489. * Creates a new instance HemisphericParticleEmitter
  15490. * @param radius the radius of the emission hemisphere (1 by default)
  15491. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15492. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15493. */
  15494. constructor(
  15495. /**
  15496. * The radius of the emission hemisphere.
  15497. */
  15498. radius?: number,
  15499. /**
  15500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15501. */
  15502. radiusRange?: number,
  15503. /**
  15504. * How much to randomize the particle direction [0-1].
  15505. */
  15506. directionRandomizer?: number);
  15507. /**
  15508. * Called by the particle System when the direction is computed for the created particle.
  15509. * @param worldMatrix is the world matrix of the particle system
  15510. * @param directionToUpdate is the direction vector to update with the result
  15511. * @param particle is the particle we are computed the direction for
  15512. */
  15513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15514. /**
  15515. * Called by the particle System when the position is computed for the created particle.
  15516. * @param worldMatrix is the world matrix of the particle system
  15517. * @param positionToUpdate is the position vector to update with the result
  15518. * @param particle is the particle we are computed the position for
  15519. */
  15520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15521. /**
  15522. * Clones the current emitter and returns a copy of it
  15523. * @returns the new emitter
  15524. */
  15525. clone(): HemisphericParticleEmitter;
  15526. /**
  15527. * Called by the GPUParticleSystem to setup the update shader
  15528. * @param effect defines the update shader
  15529. */
  15530. applyToShader(effect: Effect): void;
  15531. /**
  15532. * Returns a string to use to update the GPU particles update shader
  15533. * @returns a string containng the defines string
  15534. */
  15535. getEffectDefines(): string;
  15536. /**
  15537. * Returns the string "HemisphericParticleEmitter"
  15538. * @returns a string containing the class name
  15539. */
  15540. getClassName(): string;
  15541. /**
  15542. * Serializes the particle system to a JSON object.
  15543. * @returns the JSON object
  15544. */
  15545. serialize(): any;
  15546. /**
  15547. * Parse properties from a JSON object
  15548. * @param serializationObject defines the JSON object
  15549. */
  15550. parse(serializationObject: any): void;
  15551. }
  15552. }
  15553. declare module BABYLON {
  15554. /**
  15555. * Particle emitter emitting particles from a point.
  15556. * It emits the particles randomly between 2 given directions.
  15557. */
  15558. export class PointParticleEmitter implements IParticleEmitterType {
  15559. /**
  15560. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15561. */
  15562. direction1: Vector3;
  15563. /**
  15564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15565. */
  15566. direction2: Vector3;
  15567. /**
  15568. * Creates a new instance PointParticleEmitter
  15569. */
  15570. constructor();
  15571. /**
  15572. * Called by the particle System when the direction is computed for the created particle.
  15573. * @param worldMatrix is the world matrix of the particle system
  15574. * @param directionToUpdate is the direction vector to update with the result
  15575. * @param particle is the particle we are computed the direction for
  15576. */
  15577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15578. /**
  15579. * Called by the particle System when the position is computed for the created particle.
  15580. * @param worldMatrix is the world matrix of the particle system
  15581. * @param positionToUpdate is the position vector to update with the result
  15582. * @param particle is the particle we are computed the position for
  15583. */
  15584. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15585. /**
  15586. * Clones the current emitter and returns a copy of it
  15587. * @returns the new emitter
  15588. */
  15589. clone(): PointParticleEmitter;
  15590. /**
  15591. * Called by the GPUParticleSystem to setup the update shader
  15592. * @param effect defines the update shader
  15593. */
  15594. applyToShader(effect: Effect): void;
  15595. /**
  15596. * Returns a string to use to update the GPU particles update shader
  15597. * @returns a string containng the defines string
  15598. */
  15599. getEffectDefines(): string;
  15600. /**
  15601. * Returns the string "PointParticleEmitter"
  15602. * @returns a string containing the class name
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Serializes the particle system to a JSON object.
  15607. * @returns the JSON object
  15608. */
  15609. serialize(): any;
  15610. /**
  15611. * Parse properties from a JSON object
  15612. * @param serializationObject defines the JSON object
  15613. */
  15614. parse(serializationObject: any): void;
  15615. }
  15616. }
  15617. declare module BABYLON {
  15618. /**
  15619. * Particle emitter emitting particles from the inside of a sphere.
  15620. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15621. */
  15622. export class SphereParticleEmitter implements IParticleEmitterType {
  15623. /**
  15624. * The radius of the emission sphere.
  15625. */
  15626. radius: number;
  15627. /**
  15628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15629. */
  15630. radiusRange: number;
  15631. /**
  15632. * How much to randomize the particle direction [0-1].
  15633. */
  15634. directionRandomizer: number;
  15635. /**
  15636. * Creates a new instance SphereParticleEmitter
  15637. * @param radius the radius of the emission sphere (1 by default)
  15638. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15639. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15640. */
  15641. constructor(
  15642. /**
  15643. * The radius of the emission sphere.
  15644. */
  15645. radius?: number,
  15646. /**
  15647. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15648. */
  15649. radiusRange?: number,
  15650. /**
  15651. * How much to randomize the particle direction [0-1].
  15652. */
  15653. directionRandomizer?: number);
  15654. /**
  15655. * Called by the particle System when the direction is computed for the created particle.
  15656. * @param worldMatrix is the world matrix of the particle system
  15657. * @param directionToUpdate is the direction vector to update with the result
  15658. * @param particle is the particle we are computed the direction for
  15659. */
  15660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15661. /**
  15662. * Called by the particle System when the position is computed for the created particle.
  15663. * @param worldMatrix is the world matrix of the particle system
  15664. * @param positionToUpdate is the position vector to update with the result
  15665. * @param particle is the particle we are computed the position for
  15666. */
  15667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15668. /**
  15669. * Clones the current emitter and returns a copy of it
  15670. * @returns the new emitter
  15671. */
  15672. clone(): SphereParticleEmitter;
  15673. /**
  15674. * Called by the GPUParticleSystem to setup the update shader
  15675. * @param effect defines the update shader
  15676. */
  15677. applyToShader(effect: Effect): void;
  15678. /**
  15679. * Returns a string to use to update the GPU particles update shader
  15680. * @returns a string containng the defines string
  15681. */
  15682. getEffectDefines(): string;
  15683. /**
  15684. * Returns the string "SphereParticleEmitter"
  15685. * @returns a string containing the class name
  15686. */
  15687. getClassName(): string;
  15688. /**
  15689. * Serializes the particle system to a JSON object.
  15690. * @returns the JSON object
  15691. */
  15692. serialize(): any;
  15693. /**
  15694. * Parse properties from a JSON object
  15695. * @param serializationObject defines the JSON object
  15696. */
  15697. parse(serializationObject: any): void;
  15698. }
  15699. /**
  15700. * Particle emitter emitting particles from the inside of a sphere.
  15701. * It emits the particles randomly between two vectors.
  15702. */
  15703. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15704. /**
  15705. * The min limit of the emission direction.
  15706. */
  15707. direction1: Vector3;
  15708. /**
  15709. * The max limit of the emission direction.
  15710. */
  15711. direction2: Vector3;
  15712. /**
  15713. * Creates a new instance SphereDirectedParticleEmitter
  15714. * @param radius the radius of the emission sphere (1 by default)
  15715. * @param direction1 the min limit of the emission direction (up vector by default)
  15716. * @param direction2 the max limit of the emission direction (up vector by default)
  15717. */
  15718. constructor(radius?: number,
  15719. /**
  15720. * The min limit of the emission direction.
  15721. */
  15722. direction1?: Vector3,
  15723. /**
  15724. * The max limit of the emission direction.
  15725. */
  15726. direction2?: Vector3);
  15727. /**
  15728. * Called by the particle System when the direction is computed for the created particle.
  15729. * @param worldMatrix is the world matrix of the particle system
  15730. * @param directionToUpdate is the direction vector to update with the result
  15731. * @param particle is the particle we are computed the direction for
  15732. */
  15733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15734. /**
  15735. * Clones the current emitter and returns a copy of it
  15736. * @returns the new emitter
  15737. */
  15738. clone(): SphereDirectedParticleEmitter;
  15739. /**
  15740. * Called by the GPUParticleSystem to setup the update shader
  15741. * @param effect defines the update shader
  15742. */
  15743. applyToShader(effect: Effect): void;
  15744. /**
  15745. * Returns a string to use to update the GPU particles update shader
  15746. * @returns a string containng the defines string
  15747. */
  15748. getEffectDefines(): string;
  15749. /**
  15750. * Returns the string "SphereDirectedParticleEmitter"
  15751. * @returns a string containing the class name
  15752. */
  15753. getClassName(): string;
  15754. /**
  15755. * Serializes the particle system to a JSON object.
  15756. * @returns the JSON object
  15757. */
  15758. serialize(): any;
  15759. /**
  15760. * Parse properties from a JSON object
  15761. * @param serializationObject defines the JSON object
  15762. */
  15763. parse(serializationObject: any): void;
  15764. }
  15765. }
  15766. declare module BABYLON {
  15767. /**
  15768. * Interface representing a particle system in Babylon.js.
  15769. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15770. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15771. */
  15772. export interface IParticleSystem {
  15773. /**
  15774. * List of animations used by the particle system.
  15775. */
  15776. animations: Animation[];
  15777. /**
  15778. * The id of the Particle system.
  15779. */
  15780. id: string;
  15781. /**
  15782. * The name of the Particle system.
  15783. */
  15784. name: string;
  15785. /**
  15786. * The emitter represents the Mesh or position we are attaching the particle system to.
  15787. */
  15788. emitter: Nullable<AbstractMesh | Vector3>;
  15789. /**
  15790. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15791. */
  15792. isBillboardBased: boolean;
  15793. /**
  15794. * The rendering group used by the Particle system to chose when to render.
  15795. */
  15796. renderingGroupId: number;
  15797. /**
  15798. * The layer mask we are rendering the particles through.
  15799. */
  15800. layerMask: number;
  15801. /**
  15802. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15803. */
  15804. updateSpeed: number;
  15805. /**
  15806. * The amount of time the particle system is running (depends of the overall update speed).
  15807. */
  15808. targetStopDuration: number;
  15809. /**
  15810. * The texture used to render each particle. (this can be a spritesheet)
  15811. */
  15812. particleTexture: Nullable<Texture>;
  15813. /**
  15814. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15815. */
  15816. blendMode: number;
  15817. /**
  15818. * Minimum life time of emitting particles.
  15819. */
  15820. minLifeTime: number;
  15821. /**
  15822. * Maximum life time of emitting particles.
  15823. */
  15824. maxLifeTime: number;
  15825. /**
  15826. * Minimum Size of emitting particles.
  15827. */
  15828. minSize: number;
  15829. /**
  15830. * Maximum Size of emitting particles.
  15831. */
  15832. maxSize: number;
  15833. /**
  15834. * Minimum scale of emitting particles on X axis.
  15835. */
  15836. minScaleX: number;
  15837. /**
  15838. * Maximum scale of emitting particles on X axis.
  15839. */
  15840. maxScaleX: number;
  15841. /**
  15842. * Minimum scale of emitting particles on Y axis.
  15843. */
  15844. minScaleY: number;
  15845. /**
  15846. * Maximum scale of emitting particles on Y axis.
  15847. */
  15848. maxScaleY: number;
  15849. /**
  15850. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15851. */
  15852. color1: Color4;
  15853. /**
  15854. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15855. */
  15856. color2: Color4;
  15857. /**
  15858. * Color the particle will have at the end of its lifetime.
  15859. */
  15860. colorDead: Color4;
  15861. /**
  15862. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15863. */
  15864. emitRate: number;
  15865. /**
  15866. * You can use gravity if you want to give an orientation to your particles.
  15867. */
  15868. gravity: Vector3;
  15869. /**
  15870. * Minimum power of emitting particles.
  15871. */
  15872. minEmitPower: number;
  15873. /**
  15874. * Maximum power of emitting particles.
  15875. */
  15876. maxEmitPower: number;
  15877. /**
  15878. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15879. */
  15880. minAngularSpeed: number;
  15881. /**
  15882. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15883. */
  15884. maxAngularSpeed: number;
  15885. /**
  15886. * Gets or sets the minimal initial rotation in radians.
  15887. */
  15888. minInitialRotation: number;
  15889. /**
  15890. * Gets or sets the maximal initial rotation in radians.
  15891. */
  15892. maxInitialRotation: number;
  15893. /**
  15894. * The particle emitter type defines the emitter used by the particle system.
  15895. * It can be for example box, sphere, or cone...
  15896. */
  15897. particleEmitterType: Nullable<IParticleEmitterType>;
  15898. /**
  15899. * Defines the delay in milliseconds before starting the system (0 by default)
  15900. */
  15901. startDelay: number;
  15902. /**
  15903. * 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
  15904. */
  15905. preWarmCycles: number;
  15906. /**
  15907. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15908. */
  15909. preWarmStepOffset: number;
  15910. /**
  15911. * 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)
  15912. */
  15913. spriteCellChangeSpeed: number;
  15914. /**
  15915. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15916. */
  15917. startSpriteCellID: number;
  15918. /**
  15919. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15920. */
  15921. endSpriteCellID: number;
  15922. /**
  15923. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15924. */
  15925. spriteCellWidth: number;
  15926. /**
  15927. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15928. */
  15929. spriteCellHeight: number;
  15930. /**
  15931. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15932. */
  15933. spriteRandomStartCell: boolean;
  15934. /**
  15935. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15936. */
  15937. isAnimationSheetEnabled: boolean;
  15938. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15939. translationPivot: Vector2;
  15940. /**
  15941. * Gets or sets a texture used to add random noise to particle positions
  15942. */
  15943. noiseTexture: Nullable<BaseTexture>;
  15944. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15945. noiseStrength: Vector3;
  15946. /**
  15947. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15948. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15949. */
  15950. billboardMode: number;
  15951. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15952. limitVelocityDamping: number;
  15953. /**
  15954. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15955. */
  15956. beginAnimationOnStart: boolean;
  15957. /**
  15958. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15959. */
  15960. beginAnimationFrom: number;
  15961. /**
  15962. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15963. */
  15964. beginAnimationTo: number;
  15965. /**
  15966. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15967. */
  15968. beginAnimationLoop: boolean;
  15969. /**
  15970. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15971. */
  15972. disposeOnStop: boolean;
  15973. /**
  15974. * Gets the maximum number of particles active at the same time.
  15975. * @returns The max number of active particles.
  15976. */
  15977. getCapacity(): number;
  15978. /**
  15979. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15980. * @returns True if it has been started, otherwise false.
  15981. */
  15982. isStarted(): boolean;
  15983. /**
  15984. * Animates the particle system for this frame.
  15985. */
  15986. animate(): void;
  15987. /**
  15988. * Renders the particle system in its current state.
  15989. * @returns the current number of particles
  15990. */
  15991. render(): number;
  15992. /**
  15993. * Dispose the particle system and frees its associated resources.
  15994. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15995. */
  15996. dispose(disposeTexture?: boolean): void;
  15997. /**
  15998. * Clones the particle system.
  15999. * @param name The name of the cloned object
  16000. * @param newEmitter The new emitter to use
  16001. * @returns the cloned particle system
  16002. */
  16003. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16004. /**
  16005. * Serializes the particle system to a JSON object.
  16006. * @returns the JSON object
  16007. */
  16008. serialize(): any;
  16009. /**
  16010. * Rebuild the particle system
  16011. */
  16012. rebuild(): void;
  16013. /**
  16014. * Starts the particle system and begins to emit
  16015. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16016. */
  16017. start(delay?: number): void;
  16018. /**
  16019. * Stops the particle system.
  16020. */
  16021. stop(): void;
  16022. /**
  16023. * Remove all active particles
  16024. */
  16025. reset(): void;
  16026. /**
  16027. * Is this system ready to be used/rendered
  16028. * @return true if the system is ready
  16029. */
  16030. isReady(): boolean;
  16031. /**
  16032. * Adds a new color gradient
  16033. * @param gradient defines the gradient to use (between 0 and 1)
  16034. * @param color1 defines the color to affect to the specified gradient
  16035. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16036. * @returns the current particle system
  16037. */
  16038. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16039. /**
  16040. * Remove a specific color gradient
  16041. * @param gradient defines the gradient to remove
  16042. * @returns the current particle system
  16043. */
  16044. removeColorGradient(gradient: number): IParticleSystem;
  16045. /**
  16046. * Adds a new size gradient
  16047. * @param gradient defines the gradient to use (between 0 and 1)
  16048. * @param factor defines the size factor to affect to the specified gradient
  16049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16050. * @returns the current particle system
  16051. */
  16052. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16053. /**
  16054. * Remove a specific size gradient
  16055. * @param gradient defines the gradient to remove
  16056. * @returns the current particle system
  16057. */
  16058. removeSizeGradient(gradient: number): IParticleSystem;
  16059. /**
  16060. * Gets the current list of color gradients.
  16061. * You must use addColorGradient and removeColorGradient to udpate this list
  16062. * @returns the list of color gradients
  16063. */
  16064. getColorGradients(): Nullable<Array<ColorGradient>>;
  16065. /**
  16066. * Gets the current list of size gradients.
  16067. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16068. * @returns the list of size gradients
  16069. */
  16070. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16071. /**
  16072. * Gets the current list of angular speed gradients.
  16073. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16074. * @returns the list of angular speed gradients
  16075. */
  16076. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16077. /**
  16078. * Adds a new angular speed gradient
  16079. * @param gradient defines the gradient to use (between 0 and 1)
  16080. * @param factor defines the angular speed to affect to the specified gradient
  16081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16082. * @returns the current particle system
  16083. */
  16084. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16085. /**
  16086. * Remove a specific angular speed gradient
  16087. * @param gradient defines the gradient to remove
  16088. * @returns the current particle system
  16089. */
  16090. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16091. /**
  16092. * Gets the current list of velocity gradients.
  16093. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16094. * @returns the list of velocity gradients
  16095. */
  16096. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16097. /**
  16098. * Adds a new velocity gradient
  16099. * @param gradient defines the gradient to use (between 0 and 1)
  16100. * @param factor defines the velocity to affect to the specified gradient
  16101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16102. * @returns the current particle system
  16103. */
  16104. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16105. /**
  16106. * Remove a specific velocity gradient
  16107. * @param gradient defines the gradient to remove
  16108. * @returns the current particle system
  16109. */
  16110. removeVelocityGradient(gradient: number): IParticleSystem;
  16111. /**
  16112. * Gets the current list of limit velocity gradients.
  16113. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16114. * @returns the list of limit velocity gradients
  16115. */
  16116. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16117. /**
  16118. * Adds a new limit velocity gradient
  16119. * @param gradient defines the gradient to use (between 0 and 1)
  16120. * @param factor defines the limit velocity to affect to the specified gradient
  16121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16122. * @returns the current particle system
  16123. */
  16124. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16125. /**
  16126. * Remove a specific limit velocity gradient
  16127. * @param gradient defines the gradient to remove
  16128. * @returns the current particle system
  16129. */
  16130. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16131. /**
  16132. * Adds a new drag gradient
  16133. * @param gradient defines the gradient to use (between 0 and 1)
  16134. * @param factor defines the drag to affect to the specified gradient
  16135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16136. * @returns the current particle system
  16137. */
  16138. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16139. /**
  16140. * Remove a specific drag gradient
  16141. * @param gradient defines the gradient to remove
  16142. * @returns the current particle system
  16143. */
  16144. removeDragGradient(gradient: number): IParticleSystem;
  16145. /**
  16146. * Gets the current list of drag gradients.
  16147. * You must use addDragGradient and removeDragGradient to udpate this list
  16148. * @returns the list of drag gradients
  16149. */
  16150. getDragGradients(): Nullable<Array<FactorGradient>>;
  16151. /**
  16152. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16153. * @param gradient defines the gradient to use (between 0 and 1)
  16154. * @param factor defines the emit rate to affect to the specified gradient
  16155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16156. * @returns the current particle system
  16157. */
  16158. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16159. /**
  16160. * Remove a specific emit rate gradient
  16161. * @param gradient defines the gradient to remove
  16162. * @returns the current particle system
  16163. */
  16164. removeEmitRateGradient(gradient: number): IParticleSystem;
  16165. /**
  16166. * Gets the current list of emit rate gradients.
  16167. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16168. * @returns the list of emit rate gradients
  16169. */
  16170. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16171. /**
  16172. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16173. * @param gradient defines the gradient to use (between 0 and 1)
  16174. * @param factor defines the start size to affect to the specified gradient
  16175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16176. * @returns the current particle system
  16177. */
  16178. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16179. /**
  16180. * Remove a specific start size gradient
  16181. * @param gradient defines the gradient to remove
  16182. * @returns the current particle system
  16183. */
  16184. removeStartSizeGradient(gradient: number): IParticleSystem;
  16185. /**
  16186. * Gets the current list of start size gradients.
  16187. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16188. * @returns the list of start size gradients
  16189. */
  16190. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16191. /**
  16192. * Adds a new life time gradient
  16193. * @param gradient defines the gradient to use (between 0 and 1)
  16194. * @param factor defines the life time factor to affect to the specified gradient
  16195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16196. * @returns the current particle system
  16197. */
  16198. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16199. /**
  16200. * Remove a specific life time gradient
  16201. * @param gradient defines the gradient to remove
  16202. * @returns the current particle system
  16203. */
  16204. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16205. /**
  16206. * Gets the current list of life time gradients.
  16207. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16208. * @returns the list of life time gradients
  16209. */
  16210. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16211. /**
  16212. * Gets the current list of color gradients.
  16213. * You must use addColorGradient and removeColorGradient to udpate this list
  16214. * @returns the list of color gradients
  16215. */
  16216. getColorGradients(): Nullable<Array<ColorGradient>>;
  16217. /**
  16218. * Adds a new ramp gradient used to remap particle colors
  16219. * @param gradient defines the gradient to use (between 0 and 1)
  16220. * @param color defines the color to affect to the specified gradient
  16221. * @returns the current particle system
  16222. */
  16223. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16224. /**
  16225. * Gets the current list of ramp gradients.
  16226. * You must use addRampGradient and removeRampGradient to udpate this list
  16227. * @returns the list of ramp gradients
  16228. */
  16229. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16230. /** Gets or sets a boolean indicating that ramp gradients must be used
  16231. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16232. */
  16233. useRampGradients: boolean;
  16234. /**
  16235. * Adds a new color remap gradient
  16236. * @param gradient defines the gradient to use (between 0 and 1)
  16237. * @param min defines the color remap minimal range
  16238. * @param max defines the color remap maximal range
  16239. * @returns the current particle system
  16240. */
  16241. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16242. /**
  16243. * Gets the current list of color remap gradients.
  16244. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16245. * @returns the list of color remap gradients
  16246. */
  16247. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16248. /**
  16249. * Adds a new alpha remap gradient
  16250. * @param gradient defines the gradient to use (between 0 and 1)
  16251. * @param min defines the alpha remap minimal range
  16252. * @param max defines the alpha remap maximal range
  16253. * @returns the current particle system
  16254. */
  16255. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16256. /**
  16257. * Gets the current list of alpha remap gradients.
  16258. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16259. * @returns the list of alpha remap gradients
  16260. */
  16261. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16262. /**
  16263. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16264. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16265. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16266. * @returns the emitter
  16267. */
  16268. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16269. /**
  16270. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16271. * @param radius The radius of the hemisphere to emit from
  16272. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16273. * @returns the emitter
  16274. */
  16275. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16276. /**
  16277. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16278. * @param radius The radius of the sphere to emit from
  16279. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16280. * @returns the emitter
  16281. */
  16282. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16283. /**
  16284. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16285. * @param radius The radius of the sphere to emit from
  16286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16288. * @returns the emitter
  16289. */
  16290. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16291. /**
  16292. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16293. * @param radius The radius of the emission cylinder
  16294. * @param height The height of the emission cylinder
  16295. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16296. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16297. * @returns the emitter
  16298. */
  16299. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16300. /**
  16301. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16302. * @param radius The radius of the cylinder to emit from
  16303. * @param height The height of the emission cylinder
  16304. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16307. * @returns the emitter
  16308. */
  16309. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16310. /**
  16311. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16312. * @param radius The radius of the cone to emit from
  16313. * @param angle The base angle of the cone
  16314. * @returns the emitter
  16315. */
  16316. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16317. /**
  16318. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16321. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16322. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16323. * @returns the emitter
  16324. */
  16325. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16326. /**
  16327. * Get hosting scene
  16328. * @returns the scene
  16329. */
  16330. getScene(): Scene;
  16331. }
  16332. }
  16333. declare module BABYLON {
  16334. /**
  16335. * Creates an instance based on a source mesh.
  16336. */
  16337. export class InstancedMesh extends AbstractMesh {
  16338. private _sourceMesh;
  16339. private _currentLOD;
  16340. /** @hidden */
  16341. _indexInSourceMeshInstanceArray: number;
  16342. constructor(name: string, source: Mesh);
  16343. /**
  16344. * Returns the string "InstancedMesh".
  16345. */
  16346. getClassName(): string;
  16347. /**
  16348. * If the source mesh receives shadows
  16349. */
  16350. readonly receiveShadows: boolean;
  16351. /**
  16352. * The material of the source mesh
  16353. */
  16354. readonly material: Nullable<Material>;
  16355. /**
  16356. * Visibility of the source mesh
  16357. */
  16358. readonly visibility: number;
  16359. /**
  16360. * Skeleton of the source mesh
  16361. */
  16362. readonly skeleton: Nullable<Skeleton>;
  16363. /**
  16364. * Rendering ground id of the source mesh
  16365. */
  16366. renderingGroupId: number;
  16367. /**
  16368. * Returns the total number of vertices (integer).
  16369. */
  16370. getTotalVertices(): number;
  16371. /**
  16372. * Returns a positive integer : the total number of indices in this mesh geometry.
  16373. * @returns the numner of indices or zero if the mesh has no geometry.
  16374. */
  16375. getTotalIndices(): number;
  16376. /**
  16377. * The source mesh of the instance
  16378. */
  16379. readonly sourceMesh: Mesh;
  16380. /**
  16381. * Is this node ready to be used/rendered
  16382. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16383. * @return {boolean} is it ready
  16384. */
  16385. isReady(completeCheck?: boolean): boolean;
  16386. /**
  16387. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16388. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16389. * @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.
  16390. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16391. */
  16392. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16393. /**
  16394. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16395. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16396. * The `data` are either a numeric array either a Float32Array.
  16397. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16398. * 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).
  16399. * Note that a new underlying VertexBuffer object is created each call.
  16400. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16401. *
  16402. * Possible `kind` values :
  16403. * - VertexBuffer.PositionKind
  16404. * - VertexBuffer.UVKind
  16405. * - VertexBuffer.UV2Kind
  16406. * - VertexBuffer.UV3Kind
  16407. * - VertexBuffer.UV4Kind
  16408. * - VertexBuffer.UV5Kind
  16409. * - VertexBuffer.UV6Kind
  16410. * - VertexBuffer.ColorKind
  16411. * - VertexBuffer.MatricesIndicesKind
  16412. * - VertexBuffer.MatricesIndicesExtraKind
  16413. * - VertexBuffer.MatricesWeightsKind
  16414. * - VertexBuffer.MatricesWeightsExtraKind
  16415. *
  16416. * Returns the Mesh.
  16417. */
  16418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16419. /**
  16420. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16421. * If the mesh has no geometry, it is simply returned as it is.
  16422. * The `data` are either a numeric array either a Float32Array.
  16423. * No new underlying VertexBuffer object is created.
  16424. * 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.
  16425. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16426. *
  16427. * Possible `kind` values :
  16428. * - VertexBuffer.PositionKind
  16429. * - VertexBuffer.UVKind
  16430. * - VertexBuffer.UV2Kind
  16431. * - VertexBuffer.UV3Kind
  16432. * - VertexBuffer.UV4Kind
  16433. * - VertexBuffer.UV5Kind
  16434. * - VertexBuffer.UV6Kind
  16435. * - VertexBuffer.ColorKind
  16436. * - VertexBuffer.MatricesIndicesKind
  16437. * - VertexBuffer.MatricesIndicesExtraKind
  16438. * - VertexBuffer.MatricesWeightsKind
  16439. * - VertexBuffer.MatricesWeightsExtraKind
  16440. *
  16441. * Returns the Mesh.
  16442. */
  16443. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16444. /**
  16445. * Sets the mesh indices.
  16446. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16447. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16448. * This method creates a new index buffer each call.
  16449. * Returns the Mesh.
  16450. */
  16451. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16452. /**
  16453. * Boolean : True if the mesh owns the requested kind of data.
  16454. */
  16455. isVerticesDataPresent(kind: string): boolean;
  16456. /**
  16457. * Returns an array of indices (IndicesArray).
  16458. */
  16459. getIndices(): Nullable<IndicesArray>;
  16460. readonly _positions: Nullable<Vector3[]>;
  16461. /**
  16462. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16463. * This means the mesh underlying bounding box and sphere are recomputed.
  16464. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16465. * @returns the current mesh
  16466. */
  16467. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16468. /** @hidden */
  16469. _preActivate(): InstancedMesh;
  16470. /** @hidden */
  16471. _activate(renderId: number): InstancedMesh;
  16472. /**
  16473. * Returns the current associated LOD AbstractMesh.
  16474. */
  16475. getLOD(camera: Camera): AbstractMesh;
  16476. /** @hidden */
  16477. _syncSubMeshes(): InstancedMesh;
  16478. /** @hidden */
  16479. _generatePointsArray(): boolean;
  16480. /**
  16481. * Creates a new InstancedMesh from the current mesh.
  16482. * - name (string) : the cloned mesh name
  16483. * - newParent (optional Node) : the optional Node to parent the clone to.
  16484. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16485. *
  16486. * Returns the clone.
  16487. */
  16488. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16489. /**
  16490. * Disposes the InstancedMesh.
  16491. * Returns nothing.
  16492. */
  16493. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16494. }
  16495. }
  16496. declare module BABYLON {
  16497. /**
  16498. * Defines the options associated with the creation of a shader material.
  16499. */
  16500. export interface IShaderMaterialOptions {
  16501. /**
  16502. * Does the material work in alpha blend mode
  16503. */
  16504. needAlphaBlending: boolean;
  16505. /**
  16506. * Does the material work in alpha test mode
  16507. */
  16508. needAlphaTesting: boolean;
  16509. /**
  16510. * The list of attribute names used in the shader
  16511. */
  16512. attributes: string[];
  16513. /**
  16514. * The list of unifrom names used in the shader
  16515. */
  16516. uniforms: string[];
  16517. /**
  16518. * The list of UBO names used in the shader
  16519. */
  16520. uniformBuffers: string[];
  16521. /**
  16522. * The list of sampler names used in the shader
  16523. */
  16524. samplers: string[];
  16525. /**
  16526. * The list of defines used in the shader
  16527. */
  16528. defines: string[];
  16529. }
  16530. /**
  16531. * 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.
  16532. *
  16533. * This returned material effects how the mesh will look based on the code in the shaders.
  16534. *
  16535. * @see http://doc.babylonjs.com/how_to/shader_material
  16536. */
  16537. export class ShaderMaterial extends Material {
  16538. private _shaderPath;
  16539. private _options;
  16540. private _textures;
  16541. private _textureArrays;
  16542. private _floats;
  16543. private _ints;
  16544. private _floatsArrays;
  16545. private _colors3;
  16546. private _colors3Arrays;
  16547. private _colors4;
  16548. private _vectors2;
  16549. private _vectors3;
  16550. private _vectors4;
  16551. private _matrices;
  16552. private _matrices3x3;
  16553. private _matrices2x2;
  16554. private _vectors2Arrays;
  16555. private _vectors3Arrays;
  16556. private _cachedWorldViewMatrix;
  16557. private _renderId;
  16558. /**
  16559. * Instantiate a new shader material.
  16560. * 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.
  16561. * This returned material effects how the mesh will look based on the code in the shaders.
  16562. * @see http://doc.babylonjs.com/how_to/shader_material
  16563. * @param name Define the name of the material in the scene
  16564. * @param scene Define the scene the material belongs to
  16565. * @param shaderPath Defines the route to the shader code in one of three ways:
  16566. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16567. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16568. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16569. * @param options Define the options used to create the shader
  16570. */
  16571. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16572. /**
  16573. * Gets the options used to compile the shader.
  16574. * They can be modified to trigger a new compilation
  16575. */
  16576. readonly options: IShaderMaterialOptions;
  16577. /**
  16578. * Gets the current class name of the material e.g. "ShaderMaterial"
  16579. * Mainly use in serialization.
  16580. * @returns the class name
  16581. */
  16582. getClassName(): string;
  16583. /**
  16584. * Specifies if the material will require alpha blending
  16585. * @returns a boolean specifying if alpha blending is needed
  16586. */
  16587. needAlphaBlending(): boolean;
  16588. /**
  16589. * Specifies if this material should be rendered in alpha test mode
  16590. * @returns a boolean specifying if an alpha test is needed.
  16591. */
  16592. needAlphaTesting(): boolean;
  16593. private _checkUniform;
  16594. /**
  16595. * Set a texture in the shader.
  16596. * @param name Define the name of the uniform samplers as defined in the shader
  16597. * @param texture Define the texture to bind to this sampler
  16598. * @return the material itself allowing "fluent" like uniform updates
  16599. */
  16600. setTexture(name: string, texture: Texture): ShaderMaterial;
  16601. /**
  16602. * Set a texture array in the shader.
  16603. * @param name Define the name of the uniform sampler array as defined in the shader
  16604. * @param textures Define the list of textures to bind to this sampler
  16605. * @return the material itself allowing "fluent" like uniform updates
  16606. */
  16607. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16608. /**
  16609. * Set a float in the shader.
  16610. * @param name Define the name of the uniform as defined in the shader
  16611. * @param value Define the value to give to the uniform
  16612. * @return the material itself allowing "fluent" like uniform updates
  16613. */
  16614. setFloat(name: string, value: number): ShaderMaterial;
  16615. /**
  16616. * Set a int in the shader.
  16617. * @param name Define the name of the uniform as defined in the shader
  16618. * @param value Define the value to give to the uniform
  16619. * @return the material itself allowing "fluent" like uniform updates
  16620. */
  16621. setInt(name: string, value: number): ShaderMaterial;
  16622. /**
  16623. * Set an array of floats in the shader.
  16624. * @param name Define the name of the uniform as defined in the shader
  16625. * @param value Define the value to give to the uniform
  16626. * @return the material itself allowing "fluent" like uniform updates
  16627. */
  16628. setFloats(name: string, value: number[]): ShaderMaterial;
  16629. /**
  16630. * Set a vec3 in the shader from a Color3.
  16631. * @param name Define the name of the uniform as defined in the shader
  16632. * @param value Define the value to give to the uniform
  16633. * @return the material itself allowing "fluent" like uniform updates
  16634. */
  16635. setColor3(name: string, value: Color3): ShaderMaterial;
  16636. /**
  16637. * Set a vec3 array in the shader from a Color3 array.
  16638. * @param name Define the name of the uniform as defined in the shader
  16639. * @param value Define the value to give to the uniform
  16640. * @return the material itself allowing "fluent" like uniform updates
  16641. */
  16642. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16643. /**
  16644. * Set a vec4 in the shader from a Color4.
  16645. * @param name Define the name of the uniform as defined in the shader
  16646. * @param value Define the value to give to the uniform
  16647. * @return the material itself allowing "fluent" like uniform updates
  16648. */
  16649. setColor4(name: string, value: Color4): ShaderMaterial;
  16650. /**
  16651. * Set a vec2 in the shader from a Vector2.
  16652. * @param name Define the name of the uniform as defined in the shader
  16653. * @param value Define the value to give to the uniform
  16654. * @return the material itself allowing "fluent" like uniform updates
  16655. */
  16656. setVector2(name: string, value: Vector2): ShaderMaterial;
  16657. /**
  16658. * Set a vec3 in the shader from a Vector3.
  16659. * @param name Define the name of the uniform as defined in the shader
  16660. * @param value Define the value to give to the uniform
  16661. * @return the material itself allowing "fluent" like uniform updates
  16662. */
  16663. setVector3(name: string, value: Vector3): ShaderMaterial;
  16664. /**
  16665. * Set a vec4 in the shader from a Vector4.
  16666. * @param name Define the name of the uniform as defined in the shader
  16667. * @param value Define the value to give to the uniform
  16668. * @return the material itself allowing "fluent" like uniform updates
  16669. */
  16670. setVector4(name: string, value: Vector4): ShaderMaterial;
  16671. /**
  16672. * Set a mat4 in the shader from a Matrix.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the material itself allowing "fluent" like uniform updates
  16676. */
  16677. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16678. /**
  16679. * Set a mat3 in the shader from a Float32Array.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the material itself allowing "fluent" like uniform updates
  16683. */
  16684. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16685. /**
  16686. * Set a mat2 in the shader from a Float32Array.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the material itself allowing "fluent" like uniform updates
  16690. */
  16691. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16692. /**
  16693. * Set a vec2 array in the shader from a number array.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the material itself allowing "fluent" like uniform updates
  16697. */
  16698. setArray2(name: string, value: number[]): ShaderMaterial;
  16699. /**
  16700. * Set a vec3 array in the shader from a number array.
  16701. * @param name Define the name of the uniform as defined in the shader
  16702. * @param value Define the value to give to the uniform
  16703. * @return the material itself allowing "fluent" like uniform updates
  16704. */
  16705. setArray3(name: string, value: number[]): ShaderMaterial;
  16706. private _checkCache;
  16707. /**
  16708. * Checks if the material is ready to render the requested mesh
  16709. * @param mesh Define the mesh to render
  16710. * @param useInstances Define whether or not the material is used with instances
  16711. * @returns true if ready, otherwise false
  16712. */
  16713. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16714. /**
  16715. * Binds the world matrix to the material
  16716. * @param world defines the world transformation matrix
  16717. */
  16718. bindOnlyWorldMatrix(world: Matrix): void;
  16719. /**
  16720. * Binds the material to the mesh
  16721. * @param world defines the world transformation matrix
  16722. * @param mesh defines the mesh to bind the material to
  16723. */
  16724. bind(world: Matrix, mesh?: Mesh): void;
  16725. /**
  16726. * Gets the active textures from the material
  16727. * @returns an array of textures
  16728. */
  16729. getActiveTextures(): BaseTexture[];
  16730. /**
  16731. * Specifies if the material uses a texture
  16732. * @param texture defines the texture to check against the material
  16733. * @returns a boolean specifying if the material uses the texture
  16734. */
  16735. hasTexture(texture: BaseTexture): boolean;
  16736. /**
  16737. * Makes a duplicate of the material, and gives it a new name
  16738. * @param name defines the new name for the duplicated material
  16739. * @returns the cloned material
  16740. */
  16741. clone(name: string): ShaderMaterial;
  16742. /**
  16743. * Disposes the material
  16744. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16745. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16746. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16747. */
  16748. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16749. /**
  16750. * Serializes this material in a JSON representation
  16751. * @returns the serialized material object
  16752. */
  16753. serialize(): any;
  16754. /**
  16755. * Creates a shader material from parsed shader material data
  16756. * @param source defines the JSON represnetation of the material
  16757. * @param scene defines the hosting scene
  16758. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16759. * @returns a new material
  16760. */
  16761. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16762. }
  16763. }
  16764. declare module BABYLON {
  16765. /** @hidden */
  16766. export var colorPixelShader: {
  16767. name: string;
  16768. shader: string;
  16769. };
  16770. }
  16771. declare module BABYLON {
  16772. /** @hidden */
  16773. export var colorVertexShader: {
  16774. name: string;
  16775. shader: string;
  16776. };
  16777. }
  16778. declare module BABYLON {
  16779. /**
  16780. * Line mesh
  16781. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16782. */
  16783. export class LinesMesh extends Mesh {
  16784. /**
  16785. * If vertex color should be applied to the mesh
  16786. */
  16787. useVertexColor?: boolean | undefined;
  16788. /**
  16789. * If vertex alpha should be applied to the mesh
  16790. */
  16791. useVertexAlpha?: boolean | undefined;
  16792. /**
  16793. * Color of the line (Default: White)
  16794. */
  16795. color: Color3;
  16796. /**
  16797. * Alpha of the line (Default: 1)
  16798. */
  16799. alpha: number;
  16800. /**
  16801. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16802. * This margin is expressed in world space coordinates, so its value may vary.
  16803. * Default value is 0.1
  16804. */
  16805. intersectionThreshold: number;
  16806. private _colorShader;
  16807. /**
  16808. * Creates a new LinesMesh
  16809. * @param name defines the name
  16810. * @param scene defines the hosting scene
  16811. * @param parent defines the parent mesh if any
  16812. * @param source defines the optional source LinesMesh used to clone data from
  16813. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16814. * When false, achieved by calling a clone(), also passing False.
  16815. * This will make creation of children, recursive.
  16816. * @param useVertexColor defines if this LinesMesh supports vertex color
  16817. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16818. */
  16819. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16820. /**
  16821. * If vertex color should be applied to the mesh
  16822. */
  16823. useVertexColor?: boolean | undefined,
  16824. /**
  16825. * If vertex alpha should be applied to the mesh
  16826. */
  16827. useVertexAlpha?: boolean | undefined);
  16828. private _addClipPlaneDefine;
  16829. private _removeClipPlaneDefine;
  16830. isReady(): boolean;
  16831. /**
  16832. * Returns the string "LineMesh"
  16833. */
  16834. getClassName(): string;
  16835. /**
  16836. * @hidden
  16837. */
  16838. /**
  16839. * @hidden
  16840. */
  16841. material: Material;
  16842. /**
  16843. * @hidden
  16844. */
  16845. readonly checkCollisions: boolean;
  16846. /** @hidden */
  16847. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16848. /** @hidden */
  16849. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16850. /**
  16851. * Disposes of the line mesh
  16852. * @param doNotRecurse If children should be disposed
  16853. */
  16854. dispose(doNotRecurse?: boolean): void;
  16855. /**
  16856. * Returns a new LineMesh object cloned from the current one.
  16857. */
  16858. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16859. /**
  16860. * Creates a new InstancedLinesMesh object from the mesh model.
  16861. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16862. * @param name defines the name of the new instance
  16863. * @returns a new InstancedLinesMesh
  16864. */
  16865. createInstance(name: string): InstancedLinesMesh;
  16866. }
  16867. /**
  16868. * Creates an instance based on a source LinesMesh
  16869. */
  16870. export class InstancedLinesMesh extends InstancedMesh {
  16871. /**
  16872. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16873. * This margin is expressed in world space coordinates, so its value may vary.
  16874. * Initilized with the intersectionThreshold value of the source LinesMesh
  16875. */
  16876. intersectionThreshold: number;
  16877. constructor(name: string, source: LinesMesh);
  16878. /**
  16879. * Returns the string "InstancedLinesMesh".
  16880. */
  16881. getClassName(): string;
  16882. }
  16883. }
  16884. declare module BABYLON {
  16885. /** @hidden */
  16886. export var linePixelShader: {
  16887. name: string;
  16888. shader: string;
  16889. };
  16890. }
  16891. declare module BABYLON {
  16892. /** @hidden */
  16893. export var lineVertexShader: {
  16894. name: string;
  16895. shader: string;
  16896. };
  16897. }
  16898. declare module BABYLON {
  16899. interface AbstractMesh {
  16900. /**
  16901. * Disables the mesh edge rendering mode
  16902. * @returns the currentAbstractMesh
  16903. */
  16904. disableEdgesRendering(): AbstractMesh;
  16905. /**
  16906. * Enables the edge rendering mode on the mesh.
  16907. * This mode makes the mesh edges visible
  16908. * @param epsilon defines the maximal distance between two angles to detect a face
  16909. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16910. * @returns the currentAbstractMesh
  16911. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16912. */
  16913. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16914. /**
  16915. * Gets the edgesRenderer associated with the mesh
  16916. */
  16917. edgesRenderer: Nullable<EdgesRenderer>;
  16918. }
  16919. interface LinesMesh {
  16920. /**
  16921. * Enables the edge rendering mode on the mesh.
  16922. * This mode makes the mesh edges visible
  16923. * @param epsilon defines the maximal distance between two angles to detect a face
  16924. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16925. * @returns the currentAbstractMesh
  16926. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16927. */
  16928. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16929. }
  16930. interface InstancedLinesMesh {
  16931. /**
  16932. * Enables the edge rendering mode on the mesh.
  16933. * This mode makes the mesh edges visible
  16934. * @param epsilon defines the maximal distance between two angles to detect a face
  16935. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16936. * @returns the current InstancedLinesMesh
  16937. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16938. */
  16939. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16940. }
  16941. /**
  16942. * Defines the minimum contract an Edges renderer should follow.
  16943. */
  16944. export interface IEdgesRenderer extends IDisposable {
  16945. /**
  16946. * Gets or sets a boolean indicating if the edgesRenderer is active
  16947. */
  16948. isEnabled: boolean;
  16949. /**
  16950. * Renders the edges of the attached mesh,
  16951. */
  16952. render(): void;
  16953. /**
  16954. * Checks wether or not the edges renderer is ready to render.
  16955. * @return true if ready, otherwise false.
  16956. */
  16957. isReady(): boolean;
  16958. }
  16959. /**
  16960. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16961. */
  16962. export class EdgesRenderer implements IEdgesRenderer {
  16963. /**
  16964. * Define the size of the edges with an orthographic camera
  16965. */
  16966. edgesWidthScalerForOrthographic: number;
  16967. /**
  16968. * Define the size of the edges with a perspective camera
  16969. */
  16970. edgesWidthScalerForPerspective: number;
  16971. protected _source: AbstractMesh;
  16972. protected _linesPositions: number[];
  16973. protected _linesNormals: number[];
  16974. protected _linesIndices: number[];
  16975. protected _epsilon: number;
  16976. protected _indicesCount: number;
  16977. protected _lineShader: ShaderMaterial;
  16978. protected _ib: WebGLBuffer;
  16979. protected _buffers: {
  16980. [key: string]: Nullable<VertexBuffer>;
  16981. };
  16982. protected _checkVerticesInsteadOfIndices: boolean;
  16983. private _meshRebuildObserver;
  16984. private _meshDisposeObserver;
  16985. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16986. isEnabled: boolean;
  16987. /**
  16988. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16989. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16990. * @param source Mesh used to create edges
  16991. * @param epsilon sum of angles in adjacency to check for edge
  16992. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16993. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16994. */
  16995. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16996. protected _prepareRessources(): void;
  16997. /** @hidden */
  16998. _rebuild(): void;
  16999. /**
  17000. * Releases the required resources for the edges renderer
  17001. */
  17002. dispose(): void;
  17003. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17004. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17005. /**
  17006. * Checks if the pair of p0 and p1 is en edge
  17007. * @param faceIndex
  17008. * @param edge
  17009. * @param faceNormals
  17010. * @param p0
  17011. * @param p1
  17012. * @private
  17013. */
  17014. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17015. /**
  17016. * push line into the position, normal and index buffer
  17017. * @protected
  17018. */
  17019. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17020. /**
  17021. * Generates lines edges from adjacencjes
  17022. * @private
  17023. */
  17024. _generateEdgesLines(): void;
  17025. /**
  17026. * Checks wether or not the edges renderer is ready to render.
  17027. * @return true if ready, otherwise false.
  17028. */
  17029. isReady(): boolean;
  17030. /**
  17031. * Renders the edges of the attached mesh,
  17032. */
  17033. render(): void;
  17034. }
  17035. /**
  17036. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17037. */
  17038. export class LineEdgesRenderer extends EdgesRenderer {
  17039. /**
  17040. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17041. * @param source LineMesh used to generate edges
  17042. * @param epsilon not important (specified angle for edge detection)
  17043. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17044. */
  17045. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17046. /**
  17047. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17048. */
  17049. _generateEdgesLines(): void;
  17050. }
  17051. }
  17052. declare module BABYLON {
  17053. /**
  17054. * This represents the object necessary to create a rendering group.
  17055. * This is exclusively used and created by the rendering manager.
  17056. * To modify the behavior, you use the available helpers in your scene or meshes.
  17057. * @hidden
  17058. */
  17059. export class RenderingGroup {
  17060. index: number;
  17061. private _scene;
  17062. private _opaqueSubMeshes;
  17063. private _transparentSubMeshes;
  17064. private _alphaTestSubMeshes;
  17065. private _depthOnlySubMeshes;
  17066. private _particleSystems;
  17067. private _spriteManagers;
  17068. private _opaqueSortCompareFn;
  17069. private _alphaTestSortCompareFn;
  17070. private _transparentSortCompareFn;
  17071. private _renderOpaque;
  17072. private _renderAlphaTest;
  17073. private _renderTransparent;
  17074. private _edgesRenderers;
  17075. onBeforeTransparentRendering: () => void;
  17076. /**
  17077. * Set the opaque sort comparison function.
  17078. * If null the sub meshes will be render in the order they were created
  17079. */
  17080. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17081. /**
  17082. * Set the alpha test sort comparison function.
  17083. * If null the sub meshes will be render in the order they were created
  17084. */
  17085. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17086. /**
  17087. * Set the transparent sort comparison function.
  17088. * If null the sub meshes will be render in the order they were created
  17089. */
  17090. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17091. /**
  17092. * Creates a new rendering group.
  17093. * @param index The rendering group index
  17094. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17095. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17096. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17097. */
  17098. 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>);
  17099. /**
  17100. * Render all the sub meshes contained in the group.
  17101. * @param customRenderFunction Used to override the default render behaviour of the group.
  17102. * @returns true if rendered some submeshes.
  17103. */
  17104. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17105. /**
  17106. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17107. * @param subMeshes The submeshes to render
  17108. */
  17109. private renderOpaqueSorted;
  17110. /**
  17111. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17112. * @param subMeshes The submeshes to render
  17113. */
  17114. private renderAlphaTestSorted;
  17115. /**
  17116. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17117. * @param subMeshes The submeshes to render
  17118. */
  17119. private renderTransparentSorted;
  17120. /**
  17121. * Renders the submeshes in a specified order.
  17122. * @param subMeshes The submeshes to sort before render
  17123. * @param sortCompareFn The comparison function use to sort
  17124. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17125. * @param transparent Specifies to activate blending if true
  17126. */
  17127. private static renderSorted;
  17128. /**
  17129. * Renders the submeshes in the order they were dispatched (no sort applied).
  17130. * @param subMeshes The submeshes to render
  17131. */
  17132. private static renderUnsorted;
  17133. /**
  17134. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17135. * are rendered back to front if in the same alpha index.
  17136. *
  17137. * @param a The first submesh
  17138. * @param b The second submesh
  17139. * @returns The result of the comparison
  17140. */
  17141. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17142. /**
  17143. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17144. * are rendered back to front.
  17145. *
  17146. * @param a The first submesh
  17147. * @param b The second submesh
  17148. * @returns The result of the comparison
  17149. */
  17150. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17151. /**
  17152. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17153. * are rendered front to back (prevent overdraw).
  17154. *
  17155. * @param a The first submesh
  17156. * @param b The second submesh
  17157. * @returns The result of the comparison
  17158. */
  17159. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17160. /**
  17161. * Resets the different lists of submeshes to prepare a new frame.
  17162. */
  17163. prepare(): void;
  17164. dispose(): void;
  17165. /**
  17166. * Inserts the submesh in its correct queue depending on its material.
  17167. * @param subMesh The submesh to dispatch
  17168. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17169. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17170. */
  17171. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17172. dispatchSprites(spriteManager: ISpriteManager): void;
  17173. dispatchParticles(particleSystem: IParticleSystem): void;
  17174. private _renderParticles;
  17175. private _renderSprites;
  17176. }
  17177. }
  17178. declare module BABYLON {
  17179. /**
  17180. * Interface describing the different options available in the rendering manager
  17181. * regarding Auto Clear between groups.
  17182. */
  17183. export interface IRenderingManagerAutoClearSetup {
  17184. /**
  17185. * Defines whether or not autoclear is enable.
  17186. */
  17187. autoClear: boolean;
  17188. /**
  17189. * Defines whether or not to autoclear the depth buffer.
  17190. */
  17191. depth: boolean;
  17192. /**
  17193. * Defines whether or not to autoclear the stencil buffer.
  17194. */
  17195. stencil: boolean;
  17196. }
  17197. /**
  17198. * This class is used by the onRenderingGroupObservable
  17199. */
  17200. export class RenderingGroupInfo {
  17201. /**
  17202. * The Scene that being rendered
  17203. */
  17204. scene: Scene;
  17205. /**
  17206. * The camera currently used for the rendering pass
  17207. */
  17208. camera: Nullable<Camera>;
  17209. /**
  17210. * The ID of the renderingGroup being processed
  17211. */
  17212. renderingGroupId: number;
  17213. }
  17214. /**
  17215. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17216. * It is enable to manage the different groups as well as the different necessary sort functions.
  17217. * This should not be used directly aside of the few static configurations
  17218. */
  17219. export class RenderingManager {
  17220. /**
  17221. * The max id used for rendering groups (not included)
  17222. */
  17223. static MAX_RENDERINGGROUPS: number;
  17224. /**
  17225. * The min id used for rendering groups (included)
  17226. */
  17227. static MIN_RENDERINGGROUPS: number;
  17228. /**
  17229. * Used to globally prevent autoclearing scenes.
  17230. */
  17231. static AUTOCLEAR: boolean;
  17232. /**
  17233. * @hidden
  17234. */
  17235. _useSceneAutoClearSetup: boolean;
  17236. private _scene;
  17237. private _renderingGroups;
  17238. private _depthStencilBufferAlreadyCleaned;
  17239. private _autoClearDepthStencil;
  17240. private _customOpaqueSortCompareFn;
  17241. private _customAlphaTestSortCompareFn;
  17242. private _customTransparentSortCompareFn;
  17243. private _renderingGroupInfo;
  17244. /**
  17245. * Instantiates a new rendering group for a particular scene
  17246. * @param scene Defines the scene the groups belongs to
  17247. */
  17248. constructor(scene: Scene);
  17249. private _clearDepthStencilBuffer;
  17250. /**
  17251. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17252. * @hidden
  17253. */
  17254. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17255. /**
  17256. * Resets the different information of the group to prepare a new frame
  17257. * @hidden
  17258. */
  17259. reset(): void;
  17260. /**
  17261. * Dispose and release the group and its associated resources.
  17262. * @hidden
  17263. */
  17264. dispose(): void;
  17265. /**
  17266. * Clear the info related to rendering groups preventing retention points during dispose.
  17267. */
  17268. freeRenderingGroups(): void;
  17269. private _prepareRenderingGroup;
  17270. /**
  17271. * Add a sprite manager to the rendering manager in order to render it this frame.
  17272. * @param spriteManager Define the sprite manager to render
  17273. */
  17274. dispatchSprites(spriteManager: ISpriteManager): void;
  17275. /**
  17276. * Add a particle system to the rendering manager in order to render it this frame.
  17277. * @param particleSystem Define the particle system to render
  17278. */
  17279. dispatchParticles(particleSystem: IParticleSystem): void;
  17280. /**
  17281. * Add a submesh to the manager in order to render it this frame
  17282. * @param subMesh The submesh to dispatch
  17283. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17284. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17285. */
  17286. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17287. /**
  17288. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17289. * This allowed control for front to back rendering or reversly depending of the special needs.
  17290. *
  17291. * @param renderingGroupId The rendering group id corresponding to its index
  17292. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17293. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17294. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17295. */
  17296. 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;
  17297. /**
  17298. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17299. *
  17300. * @param renderingGroupId The rendering group id corresponding to its index
  17301. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17302. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17303. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17304. */
  17305. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17306. /**
  17307. * Gets the current auto clear configuration for one rendering group of the rendering
  17308. * manager.
  17309. * @param index the rendering group index to get the information for
  17310. * @returns The auto clear setup for the requested rendering group
  17311. */
  17312. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17313. }
  17314. }
  17315. declare module BABYLON {
  17316. /**
  17317. * This Helps creating a texture that will be created from a camera in your scene.
  17318. * It is basically a dynamic texture that could be used to create special effects for instance.
  17319. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17320. */
  17321. export class RenderTargetTexture extends Texture {
  17322. isCube: boolean;
  17323. /**
  17324. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17325. */
  17326. static readonly REFRESHRATE_RENDER_ONCE: number;
  17327. /**
  17328. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17329. */
  17330. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17331. /**
  17332. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17333. * the central point of your effect and can save a lot of performances.
  17334. */
  17335. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17336. /**
  17337. * Use this predicate to dynamically define the list of mesh you want to render.
  17338. * If set, the renderList property will be overwritten.
  17339. */
  17340. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17341. private _renderList;
  17342. /**
  17343. * Use this list to define the list of mesh you want to render.
  17344. */
  17345. renderList: Nullable<Array<AbstractMesh>>;
  17346. private _hookArray;
  17347. /**
  17348. * Define if particles should be rendered in your texture.
  17349. */
  17350. renderParticles: boolean;
  17351. /**
  17352. * Define if sprites should be rendered in your texture.
  17353. */
  17354. renderSprites: boolean;
  17355. /**
  17356. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17357. */
  17358. coordinatesMode: number;
  17359. /**
  17360. * Define the camera used to render the texture.
  17361. */
  17362. activeCamera: Nullable<Camera>;
  17363. /**
  17364. * Override the render function of the texture with your own one.
  17365. */
  17366. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17367. /**
  17368. * Define if camera post processes should be use while rendering the texture.
  17369. */
  17370. useCameraPostProcesses: boolean;
  17371. /**
  17372. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17373. */
  17374. ignoreCameraViewport: boolean;
  17375. private _postProcessManager;
  17376. private _postProcesses;
  17377. private _resizeObserver;
  17378. /**
  17379. * An event triggered when the texture is unbind.
  17380. */
  17381. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17382. /**
  17383. * An event triggered when the texture is unbind.
  17384. */
  17385. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17386. private _onAfterUnbindObserver;
  17387. /**
  17388. * Set a after unbind callback in the texture.
  17389. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17390. */
  17391. onAfterUnbind: () => void;
  17392. /**
  17393. * An event triggered before rendering the texture
  17394. */
  17395. onBeforeRenderObservable: Observable<number>;
  17396. private _onBeforeRenderObserver;
  17397. /**
  17398. * Set a before render callback in the texture.
  17399. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17400. */
  17401. onBeforeRender: (faceIndex: number) => void;
  17402. /**
  17403. * An event triggered after rendering the texture
  17404. */
  17405. onAfterRenderObservable: Observable<number>;
  17406. private _onAfterRenderObserver;
  17407. /**
  17408. * Set a after render callback in the texture.
  17409. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17410. */
  17411. onAfterRender: (faceIndex: number) => void;
  17412. /**
  17413. * An event triggered after the texture clear
  17414. */
  17415. onClearObservable: Observable<Engine>;
  17416. private _onClearObserver;
  17417. /**
  17418. * Set a clear callback in the texture.
  17419. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17420. */
  17421. onClear: (Engine: Engine) => void;
  17422. /**
  17423. * Define the clear color of the Render Target if it should be different from the scene.
  17424. */
  17425. clearColor: Color4;
  17426. protected _size: number | {
  17427. width: number;
  17428. height: number;
  17429. };
  17430. protected _initialSizeParameter: number | {
  17431. width: number;
  17432. height: number;
  17433. } | {
  17434. ratio: number;
  17435. };
  17436. protected _sizeRatio: Nullable<number>;
  17437. /** @hidden */
  17438. _generateMipMaps: boolean;
  17439. protected _renderingManager: RenderingManager;
  17440. /** @hidden */
  17441. _waitingRenderList: string[];
  17442. protected _doNotChangeAspectRatio: boolean;
  17443. protected _currentRefreshId: number;
  17444. protected _refreshRate: number;
  17445. protected _textureMatrix: Matrix;
  17446. protected _samples: number;
  17447. protected _renderTargetOptions: RenderTargetCreationOptions;
  17448. /**
  17449. * Gets render target creation options that were used.
  17450. */
  17451. readonly renderTargetOptions: RenderTargetCreationOptions;
  17452. protected _engine: Engine;
  17453. protected _onRatioRescale(): void;
  17454. /**
  17455. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17456. * It must define where the camera used to render the texture is set
  17457. */
  17458. boundingBoxPosition: Vector3;
  17459. private _boundingBoxSize;
  17460. /**
  17461. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17462. * When defined, the cubemap will switch to local mode
  17463. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17464. * @example https://www.babylonjs-playground.com/#RNASML
  17465. */
  17466. boundingBoxSize: Vector3;
  17467. /**
  17468. * In case the RTT has been created with a depth texture, get the associated
  17469. * depth texture.
  17470. * Otherwise, return null.
  17471. */
  17472. depthStencilTexture: Nullable<InternalTexture>;
  17473. /**
  17474. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17475. * or used a shadow, depth texture...
  17476. * @param name The friendly name of the texture
  17477. * @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)
  17478. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17479. * @param generateMipMaps True if mip maps need to be generated after render.
  17480. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17481. * @param type The type of the buffer in the RTT (int, half float, float...)
  17482. * @param isCube True if a cube texture needs to be created
  17483. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17484. * @param generateDepthBuffer True to generate a depth buffer
  17485. * @param generateStencilBuffer True to generate a stencil buffer
  17486. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17487. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17488. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17489. */
  17490. constructor(name: string, size: number | {
  17491. width: number;
  17492. height: number;
  17493. } | {
  17494. ratio: number;
  17495. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17496. /**
  17497. * Creates a depth stencil texture.
  17498. * This is only available in WebGL 2 or with the depth texture extension available.
  17499. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17500. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17501. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17502. */
  17503. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17504. private _processSizeParameter;
  17505. /**
  17506. * Define the number of samples to use in case of MSAA.
  17507. * It defaults to one meaning no MSAA has been enabled.
  17508. */
  17509. samples: number;
  17510. /**
  17511. * Resets the refresh counter of the texture and start bak from scratch.
  17512. * Could be useful to regenerate the texture if it is setup to render only once.
  17513. */
  17514. resetRefreshCounter(): void;
  17515. /**
  17516. * Define the refresh rate of the texture or the rendering frequency.
  17517. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17518. */
  17519. refreshRate: number;
  17520. /**
  17521. * Adds a post process to the render target rendering passes.
  17522. * @param postProcess define the post process to add
  17523. */
  17524. addPostProcess(postProcess: PostProcess): void;
  17525. /**
  17526. * Clear all the post processes attached to the render target
  17527. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17528. */
  17529. clearPostProcesses(dispose?: boolean): void;
  17530. /**
  17531. * Remove one of the post process from the list of attached post processes to the texture
  17532. * @param postProcess define the post process to remove from the list
  17533. */
  17534. removePostProcess(postProcess: PostProcess): void;
  17535. /** @hidden */
  17536. _shouldRender(): boolean;
  17537. /**
  17538. * Gets the actual render size of the texture.
  17539. * @returns the width of the render size
  17540. */
  17541. getRenderSize(): number;
  17542. /**
  17543. * Gets the actual render width of the texture.
  17544. * @returns the width of the render size
  17545. */
  17546. getRenderWidth(): number;
  17547. /**
  17548. * Gets the actual render height of the texture.
  17549. * @returns the height of the render size
  17550. */
  17551. getRenderHeight(): number;
  17552. /**
  17553. * Get if the texture can be rescaled or not.
  17554. */
  17555. readonly canRescale: boolean;
  17556. /**
  17557. * Resize the texture using a ratio.
  17558. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17559. */
  17560. scale(ratio: number): void;
  17561. /**
  17562. * Get the texture reflection matrix used to rotate/transform the reflection.
  17563. * @returns the reflection matrix
  17564. */
  17565. getReflectionTextureMatrix(): Matrix;
  17566. /**
  17567. * Resize the texture to a new desired size.
  17568. * Be carrefull as it will recreate all the data in the new texture.
  17569. * @param size Define the new size. It can be:
  17570. * - a number for squared texture,
  17571. * - an object containing { width: number, height: number }
  17572. * - or an object containing a ratio { ratio: number }
  17573. */
  17574. resize(size: number | {
  17575. width: number;
  17576. height: number;
  17577. } | {
  17578. ratio: number;
  17579. }): void;
  17580. /**
  17581. * Renders all the objects from the render list into the texture.
  17582. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17583. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17584. */
  17585. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17586. private _bestReflectionRenderTargetDimension;
  17587. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17588. private renderToTarget;
  17589. /**
  17590. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17591. * This allowed control for front to back rendering or reversly depending of the special needs.
  17592. *
  17593. * @param renderingGroupId The rendering group id corresponding to its index
  17594. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17595. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17596. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17597. */
  17598. 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;
  17599. /**
  17600. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17601. *
  17602. * @param renderingGroupId The rendering group id corresponding to its index
  17603. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17604. */
  17605. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17606. /**
  17607. * Clones the texture.
  17608. * @returns the cloned texture
  17609. */
  17610. clone(): RenderTargetTexture;
  17611. /**
  17612. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17613. * @returns The JSON representation of the texture
  17614. */
  17615. serialize(): any;
  17616. /**
  17617. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17618. */
  17619. disposeFramebufferObjects(): void;
  17620. /**
  17621. * Dispose the texture and release its associated resources.
  17622. */
  17623. dispose(): void;
  17624. /** @hidden */
  17625. _rebuild(): void;
  17626. /**
  17627. * Clear the info related to rendering groups preventing retention point in material dispose.
  17628. */
  17629. freeRenderingGroups(): void;
  17630. }
  17631. }
  17632. declare module BABYLON {
  17633. /**
  17634. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17635. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17636. * You can then easily use it as a reflectionTexture on a flat surface.
  17637. * In case the surface is not a plane, please consider relying on reflection probes.
  17638. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17639. */
  17640. export class MirrorTexture extends RenderTargetTexture {
  17641. private scene;
  17642. /**
  17643. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17644. * 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.
  17645. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17646. */
  17647. mirrorPlane: Plane;
  17648. /**
  17649. * Define the blur ratio used to blur the reflection if needed.
  17650. */
  17651. blurRatio: number;
  17652. /**
  17653. * Define the adaptive blur kernel used to blur the reflection if needed.
  17654. * This will autocompute the closest best match for the `blurKernel`
  17655. */
  17656. adaptiveBlurKernel: number;
  17657. /**
  17658. * Define the blur kernel used to blur the reflection if needed.
  17659. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17660. */
  17661. blurKernel: number;
  17662. /**
  17663. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17664. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17665. */
  17666. blurKernelX: number;
  17667. /**
  17668. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17669. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17670. */
  17671. blurKernelY: number;
  17672. private _autoComputeBlurKernel;
  17673. protected _onRatioRescale(): void;
  17674. private _updateGammaSpace;
  17675. private _imageProcessingConfigChangeObserver;
  17676. private _transformMatrix;
  17677. private _mirrorMatrix;
  17678. private _savedViewMatrix;
  17679. private _blurX;
  17680. private _blurY;
  17681. private _adaptiveBlurKernel;
  17682. private _blurKernelX;
  17683. private _blurKernelY;
  17684. private _blurRatio;
  17685. /**
  17686. * Instantiates a Mirror Texture.
  17687. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17688. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17689. * You can then easily use it as a reflectionTexture on a flat surface.
  17690. * In case the surface is not a plane, please consider relying on reflection probes.
  17691. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17692. * @param name
  17693. * @param size
  17694. * @param scene
  17695. * @param generateMipMaps
  17696. * @param type
  17697. * @param samplingMode
  17698. * @param generateDepthBuffer
  17699. */
  17700. constructor(name: string, size: number | {
  17701. width: number;
  17702. height: number;
  17703. } | {
  17704. ratio: number;
  17705. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17706. private _preparePostProcesses;
  17707. /**
  17708. * Clone the mirror texture.
  17709. * @returns the cloned texture
  17710. */
  17711. clone(): MirrorTexture;
  17712. /**
  17713. * Serialize the texture to a JSON representation you could use in Parse later on
  17714. * @returns the serialized JSON representation
  17715. */
  17716. serialize(): any;
  17717. /**
  17718. * Dispose the texture and release its associated resources.
  17719. */
  17720. dispose(): void;
  17721. }
  17722. }
  17723. declare module BABYLON {
  17724. /**
  17725. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17726. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17727. */
  17728. export class Texture extends BaseTexture {
  17729. /** @hidden */
  17730. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17731. /** @hidden */
  17732. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17733. /** @hidden */
  17734. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17735. /** nearest is mag = nearest and min = nearest and mip = linear */
  17736. static readonly NEAREST_SAMPLINGMODE: number;
  17737. /** nearest is mag = nearest and min = nearest and mip = linear */
  17738. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17739. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17740. static readonly BILINEAR_SAMPLINGMODE: number;
  17741. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17742. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17743. /** Trilinear is mag = linear and min = linear and mip = linear */
  17744. static readonly TRILINEAR_SAMPLINGMODE: number;
  17745. /** Trilinear is mag = linear and min = linear and mip = linear */
  17746. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17747. /** mag = nearest and min = nearest and mip = nearest */
  17748. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17749. /** mag = nearest and min = linear and mip = nearest */
  17750. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17751. /** mag = nearest and min = linear and mip = linear */
  17752. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17753. /** mag = nearest and min = linear and mip = none */
  17754. static readonly NEAREST_LINEAR: number;
  17755. /** mag = nearest and min = nearest and mip = none */
  17756. static readonly NEAREST_NEAREST: number;
  17757. /** mag = linear and min = nearest and mip = nearest */
  17758. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17759. /** mag = linear and min = nearest and mip = linear */
  17760. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17761. /** mag = linear and min = linear and mip = none */
  17762. static readonly LINEAR_LINEAR: number;
  17763. /** mag = linear and min = nearest and mip = none */
  17764. static readonly LINEAR_NEAREST: number;
  17765. /** Explicit coordinates mode */
  17766. static readonly EXPLICIT_MODE: number;
  17767. /** Spherical coordinates mode */
  17768. static readonly SPHERICAL_MODE: number;
  17769. /** Planar coordinates mode */
  17770. static readonly PLANAR_MODE: number;
  17771. /** Cubic coordinates mode */
  17772. static readonly CUBIC_MODE: number;
  17773. /** Projection coordinates mode */
  17774. static readonly PROJECTION_MODE: number;
  17775. /** Inverse Cubic coordinates mode */
  17776. static readonly SKYBOX_MODE: number;
  17777. /** Inverse Cubic coordinates mode */
  17778. static readonly INVCUBIC_MODE: number;
  17779. /** Equirectangular coordinates mode */
  17780. static readonly EQUIRECTANGULAR_MODE: number;
  17781. /** Equirectangular Fixed coordinates mode */
  17782. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17783. /** Equirectangular Fixed Mirrored coordinates mode */
  17784. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17785. /** Texture is not repeating outside of 0..1 UVs */
  17786. static readonly CLAMP_ADDRESSMODE: number;
  17787. /** Texture is repeating outside of 0..1 UVs */
  17788. static readonly WRAP_ADDRESSMODE: number;
  17789. /** Texture is repeating and mirrored */
  17790. static readonly MIRROR_ADDRESSMODE: number;
  17791. /**
  17792. * 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
  17793. */
  17794. static UseSerializedUrlIfAny: boolean;
  17795. /**
  17796. * Define the url of the texture.
  17797. */
  17798. url: Nullable<string>;
  17799. /**
  17800. * Define an offset on the texture to offset the u coordinates of the UVs
  17801. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17802. */
  17803. uOffset: number;
  17804. /**
  17805. * Define an offset on the texture to offset the v coordinates of the UVs
  17806. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17807. */
  17808. vOffset: number;
  17809. /**
  17810. * Define an offset on the texture to scale the u coordinates of the UVs
  17811. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17812. */
  17813. uScale: number;
  17814. /**
  17815. * Define an offset on the texture to scale the v coordinates of the UVs
  17816. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17817. */
  17818. vScale: number;
  17819. /**
  17820. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17821. * @see http://doc.babylonjs.com/how_to/more_materials
  17822. */
  17823. uAng: number;
  17824. /**
  17825. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17826. * @see http://doc.babylonjs.com/how_to/more_materials
  17827. */
  17828. vAng: number;
  17829. /**
  17830. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17831. * @see http://doc.babylonjs.com/how_to/more_materials
  17832. */
  17833. wAng: number;
  17834. /**
  17835. * Defines the center of rotation (U)
  17836. */
  17837. uRotationCenter: number;
  17838. /**
  17839. * Defines the center of rotation (V)
  17840. */
  17841. vRotationCenter: number;
  17842. /**
  17843. * Defines the center of rotation (W)
  17844. */
  17845. wRotationCenter: number;
  17846. /**
  17847. * Are mip maps generated for this texture or not.
  17848. */
  17849. readonly noMipmap: boolean;
  17850. /**
  17851. * List of inspectable custom properties (used by the Inspector)
  17852. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17853. */
  17854. inspectableCustomProperties: IInspectable[];
  17855. private _noMipmap;
  17856. /** @hidden */
  17857. _invertY: boolean;
  17858. private _rowGenerationMatrix;
  17859. private _cachedTextureMatrix;
  17860. private _projectionModeMatrix;
  17861. private _t0;
  17862. private _t1;
  17863. private _t2;
  17864. private _cachedUOffset;
  17865. private _cachedVOffset;
  17866. private _cachedUScale;
  17867. private _cachedVScale;
  17868. private _cachedUAng;
  17869. private _cachedVAng;
  17870. private _cachedWAng;
  17871. private _cachedProjectionMatrixId;
  17872. private _cachedCoordinatesMode;
  17873. /** @hidden */
  17874. protected _initialSamplingMode: number;
  17875. /** @hidden */
  17876. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17877. private _deleteBuffer;
  17878. protected _format: Nullable<number>;
  17879. private _delayedOnLoad;
  17880. private _delayedOnError;
  17881. /**
  17882. * Observable triggered once the texture has been loaded.
  17883. */
  17884. onLoadObservable: Observable<Texture>;
  17885. protected _isBlocking: boolean;
  17886. /**
  17887. * Is the texture preventing material to render while loading.
  17888. * If false, a default texture will be used instead of the loading one during the preparation step.
  17889. */
  17890. isBlocking: boolean;
  17891. /**
  17892. * Get the current sampling mode associated with the texture.
  17893. */
  17894. readonly samplingMode: number;
  17895. /**
  17896. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17897. */
  17898. readonly invertY: boolean;
  17899. /**
  17900. * Instantiates a new texture.
  17901. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17902. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17903. * @param url define the url of the picture to load as a texture
  17904. * @param scene define the scene the texture will belong to
  17905. * @param noMipmap define if the texture will require mip maps or not
  17906. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17907. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17908. * @param onLoad define a callback triggered when the texture has been loaded
  17909. * @param onError define a callback triggered when an error occurred during the loading session
  17910. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17911. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17912. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17913. */
  17914. 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);
  17915. /**
  17916. * Update the url (and optional buffer) of this texture if url was null during construction.
  17917. * @param url the url of the texture
  17918. * @param buffer the buffer of the texture (defaults to null)
  17919. * @param onLoad callback called when the texture is loaded (defaults to null)
  17920. */
  17921. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17922. /**
  17923. * Finish the loading sequence of a texture flagged as delayed load.
  17924. * @hidden
  17925. */
  17926. delayLoad(): void;
  17927. private _prepareRowForTextureGeneration;
  17928. /**
  17929. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17930. * @returns the transform matrix of the texture.
  17931. */
  17932. getTextureMatrix(): Matrix;
  17933. /**
  17934. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17935. * @returns The reflection texture transform
  17936. */
  17937. getReflectionTextureMatrix(): Matrix;
  17938. /**
  17939. * Clones the texture.
  17940. * @returns the cloned texture
  17941. */
  17942. clone(): Texture;
  17943. /**
  17944. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17945. * @returns The JSON representation of the texture
  17946. */
  17947. serialize(): any;
  17948. /**
  17949. * Get the current class name of the texture useful for serialization or dynamic coding.
  17950. * @returns "Texture"
  17951. */
  17952. getClassName(): string;
  17953. /**
  17954. * Dispose the texture and release its associated resources.
  17955. */
  17956. dispose(): void;
  17957. /**
  17958. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17959. * @param parsedTexture Define the JSON representation of the texture
  17960. * @param scene Define the scene the parsed texture should be instantiated in
  17961. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17962. * @returns The parsed texture if successful
  17963. */
  17964. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17965. /**
  17966. * Creates a texture from its base 64 representation.
  17967. * @param data Define the base64 payload without the data: prefix
  17968. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17969. * @param scene Define the scene the texture should belong to
  17970. * @param noMipmap Forces the texture to not create mip map information if true
  17971. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17972. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17973. * @param onLoad define a callback triggered when the texture has been loaded
  17974. * @param onError define a callback triggered when an error occurred during the loading session
  17975. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17976. * @returns the created texture
  17977. */
  17978. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17979. /**
  17980. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17981. * @param data Define the base64 payload without the data: prefix
  17982. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17983. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17984. * @param scene Define the scene the texture should belong to
  17985. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17986. * @param noMipmap Forces the texture to not create mip map information if true
  17987. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17988. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17989. * @param onLoad define a callback triggered when the texture has been loaded
  17990. * @param onError define a callback triggered when an error occurred during the loading session
  17991. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17992. * @returns the created texture
  17993. */
  17994. 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;
  17995. }
  17996. }
  17997. declare module BABYLON {
  17998. /**
  17999. * Raw texture can help creating a texture directly from an array of data.
  18000. * This can be super useful if you either get the data from an uncompressed source or
  18001. * if you wish to create your texture pixel by pixel.
  18002. */
  18003. export class RawTexture extends Texture {
  18004. /**
  18005. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18006. */
  18007. format: number;
  18008. private _engine;
  18009. /**
  18010. * Instantiates a new RawTexture.
  18011. * Raw texture can help creating a texture directly from an array of data.
  18012. * This can be super useful if you either get the data from an uncompressed source or
  18013. * if you wish to create your texture pixel by pixel.
  18014. * @param data define the array of data to use to create the texture
  18015. * @param width define the width of the texture
  18016. * @param height define the height of the texture
  18017. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18018. * @param scene define the scene the texture belongs to
  18019. * @param generateMipMaps define whether mip maps should be generated or not
  18020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18023. */
  18024. constructor(data: ArrayBufferView, width: number, height: number,
  18025. /**
  18026. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18027. */
  18028. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18029. /**
  18030. * Updates the texture underlying data.
  18031. * @param data Define the new data of the texture
  18032. */
  18033. update(data: ArrayBufferView): void;
  18034. /**
  18035. * Creates a luminance texture from some data.
  18036. * @param data Define the texture data
  18037. * @param width Define the width of the texture
  18038. * @param height Define the height of the texture
  18039. * @param scene Define the scene the texture belongs to
  18040. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18041. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18042. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18043. * @returns the luminance texture
  18044. */
  18045. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18046. /**
  18047. * Creates a luminance alpha texture from some data.
  18048. * @param data Define the texture data
  18049. * @param width Define the width of the texture
  18050. * @param height Define the height of the texture
  18051. * @param scene Define the scene the texture belongs to
  18052. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18053. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18054. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18055. * @returns the luminance alpha texture
  18056. */
  18057. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18058. /**
  18059. * Creates an alpha texture from some data.
  18060. * @param data Define the texture data
  18061. * @param width Define the width of the texture
  18062. * @param height Define the height of the texture
  18063. * @param scene Define the scene the texture belongs to
  18064. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18065. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18066. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18067. * @returns the alpha texture
  18068. */
  18069. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18070. /**
  18071. * Creates a RGB texture from some data.
  18072. * @param data Define the texture data
  18073. * @param width Define the width of the texture
  18074. * @param height Define the height of the texture
  18075. * @param scene Define the scene the texture belongs to
  18076. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18077. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18078. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18079. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18080. * @returns the RGB alpha texture
  18081. */
  18082. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18083. /**
  18084. * Creates a RGBA texture from some data.
  18085. * @param data Define the texture data
  18086. * @param width Define the width of the texture
  18087. * @param height Define the height of the texture
  18088. * @param scene Define the scene the texture belongs to
  18089. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18090. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18091. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18092. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18093. * @returns the RGBA texture
  18094. */
  18095. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18096. /**
  18097. * Creates a R texture from some data.
  18098. * @param data Define the texture data
  18099. * @param width Define the width of the texture
  18100. * @param height Define the height of the texture
  18101. * @param scene Define the scene the texture belongs to
  18102. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18103. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18104. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18105. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18106. * @returns the R texture
  18107. */
  18108. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18109. }
  18110. }
  18111. declare module BABYLON {
  18112. /**
  18113. * Defines a runtime animation
  18114. */
  18115. export class RuntimeAnimation {
  18116. private _events;
  18117. /**
  18118. * The current frame of the runtime animation
  18119. */
  18120. private _currentFrame;
  18121. /**
  18122. * The animation used by the runtime animation
  18123. */
  18124. private _animation;
  18125. /**
  18126. * The target of the runtime animation
  18127. */
  18128. private _target;
  18129. /**
  18130. * The initiating animatable
  18131. */
  18132. private _host;
  18133. /**
  18134. * The original value of the runtime animation
  18135. */
  18136. private _originalValue;
  18137. /**
  18138. * The original blend value of the runtime animation
  18139. */
  18140. private _originalBlendValue;
  18141. /**
  18142. * The offsets cache of the runtime animation
  18143. */
  18144. private _offsetsCache;
  18145. /**
  18146. * The high limits cache of the runtime animation
  18147. */
  18148. private _highLimitsCache;
  18149. /**
  18150. * Specifies if the runtime animation has been stopped
  18151. */
  18152. private _stopped;
  18153. /**
  18154. * The blending factor of the runtime animation
  18155. */
  18156. private _blendingFactor;
  18157. /**
  18158. * The BabylonJS scene
  18159. */
  18160. private _scene;
  18161. /**
  18162. * The current value of the runtime animation
  18163. */
  18164. private _currentValue;
  18165. /** @hidden */
  18166. _workValue: any;
  18167. /**
  18168. * The active target of the runtime animation
  18169. */
  18170. private _activeTarget;
  18171. /**
  18172. * The target path of the runtime animation
  18173. */
  18174. private _targetPath;
  18175. /**
  18176. * The weight of the runtime animation
  18177. */
  18178. private _weight;
  18179. /**
  18180. * The ratio offset of the runtime animation
  18181. */
  18182. private _ratioOffset;
  18183. /**
  18184. * The previous delay of the runtime animation
  18185. */
  18186. private _previousDelay;
  18187. /**
  18188. * The previous ratio of the runtime animation
  18189. */
  18190. private _previousRatio;
  18191. /**
  18192. * Gets the current frame of the runtime animation
  18193. */
  18194. readonly currentFrame: number;
  18195. /**
  18196. * Gets the weight of the runtime animation
  18197. */
  18198. readonly weight: number;
  18199. /**
  18200. * Gets the current value of the runtime animation
  18201. */
  18202. readonly currentValue: any;
  18203. /**
  18204. * Gets the target path of the runtime animation
  18205. */
  18206. readonly targetPath: string;
  18207. /**
  18208. * Gets the actual target of the runtime animation
  18209. */
  18210. readonly target: any;
  18211. /**
  18212. * Create a new RuntimeAnimation object
  18213. * @param target defines the target of the animation
  18214. * @param animation defines the source animation object
  18215. * @param scene defines the hosting scene
  18216. * @param host defines the initiating Animatable
  18217. */
  18218. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18219. /**
  18220. * Gets the animation from the runtime animation
  18221. */
  18222. readonly animation: Animation;
  18223. /**
  18224. * Resets the runtime animation to the beginning
  18225. * @param restoreOriginal defines whether to restore the target property to the original value
  18226. */
  18227. reset(restoreOriginal?: boolean): void;
  18228. /**
  18229. * Specifies if the runtime animation is stopped
  18230. * @returns Boolean specifying if the runtime animation is stopped
  18231. */
  18232. isStopped(): boolean;
  18233. /**
  18234. * Disposes of the runtime animation
  18235. */
  18236. dispose(): void;
  18237. /**
  18238. * Interpolates the animation from the current frame
  18239. * @param currentFrame The frame to interpolate the animation to
  18240. * @param repeatCount The number of times that the animation should loop
  18241. * @param loopMode The type of looping mode to use
  18242. * @param offsetValue Animation offset value
  18243. * @param highLimitValue The high limit value
  18244. * @returns The interpolated value
  18245. */
  18246. private _interpolate;
  18247. /**
  18248. * Apply the interpolated value to the target
  18249. * @param currentValue defines the value computed by the animation
  18250. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18251. */
  18252. setValue(currentValue: any, weight?: number): void;
  18253. private _setValue;
  18254. /**
  18255. * Gets the loop pmode of the runtime animation
  18256. * @returns Loop Mode
  18257. */
  18258. private _getCorrectLoopMode;
  18259. /**
  18260. * Move the current animation to a given frame
  18261. * @param frame defines the frame to move to
  18262. */
  18263. goToFrame(frame: number): void;
  18264. /**
  18265. * @hidden Internal use only
  18266. */
  18267. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18268. /**
  18269. * Execute the current animation
  18270. * @param delay defines the delay to add to the current frame
  18271. * @param from defines the lower bound of the animation range
  18272. * @param to defines the upper bound of the animation range
  18273. * @param loop defines if the current animation must loop
  18274. * @param speedRatio defines the current speed ratio
  18275. * @param weight defines the weight of the animation (default is -1 so no weight)
  18276. * @param onLoop optional callback called when animation loops
  18277. * @returns a boolean indicating if the animation is running
  18278. */
  18279. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18280. }
  18281. }
  18282. declare module BABYLON {
  18283. /**
  18284. * Class used to store an actual running animation
  18285. */
  18286. export class Animatable {
  18287. /** defines the target object */
  18288. target: any;
  18289. /** defines the starting frame number (default is 0) */
  18290. fromFrame: number;
  18291. /** defines the ending frame number (default is 100) */
  18292. toFrame: number;
  18293. /** defines if the animation must loop (default is false) */
  18294. loopAnimation: boolean;
  18295. /** defines a callback to call when animation ends if it is not looping */
  18296. onAnimationEnd?: (() => void) | null | undefined;
  18297. /** defines a callback to call when animation loops */
  18298. onAnimationLoop?: (() => void) | null | undefined;
  18299. private _localDelayOffset;
  18300. private _pausedDelay;
  18301. private _runtimeAnimations;
  18302. private _paused;
  18303. private _scene;
  18304. private _speedRatio;
  18305. private _weight;
  18306. private _syncRoot;
  18307. /**
  18308. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18309. * This will only apply for non looping animation (default is true)
  18310. */
  18311. disposeOnEnd: boolean;
  18312. /**
  18313. * Gets a boolean indicating if the animation has started
  18314. */
  18315. animationStarted: boolean;
  18316. /**
  18317. * Observer raised when the animation ends
  18318. */
  18319. onAnimationEndObservable: Observable<Animatable>;
  18320. /**
  18321. * Observer raised when the animation loops
  18322. */
  18323. onAnimationLoopObservable: Observable<Animatable>;
  18324. /**
  18325. * Gets the root Animatable used to synchronize and normalize animations
  18326. */
  18327. readonly syncRoot: Animatable;
  18328. /**
  18329. * Gets the current frame of the first RuntimeAnimation
  18330. * Used to synchronize Animatables
  18331. */
  18332. readonly masterFrame: number;
  18333. /**
  18334. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18335. */
  18336. weight: number;
  18337. /**
  18338. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18339. */
  18340. speedRatio: number;
  18341. /**
  18342. * Creates a new Animatable
  18343. * @param scene defines the hosting scene
  18344. * @param target defines the target object
  18345. * @param fromFrame defines the starting frame number (default is 0)
  18346. * @param toFrame defines the ending frame number (default is 100)
  18347. * @param loopAnimation defines if the animation must loop (default is false)
  18348. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18349. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18350. * @param animations defines a group of animation to add to the new Animatable
  18351. * @param onAnimationLoop defines a callback to call when animation loops
  18352. */
  18353. constructor(scene: Scene,
  18354. /** defines the target object */
  18355. target: any,
  18356. /** defines the starting frame number (default is 0) */
  18357. fromFrame?: number,
  18358. /** defines the ending frame number (default is 100) */
  18359. toFrame?: number,
  18360. /** defines if the animation must loop (default is false) */
  18361. loopAnimation?: boolean, speedRatio?: number,
  18362. /** defines a callback to call when animation ends if it is not looping */
  18363. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18364. /** defines a callback to call when animation loops */
  18365. onAnimationLoop?: (() => void) | null | undefined);
  18366. /**
  18367. * Synchronize and normalize current Animatable with a source Animatable
  18368. * This is useful when using animation weights and when animations are not of the same length
  18369. * @param root defines the root Animatable to synchronize with
  18370. * @returns the current Animatable
  18371. */
  18372. syncWith(root: Animatable): Animatable;
  18373. /**
  18374. * Gets the list of runtime animations
  18375. * @returns an array of RuntimeAnimation
  18376. */
  18377. getAnimations(): RuntimeAnimation[];
  18378. /**
  18379. * Adds more animations to the current animatable
  18380. * @param target defines the target of the animations
  18381. * @param animations defines the new animations to add
  18382. */
  18383. appendAnimations(target: any, animations: Animation[]): void;
  18384. /**
  18385. * Gets the source animation for a specific property
  18386. * @param property defines the propertyu to look for
  18387. * @returns null or the source animation for the given property
  18388. */
  18389. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18390. /**
  18391. * Gets the runtime animation for a specific property
  18392. * @param property defines the propertyu to look for
  18393. * @returns null or the runtime animation for the given property
  18394. */
  18395. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18396. /**
  18397. * Resets the animatable to its original state
  18398. */
  18399. reset(): void;
  18400. /**
  18401. * Allows the animatable to blend with current running animations
  18402. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18403. * @param blendingSpeed defines the blending speed to use
  18404. */
  18405. enableBlending(blendingSpeed: number): void;
  18406. /**
  18407. * Disable animation blending
  18408. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18409. */
  18410. disableBlending(): void;
  18411. /**
  18412. * Jump directly to a given frame
  18413. * @param frame defines the frame to jump to
  18414. */
  18415. goToFrame(frame: number): void;
  18416. /**
  18417. * Pause the animation
  18418. */
  18419. pause(): void;
  18420. /**
  18421. * Restart the animation
  18422. */
  18423. restart(): void;
  18424. private _raiseOnAnimationEnd;
  18425. /**
  18426. * Stop and delete the current animation
  18427. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18428. * @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)
  18429. */
  18430. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18431. /**
  18432. * Wait asynchronously for the animation to end
  18433. * @returns a promise which will be fullfilled when the animation ends
  18434. */
  18435. waitAsync(): Promise<Animatable>;
  18436. /** @hidden */
  18437. _animate(delay: number): boolean;
  18438. }
  18439. interface Scene {
  18440. /** @hidden */
  18441. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18442. /** @hidden */
  18443. _processLateAnimationBindingsForMatrices(holder: {
  18444. totalWeight: number;
  18445. animations: RuntimeAnimation[];
  18446. originalValue: Matrix;
  18447. }): any;
  18448. /** @hidden */
  18449. _processLateAnimationBindingsForQuaternions(holder: {
  18450. totalWeight: number;
  18451. animations: RuntimeAnimation[];
  18452. originalValue: Quaternion;
  18453. }, refQuaternion: Quaternion): Quaternion;
  18454. /** @hidden */
  18455. _processLateAnimationBindings(): void;
  18456. /**
  18457. * Will start the animation sequence of a given target
  18458. * @param target defines the target
  18459. * @param from defines from which frame should animation start
  18460. * @param to defines until which frame should animation run.
  18461. * @param weight defines the weight to apply to the animation (1.0 by default)
  18462. * @param loop defines if the animation loops
  18463. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18464. * @param onAnimationEnd defines the function to be executed when the animation ends
  18465. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18466. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18467. * @param onAnimationLoop defines the callback to call when an animation loops
  18468. * @returns the animatable object created for this animation
  18469. */
  18470. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18471. /**
  18472. * Will start the animation sequence of a given target
  18473. * @param target defines the target
  18474. * @param from defines from which frame should animation start
  18475. * @param to defines until which frame should animation run.
  18476. * @param loop defines if the animation loops
  18477. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18478. * @param onAnimationEnd defines the function to be executed when the animation ends
  18479. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18480. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18481. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18482. * @param onAnimationLoop defines the callback to call when an animation loops
  18483. * @returns the animatable object created for this animation
  18484. */
  18485. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18486. /**
  18487. * Will start the animation sequence of a given target and its hierarchy
  18488. * @param target defines the target
  18489. * @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.
  18490. * @param from defines from which frame should animation start
  18491. * @param to defines until which frame should animation run.
  18492. * @param loop defines if the animation loops
  18493. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18494. * @param onAnimationEnd defines the function to be executed when the animation ends
  18495. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18496. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18497. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18498. * @param onAnimationLoop defines the callback to call when an animation loops
  18499. * @returns the list of created animatables
  18500. */
  18501. 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[];
  18502. /**
  18503. * Begin a new animation on a given node
  18504. * @param target defines the target where the animation will take place
  18505. * @param animations defines the list of animations to start
  18506. * @param from defines the initial value
  18507. * @param to defines the final value
  18508. * @param loop defines if you want animation to loop (off by default)
  18509. * @param speedRatio defines the speed ratio to apply to all animations
  18510. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18511. * @param onAnimationLoop defines the callback to call when an animation loops
  18512. * @returns the list of created animatables
  18513. */
  18514. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18515. /**
  18516. * Begin a new animation on a given node and its hierarchy
  18517. * @param target defines the root node where the animation will take place
  18518. * @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.
  18519. * @param animations defines the list of animations to start
  18520. * @param from defines the initial value
  18521. * @param to defines the final value
  18522. * @param loop defines if you want animation to loop (off by default)
  18523. * @param speedRatio defines the speed ratio to apply to all animations
  18524. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18525. * @param onAnimationLoop defines the callback to call when an animation loops
  18526. * @returns the list of animatables created for all nodes
  18527. */
  18528. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18529. /**
  18530. * Gets the animatable associated with a specific target
  18531. * @param target defines the target of the animatable
  18532. * @returns the required animatable if found
  18533. */
  18534. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18535. /**
  18536. * Gets all animatables associated with a given target
  18537. * @param target defines the target to look animatables for
  18538. * @returns an array of Animatables
  18539. */
  18540. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18541. /**
  18542. * Will stop the animation of the given target
  18543. * @param target - the target
  18544. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18545. * @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)
  18546. */
  18547. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18548. /**
  18549. * Stops and removes all animations that have been applied to the scene
  18550. */
  18551. stopAllAnimations(): void;
  18552. }
  18553. interface Bone {
  18554. /**
  18555. * Copy an animation range from another bone
  18556. * @param source defines the source bone
  18557. * @param rangeName defines the range name to copy
  18558. * @param frameOffset defines the frame offset
  18559. * @param rescaleAsRequired defines if rescaling must be applied if required
  18560. * @param skelDimensionsRatio defines the scaling ratio
  18561. * @returns true if operation was successful
  18562. */
  18563. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18564. }
  18565. }
  18566. declare module BABYLON {
  18567. /**
  18568. * Class used to handle skinning animations
  18569. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18570. */
  18571. export class Skeleton implements IAnimatable {
  18572. /** defines the skeleton name */
  18573. name: string;
  18574. /** defines the skeleton Id */
  18575. id: string;
  18576. /**
  18577. * Defines the list of child bones
  18578. */
  18579. bones: Bone[];
  18580. /**
  18581. * Defines an estimate of the dimension of the skeleton at rest
  18582. */
  18583. dimensionsAtRest: Vector3;
  18584. /**
  18585. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18586. */
  18587. needInitialSkinMatrix: boolean;
  18588. /**
  18589. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18590. */
  18591. overrideMesh: Nullable<AbstractMesh>;
  18592. /**
  18593. * Gets the list of animations attached to this skeleton
  18594. */
  18595. animations: Array<Animation>;
  18596. private _scene;
  18597. private _isDirty;
  18598. private _transformMatrices;
  18599. private _transformMatrixTexture;
  18600. private _meshesWithPoseMatrix;
  18601. private _animatables;
  18602. private _identity;
  18603. private _synchronizedWithMesh;
  18604. private _ranges;
  18605. private _lastAbsoluteTransformsUpdateId;
  18606. private _canUseTextureForBones;
  18607. private _uniqueId;
  18608. /** @hidden */
  18609. _numBonesWithLinkedTransformNode: number;
  18610. /**
  18611. * Specifies if the skeleton should be serialized
  18612. */
  18613. doNotSerialize: boolean;
  18614. private _useTextureToStoreBoneMatrices;
  18615. /**
  18616. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18617. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18618. */
  18619. useTextureToStoreBoneMatrices: boolean;
  18620. private _animationPropertiesOverride;
  18621. /**
  18622. * Gets or sets the animation properties override
  18623. */
  18624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18625. /**
  18626. * List of inspectable custom properties (used by the Inspector)
  18627. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18628. */
  18629. inspectableCustomProperties: IInspectable[];
  18630. /**
  18631. * An observable triggered before computing the skeleton's matrices
  18632. */
  18633. onBeforeComputeObservable: Observable<Skeleton>;
  18634. /**
  18635. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18636. */
  18637. readonly isUsingTextureForMatrices: boolean;
  18638. /**
  18639. * Gets the unique ID of this skeleton
  18640. */
  18641. readonly uniqueId: number;
  18642. /**
  18643. * Creates a new skeleton
  18644. * @param name defines the skeleton name
  18645. * @param id defines the skeleton Id
  18646. * @param scene defines the hosting scene
  18647. */
  18648. constructor(
  18649. /** defines the skeleton name */
  18650. name: string,
  18651. /** defines the skeleton Id */
  18652. id: string, scene: Scene);
  18653. /**
  18654. * Gets the current object class name.
  18655. * @return the class name
  18656. */
  18657. getClassName(): string;
  18658. /**
  18659. * Returns an array containing the root bones
  18660. * @returns an array containing the root bones
  18661. */
  18662. getChildren(): Array<Bone>;
  18663. /**
  18664. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18665. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18666. * @returns a Float32Array containing matrices data
  18667. */
  18668. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18669. /**
  18670. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18671. * @returns a raw texture containing the data
  18672. */
  18673. getTransformMatrixTexture(): Nullable<RawTexture>;
  18674. /**
  18675. * Gets the current hosting scene
  18676. * @returns a scene object
  18677. */
  18678. getScene(): Scene;
  18679. /**
  18680. * Gets a string representing the current skeleton data
  18681. * @param fullDetails defines a boolean indicating if we want a verbose version
  18682. * @returns a string representing the current skeleton data
  18683. */
  18684. toString(fullDetails?: boolean): string;
  18685. /**
  18686. * Get bone's index searching by name
  18687. * @param name defines bone's name to search for
  18688. * @return the indice of the bone. Returns -1 if not found
  18689. */
  18690. getBoneIndexByName(name: string): number;
  18691. /**
  18692. * Creater a new animation range
  18693. * @param name defines the name of the range
  18694. * @param from defines the start key
  18695. * @param to defines the end key
  18696. */
  18697. createAnimationRange(name: string, from: number, to: number): void;
  18698. /**
  18699. * Delete a specific animation range
  18700. * @param name defines the name of the range
  18701. * @param deleteFrames defines if frames must be removed as well
  18702. */
  18703. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18704. /**
  18705. * Gets a specific animation range
  18706. * @param name defines the name of the range to look for
  18707. * @returns the requested animation range or null if not found
  18708. */
  18709. getAnimationRange(name: string): Nullable<AnimationRange>;
  18710. /**
  18711. * Gets the list of all animation ranges defined on this skeleton
  18712. * @returns an array
  18713. */
  18714. getAnimationRanges(): Nullable<AnimationRange>[];
  18715. /**
  18716. * Copy animation range from a source skeleton.
  18717. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18718. * @param source defines the source skeleton
  18719. * @param name defines the name of the range to copy
  18720. * @param rescaleAsRequired defines if rescaling must be applied if required
  18721. * @returns true if operation was successful
  18722. */
  18723. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18724. /**
  18725. * Forces the skeleton to go to rest pose
  18726. */
  18727. returnToRest(): void;
  18728. private _getHighestAnimationFrame;
  18729. /**
  18730. * Begin a specific animation range
  18731. * @param name defines the name of the range to start
  18732. * @param loop defines if looping must be turned on (false by default)
  18733. * @param speedRatio defines the speed ratio to apply (1 by default)
  18734. * @param onAnimationEnd defines a callback which will be called when animation will end
  18735. * @returns a new animatable
  18736. */
  18737. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18738. /** @hidden */
  18739. _markAsDirty(): void;
  18740. /** @hidden */
  18741. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18742. /** @hidden */
  18743. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18744. private _computeTransformMatrices;
  18745. /**
  18746. * Build all resources required to render a skeleton
  18747. */
  18748. prepare(): void;
  18749. /**
  18750. * Gets the list of animatables currently running for this skeleton
  18751. * @returns an array of animatables
  18752. */
  18753. getAnimatables(): IAnimatable[];
  18754. /**
  18755. * Clone the current skeleton
  18756. * @param name defines the name of the new skeleton
  18757. * @param id defines the id of the enw skeleton
  18758. * @returns the new skeleton
  18759. */
  18760. clone(name: string, id: string): Skeleton;
  18761. /**
  18762. * Enable animation blending for this skeleton
  18763. * @param blendingSpeed defines the blending speed to apply
  18764. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18765. */
  18766. enableBlending(blendingSpeed?: number): void;
  18767. /**
  18768. * Releases all resources associated with the current skeleton
  18769. */
  18770. dispose(): void;
  18771. /**
  18772. * Serialize the skeleton in a JSON object
  18773. * @returns a JSON object
  18774. */
  18775. serialize(): any;
  18776. /**
  18777. * Creates a new skeleton from serialized data
  18778. * @param parsedSkeleton defines the serialized data
  18779. * @param scene defines the hosting scene
  18780. * @returns a new skeleton
  18781. */
  18782. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18783. /**
  18784. * Compute all node absolute transforms
  18785. * @param forceUpdate defines if computation must be done even if cache is up to date
  18786. */
  18787. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18788. /**
  18789. * Gets the root pose matrix
  18790. * @returns a matrix
  18791. */
  18792. getPoseMatrix(): Nullable<Matrix>;
  18793. /**
  18794. * Sorts bones per internal index
  18795. */
  18796. sortBones(): void;
  18797. private _sortBones;
  18798. }
  18799. }
  18800. declare module BABYLON {
  18801. /**
  18802. * Defines a target to use with MorphTargetManager
  18803. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18804. */
  18805. export class MorphTarget implements IAnimatable {
  18806. /** defines the name of the target */
  18807. name: string;
  18808. /**
  18809. * Gets or sets the list of animations
  18810. */
  18811. animations: Animation[];
  18812. private _scene;
  18813. private _positions;
  18814. private _normals;
  18815. private _tangents;
  18816. private _influence;
  18817. /**
  18818. * Observable raised when the influence changes
  18819. */
  18820. onInfluenceChanged: Observable<boolean>;
  18821. /** @hidden */
  18822. _onDataLayoutChanged: Observable<void>;
  18823. /**
  18824. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18825. */
  18826. influence: number;
  18827. /**
  18828. * Gets or sets the id of the morph Target
  18829. */
  18830. id: string;
  18831. private _animationPropertiesOverride;
  18832. /**
  18833. * Gets or sets the animation properties override
  18834. */
  18835. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18836. /**
  18837. * Creates a new MorphTarget
  18838. * @param name defines the name of the target
  18839. * @param influence defines the influence to use
  18840. * @param scene defines the scene the morphtarget belongs to
  18841. */
  18842. constructor(
  18843. /** defines the name of the target */
  18844. name: string, influence?: number, scene?: Nullable<Scene>);
  18845. /**
  18846. * Gets a boolean defining if the target contains position data
  18847. */
  18848. readonly hasPositions: boolean;
  18849. /**
  18850. * Gets a boolean defining if the target contains normal data
  18851. */
  18852. readonly hasNormals: boolean;
  18853. /**
  18854. * Gets a boolean defining if the target contains tangent data
  18855. */
  18856. readonly hasTangents: boolean;
  18857. /**
  18858. * Affects position data to this target
  18859. * @param data defines the position data to use
  18860. */
  18861. setPositions(data: Nullable<FloatArray>): void;
  18862. /**
  18863. * Gets the position data stored in this target
  18864. * @returns a FloatArray containing the position data (or null if not present)
  18865. */
  18866. getPositions(): Nullable<FloatArray>;
  18867. /**
  18868. * Affects normal data to this target
  18869. * @param data defines the normal data to use
  18870. */
  18871. setNormals(data: Nullable<FloatArray>): void;
  18872. /**
  18873. * Gets the normal data stored in this target
  18874. * @returns a FloatArray containing the normal data (or null if not present)
  18875. */
  18876. getNormals(): Nullable<FloatArray>;
  18877. /**
  18878. * Affects tangent data to this target
  18879. * @param data defines the tangent data to use
  18880. */
  18881. setTangents(data: Nullable<FloatArray>): void;
  18882. /**
  18883. * Gets the tangent data stored in this target
  18884. * @returns a FloatArray containing the tangent data (or null if not present)
  18885. */
  18886. getTangents(): Nullable<FloatArray>;
  18887. /**
  18888. * Serializes the current target into a Serialization object
  18889. * @returns the serialized object
  18890. */
  18891. serialize(): any;
  18892. /**
  18893. * Returns the string "MorphTarget"
  18894. * @returns "MorphTarget"
  18895. */
  18896. getClassName(): string;
  18897. /**
  18898. * Creates a new target from serialized data
  18899. * @param serializationObject defines the serialized data to use
  18900. * @returns a new MorphTarget
  18901. */
  18902. static Parse(serializationObject: any): MorphTarget;
  18903. /**
  18904. * Creates a MorphTarget from mesh data
  18905. * @param mesh defines the source mesh
  18906. * @param name defines the name to use for the new target
  18907. * @param influence defines the influence to attach to the target
  18908. * @returns a new MorphTarget
  18909. */
  18910. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18911. }
  18912. }
  18913. declare module BABYLON {
  18914. /**
  18915. * This class is used to deform meshes using morphing between different targets
  18916. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18917. */
  18918. export class MorphTargetManager {
  18919. private _targets;
  18920. private _targetInfluenceChangedObservers;
  18921. private _targetDataLayoutChangedObservers;
  18922. private _activeTargets;
  18923. private _scene;
  18924. private _influences;
  18925. private _supportsNormals;
  18926. private _supportsTangents;
  18927. private _vertexCount;
  18928. private _uniqueId;
  18929. private _tempInfluences;
  18930. /**
  18931. * Creates a new MorphTargetManager
  18932. * @param scene defines the current scene
  18933. */
  18934. constructor(scene?: Nullable<Scene>);
  18935. /**
  18936. * Gets the unique ID of this manager
  18937. */
  18938. readonly uniqueId: number;
  18939. /**
  18940. * Gets the number of vertices handled by this manager
  18941. */
  18942. readonly vertexCount: number;
  18943. /**
  18944. * Gets a boolean indicating if this manager supports morphing of normals
  18945. */
  18946. readonly supportsNormals: boolean;
  18947. /**
  18948. * Gets a boolean indicating if this manager supports morphing of tangents
  18949. */
  18950. readonly supportsTangents: boolean;
  18951. /**
  18952. * Gets the number of targets stored in this manager
  18953. */
  18954. readonly numTargets: number;
  18955. /**
  18956. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18957. */
  18958. readonly numInfluencers: number;
  18959. /**
  18960. * Gets the list of influences (one per target)
  18961. */
  18962. readonly influences: Float32Array;
  18963. /**
  18964. * Gets the active target at specified index. An active target is a target with an influence > 0
  18965. * @param index defines the index to check
  18966. * @returns the requested target
  18967. */
  18968. getActiveTarget(index: number): MorphTarget;
  18969. /**
  18970. * Gets the target at specified index
  18971. * @param index defines the index to check
  18972. * @returns the requested target
  18973. */
  18974. getTarget(index: number): MorphTarget;
  18975. /**
  18976. * Add a new target to this manager
  18977. * @param target defines the target to add
  18978. */
  18979. addTarget(target: MorphTarget): void;
  18980. /**
  18981. * Removes a target from the manager
  18982. * @param target defines the target to remove
  18983. */
  18984. removeTarget(target: MorphTarget): void;
  18985. /**
  18986. * Serializes the current manager into a Serialization object
  18987. * @returns the serialized object
  18988. */
  18989. serialize(): any;
  18990. private _syncActiveTargets;
  18991. /**
  18992. * Syncrhonize the targets with all the meshes using this morph target manager
  18993. */
  18994. synchronize(): void;
  18995. /**
  18996. * Creates a new MorphTargetManager from serialized data
  18997. * @param serializationObject defines the serialized data
  18998. * @param scene defines the hosting scene
  18999. * @returns the new MorphTargetManager
  19000. */
  19001. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19002. }
  19003. }
  19004. declare module BABYLON {
  19005. /**
  19006. * Mesh representing the gorund
  19007. */
  19008. export class GroundMesh extends Mesh {
  19009. /** If octree should be generated */
  19010. generateOctree: boolean;
  19011. private _heightQuads;
  19012. /** @hidden */
  19013. _subdivisionsX: number;
  19014. /** @hidden */
  19015. _subdivisionsY: number;
  19016. /** @hidden */
  19017. _width: number;
  19018. /** @hidden */
  19019. _height: number;
  19020. /** @hidden */
  19021. _minX: number;
  19022. /** @hidden */
  19023. _maxX: number;
  19024. /** @hidden */
  19025. _minZ: number;
  19026. /** @hidden */
  19027. _maxZ: number;
  19028. constructor(name: string, scene: Scene);
  19029. /**
  19030. * "GroundMesh"
  19031. * @returns "GroundMesh"
  19032. */
  19033. getClassName(): string;
  19034. /**
  19035. * The minimum of x and y subdivisions
  19036. */
  19037. readonly subdivisions: number;
  19038. /**
  19039. * X subdivisions
  19040. */
  19041. readonly subdivisionsX: number;
  19042. /**
  19043. * Y subdivisions
  19044. */
  19045. readonly subdivisionsY: number;
  19046. /**
  19047. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19048. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19049. * @param chunksCount the number of subdivisions for x and y
  19050. * @param octreeBlocksSize (Default: 32)
  19051. */
  19052. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19053. /**
  19054. * Returns a height (y) value in the Worl system :
  19055. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19056. * @param x x coordinate
  19057. * @param z z coordinate
  19058. * @returns the ground y position if (x, z) are outside the ground surface.
  19059. */
  19060. getHeightAtCoordinates(x: number, z: number): number;
  19061. /**
  19062. * Returns a normalized vector (Vector3) orthogonal to the ground
  19063. * at the ground coordinates (x, z) expressed in the World system.
  19064. * @param x x coordinate
  19065. * @param z z coordinate
  19066. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19067. */
  19068. getNormalAtCoordinates(x: number, z: number): Vector3;
  19069. /**
  19070. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19071. * at the ground coordinates (x, z) expressed in the World system.
  19072. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19073. * @param x x coordinate
  19074. * @param z z coordinate
  19075. * @param ref vector to store the result
  19076. * @returns the GroundMesh.
  19077. */
  19078. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19079. /**
  19080. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19081. * if the ground has been updated.
  19082. * This can be used in the render loop.
  19083. * @returns the GroundMesh.
  19084. */
  19085. updateCoordinateHeights(): GroundMesh;
  19086. private _getFacetAt;
  19087. private _initHeightQuads;
  19088. private _computeHeightQuads;
  19089. /**
  19090. * Serializes this ground mesh
  19091. * @param serializationObject object to write serialization to
  19092. */
  19093. serialize(serializationObject: any): void;
  19094. /**
  19095. * Parses a serialized ground mesh
  19096. * @param parsedMesh the serialized mesh
  19097. * @param scene the scene to create the ground mesh in
  19098. * @returns the created ground mesh
  19099. */
  19100. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19101. }
  19102. }
  19103. declare module BABYLON {
  19104. /**
  19105. * Interface for Physics-Joint data
  19106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19107. */
  19108. export interface PhysicsJointData {
  19109. /**
  19110. * The main pivot of the joint
  19111. */
  19112. mainPivot?: Vector3;
  19113. /**
  19114. * The connected pivot of the joint
  19115. */
  19116. connectedPivot?: Vector3;
  19117. /**
  19118. * The main axis of the joint
  19119. */
  19120. mainAxis?: Vector3;
  19121. /**
  19122. * The connected axis of the joint
  19123. */
  19124. connectedAxis?: Vector3;
  19125. /**
  19126. * The collision of the joint
  19127. */
  19128. collision?: boolean;
  19129. /**
  19130. * Native Oimo/Cannon/Energy data
  19131. */
  19132. nativeParams?: any;
  19133. }
  19134. /**
  19135. * This is a holder class for the physics joint created by the physics plugin
  19136. * It holds a set of functions to control the underlying joint
  19137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19138. */
  19139. export class PhysicsJoint {
  19140. /**
  19141. * The type of the physics joint
  19142. */
  19143. type: number;
  19144. /**
  19145. * The data for the physics joint
  19146. */
  19147. jointData: PhysicsJointData;
  19148. private _physicsJoint;
  19149. protected _physicsPlugin: IPhysicsEnginePlugin;
  19150. /**
  19151. * Initializes the physics joint
  19152. * @param type The type of the physics joint
  19153. * @param jointData The data for the physics joint
  19154. */
  19155. constructor(
  19156. /**
  19157. * The type of the physics joint
  19158. */
  19159. type: number,
  19160. /**
  19161. * The data for the physics joint
  19162. */
  19163. jointData: PhysicsJointData);
  19164. /**
  19165. * Gets the physics joint
  19166. */
  19167. /**
  19168. * Sets the physics joint
  19169. */
  19170. physicsJoint: any;
  19171. /**
  19172. * Sets the physics plugin
  19173. */
  19174. physicsPlugin: IPhysicsEnginePlugin;
  19175. /**
  19176. * Execute a function that is physics-plugin specific.
  19177. * @param {Function} func the function that will be executed.
  19178. * It accepts two parameters: the physics world and the physics joint
  19179. */
  19180. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19181. /**
  19182. * Distance-Joint type
  19183. */
  19184. static DistanceJoint: number;
  19185. /**
  19186. * Hinge-Joint type
  19187. */
  19188. static HingeJoint: number;
  19189. /**
  19190. * Ball-and-Socket joint type
  19191. */
  19192. static BallAndSocketJoint: number;
  19193. /**
  19194. * Wheel-Joint type
  19195. */
  19196. static WheelJoint: number;
  19197. /**
  19198. * Slider-Joint type
  19199. */
  19200. static SliderJoint: number;
  19201. /**
  19202. * Prismatic-Joint type
  19203. */
  19204. static PrismaticJoint: number;
  19205. /**
  19206. * Universal-Joint type
  19207. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19208. */
  19209. static UniversalJoint: number;
  19210. /**
  19211. * Hinge-Joint 2 type
  19212. */
  19213. static Hinge2Joint: number;
  19214. /**
  19215. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19216. */
  19217. static PointToPointJoint: number;
  19218. /**
  19219. * Spring-Joint type
  19220. */
  19221. static SpringJoint: number;
  19222. /**
  19223. * Lock-Joint type
  19224. */
  19225. static LockJoint: number;
  19226. }
  19227. /**
  19228. * A class representing a physics distance joint
  19229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19230. */
  19231. export class DistanceJoint extends PhysicsJoint {
  19232. /**
  19233. *
  19234. * @param jointData The data for the Distance-Joint
  19235. */
  19236. constructor(jointData: DistanceJointData);
  19237. /**
  19238. * Update the predefined distance.
  19239. * @param maxDistance The maximum preferred distance
  19240. * @param minDistance The minimum preferred distance
  19241. */
  19242. updateDistance(maxDistance: number, minDistance?: number): void;
  19243. }
  19244. /**
  19245. * Represents a Motor-Enabled Joint
  19246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19247. */
  19248. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19249. /**
  19250. * Initializes the Motor-Enabled Joint
  19251. * @param type The type of the joint
  19252. * @param jointData The physica joint data for the joint
  19253. */
  19254. constructor(type: number, jointData: PhysicsJointData);
  19255. /**
  19256. * Set the motor values.
  19257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19258. * @param force the force to apply
  19259. * @param maxForce max force for this motor.
  19260. */
  19261. setMotor(force?: number, maxForce?: number): void;
  19262. /**
  19263. * Set the motor's limits.
  19264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19265. * @param upperLimit The upper limit of the motor
  19266. * @param lowerLimit The lower limit of the motor
  19267. */
  19268. setLimit(upperLimit: number, lowerLimit?: number): void;
  19269. }
  19270. /**
  19271. * This class represents a single physics Hinge-Joint
  19272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19273. */
  19274. export class HingeJoint extends MotorEnabledJoint {
  19275. /**
  19276. * Initializes the Hinge-Joint
  19277. * @param jointData The joint data for the Hinge-Joint
  19278. */
  19279. constructor(jointData: PhysicsJointData);
  19280. /**
  19281. * Set the motor values.
  19282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19283. * @param {number} force the force to apply
  19284. * @param {number} maxForce max force for this motor.
  19285. */
  19286. setMotor(force?: number, maxForce?: number): void;
  19287. /**
  19288. * Set the motor's limits.
  19289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19290. * @param upperLimit The upper limit of the motor
  19291. * @param lowerLimit The lower limit of the motor
  19292. */
  19293. setLimit(upperLimit: number, lowerLimit?: number): void;
  19294. }
  19295. /**
  19296. * This class represents a dual hinge physics joint (same as wheel joint)
  19297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19298. */
  19299. export class Hinge2Joint extends MotorEnabledJoint {
  19300. /**
  19301. * Initializes the Hinge2-Joint
  19302. * @param jointData The joint data for the Hinge2-Joint
  19303. */
  19304. constructor(jointData: PhysicsJointData);
  19305. /**
  19306. * Set the motor values.
  19307. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19308. * @param {number} targetSpeed the speed the motor is to reach
  19309. * @param {number} maxForce max force for this motor.
  19310. * @param {motorIndex} the motor's index, 0 or 1.
  19311. */
  19312. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19313. /**
  19314. * Set the motor limits.
  19315. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19316. * @param {number} upperLimit the upper limit
  19317. * @param {number} lowerLimit lower limit
  19318. * @param {motorIndex} the motor's index, 0 or 1.
  19319. */
  19320. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19321. }
  19322. /**
  19323. * Interface for a motor enabled joint
  19324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19325. */
  19326. export interface IMotorEnabledJoint {
  19327. /**
  19328. * Physics joint
  19329. */
  19330. physicsJoint: any;
  19331. /**
  19332. * Sets the motor of the motor-enabled joint
  19333. * @param force The force of the motor
  19334. * @param maxForce The maximum force of the motor
  19335. * @param motorIndex The index of the motor
  19336. */
  19337. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19338. /**
  19339. * Sets the limit of the motor
  19340. * @param upperLimit The upper limit of the motor
  19341. * @param lowerLimit The lower limit of the motor
  19342. * @param motorIndex The index of the motor
  19343. */
  19344. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19345. }
  19346. /**
  19347. * Joint data for a Distance-Joint
  19348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19349. */
  19350. export interface DistanceJointData extends PhysicsJointData {
  19351. /**
  19352. * Max distance the 2 joint objects can be apart
  19353. */
  19354. maxDistance: number;
  19355. }
  19356. /**
  19357. * Joint data from a spring joint
  19358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19359. */
  19360. export interface SpringJointData extends PhysicsJointData {
  19361. /**
  19362. * Length of the spring
  19363. */
  19364. length: number;
  19365. /**
  19366. * Stiffness of the spring
  19367. */
  19368. stiffness: number;
  19369. /**
  19370. * Damping of the spring
  19371. */
  19372. damping: number;
  19373. /** this callback will be called when applying the force to the impostors. */
  19374. forceApplicationCallback: () => void;
  19375. }
  19376. }
  19377. declare module BABYLON {
  19378. /**
  19379. * Holds the data for the raycast result
  19380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19381. */
  19382. export class PhysicsRaycastResult {
  19383. private _hasHit;
  19384. private _hitDistance;
  19385. private _hitNormalWorld;
  19386. private _hitPointWorld;
  19387. private _rayFromWorld;
  19388. private _rayToWorld;
  19389. /**
  19390. * Gets if there was a hit
  19391. */
  19392. readonly hasHit: boolean;
  19393. /**
  19394. * Gets the distance from the hit
  19395. */
  19396. readonly hitDistance: number;
  19397. /**
  19398. * Gets the hit normal/direction in the world
  19399. */
  19400. readonly hitNormalWorld: Vector3;
  19401. /**
  19402. * Gets the hit point in the world
  19403. */
  19404. readonly hitPointWorld: Vector3;
  19405. /**
  19406. * Gets the ray "start point" of the ray in the world
  19407. */
  19408. readonly rayFromWorld: Vector3;
  19409. /**
  19410. * Gets the ray "end point" of the ray in the world
  19411. */
  19412. readonly rayToWorld: Vector3;
  19413. /**
  19414. * Sets the hit data (normal & point in world space)
  19415. * @param hitNormalWorld defines the normal in world space
  19416. * @param hitPointWorld defines the point in world space
  19417. */
  19418. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19419. /**
  19420. * Sets the distance from the start point to the hit point
  19421. * @param distance
  19422. */
  19423. setHitDistance(distance: number): void;
  19424. /**
  19425. * Calculates the distance manually
  19426. */
  19427. calculateHitDistance(): void;
  19428. /**
  19429. * Resets all the values to default
  19430. * @param from The from point on world space
  19431. * @param to The to point on world space
  19432. */
  19433. reset(from?: Vector3, to?: Vector3): void;
  19434. }
  19435. /**
  19436. * Interface for the size containing width and height
  19437. */
  19438. interface IXYZ {
  19439. /**
  19440. * X
  19441. */
  19442. x: number;
  19443. /**
  19444. * Y
  19445. */
  19446. y: number;
  19447. /**
  19448. * Z
  19449. */
  19450. z: number;
  19451. }
  19452. }
  19453. declare module BABYLON {
  19454. /**
  19455. * Interface used to describe a physics joint
  19456. */
  19457. export interface PhysicsImpostorJoint {
  19458. /** Defines the main impostor to which the joint is linked */
  19459. mainImpostor: PhysicsImpostor;
  19460. /** Defines the impostor that is connected to the main impostor using this joint */
  19461. connectedImpostor: PhysicsImpostor;
  19462. /** Defines the joint itself */
  19463. joint: PhysicsJoint;
  19464. }
  19465. /** @hidden */
  19466. export interface IPhysicsEnginePlugin {
  19467. world: any;
  19468. name: string;
  19469. setGravity(gravity: Vector3): void;
  19470. setTimeStep(timeStep: number): void;
  19471. getTimeStep(): number;
  19472. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19473. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19474. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19475. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19476. removePhysicsBody(impostor: PhysicsImpostor): void;
  19477. generateJoint(joint: PhysicsImpostorJoint): void;
  19478. removeJoint(joint: PhysicsImpostorJoint): void;
  19479. isSupported(): boolean;
  19480. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19481. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19482. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19483. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19484. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19485. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19486. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19487. getBodyMass(impostor: PhysicsImpostor): number;
  19488. getBodyFriction(impostor: PhysicsImpostor): number;
  19489. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19490. getBodyRestitution(impostor: PhysicsImpostor): number;
  19491. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19492. getBodyPressure?(impostor: PhysicsImpostor): number;
  19493. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19494. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19495. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19496. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19497. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19498. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19499. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19500. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19501. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19502. sleepBody(impostor: PhysicsImpostor): void;
  19503. wakeUpBody(impostor: PhysicsImpostor): void;
  19504. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19505. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19506. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19507. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19508. getRadius(impostor: PhysicsImpostor): number;
  19509. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19510. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19511. dispose(): void;
  19512. }
  19513. /**
  19514. * Interface used to define a physics engine
  19515. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19516. */
  19517. export interface IPhysicsEngine {
  19518. /**
  19519. * Gets the gravity vector used by the simulation
  19520. */
  19521. gravity: Vector3;
  19522. /**
  19523. * Sets the gravity vector used by the simulation
  19524. * @param gravity defines the gravity vector to use
  19525. */
  19526. setGravity(gravity: Vector3): void;
  19527. /**
  19528. * Set the time step of the physics engine.
  19529. * Default is 1/60.
  19530. * To slow it down, enter 1/600 for example.
  19531. * To speed it up, 1/30
  19532. * @param newTimeStep the new timestep to apply to this world.
  19533. */
  19534. setTimeStep(newTimeStep: number): void;
  19535. /**
  19536. * Get the time step of the physics engine.
  19537. * @returns the current time step
  19538. */
  19539. getTimeStep(): number;
  19540. /**
  19541. * Release all resources
  19542. */
  19543. dispose(): void;
  19544. /**
  19545. * Gets the name of the current physics plugin
  19546. * @returns the name of the plugin
  19547. */
  19548. getPhysicsPluginName(): string;
  19549. /**
  19550. * Adding a new impostor for the impostor tracking.
  19551. * This will be done by the impostor itself.
  19552. * @param impostor the impostor to add
  19553. */
  19554. addImpostor(impostor: PhysicsImpostor): void;
  19555. /**
  19556. * Remove an impostor from the engine.
  19557. * This impostor and its mesh will not longer be updated by the physics engine.
  19558. * @param impostor the impostor to remove
  19559. */
  19560. removeImpostor(impostor: PhysicsImpostor): void;
  19561. /**
  19562. * Add a joint to the physics engine
  19563. * @param mainImpostor defines the main impostor to which the joint is added.
  19564. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19565. * @param joint defines the joint that will connect both impostors.
  19566. */
  19567. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19568. /**
  19569. * Removes a joint from the simulation
  19570. * @param mainImpostor defines the impostor used with the joint
  19571. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19572. * @param joint defines the joint to remove
  19573. */
  19574. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19575. /**
  19576. * Gets the current plugin used to run the simulation
  19577. * @returns current plugin
  19578. */
  19579. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19580. /**
  19581. * Gets the list of physic impostors
  19582. * @returns an array of PhysicsImpostor
  19583. */
  19584. getImpostors(): Array<PhysicsImpostor>;
  19585. /**
  19586. * Gets the impostor for a physics enabled object
  19587. * @param object defines the object impersonated by the impostor
  19588. * @returns the PhysicsImpostor or null if not found
  19589. */
  19590. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19591. /**
  19592. * Gets the impostor for a physics body object
  19593. * @param body defines physics body used by the impostor
  19594. * @returns the PhysicsImpostor or null if not found
  19595. */
  19596. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19597. /**
  19598. * Does a raycast in the physics world
  19599. * @param from when should the ray start?
  19600. * @param to when should the ray end?
  19601. * @returns PhysicsRaycastResult
  19602. */
  19603. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19604. /**
  19605. * Called by the scene. No need to call it.
  19606. * @param delta defines the timespam between frames
  19607. */
  19608. _step(delta: number): void;
  19609. }
  19610. }
  19611. declare module BABYLON {
  19612. /**
  19613. * The interface for the physics imposter parameters
  19614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19615. */
  19616. export interface PhysicsImpostorParameters {
  19617. /**
  19618. * The mass of the physics imposter
  19619. */
  19620. mass: number;
  19621. /**
  19622. * The friction of the physics imposter
  19623. */
  19624. friction?: number;
  19625. /**
  19626. * The coefficient of restitution of the physics imposter
  19627. */
  19628. restitution?: number;
  19629. /**
  19630. * The native options of the physics imposter
  19631. */
  19632. nativeOptions?: any;
  19633. /**
  19634. * Specifies if the parent should be ignored
  19635. */
  19636. ignoreParent?: boolean;
  19637. /**
  19638. * Specifies if bi-directional transformations should be disabled
  19639. */
  19640. disableBidirectionalTransformation?: boolean;
  19641. /**
  19642. * The pressure inside the physics imposter, soft object only
  19643. */
  19644. pressure?: number;
  19645. /**
  19646. * The stiffness the physics imposter, soft object only
  19647. */
  19648. stiffness?: number;
  19649. /**
  19650. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19651. */
  19652. velocityIterations?: number;
  19653. /**
  19654. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19655. */
  19656. positionIterations?: number;
  19657. /**
  19658. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19659. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19660. * Add to fix multiple points
  19661. */
  19662. fixedPoints?: number;
  19663. /**
  19664. * The collision margin around a soft object
  19665. */
  19666. margin?: number;
  19667. /**
  19668. * The collision margin around a soft object
  19669. */
  19670. damping?: number;
  19671. /**
  19672. * The path for a rope based on an extrusion
  19673. */
  19674. path?: any;
  19675. /**
  19676. * The shape of an extrusion used for a rope based on an extrusion
  19677. */
  19678. shape?: any;
  19679. }
  19680. /**
  19681. * Interface for a physics-enabled object
  19682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19683. */
  19684. export interface IPhysicsEnabledObject {
  19685. /**
  19686. * The position of the physics-enabled object
  19687. */
  19688. position: Vector3;
  19689. /**
  19690. * The rotation of the physics-enabled object
  19691. */
  19692. rotationQuaternion: Nullable<Quaternion>;
  19693. /**
  19694. * The scale of the physics-enabled object
  19695. */
  19696. scaling: Vector3;
  19697. /**
  19698. * The rotation of the physics-enabled object
  19699. */
  19700. rotation?: Vector3;
  19701. /**
  19702. * The parent of the physics-enabled object
  19703. */
  19704. parent?: any;
  19705. /**
  19706. * The bounding info of the physics-enabled object
  19707. * @returns The bounding info of the physics-enabled object
  19708. */
  19709. getBoundingInfo(): BoundingInfo;
  19710. /**
  19711. * Computes the world matrix
  19712. * @param force Specifies if the world matrix should be computed by force
  19713. * @returns A world matrix
  19714. */
  19715. computeWorldMatrix(force: boolean): Matrix;
  19716. /**
  19717. * Gets the world matrix
  19718. * @returns A world matrix
  19719. */
  19720. getWorldMatrix?(): Matrix;
  19721. /**
  19722. * Gets the child meshes
  19723. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19724. * @returns An array of abstract meshes
  19725. */
  19726. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19727. /**
  19728. * Gets the vertex data
  19729. * @param kind The type of vertex data
  19730. * @returns A nullable array of numbers, or a float32 array
  19731. */
  19732. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19733. /**
  19734. * Gets the indices from the mesh
  19735. * @returns A nullable array of index arrays
  19736. */
  19737. getIndices?(): Nullable<IndicesArray>;
  19738. /**
  19739. * Gets the scene from the mesh
  19740. * @returns the indices array or null
  19741. */
  19742. getScene?(): Scene;
  19743. /**
  19744. * Gets the absolute position from the mesh
  19745. * @returns the absolute position
  19746. */
  19747. getAbsolutePosition(): Vector3;
  19748. /**
  19749. * Gets the absolute pivot point from the mesh
  19750. * @returns the absolute pivot point
  19751. */
  19752. getAbsolutePivotPoint(): Vector3;
  19753. /**
  19754. * Rotates the mesh
  19755. * @param axis The axis of rotation
  19756. * @param amount The amount of rotation
  19757. * @param space The space of the rotation
  19758. * @returns The rotation transform node
  19759. */
  19760. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19761. /**
  19762. * Translates the mesh
  19763. * @param axis The axis of translation
  19764. * @param distance The distance of translation
  19765. * @param space The space of the translation
  19766. * @returns The transform node
  19767. */
  19768. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19769. /**
  19770. * Sets the absolute position of the mesh
  19771. * @param absolutePosition The absolute position of the mesh
  19772. * @returns The transform node
  19773. */
  19774. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19775. /**
  19776. * Gets the class name of the mesh
  19777. * @returns The class name
  19778. */
  19779. getClassName(): string;
  19780. }
  19781. /**
  19782. * Represents a physics imposter
  19783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19784. */
  19785. export class PhysicsImpostor {
  19786. /**
  19787. * The physics-enabled object used as the physics imposter
  19788. */
  19789. object: IPhysicsEnabledObject;
  19790. /**
  19791. * The type of the physics imposter
  19792. */
  19793. type: number;
  19794. private _options;
  19795. private _scene?;
  19796. /**
  19797. * The default object size of the imposter
  19798. */
  19799. static DEFAULT_OBJECT_SIZE: Vector3;
  19800. /**
  19801. * The identity quaternion of the imposter
  19802. */
  19803. static IDENTITY_QUATERNION: Quaternion;
  19804. /** @hidden */
  19805. _pluginData: any;
  19806. private _physicsEngine;
  19807. private _physicsBody;
  19808. private _bodyUpdateRequired;
  19809. private _onBeforePhysicsStepCallbacks;
  19810. private _onAfterPhysicsStepCallbacks;
  19811. /** @hidden */
  19812. _onPhysicsCollideCallbacks: Array<{
  19813. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19814. otherImpostors: Array<PhysicsImpostor>;
  19815. }>;
  19816. private _deltaPosition;
  19817. private _deltaRotation;
  19818. private _deltaRotationConjugated;
  19819. /** hidden */
  19820. _isFromLine: boolean;
  19821. private _parent;
  19822. private _isDisposed;
  19823. private static _tmpVecs;
  19824. private static _tmpQuat;
  19825. /**
  19826. * Specifies if the physics imposter is disposed
  19827. */
  19828. readonly isDisposed: boolean;
  19829. /**
  19830. * Gets the mass of the physics imposter
  19831. */
  19832. mass: number;
  19833. /**
  19834. * Gets the coefficient of friction
  19835. */
  19836. /**
  19837. * Sets the coefficient of friction
  19838. */
  19839. friction: number;
  19840. /**
  19841. * Gets the coefficient of restitution
  19842. */
  19843. /**
  19844. * Sets the coefficient of restitution
  19845. */
  19846. restitution: number;
  19847. /**
  19848. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  19849. */
  19850. /**
  19851. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  19852. */
  19853. pressure: number;
  19854. /**
  19855. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19856. */
  19857. /**
  19858. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19859. */
  19860. stiffness: number;
  19861. /**
  19862. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19863. */
  19864. /**
  19865. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19866. */
  19867. velocityIterations: number;
  19868. /**
  19869. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19870. */
  19871. /**
  19872. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19873. */
  19874. positionIterations: number;
  19875. /**
  19876. * The unique id of the physics imposter
  19877. * set by the physics engine when adding this impostor to the array
  19878. */
  19879. uniqueId: number;
  19880. /**
  19881. * @hidden
  19882. */
  19883. soft: boolean;
  19884. /**
  19885. * @hidden
  19886. */
  19887. segments: number;
  19888. private _joints;
  19889. /**
  19890. * Initializes the physics imposter
  19891. * @param object The physics-enabled object used as the physics imposter
  19892. * @param type The type of the physics imposter
  19893. * @param _options The options for the physics imposter
  19894. * @param _scene The Babylon scene
  19895. */
  19896. constructor(
  19897. /**
  19898. * The physics-enabled object used as the physics imposter
  19899. */
  19900. object: IPhysicsEnabledObject,
  19901. /**
  19902. * The type of the physics imposter
  19903. */
  19904. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19905. /**
  19906. * This function will completly initialize this impostor.
  19907. * It will create a new body - but only if this mesh has no parent.
  19908. * If it has, this impostor will not be used other than to define the impostor
  19909. * of the child mesh.
  19910. * @hidden
  19911. */
  19912. _init(): void;
  19913. private _getPhysicsParent;
  19914. /**
  19915. * Should a new body be generated.
  19916. * @returns boolean specifying if body initialization is required
  19917. */
  19918. isBodyInitRequired(): boolean;
  19919. /**
  19920. * Sets the updated scaling
  19921. * @param updated Specifies if the scaling is updated
  19922. */
  19923. setScalingUpdated(): void;
  19924. /**
  19925. * Force a regeneration of this or the parent's impostor's body.
  19926. * Use under cautious - This will remove all joints already implemented.
  19927. */
  19928. forceUpdate(): void;
  19929. /**
  19930. * Gets the body that holds this impostor. Either its own, or its parent.
  19931. */
  19932. /**
  19933. * Set the physics body. Used mainly by the physics engine/plugin
  19934. */
  19935. physicsBody: any;
  19936. /**
  19937. * Get the parent of the physics imposter
  19938. * @returns Physics imposter or null
  19939. */
  19940. /**
  19941. * Sets the parent of the physics imposter
  19942. */
  19943. parent: Nullable<PhysicsImpostor>;
  19944. /**
  19945. * Resets the update flags
  19946. */
  19947. resetUpdateFlags(): void;
  19948. /**
  19949. * Gets the object extend size
  19950. * @returns the object extend size
  19951. */
  19952. getObjectExtendSize(): Vector3;
  19953. /**
  19954. * Gets the object center
  19955. * @returns The object center
  19956. */
  19957. getObjectCenter(): Vector3;
  19958. /**
  19959. * Get a specific parametes from the options parameter
  19960. * @param paramName The object parameter name
  19961. * @returns The object parameter
  19962. */
  19963. getParam(paramName: string): any;
  19964. /**
  19965. * Sets a specific parameter in the options given to the physics plugin
  19966. * @param paramName The parameter name
  19967. * @param value The value of the parameter
  19968. */
  19969. setParam(paramName: string, value: number): void;
  19970. /**
  19971. * Specifically change the body's mass option. Won't recreate the physics body object
  19972. * @param mass The mass of the physics imposter
  19973. */
  19974. setMass(mass: number): void;
  19975. /**
  19976. * Gets the linear velocity
  19977. * @returns linear velocity or null
  19978. */
  19979. getLinearVelocity(): Nullable<Vector3>;
  19980. /**
  19981. * Sets the linear velocity
  19982. * @param velocity linear velocity or null
  19983. */
  19984. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19985. /**
  19986. * Gets the angular velocity
  19987. * @returns angular velocity or null
  19988. */
  19989. getAngularVelocity(): Nullable<Vector3>;
  19990. /**
  19991. * Sets the angular velocity
  19992. * @param velocity The velocity or null
  19993. */
  19994. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19995. /**
  19996. * Execute a function with the physics plugin native code
  19997. * Provide a function the will have two variables - the world object and the physics body object
  19998. * @param func The function to execute with the physics plugin native code
  19999. */
  20000. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20001. /**
  20002. * Register a function that will be executed before the physics world is stepping forward
  20003. * @param func The function to execute before the physics world is stepped forward
  20004. */
  20005. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20006. /**
  20007. * Unregister a function that will be executed before the physics world is stepping forward
  20008. * @param func The function to execute before the physics world is stepped forward
  20009. */
  20010. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20011. /**
  20012. * Register a function that will be executed after the physics step
  20013. * @param func The function to execute after physics step
  20014. */
  20015. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20016. /**
  20017. * Unregisters a function that will be executed after the physics step
  20018. * @param func The function to execute after physics step
  20019. */
  20020. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20021. /**
  20022. * register a function that will be executed when this impostor collides against a different body
  20023. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20024. * @param func Callback that is executed on collision
  20025. */
  20026. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20027. /**
  20028. * Unregisters the physics imposter on contact
  20029. * @param collideAgainst The physics object to collide against
  20030. * @param func Callback to execute on collision
  20031. */
  20032. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20033. private _tmpQuat;
  20034. private _tmpQuat2;
  20035. /**
  20036. * Get the parent rotation
  20037. * @returns The parent rotation
  20038. */
  20039. getParentsRotation(): Quaternion;
  20040. /**
  20041. * this function is executed by the physics engine.
  20042. */
  20043. beforeStep: () => void;
  20044. /**
  20045. * this function is executed by the physics engine
  20046. */
  20047. afterStep: () => void;
  20048. /**
  20049. * Legacy collision detection event support
  20050. */
  20051. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20052. /**
  20053. * event and body object due to cannon's event-based architecture.
  20054. */
  20055. onCollide: (e: {
  20056. body: any;
  20057. }) => void;
  20058. /**
  20059. * Apply a force
  20060. * @param force The force to apply
  20061. * @param contactPoint The contact point for the force
  20062. * @returns The physics imposter
  20063. */
  20064. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20065. /**
  20066. * Apply an impulse
  20067. * @param force The impulse force
  20068. * @param contactPoint The contact point for the impulse force
  20069. * @returns The physics imposter
  20070. */
  20071. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20072. /**
  20073. * A help function to create a joint
  20074. * @param otherImpostor A physics imposter used to create a joint
  20075. * @param jointType The type of joint
  20076. * @param jointData The data for the joint
  20077. * @returns The physics imposter
  20078. */
  20079. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20080. /**
  20081. * Add a joint to this impostor with a different impostor
  20082. * @param otherImpostor A physics imposter used to add a joint
  20083. * @param joint The joint to add
  20084. * @returns The physics imposter
  20085. */
  20086. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20087. /**
  20088. * Add an anchor to a cloth impostor
  20089. * @param otherImpostor rigid impostor to anchor to
  20090. * @param width ratio across width from 0 to 1
  20091. * @param height ratio up height from 0 to 1
  20092. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20093. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20094. * @returns impostor the soft imposter
  20095. */
  20096. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20097. /**
  20098. * Add a hook to a rope impostor
  20099. * @param otherImpostor rigid impostor to anchor to
  20100. * @param length ratio across rope from 0 to 1
  20101. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20102. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20103. * @returns impostor the rope imposter
  20104. */
  20105. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20106. /**
  20107. * Will keep this body still, in a sleep mode.
  20108. * @returns the physics imposter
  20109. */
  20110. sleep(): PhysicsImpostor;
  20111. /**
  20112. * Wake the body up.
  20113. * @returns The physics imposter
  20114. */
  20115. wakeUp(): PhysicsImpostor;
  20116. /**
  20117. * Clones the physics imposter
  20118. * @param newObject The physics imposter clones to this physics-enabled object
  20119. * @returns A nullable physics imposter
  20120. */
  20121. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20122. /**
  20123. * Disposes the physics imposter
  20124. */
  20125. dispose(): void;
  20126. /**
  20127. * Sets the delta position
  20128. * @param position The delta position amount
  20129. */
  20130. setDeltaPosition(position: Vector3): void;
  20131. /**
  20132. * Sets the delta rotation
  20133. * @param rotation The delta rotation amount
  20134. */
  20135. setDeltaRotation(rotation: Quaternion): void;
  20136. /**
  20137. * Gets the box size of the physics imposter and stores the result in the input parameter
  20138. * @param result Stores the box size
  20139. * @returns The physics imposter
  20140. */
  20141. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20142. /**
  20143. * Gets the radius of the physics imposter
  20144. * @returns Radius of the physics imposter
  20145. */
  20146. getRadius(): number;
  20147. /**
  20148. * Sync a bone with this impostor
  20149. * @param bone The bone to sync to the impostor.
  20150. * @param boneMesh The mesh that the bone is influencing.
  20151. * @param jointPivot The pivot of the joint / bone in local space.
  20152. * @param distToJoint Optional distance from the impostor to the joint.
  20153. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20154. */
  20155. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20156. /**
  20157. * Sync impostor to a bone
  20158. * @param bone The bone that the impostor will be synced to.
  20159. * @param boneMesh The mesh that the bone is influencing.
  20160. * @param jointPivot The pivot of the joint / bone in local space.
  20161. * @param distToJoint Optional distance from the impostor to the joint.
  20162. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20163. * @param boneAxis Optional vector3 axis the bone is aligned with
  20164. */
  20165. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20166. /**
  20167. * No-Imposter type
  20168. */
  20169. static NoImpostor: number;
  20170. /**
  20171. * Sphere-Imposter type
  20172. */
  20173. static SphereImpostor: number;
  20174. /**
  20175. * Box-Imposter type
  20176. */
  20177. static BoxImpostor: number;
  20178. /**
  20179. * Plane-Imposter type
  20180. */
  20181. static PlaneImpostor: number;
  20182. /**
  20183. * Mesh-imposter type
  20184. */
  20185. static MeshImpostor: number;
  20186. /**
  20187. * Cylinder-Imposter type
  20188. */
  20189. static CylinderImpostor: number;
  20190. /**
  20191. * Particle-Imposter type
  20192. */
  20193. static ParticleImpostor: number;
  20194. /**
  20195. * Heightmap-Imposter type
  20196. */
  20197. static HeightmapImpostor: number;
  20198. /**
  20199. * ConvexHull-Impostor type (Ammo.js plugin only)
  20200. */
  20201. static ConvexHullImpostor: number;
  20202. /**
  20203. * Rope-Imposter type
  20204. */
  20205. static RopeImpostor: number;
  20206. /**
  20207. * Cloth-Imposter type
  20208. */
  20209. static ClothImpostor: number;
  20210. /**
  20211. * Softbody-Imposter type
  20212. */
  20213. static SoftbodyImpostor: number;
  20214. }
  20215. }
  20216. declare module BABYLON {
  20217. /**
  20218. * Class used to represent a specific level of detail of a mesh
  20219. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20220. */
  20221. export class MeshLODLevel {
  20222. /** Defines the distance where this level should star being displayed */
  20223. distance: number;
  20224. /** Defines the mesh to use to render this level */
  20225. mesh: Nullable<Mesh>;
  20226. /**
  20227. * Creates a new LOD level
  20228. * @param distance defines the distance where this level should star being displayed
  20229. * @param mesh defines the mesh to use to render this level
  20230. */
  20231. constructor(
  20232. /** Defines the distance where this level should star being displayed */
  20233. distance: number,
  20234. /** Defines the mesh to use to render this level */
  20235. mesh: Nullable<Mesh>);
  20236. }
  20237. /**
  20238. * @hidden
  20239. **/
  20240. export class _CreationDataStorage {
  20241. closePath?: boolean;
  20242. closeArray?: boolean;
  20243. idx: number[];
  20244. dashSize: number;
  20245. gapSize: number;
  20246. path3D: Path3D;
  20247. pathArray: Vector3[][];
  20248. arc: number;
  20249. radius: number;
  20250. cap: number;
  20251. tessellation: number;
  20252. }
  20253. /**
  20254. * @hidden
  20255. **/
  20256. class _InstanceDataStorage {
  20257. visibleInstances: any;
  20258. renderIdForInstances: number[];
  20259. batchCache: _InstancesBatch;
  20260. instancesBufferSize: number;
  20261. instancesBuffer: Nullable<Buffer>;
  20262. instancesData: Float32Array;
  20263. overridenInstanceCount: number;
  20264. }
  20265. /**
  20266. * @hidden
  20267. **/
  20268. export class _InstancesBatch {
  20269. mustReturn: boolean;
  20270. visibleInstances: Nullable<InstancedMesh[]>[];
  20271. renderSelf: boolean[];
  20272. }
  20273. /**
  20274. * Class used to represent renderable models
  20275. */
  20276. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20277. /**
  20278. * Mesh side orientation : usually the external or front surface
  20279. */
  20280. static readonly FRONTSIDE: number;
  20281. /**
  20282. * Mesh side orientation : usually the internal or back surface
  20283. */
  20284. static readonly BACKSIDE: number;
  20285. /**
  20286. * Mesh side orientation : both internal and external or front and back surfaces
  20287. */
  20288. static readonly DOUBLESIDE: number;
  20289. /**
  20290. * Mesh side orientation : by default, `FRONTSIDE`
  20291. */
  20292. static readonly DEFAULTSIDE: number;
  20293. /**
  20294. * Mesh cap setting : no cap
  20295. */
  20296. static readonly NO_CAP: number;
  20297. /**
  20298. * Mesh cap setting : one cap at the beginning of the mesh
  20299. */
  20300. static readonly CAP_START: number;
  20301. /**
  20302. * Mesh cap setting : one cap at the end of the mesh
  20303. */
  20304. static readonly CAP_END: number;
  20305. /**
  20306. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20307. */
  20308. static readonly CAP_ALL: number;
  20309. /**
  20310. * Gets the default side orientation.
  20311. * @param orientation the orientation to value to attempt to get
  20312. * @returns the default orientation
  20313. * @hidden
  20314. */
  20315. static _GetDefaultSideOrientation(orientation?: number): number;
  20316. private _onBeforeRenderObservable;
  20317. private _onBeforeBindObservable;
  20318. private _onAfterRenderObservable;
  20319. private _onBeforeDrawObservable;
  20320. /**
  20321. * An event triggered before rendering the mesh
  20322. */
  20323. readonly onBeforeRenderObservable: Observable<Mesh>;
  20324. /**
  20325. * An event triggered before binding the mesh
  20326. */
  20327. readonly onBeforeBindObservable: Observable<Mesh>;
  20328. /**
  20329. * An event triggered after rendering the mesh
  20330. */
  20331. readonly onAfterRenderObservable: Observable<Mesh>;
  20332. /**
  20333. * An event triggered before drawing the mesh
  20334. */
  20335. readonly onBeforeDrawObservable: Observable<Mesh>;
  20336. private _onBeforeDrawObserver;
  20337. /**
  20338. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20339. */
  20340. onBeforeDraw: () => void;
  20341. /**
  20342. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20343. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20344. */
  20345. delayLoadState: number;
  20346. /**
  20347. * Gets the list of instances created from this mesh
  20348. * it is not supposed to be modified manually.
  20349. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20350. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20351. */
  20352. instances: InstancedMesh[];
  20353. /**
  20354. * Gets the file containing delay loading data for this mesh
  20355. */
  20356. delayLoadingFile: string;
  20357. /** @hidden */
  20358. _binaryInfo: any;
  20359. private _LODLevels;
  20360. /**
  20361. * User defined function used to change how LOD level selection is done
  20362. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20363. */
  20364. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20365. private _morphTargetManager;
  20366. /**
  20367. * Gets or sets the morph target manager
  20368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20369. */
  20370. morphTargetManager: Nullable<MorphTargetManager>;
  20371. /** @hidden */
  20372. _creationDataStorage: Nullable<_CreationDataStorage>;
  20373. /** @hidden */
  20374. _geometry: Nullable<Geometry>;
  20375. /** @hidden */
  20376. _delayInfo: Array<string>;
  20377. /** @hidden */
  20378. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20379. /** @hidden */
  20380. _instanceDataStorage: _InstanceDataStorage;
  20381. private _effectiveMaterial;
  20382. /** @hidden */
  20383. _shouldGenerateFlatShading: boolean;
  20384. private _preActivateId;
  20385. /** @hidden */
  20386. _originalBuilderSideOrientation: number;
  20387. /**
  20388. * Use this property to change the original side orientation defined at construction time
  20389. */
  20390. overrideMaterialSideOrientation: Nullable<number>;
  20391. private _areNormalsFrozen;
  20392. private _sourcePositions;
  20393. private _sourceNormals;
  20394. private _source;
  20395. private meshMap;
  20396. /**
  20397. * Gets the source mesh (the one used to clone this one from)
  20398. */
  20399. readonly source: Nullable<Mesh>;
  20400. /**
  20401. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20402. */
  20403. isUnIndexed: boolean;
  20404. /**
  20405. * @constructor
  20406. * @param name The value used by scene.getMeshByName() to do a lookup.
  20407. * @param scene The scene to add this mesh to.
  20408. * @param parent The parent of this mesh, if it has one
  20409. * @param source An optional Mesh from which geometry is shared, cloned.
  20410. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20411. * When false, achieved by calling a clone(), also passing False.
  20412. * This will make creation of children, recursive.
  20413. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20414. */
  20415. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20416. /**
  20417. * Gets the class name
  20418. * @returns the string "Mesh".
  20419. */
  20420. getClassName(): string;
  20421. /** @hidden */
  20422. readonly _isMesh: boolean;
  20423. /**
  20424. * Returns a description of this mesh
  20425. * @param fullDetails define if full details about this mesh must be used
  20426. * @returns a descriptive string representing this mesh
  20427. */
  20428. toString(fullDetails?: boolean): string;
  20429. /** @hidden */
  20430. _unBindEffect(): void;
  20431. /**
  20432. * Gets a boolean indicating if this mesh has LOD
  20433. */
  20434. readonly hasLODLevels: boolean;
  20435. /**
  20436. * Gets the list of MeshLODLevel associated with the current mesh
  20437. * @returns an array of MeshLODLevel
  20438. */
  20439. getLODLevels(): MeshLODLevel[];
  20440. private _sortLODLevels;
  20441. /**
  20442. * Add a mesh as LOD level triggered at the given distance.
  20443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20444. * @param distance The distance from the center of the object to show this level
  20445. * @param mesh The mesh to be added as LOD level (can be null)
  20446. * @return This mesh (for chaining)
  20447. */
  20448. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20449. /**
  20450. * Returns the LOD level mesh at the passed distance or null if not found.
  20451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20452. * @param distance The distance from the center of the object to show this level
  20453. * @returns a Mesh or `null`
  20454. */
  20455. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20456. /**
  20457. * Remove a mesh from the LOD array
  20458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20459. * @param mesh defines the mesh to be removed
  20460. * @return This mesh (for chaining)
  20461. */
  20462. removeLODLevel(mesh: Mesh): Mesh;
  20463. /**
  20464. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20465. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20466. * @param camera defines the camera to use to compute distance
  20467. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20468. * @return This mesh (for chaining)
  20469. */
  20470. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20471. /**
  20472. * Gets the mesh internal Geometry object
  20473. */
  20474. readonly geometry: Nullable<Geometry>;
  20475. /**
  20476. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20477. * @returns the total number of vertices
  20478. */
  20479. getTotalVertices(): number;
  20480. /**
  20481. * Returns the content of an associated vertex buffer
  20482. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20483. * - VertexBuffer.PositionKind
  20484. * - VertexBuffer.UVKind
  20485. * - VertexBuffer.UV2Kind
  20486. * - VertexBuffer.UV3Kind
  20487. * - VertexBuffer.UV4Kind
  20488. * - VertexBuffer.UV5Kind
  20489. * - VertexBuffer.UV6Kind
  20490. * - VertexBuffer.ColorKind
  20491. * - VertexBuffer.MatricesIndicesKind
  20492. * - VertexBuffer.MatricesIndicesExtraKind
  20493. * - VertexBuffer.MatricesWeightsKind
  20494. * - VertexBuffer.MatricesWeightsExtraKind
  20495. * @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
  20496. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20497. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20498. */
  20499. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20500. /**
  20501. * Returns the mesh VertexBuffer object from the requested `kind`
  20502. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20503. * - VertexBuffer.PositionKind
  20504. * - VertexBuffer.UVKind
  20505. * - VertexBuffer.UV2Kind
  20506. * - VertexBuffer.UV3Kind
  20507. * - VertexBuffer.UV4Kind
  20508. * - VertexBuffer.UV5Kind
  20509. * - VertexBuffer.UV6Kind
  20510. * - VertexBuffer.ColorKind
  20511. * - VertexBuffer.MatricesIndicesKind
  20512. * - VertexBuffer.MatricesIndicesExtraKind
  20513. * - VertexBuffer.MatricesWeightsKind
  20514. * - VertexBuffer.MatricesWeightsExtraKind
  20515. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20516. */
  20517. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20518. /**
  20519. * Tests if a specific vertex buffer is associated with this mesh
  20520. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20521. * - VertexBuffer.PositionKind
  20522. * - VertexBuffer.UVKind
  20523. * - VertexBuffer.UV2Kind
  20524. * - VertexBuffer.UV3Kind
  20525. * - VertexBuffer.UV4Kind
  20526. * - VertexBuffer.UV5Kind
  20527. * - VertexBuffer.UV6Kind
  20528. * - VertexBuffer.ColorKind
  20529. * - VertexBuffer.MatricesIndicesKind
  20530. * - VertexBuffer.MatricesIndicesExtraKind
  20531. * - VertexBuffer.MatricesWeightsKind
  20532. * - VertexBuffer.MatricesWeightsExtraKind
  20533. * @returns a boolean
  20534. */
  20535. isVerticesDataPresent(kind: string): boolean;
  20536. /**
  20537. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20538. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20539. * - VertexBuffer.PositionKind
  20540. * - VertexBuffer.UVKind
  20541. * - VertexBuffer.UV2Kind
  20542. * - VertexBuffer.UV3Kind
  20543. * - VertexBuffer.UV4Kind
  20544. * - VertexBuffer.UV5Kind
  20545. * - VertexBuffer.UV6Kind
  20546. * - VertexBuffer.ColorKind
  20547. * - VertexBuffer.MatricesIndicesKind
  20548. * - VertexBuffer.MatricesIndicesExtraKind
  20549. * - VertexBuffer.MatricesWeightsKind
  20550. * - VertexBuffer.MatricesWeightsExtraKind
  20551. * @returns a boolean
  20552. */
  20553. isVertexBufferUpdatable(kind: string): boolean;
  20554. /**
  20555. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20556. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20557. * - VertexBuffer.PositionKind
  20558. * - VertexBuffer.UVKind
  20559. * - VertexBuffer.UV2Kind
  20560. * - VertexBuffer.UV3Kind
  20561. * - VertexBuffer.UV4Kind
  20562. * - VertexBuffer.UV5Kind
  20563. * - VertexBuffer.UV6Kind
  20564. * - VertexBuffer.ColorKind
  20565. * - VertexBuffer.MatricesIndicesKind
  20566. * - VertexBuffer.MatricesIndicesExtraKind
  20567. * - VertexBuffer.MatricesWeightsKind
  20568. * - VertexBuffer.MatricesWeightsExtraKind
  20569. * @returns an array of strings
  20570. */
  20571. getVerticesDataKinds(): string[];
  20572. /**
  20573. * Returns a positive integer : the total number of indices in this mesh geometry.
  20574. * @returns the numner of indices or zero if the mesh has no geometry.
  20575. */
  20576. getTotalIndices(): number;
  20577. /**
  20578. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20579. * @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.
  20580. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20581. * @returns the indices array or an empty array if the mesh has no geometry
  20582. */
  20583. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20584. readonly isBlocked: boolean;
  20585. /**
  20586. * Determine if the current mesh is ready to be rendered
  20587. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20588. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20589. * @returns true if all associated assets are ready (material, textures, shaders)
  20590. */
  20591. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20592. /**
  20593. * 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.
  20594. */
  20595. readonly areNormalsFrozen: boolean;
  20596. /**
  20597. * 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.
  20598. * @returns the current mesh
  20599. */
  20600. freezeNormals(): Mesh;
  20601. /**
  20602. * 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
  20603. * @returns the current mesh
  20604. */
  20605. unfreezeNormals(): Mesh;
  20606. /**
  20607. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20608. */
  20609. overridenInstanceCount: number;
  20610. /** @hidden */
  20611. _preActivate(): Mesh;
  20612. /** @hidden */
  20613. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20614. /** @hidden */
  20615. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20616. /**
  20617. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20618. * This means the mesh underlying bounding box and sphere are recomputed.
  20619. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20620. * @returns the current mesh
  20621. */
  20622. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20623. /** @hidden */
  20624. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20625. /**
  20626. * This function will subdivide the mesh into multiple submeshes
  20627. * @param count defines the expected number of submeshes
  20628. */
  20629. subdivide(count: number): void;
  20630. /**
  20631. * Copy a FloatArray into a specific associated vertex buffer
  20632. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20633. * - VertexBuffer.PositionKind
  20634. * - VertexBuffer.UVKind
  20635. * - VertexBuffer.UV2Kind
  20636. * - VertexBuffer.UV3Kind
  20637. * - VertexBuffer.UV4Kind
  20638. * - VertexBuffer.UV5Kind
  20639. * - VertexBuffer.UV6Kind
  20640. * - VertexBuffer.ColorKind
  20641. * - VertexBuffer.MatricesIndicesKind
  20642. * - VertexBuffer.MatricesIndicesExtraKind
  20643. * - VertexBuffer.MatricesWeightsKind
  20644. * - VertexBuffer.MatricesWeightsExtraKind
  20645. * @param data defines the data source
  20646. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20647. * @param stride defines the data stride size (can be null)
  20648. * @returns the current mesh
  20649. */
  20650. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20651. /**
  20652. * Flags an associated vertex buffer as updatable
  20653. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20654. * - VertexBuffer.PositionKind
  20655. * - VertexBuffer.UVKind
  20656. * - VertexBuffer.UV2Kind
  20657. * - VertexBuffer.UV3Kind
  20658. * - VertexBuffer.UV4Kind
  20659. * - VertexBuffer.UV5Kind
  20660. * - VertexBuffer.UV6Kind
  20661. * - VertexBuffer.ColorKind
  20662. * - VertexBuffer.MatricesIndicesKind
  20663. * - VertexBuffer.MatricesIndicesExtraKind
  20664. * - VertexBuffer.MatricesWeightsKind
  20665. * - VertexBuffer.MatricesWeightsExtraKind
  20666. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20667. */
  20668. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20669. /**
  20670. * Sets the mesh global Vertex Buffer
  20671. * @param buffer defines the buffer to use
  20672. * @returns the current mesh
  20673. */
  20674. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20675. /**
  20676. * Update a specific associated vertex buffer
  20677. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20678. * - VertexBuffer.PositionKind
  20679. * - VertexBuffer.UVKind
  20680. * - VertexBuffer.UV2Kind
  20681. * - VertexBuffer.UV3Kind
  20682. * - VertexBuffer.UV4Kind
  20683. * - VertexBuffer.UV5Kind
  20684. * - VertexBuffer.UV6Kind
  20685. * - VertexBuffer.ColorKind
  20686. * - VertexBuffer.MatricesIndicesKind
  20687. * - VertexBuffer.MatricesIndicesExtraKind
  20688. * - VertexBuffer.MatricesWeightsKind
  20689. * - VertexBuffer.MatricesWeightsExtraKind
  20690. * @param data defines the data source
  20691. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20692. * @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)
  20693. * @returns the current mesh
  20694. */
  20695. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20696. /**
  20697. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20698. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20699. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20700. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20701. * @returns the current mesh
  20702. */
  20703. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20704. /**
  20705. * Creates a un-shared specific occurence of the geometry for the mesh.
  20706. * @returns the current mesh
  20707. */
  20708. makeGeometryUnique(): Mesh;
  20709. /**
  20710. * Set the index buffer of this mesh
  20711. * @param indices defines the source data
  20712. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20713. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20714. * @returns the current mesh
  20715. */
  20716. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20717. /**
  20718. * Update the current index buffer
  20719. * @param indices defines the source data
  20720. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20721. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20722. * @returns the current mesh
  20723. */
  20724. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20725. /**
  20726. * Invert the geometry to move from a right handed system to a left handed one.
  20727. * @returns the current mesh
  20728. */
  20729. toLeftHanded(): Mesh;
  20730. /** @hidden */
  20731. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20732. /** @hidden */
  20733. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20734. /**
  20735. * Registers for this mesh a javascript function called just before the rendering process
  20736. * @param func defines the function to call before rendering this mesh
  20737. * @returns the current mesh
  20738. */
  20739. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20740. /**
  20741. * Disposes a previously registered javascript function called before the rendering
  20742. * @param func defines the function to remove
  20743. * @returns the current mesh
  20744. */
  20745. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20746. /**
  20747. * Registers for this mesh a javascript function called just after the rendering is complete
  20748. * @param func defines the function to call after rendering this mesh
  20749. * @returns the current mesh
  20750. */
  20751. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20752. /**
  20753. * Disposes a previously registered javascript function called after the rendering.
  20754. * @param func defines the function to remove
  20755. * @returns the current mesh
  20756. */
  20757. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20758. /** @hidden */
  20759. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20760. /** @hidden */
  20761. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20762. /** @hidden */
  20763. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20764. /**
  20765. * 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
  20766. * @param subMesh defines the subMesh to render
  20767. * @param enableAlphaMode defines if alpha mode can be changed
  20768. * @returns the current mesh
  20769. */
  20770. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20771. private _onBeforeDraw;
  20772. /**
  20773. * Renormalize the mesh and patch it up if there are no weights
  20774. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20775. * However in the case of zero weights then we set just a single influence to 1.
  20776. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20777. */
  20778. cleanMatrixWeights(): void;
  20779. private normalizeSkinFourWeights;
  20780. private normalizeSkinWeightsAndExtra;
  20781. /**
  20782. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20783. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20784. * the user know there was an issue with importing the mesh
  20785. * @returns a validation object with skinned, valid and report string
  20786. */
  20787. validateSkinning(): {
  20788. skinned: boolean;
  20789. valid: boolean;
  20790. report: string;
  20791. };
  20792. /** @hidden */
  20793. _checkDelayState(): Mesh;
  20794. private _queueLoad;
  20795. /**
  20796. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20797. * A mesh is in the frustum if its bounding box intersects the frustum
  20798. * @param frustumPlanes defines the frustum to test
  20799. * @returns true if the mesh is in the frustum planes
  20800. */
  20801. isInFrustum(frustumPlanes: Plane[]): boolean;
  20802. /**
  20803. * Sets the mesh material by the material or multiMaterial `id` property
  20804. * @param id is a string identifying the material or the multiMaterial
  20805. * @returns the current mesh
  20806. */
  20807. setMaterialByID(id: string): Mesh;
  20808. /**
  20809. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20810. * @returns an array of IAnimatable
  20811. */
  20812. getAnimatables(): IAnimatable[];
  20813. /**
  20814. * Modifies the mesh geometry according to the passed transformation matrix.
  20815. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20816. * The mesh normals are modified using the same transformation.
  20817. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20818. * @param transform defines the transform matrix to use
  20819. * @see http://doc.babylonjs.com/resources/baking_transformations
  20820. * @returns the current mesh
  20821. */
  20822. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20823. /**
  20824. * Modifies the mesh geometry according to its own current World Matrix.
  20825. * The mesh World Matrix is then reset.
  20826. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20827. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20828. * @see http://doc.babylonjs.com/resources/baking_transformations
  20829. * @returns the current mesh
  20830. */
  20831. bakeCurrentTransformIntoVertices(): Mesh;
  20832. /** @hidden */
  20833. readonly _positions: Nullable<Vector3[]>;
  20834. /** @hidden */
  20835. _resetPointsArrayCache(): Mesh;
  20836. /** @hidden */
  20837. _generatePointsArray(): boolean;
  20838. /**
  20839. * Returns a new Mesh object generated from the current mesh properties.
  20840. * This method must not get confused with createInstance()
  20841. * @param name is a string, the name given to the new mesh
  20842. * @param newParent can be any Node object (default `null`)
  20843. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20844. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20845. * @returns a new mesh
  20846. */
  20847. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20848. /**
  20849. * Releases resources associated with this mesh.
  20850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20852. */
  20853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20854. /**
  20855. * Modifies the mesh geometry according to a displacement map.
  20856. * 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.
  20857. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20858. * @param url is a string, the URL from the image file is to be downloaded.
  20859. * @param minHeight is the lower limit of the displacement.
  20860. * @param maxHeight is the upper limit of the displacement.
  20861. * @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.
  20862. * @param uvOffset is an optional vector2 used to offset UV.
  20863. * @param uvScale is an optional vector2 used to scale UV.
  20864. * @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.
  20865. * @returns the Mesh.
  20866. */
  20867. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20868. /**
  20869. * Modifies the mesh geometry according to a displacementMap buffer.
  20870. * 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.
  20871. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20872. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20873. * @param heightMapWidth is the width of the buffer image.
  20874. * @param heightMapHeight is the height of the buffer image.
  20875. * @param minHeight is the lower limit of the displacement.
  20876. * @param maxHeight is the upper limit of the displacement.
  20877. * @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.
  20878. * @param uvOffset is an optional vector2 used to offset UV.
  20879. * @param uvScale is an optional vector2 used to scale UV.
  20880. * @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.
  20881. * @returns the Mesh.
  20882. */
  20883. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20884. /**
  20885. * Modify the mesh to get a flat shading rendering.
  20886. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20887. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20888. * @returns current mesh
  20889. */
  20890. convertToFlatShadedMesh(): Mesh;
  20891. /**
  20892. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20893. * In other words, more vertices, no more indices and a single bigger VBO.
  20894. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20895. * @returns current mesh
  20896. */
  20897. convertToUnIndexedMesh(): Mesh;
  20898. /**
  20899. * Inverses facet orientations.
  20900. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20901. * @param flipNormals will also inverts the normals
  20902. * @returns current mesh
  20903. */
  20904. flipFaces(flipNormals?: boolean): Mesh;
  20905. /**
  20906. * Increase the number of facets and hence vertices in a mesh
  20907. * Vertex normals are interpolated from existing vertex normals
  20908. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20909. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  20910. */
  20911. increaseVertices(numberPerEdge: number): void;
  20912. /**
  20913. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  20914. * This will undo any application of covertToFlatShadedMesh
  20915. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20916. */
  20917. forceSharedVertices(): void;
  20918. /** @hidden */
  20919. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20920. /** @hidden */
  20921. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20922. /**
  20923. * Creates a new InstancedMesh object from the mesh model.
  20924. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20925. * @param name defines the name of the new instance
  20926. * @returns a new InstancedMesh
  20927. */
  20928. createInstance(name: string): InstancedMesh;
  20929. /**
  20930. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20931. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20932. * @returns the current mesh
  20933. */
  20934. synchronizeInstances(): Mesh;
  20935. /**
  20936. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20937. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20938. * This should be used together with the simplification to avoid disappearing triangles.
  20939. * @param successCallback an optional success callback to be called after the optimization finished.
  20940. * @returns the current mesh
  20941. */
  20942. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20943. /**
  20944. * Serialize current mesh
  20945. * @param serializationObject defines the object which will receive the serialization data
  20946. */
  20947. serialize(serializationObject: any): void;
  20948. /** @hidden */
  20949. _syncGeometryWithMorphTargetManager(): void;
  20950. /** @hidden */
  20951. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20952. /**
  20953. * Returns a new Mesh object parsed from the source provided.
  20954. * @param parsedMesh is the source
  20955. * @param scene defines the hosting scene
  20956. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20957. * @returns a new Mesh
  20958. */
  20959. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20960. /**
  20961. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20962. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20963. * @param name defines the name of the mesh to create
  20964. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20965. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20966. * @param closePath creates a seam between the first and the last points of each path of the path array
  20967. * @param offset is taken in account only if the `pathArray` is containing a single path
  20968. * @param scene defines the hosting scene
  20969. * @param updatable defines if the mesh must be flagged as updatable
  20970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20971. * @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)
  20972. * @returns a new Mesh
  20973. */
  20974. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20975. /**
  20976. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20977. * @param name defines the name of the mesh to create
  20978. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20979. * @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
  20980. * @param scene defines the hosting scene
  20981. * @param updatable defines if the mesh must be flagged as updatable
  20982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20983. * @returns a new Mesh
  20984. */
  20985. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20986. /**
  20987. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20988. * @param name defines the name of the mesh to create
  20989. * @param size sets the size (float) of each box side (default 1)
  20990. * @param scene defines the hosting scene
  20991. * @param updatable defines if the mesh must be flagged as updatable
  20992. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20993. * @returns a new Mesh
  20994. */
  20995. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20996. /**
  20997. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20998. * @param name defines the name of the mesh to create
  20999. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21000. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21001. * @param scene defines the hosting scene
  21002. * @param updatable defines if the mesh must be flagged as updatable
  21003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21004. * @returns a new Mesh
  21005. */
  21006. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21007. /**
  21008. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21009. * @param name defines the name of the mesh to create
  21010. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21011. * @param diameterTop set the top cap diameter (floats, default 1)
  21012. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21013. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21014. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21015. * @param scene defines the hosting scene
  21016. * @param updatable defines if the mesh must be flagged as updatable
  21017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21018. * @returns a new Mesh
  21019. */
  21020. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21021. /**
  21022. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21023. * @param name defines the name of the mesh to create
  21024. * @param diameter sets the diameter size (float) of the torus (default 1)
  21025. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21026. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21027. * @param scene defines the hosting scene
  21028. * @param updatable defines if the mesh must be flagged as updatable
  21029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21030. * @returns a new Mesh
  21031. */
  21032. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21033. /**
  21034. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21035. * @param name defines the name of the mesh to create
  21036. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21037. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21038. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21039. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21040. * @param p the number of windings on X axis (positive integers, default 2)
  21041. * @param q the number of windings on Y axis (positive integers, default 3)
  21042. * @param scene defines the hosting scene
  21043. * @param updatable defines if the mesh must be flagged as updatable
  21044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21045. * @returns a new Mesh
  21046. */
  21047. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21048. /**
  21049. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21050. * @param name defines the name of the mesh to create
  21051. * @param points is an array successive Vector3
  21052. * @param scene defines the hosting scene
  21053. * @param updatable defines if the mesh must be flagged as updatable
  21054. * @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).
  21055. * @returns a new Mesh
  21056. */
  21057. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21058. /**
  21059. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21060. * @param name defines the name of the mesh to create
  21061. * @param points is an array successive Vector3
  21062. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21063. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21064. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21065. * @param scene defines the hosting scene
  21066. * @param updatable defines if the mesh must be flagged as updatable
  21067. * @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)
  21068. * @returns a new Mesh
  21069. */
  21070. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21071. /**
  21072. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21073. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21074. * 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.
  21075. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21077. * Remember you can only change the shape positions, not their number when updating a polygon.
  21078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21079. * @param name defines the name of the mesh to create
  21080. * @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
  21081. * @param scene defines the hosting scene
  21082. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21083. * @param updatable defines if the mesh must be flagged as updatable
  21084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21085. * @param earcutInjection can be used to inject your own earcut reference
  21086. * @returns a new Mesh
  21087. */
  21088. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21089. /**
  21090. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21092. * @param name defines the name of the mesh to create
  21093. * @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
  21094. * @param depth defines the height of extrusion
  21095. * @param scene defines the hosting scene
  21096. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21097. * @param updatable defines if the mesh must be flagged as updatable
  21098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21099. * @param earcutInjection can be used to inject your own earcut reference
  21100. * @returns a new Mesh
  21101. */
  21102. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21103. /**
  21104. * Creates an extruded shape mesh.
  21105. * 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
  21106. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21107. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21108. * @param name defines the name of the mesh to create
  21109. * @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
  21110. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21111. * @param scale is the value to scale the shape
  21112. * @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
  21113. * @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
  21114. * @param scene defines the hosting scene
  21115. * @param updatable defines if the mesh must be flagged as updatable
  21116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21117. * @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)
  21118. * @returns a new Mesh
  21119. */
  21120. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21121. /**
  21122. * Creates an custom extruded shape mesh.
  21123. * The custom extrusion is a parametric shape.
  21124. * It has no predefined shape. Its final shape will depend on the input parameters.
  21125. * Please consider using the same method from the MeshBuilder class instead
  21126. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21127. * @param name defines the name of the mesh to create
  21128. * @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
  21129. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21130. * @param scaleFunction is a custom Javascript function called on each path point
  21131. * @param rotationFunction is a custom Javascript function called on each path point
  21132. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21133. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21134. * @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
  21135. * @param scene defines the hosting scene
  21136. * @param updatable defines if the mesh must be flagged as updatable
  21137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21138. * @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)
  21139. * @returns a new Mesh
  21140. */
  21141. 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;
  21142. /**
  21143. * Creates lathe mesh.
  21144. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21145. * Please consider using the same method from the MeshBuilder class instead
  21146. * @param name defines the name of the mesh to create
  21147. * @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
  21148. * @param radius is the radius value of the lathe
  21149. * @param tessellation is the side number of the lathe.
  21150. * @param scene defines the hosting scene
  21151. * @param updatable defines if the mesh must be flagged as updatable
  21152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21153. * @returns a new Mesh
  21154. */
  21155. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21156. /**
  21157. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21158. * @param name defines the name of the mesh to create
  21159. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21160. * @param scene defines the hosting scene
  21161. * @param updatable defines if the mesh must be flagged as updatable
  21162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21163. * @returns a new Mesh
  21164. */
  21165. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21166. /**
  21167. * Creates a ground mesh.
  21168. * Please consider using the same method from the MeshBuilder class instead
  21169. * @param name defines the name of the mesh to create
  21170. * @param width set the width of the ground
  21171. * @param height set the height of the ground
  21172. * @param subdivisions sets the number of subdivisions per side
  21173. * @param scene defines the hosting scene
  21174. * @param updatable defines if the mesh must be flagged as updatable
  21175. * @returns a new Mesh
  21176. */
  21177. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21178. /**
  21179. * Creates a tiled ground mesh.
  21180. * Please consider using the same method from the MeshBuilder class instead
  21181. * @param name defines the name of the mesh to create
  21182. * @param xmin set the ground minimum X coordinate
  21183. * @param zmin set the ground minimum Y coordinate
  21184. * @param xmax set the ground maximum X coordinate
  21185. * @param zmax set the ground maximum Z coordinate
  21186. * @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
  21187. * @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
  21188. * @param scene defines the hosting scene
  21189. * @param updatable defines if the mesh must be flagged as updatable
  21190. * @returns a new Mesh
  21191. */
  21192. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21193. w: number;
  21194. h: number;
  21195. }, precision: {
  21196. w: number;
  21197. h: number;
  21198. }, scene: Scene, updatable?: boolean): Mesh;
  21199. /**
  21200. * Creates a ground mesh from a height map.
  21201. * Please consider using the same method from the MeshBuilder class instead
  21202. * @see http://doc.babylonjs.com/babylon101/height_map
  21203. * @param name defines the name of the mesh to create
  21204. * @param url sets the URL of the height map image resource
  21205. * @param width set the ground width size
  21206. * @param height set the ground height size
  21207. * @param subdivisions sets the number of subdivision per side
  21208. * @param minHeight is the minimum altitude on the ground
  21209. * @param maxHeight is the maximum altitude on the ground
  21210. * @param scene defines the hosting scene
  21211. * @param updatable defines if the mesh must be flagged as updatable
  21212. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21213. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21214. * @returns a new Mesh
  21215. */
  21216. 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;
  21217. /**
  21218. * Creates a tube mesh.
  21219. * The tube is a parametric shape.
  21220. * It has no predefined shape. Its final shape will depend on the input parameters.
  21221. * Please consider using the same method from the MeshBuilder class instead
  21222. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21223. * @param name defines the name of the mesh to create
  21224. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21225. * @param radius sets the tube radius size
  21226. * @param tessellation is the number of sides on the tubular surface
  21227. * @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
  21228. * @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
  21229. * @param scene defines the hosting scene
  21230. * @param updatable defines if the mesh must be flagged as updatable
  21231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21232. * @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)
  21233. * @returns a new Mesh
  21234. */
  21235. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21236. (i: number, distance: number): number;
  21237. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21238. /**
  21239. * Creates a polyhedron mesh.
  21240. * Please consider using the same method from the MeshBuilder class instead.
  21241. * * 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
  21242. * * The parameter `size` (positive float, default 1) sets the polygon size
  21243. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21244. * * 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`
  21245. * * 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
  21246. * * 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)`)
  21247. * * 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
  21248. * * 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
  21249. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21250. * * 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
  21251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21252. * @param name defines the name of the mesh to create
  21253. * @param options defines the options used to create the mesh
  21254. * @param scene defines the hosting scene
  21255. * @returns a new Mesh
  21256. */
  21257. static CreatePolyhedron(name: string, options: {
  21258. type?: number;
  21259. size?: number;
  21260. sizeX?: number;
  21261. sizeY?: number;
  21262. sizeZ?: number;
  21263. custom?: any;
  21264. faceUV?: Vector4[];
  21265. faceColors?: Color4[];
  21266. updatable?: boolean;
  21267. sideOrientation?: number;
  21268. }, scene: Scene): Mesh;
  21269. /**
  21270. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21271. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21272. * * 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`)
  21273. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21274. * * 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
  21275. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21276. * * 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
  21277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21278. * @param name defines the name of the mesh
  21279. * @param options defines the options used to create the mesh
  21280. * @param scene defines the hosting scene
  21281. * @returns a new Mesh
  21282. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21283. */
  21284. static CreateIcoSphere(name: string, options: {
  21285. radius?: number;
  21286. flat?: boolean;
  21287. subdivisions?: number;
  21288. sideOrientation?: number;
  21289. updatable?: boolean;
  21290. }, scene: Scene): Mesh;
  21291. /**
  21292. * Creates a decal mesh.
  21293. * Please consider using the same method from the MeshBuilder class instead.
  21294. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21295. * @param name defines the name of the mesh
  21296. * @param sourceMesh defines the mesh receiving the decal
  21297. * @param position sets the position of the decal in world coordinates
  21298. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21299. * @param size sets the decal scaling
  21300. * @param angle sets the angle to rotate the decal
  21301. * @returns a new Mesh
  21302. */
  21303. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21304. /**
  21305. * Prepare internal position array for software CPU skinning
  21306. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21307. */
  21308. setPositionsForCPUSkinning(): Float32Array;
  21309. /**
  21310. * Prepare internal normal array for software CPU skinning
  21311. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21312. */
  21313. setNormalsForCPUSkinning(): Float32Array;
  21314. /**
  21315. * Updates the vertex buffer by applying transformation from the bones
  21316. * @param skeleton defines the skeleton to apply to current mesh
  21317. * @returns the current mesh
  21318. */
  21319. applySkeleton(skeleton: Skeleton): Mesh;
  21320. /**
  21321. * 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
  21322. * @param meshes defines the list of meshes to scan
  21323. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21324. */
  21325. static MinMax(meshes: AbstractMesh[]): {
  21326. min: Vector3;
  21327. max: Vector3;
  21328. };
  21329. /**
  21330. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21331. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21332. * @returns a vector3
  21333. */
  21334. static Center(meshesOrMinMaxVector: {
  21335. min: Vector3;
  21336. max: Vector3;
  21337. } | AbstractMesh[]): Vector3;
  21338. /**
  21339. * Merge the array of meshes into a single mesh for performance reasons.
  21340. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21341. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21342. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21343. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21344. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21345. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21346. * @returns a new mesh
  21347. */
  21348. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21349. /** @hidden */
  21350. addInstance(instance: InstancedMesh): void;
  21351. /** @hidden */
  21352. removeInstance(instance: InstancedMesh): void;
  21353. }
  21354. }
  21355. declare module BABYLON {
  21356. /**
  21357. * Base class for the main features of a material in Babylon.js
  21358. */
  21359. export class Material implements IAnimatable {
  21360. /**
  21361. * Returns the triangle fill mode
  21362. */
  21363. static readonly TriangleFillMode: number;
  21364. /**
  21365. * Returns the wireframe mode
  21366. */
  21367. static readonly WireFrameFillMode: number;
  21368. /**
  21369. * Returns the point fill mode
  21370. */
  21371. static readonly PointFillMode: number;
  21372. /**
  21373. * Returns the point list draw mode
  21374. */
  21375. static readonly PointListDrawMode: number;
  21376. /**
  21377. * Returns the line list draw mode
  21378. */
  21379. static readonly LineListDrawMode: number;
  21380. /**
  21381. * Returns the line loop draw mode
  21382. */
  21383. static readonly LineLoopDrawMode: number;
  21384. /**
  21385. * Returns the line strip draw mode
  21386. */
  21387. static readonly LineStripDrawMode: number;
  21388. /**
  21389. * Returns the triangle strip draw mode
  21390. */
  21391. static readonly TriangleStripDrawMode: number;
  21392. /**
  21393. * Returns the triangle fan draw mode
  21394. */
  21395. static readonly TriangleFanDrawMode: number;
  21396. /**
  21397. * Stores the clock-wise side orientation
  21398. */
  21399. static readonly ClockWiseSideOrientation: number;
  21400. /**
  21401. * Stores the counter clock-wise side orientation
  21402. */
  21403. static readonly CounterClockWiseSideOrientation: number;
  21404. /**
  21405. * The dirty texture flag value
  21406. */
  21407. static readonly TextureDirtyFlag: number;
  21408. /**
  21409. * The dirty light flag value
  21410. */
  21411. static readonly LightDirtyFlag: number;
  21412. /**
  21413. * The dirty fresnel flag value
  21414. */
  21415. static readonly FresnelDirtyFlag: number;
  21416. /**
  21417. * The dirty attribute flag value
  21418. */
  21419. static readonly AttributesDirtyFlag: number;
  21420. /**
  21421. * The dirty misc flag value
  21422. */
  21423. static readonly MiscDirtyFlag: number;
  21424. /**
  21425. * The all dirty flag value
  21426. */
  21427. static readonly AllDirtyFlag: number;
  21428. /**
  21429. * The ID of the material
  21430. */
  21431. id: string;
  21432. /**
  21433. * Gets or sets the unique id of the material
  21434. */
  21435. uniqueId: number;
  21436. /**
  21437. * The name of the material
  21438. */
  21439. name: string;
  21440. /**
  21441. * Gets or sets user defined metadata
  21442. */
  21443. metadata: any;
  21444. /**
  21445. * For internal use only. Please do not use.
  21446. */
  21447. reservedDataStore: any;
  21448. /**
  21449. * Specifies if the ready state should be checked on each call
  21450. */
  21451. checkReadyOnEveryCall: boolean;
  21452. /**
  21453. * Specifies if the ready state should be checked once
  21454. */
  21455. checkReadyOnlyOnce: boolean;
  21456. /**
  21457. * The state of the material
  21458. */
  21459. state: string;
  21460. /**
  21461. * The alpha value of the material
  21462. */
  21463. protected _alpha: number;
  21464. /**
  21465. * List of inspectable custom properties (used by the Inspector)
  21466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21467. */
  21468. inspectableCustomProperties: IInspectable[];
  21469. /**
  21470. * Sets the alpha value of the material
  21471. */
  21472. /**
  21473. * Gets the alpha value of the material
  21474. */
  21475. alpha: number;
  21476. /**
  21477. * Specifies if back face culling is enabled
  21478. */
  21479. protected _backFaceCulling: boolean;
  21480. /**
  21481. * Sets the back-face culling state
  21482. */
  21483. /**
  21484. * Gets the back-face culling state
  21485. */
  21486. backFaceCulling: boolean;
  21487. /**
  21488. * Stores the value for side orientation
  21489. */
  21490. sideOrientation: number;
  21491. /**
  21492. * Callback triggered when the material is compiled
  21493. */
  21494. onCompiled: (effect: Effect) => void;
  21495. /**
  21496. * Callback triggered when an error occurs
  21497. */
  21498. onError: (effect: Effect, errors: string) => void;
  21499. /**
  21500. * Callback triggered to get the render target textures
  21501. */
  21502. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21503. /**
  21504. * Gets a boolean indicating that current material needs to register RTT
  21505. */
  21506. readonly hasRenderTargetTextures: boolean;
  21507. /**
  21508. * Specifies if the material should be serialized
  21509. */
  21510. doNotSerialize: boolean;
  21511. /**
  21512. * @hidden
  21513. */
  21514. _storeEffectOnSubMeshes: boolean;
  21515. /**
  21516. * Stores the animations for the material
  21517. */
  21518. animations: Array<Animation>;
  21519. /**
  21520. * An event triggered when the material is disposed
  21521. */
  21522. onDisposeObservable: Observable<Material>;
  21523. /**
  21524. * An observer which watches for dispose events
  21525. */
  21526. private _onDisposeObserver;
  21527. private _onUnBindObservable;
  21528. /**
  21529. * Called during a dispose event
  21530. */
  21531. onDispose: () => void;
  21532. private _onBindObservable;
  21533. /**
  21534. * An event triggered when the material is bound
  21535. */
  21536. readonly onBindObservable: Observable<AbstractMesh>;
  21537. /**
  21538. * An observer which watches for bind events
  21539. */
  21540. private _onBindObserver;
  21541. /**
  21542. * Called during a bind event
  21543. */
  21544. onBind: (Mesh: AbstractMesh) => void;
  21545. /**
  21546. * An event triggered when the material is unbound
  21547. */
  21548. readonly onUnBindObservable: Observable<Material>;
  21549. /**
  21550. * Stores the value of the alpha mode
  21551. */
  21552. private _alphaMode;
  21553. /**
  21554. * Sets the value of the alpha mode.
  21555. *
  21556. * | Value | Type | Description |
  21557. * | --- | --- | --- |
  21558. * | 0 | ALPHA_DISABLE | |
  21559. * | 1 | ALPHA_ADD | |
  21560. * | 2 | ALPHA_COMBINE | |
  21561. * | 3 | ALPHA_SUBTRACT | |
  21562. * | 4 | ALPHA_MULTIPLY | |
  21563. * | 5 | ALPHA_MAXIMIZED | |
  21564. * | 6 | ALPHA_ONEONE | |
  21565. * | 7 | ALPHA_PREMULTIPLIED | |
  21566. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21567. * | 9 | ALPHA_INTERPOLATE | |
  21568. * | 10 | ALPHA_SCREENMODE | |
  21569. *
  21570. */
  21571. /**
  21572. * Gets the value of the alpha mode
  21573. */
  21574. alphaMode: number;
  21575. /**
  21576. * Stores the state of the need depth pre-pass value
  21577. */
  21578. private _needDepthPrePass;
  21579. /**
  21580. * Sets the need depth pre-pass value
  21581. */
  21582. /**
  21583. * Gets the depth pre-pass value
  21584. */
  21585. needDepthPrePass: boolean;
  21586. /**
  21587. * Specifies if depth writing should be disabled
  21588. */
  21589. disableDepthWrite: boolean;
  21590. /**
  21591. * Specifies if depth writing should be forced
  21592. */
  21593. forceDepthWrite: boolean;
  21594. /**
  21595. * Specifies if there should be a separate pass for culling
  21596. */
  21597. separateCullingPass: boolean;
  21598. /**
  21599. * Stores the state specifing if fog should be enabled
  21600. */
  21601. private _fogEnabled;
  21602. /**
  21603. * Sets the state for enabling fog
  21604. */
  21605. /**
  21606. * Gets the value of the fog enabled state
  21607. */
  21608. fogEnabled: boolean;
  21609. /**
  21610. * Stores the size of points
  21611. */
  21612. pointSize: number;
  21613. /**
  21614. * Stores the z offset value
  21615. */
  21616. zOffset: number;
  21617. /**
  21618. * Gets a value specifying if wireframe mode is enabled
  21619. */
  21620. /**
  21621. * Sets the state of wireframe mode
  21622. */
  21623. wireframe: boolean;
  21624. /**
  21625. * Gets the value specifying if point clouds are enabled
  21626. */
  21627. /**
  21628. * Sets the state of point cloud mode
  21629. */
  21630. pointsCloud: boolean;
  21631. /**
  21632. * Gets the material fill mode
  21633. */
  21634. /**
  21635. * Sets the material fill mode
  21636. */
  21637. fillMode: number;
  21638. /**
  21639. * @hidden
  21640. * Stores the effects for the material
  21641. */
  21642. _effect: Nullable<Effect>;
  21643. /**
  21644. * @hidden
  21645. * Specifies if the material was previously ready
  21646. */
  21647. _wasPreviouslyReady: boolean;
  21648. /**
  21649. * Specifies if uniform buffers should be used
  21650. */
  21651. private _useUBO;
  21652. /**
  21653. * Stores a reference to the scene
  21654. */
  21655. private _scene;
  21656. /**
  21657. * Stores the fill mode state
  21658. */
  21659. private _fillMode;
  21660. /**
  21661. * Specifies if the depth write state should be cached
  21662. */
  21663. private _cachedDepthWriteState;
  21664. /**
  21665. * Stores the uniform buffer
  21666. */
  21667. protected _uniformBuffer: UniformBuffer;
  21668. /** @hidden */
  21669. _indexInSceneMaterialArray: number;
  21670. /** @hidden */
  21671. meshMap: Nullable<{
  21672. [id: string]: AbstractMesh | undefined;
  21673. }>;
  21674. /**
  21675. * Creates a material instance
  21676. * @param name defines the name of the material
  21677. * @param scene defines the scene to reference
  21678. * @param doNotAdd specifies if the material should be added to the scene
  21679. */
  21680. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21681. /**
  21682. * Returns a string representation of the current material
  21683. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21684. * @returns a string with material information
  21685. */
  21686. toString(fullDetails?: boolean): string;
  21687. /**
  21688. * Gets the class name of the material
  21689. * @returns a string with the class name of the material
  21690. */
  21691. getClassName(): string;
  21692. /**
  21693. * Specifies if updates for the material been locked
  21694. */
  21695. readonly isFrozen: boolean;
  21696. /**
  21697. * Locks updates for the material
  21698. */
  21699. freeze(): void;
  21700. /**
  21701. * Unlocks updates for the material
  21702. */
  21703. unfreeze(): void;
  21704. /**
  21705. * Specifies if the material is ready to be used
  21706. * @param mesh defines the mesh to check
  21707. * @param useInstances specifies if instances should be used
  21708. * @returns a boolean indicating if the material is ready to be used
  21709. */
  21710. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21711. /**
  21712. * Specifies that the submesh is ready to be used
  21713. * @param mesh defines the mesh to check
  21714. * @param subMesh defines which submesh to check
  21715. * @param useInstances specifies that instances should be used
  21716. * @returns a boolean indicating that the submesh is ready or not
  21717. */
  21718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21719. /**
  21720. * Returns the material effect
  21721. * @returns the effect associated with the material
  21722. */
  21723. getEffect(): Nullable<Effect>;
  21724. /**
  21725. * Returns the current scene
  21726. * @returns a Scene
  21727. */
  21728. getScene(): Scene;
  21729. /**
  21730. * Specifies if the material will require alpha blending
  21731. * @returns a boolean specifying if alpha blending is needed
  21732. */
  21733. needAlphaBlending(): boolean;
  21734. /**
  21735. * Specifies if the mesh will require alpha blending
  21736. * @param mesh defines the mesh to check
  21737. * @returns a boolean specifying if alpha blending is needed for the mesh
  21738. */
  21739. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21740. /**
  21741. * Specifies if this material should be rendered in alpha test mode
  21742. * @returns a boolean specifying if an alpha test is needed.
  21743. */
  21744. needAlphaTesting(): boolean;
  21745. /**
  21746. * Gets the texture used for the alpha test
  21747. * @returns the texture to use for alpha testing
  21748. */
  21749. getAlphaTestTexture(): Nullable<BaseTexture>;
  21750. /**
  21751. * Marks the material to indicate that it needs to be re-calculated
  21752. */
  21753. markDirty(): void;
  21754. /** @hidden */
  21755. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21756. /**
  21757. * Binds the material to the mesh
  21758. * @param world defines the world transformation matrix
  21759. * @param mesh defines the mesh to bind the material to
  21760. */
  21761. bind(world: Matrix, mesh?: Mesh): void;
  21762. /**
  21763. * Binds the submesh to the material
  21764. * @param world defines the world transformation matrix
  21765. * @param mesh defines the mesh containing the submesh
  21766. * @param subMesh defines the submesh to bind the material to
  21767. */
  21768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21769. /**
  21770. * Binds the world matrix to the material
  21771. * @param world defines the world transformation matrix
  21772. */
  21773. bindOnlyWorldMatrix(world: Matrix): void;
  21774. /**
  21775. * Binds the scene's uniform buffer to the effect.
  21776. * @param effect defines the effect to bind to the scene uniform buffer
  21777. * @param sceneUbo defines the uniform buffer storing scene data
  21778. */
  21779. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21780. /**
  21781. * Binds the view matrix to the effect
  21782. * @param effect defines the effect to bind the view matrix to
  21783. */
  21784. bindView(effect: Effect): void;
  21785. /**
  21786. * Binds the view projection matrix to the effect
  21787. * @param effect defines the effect to bind the view projection matrix to
  21788. */
  21789. bindViewProjection(effect: Effect): void;
  21790. /**
  21791. * Specifies if material alpha testing should be turned on for the mesh
  21792. * @param mesh defines the mesh to check
  21793. */
  21794. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21795. /**
  21796. * Processes to execute after binding the material to a mesh
  21797. * @param mesh defines the rendered mesh
  21798. */
  21799. protected _afterBind(mesh?: Mesh): void;
  21800. /**
  21801. * Unbinds the material from the mesh
  21802. */
  21803. unbind(): void;
  21804. /**
  21805. * Gets the active textures from the material
  21806. * @returns an array of textures
  21807. */
  21808. getActiveTextures(): BaseTexture[];
  21809. /**
  21810. * Specifies if the material uses a texture
  21811. * @param texture defines the texture to check against the material
  21812. * @returns a boolean specifying if the material uses the texture
  21813. */
  21814. hasTexture(texture: BaseTexture): boolean;
  21815. /**
  21816. * Makes a duplicate of the material, and gives it a new name
  21817. * @param name defines the new name for the duplicated material
  21818. * @returns the cloned material
  21819. */
  21820. clone(name: string): Nullable<Material>;
  21821. /**
  21822. * Gets the meshes bound to the material
  21823. * @returns an array of meshes bound to the material
  21824. */
  21825. getBindedMeshes(): AbstractMesh[];
  21826. /**
  21827. * Force shader compilation
  21828. * @param mesh defines the mesh associated with this material
  21829. * @param onCompiled defines a function to execute once the material is compiled
  21830. * @param options defines the options to configure the compilation
  21831. */
  21832. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21833. clipPlane: boolean;
  21834. }>): void;
  21835. /**
  21836. * Force shader compilation
  21837. * @param mesh defines the mesh that will use this material
  21838. * @param options defines additional options for compiling the shaders
  21839. * @returns a promise that resolves when the compilation completes
  21840. */
  21841. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21842. clipPlane: boolean;
  21843. }>): Promise<void>;
  21844. private static readonly _ImageProcessingDirtyCallBack;
  21845. private static readonly _TextureDirtyCallBack;
  21846. private static readonly _FresnelDirtyCallBack;
  21847. private static readonly _MiscDirtyCallBack;
  21848. private static readonly _LightsDirtyCallBack;
  21849. private static readonly _AttributeDirtyCallBack;
  21850. private static _FresnelAndMiscDirtyCallBack;
  21851. private static _TextureAndMiscDirtyCallBack;
  21852. private static readonly _DirtyCallbackArray;
  21853. private static readonly _RunDirtyCallBacks;
  21854. /**
  21855. * Marks a define in the material to indicate that it needs to be re-computed
  21856. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21857. */
  21858. markAsDirty(flag: number): void;
  21859. /**
  21860. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21861. * @param func defines a function which checks material defines against the submeshes
  21862. */
  21863. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21864. /**
  21865. * Indicates that image processing needs to be re-calculated for all submeshes
  21866. */
  21867. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21868. /**
  21869. * Indicates that textures need to be re-calculated for all submeshes
  21870. */
  21871. protected _markAllSubMeshesAsTexturesDirty(): void;
  21872. /**
  21873. * Indicates that fresnel needs to be re-calculated for all submeshes
  21874. */
  21875. protected _markAllSubMeshesAsFresnelDirty(): void;
  21876. /**
  21877. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21878. */
  21879. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21880. /**
  21881. * Indicates that lights need to be re-calculated for all submeshes
  21882. */
  21883. protected _markAllSubMeshesAsLightsDirty(): void;
  21884. /**
  21885. * Indicates that attributes need to be re-calculated for all submeshes
  21886. */
  21887. protected _markAllSubMeshesAsAttributesDirty(): void;
  21888. /**
  21889. * Indicates that misc needs to be re-calculated for all submeshes
  21890. */
  21891. protected _markAllSubMeshesAsMiscDirty(): void;
  21892. /**
  21893. * Indicates that textures and misc need to be re-calculated for all submeshes
  21894. */
  21895. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21896. /**
  21897. * Disposes the material
  21898. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21899. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21900. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21901. */
  21902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21903. /** @hidden */
  21904. private releaseVertexArrayObject;
  21905. /**
  21906. * Serializes this material
  21907. * @returns the serialized material object
  21908. */
  21909. serialize(): any;
  21910. /**
  21911. * Creates a material from parsed material data
  21912. * @param parsedMaterial defines parsed material data
  21913. * @param scene defines the hosting scene
  21914. * @param rootUrl defines the root URL to use to load textures
  21915. * @returns a new material
  21916. */
  21917. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21918. }
  21919. }
  21920. declare module BABYLON {
  21921. /**
  21922. * Base class for submeshes
  21923. */
  21924. export class BaseSubMesh {
  21925. /** @hidden */
  21926. _materialDefines: Nullable<MaterialDefines>;
  21927. /** @hidden */
  21928. _materialEffect: Nullable<Effect>;
  21929. /**
  21930. * Gets associated effect
  21931. */
  21932. readonly effect: Nullable<Effect>;
  21933. /**
  21934. * Sets associated effect (effect used to render this submesh)
  21935. * @param effect defines the effect to associate with
  21936. * @param defines defines the set of defines used to compile this effect
  21937. */
  21938. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21939. }
  21940. /**
  21941. * Defines a subdivision inside a mesh
  21942. */
  21943. export class SubMesh extends BaseSubMesh implements ICullable {
  21944. /** the material index to use */
  21945. materialIndex: number;
  21946. /** vertex index start */
  21947. verticesStart: number;
  21948. /** vertices count */
  21949. verticesCount: number;
  21950. /** index start */
  21951. indexStart: number;
  21952. /** indices count */
  21953. indexCount: number;
  21954. /** @hidden */
  21955. _linesIndexCount: number;
  21956. private _mesh;
  21957. private _renderingMesh;
  21958. private _boundingInfo;
  21959. private _linesIndexBuffer;
  21960. /** @hidden */
  21961. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21962. /** @hidden */
  21963. _trianglePlanes: Plane[];
  21964. /** @hidden */
  21965. _lastColliderTransformMatrix: Matrix;
  21966. /** @hidden */
  21967. _renderId: number;
  21968. /** @hidden */
  21969. _alphaIndex: number;
  21970. /** @hidden */
  21971. _distanceToCamera: number;
  21972. /** @hidden */
  21973. _id: number;
  21974. private _currentMaterial;
  21975. /**
  21976. * Add a new submesh to a mesh
  21977. * @param materialIndex defines the material index to use
  21978. * @param verticesStart defines vertex index start
  21979. * @param verticesCount defines vertices count
  21980. * @param indexStart defines index start
  21981. * @param indexCount defines indices count
  21982. * @param mesh defines the parent mesh
  21983. * @param renderingMesh defines an optional rendering mesh
  21984. * @param createBoundingBox defines if bounding box should be created for this submesh
  21985. * @returns the new submesh
  21986. */
  21987. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21988. /**
  21989. * Creates a new submesh
  21990. * @param materialIndex defines the material index to use
  21991. * @param verticesStart defines vertex index start
  21992. * @param verticesCount defines vertices count
  21993. * @param indexStart defines index start
  21994. * @param indexCount defines indices count
  21995. * @param mesh defines the parent mesh
  21996. * @param renderingMesh defines an optional rendering mesh
  21997. * @param createBoundingBox defines if bounding box should be created for this submesh
  21998. */
  21999. constructor(
  22000. /** the material index to use */
  22001. materialIndex: number,
  22002. /** vertex index start */
  22003. verticesStart: number,
  22004. /** vertices count */
  22005. verticesCount: number,
  22006. /** index start */
  22007. indexStart: number,
  22008. /** indices count */
  22009. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22010. /**
  22011. * Returns true if this submesh covers the entire parent mesh
  22012. * @ignorenaming
  22013. */
  22014. readonly IsGlobal: boolean;
  22015. /**
  22016. * Returns the submesh BoudingInfo object
  22017. * @returns current bounding info (or mesh's one if the submesh is global)
  22018. */
  22019. getBoundingInfo(): BoundingInfo;
  22020. /**
  22021. * Sets the submesh BoundingInfo
  22022. * @param boundingInfo defines the new bounding info to use
  22023. * @returns the SubMesh
  22024. */
  22025. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22026. /**
  22027. * Returns the mesh of the current submesh
  22028. * @return the parent mesh
  22029. */
  22030. getMesh(): AbstractMesh;
  22031. /**
  22032. * Returns the rendering mesh of the submesh
  22033. * @returns the rendering mesh (could be different from parent mesh)
  22034. */
  22035. getRenderingMesh(): Mesh;
  22036. /**
  22037. * Returns the submesh material
  22038. * @returns null or the current material
  22039. */
  22040. getMaterial(): Nullable<Material>;
  22041. /**
  22042. * Sets a new updated BoundingInfo object to the submesh
  22043. * @returns the SubMesh
  22044. */
  22045. refreshBoundingInfo(): SubMesh;
  22046. /** @hidden */
  22047. _checkCollision(collider: Collider): boolean;
  22048. /**
  22049. * Updates the submesh BoundingInfo
  22050. * @param world defines the world matrix to use to update the bounding info
  22051. * @returns the submesh
  22052. */
  22053. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22054. /**
  22055. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22056. * @param frustumPlanes defines the frustum planes
  22057. * @returns true if the submesh is intersecting with the frustum
  22058. */
  22059. isInFrustum(frustumPlanes: Plane[]): boolean;
  22060. /**
  22061. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22062. * @param frustumPlanes defines the frustum planes
  22063. * @returns true if the submesh is inside the frustum
  22064. */
  22065. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22066. /**
  22067. * Renders the submesh
  22068. * @param enableAlphaMode defines if alpha needs to be used
  22069. * @returns the submesh
  22070. */
  22071. render(enableAlphaMode: boolean): SubMesh;
  22072. /**
  22073. * @hidden
  22074. */
  22075. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22076. /**
  22077. * Checks if the submesh intersects with a ray
  22078. * @param ray defines the ray to test
  22079. * @returns true is the passed ray intersects the submesh bounding box
  22080. */
  22081. canIntersects(ray: Ray): boolean;
  22082. /**
  22083. * Intersects current submesh with a ray
  22084. * @param ray defines the ray to test
  22085. * @param positions defines mesh's positions array
  22086. * @param indices defines mesh's indices array
  22087. * @param fastCheck defines if only bounding info should be used
  22088. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22089. * @returns intersection info or null if no intersection
  22090. */
  22091. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22092. /** @hidden */
  22093. private _intersectLines;
  22094. /** @hidden */
  22095. private _intersectTriangles;
  22096. /** @hidden */
  22097. _rebuild(): void;
  22098. /**
  22099. * Creates a new submesh from the passed mesh
  22100. * @param newMesh defines the new hosting mesh
  22101. * @param newRenderingMesh defines an optional rendering mesh
  22102. * @returns the new submesh
  22103. */
  22104. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22105. /**
  22106. * Release associated resources
  22107. */
  22108. dispose(): void;
  22109. /**
  22110. * Gets the class name
  22111. * @returns the string "SubMesh".
  22112. */
  22113. getClassName(): string;
  22114. /**
  22115. * Creates a new submesh from indices data
  22116. * @param materialIndex the index of the main mesh material
  22117. * @param startIndex the index where to start the copy in the mesh indices array
  22118. * @param indexCount the number of indices to copy then from the startIndex
  22119. * @param mesh the main mesh to create the submesh from
  22120. * @param renderingMesh the optional rendering mesh
  22121. * @returns a new submesh
  22122. */
  22123. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22124. }
  22125. }
  22126. declare module BABYLON {
  22127. /**
  22128. * Class used to store geometry data (vertex buffers + index buffer)
  22129. */
  22130. export class Geometry implements IGetSetVerticesData {
  22131. /**
  22132. * Gets or sets the ID of the geometry
  22133. */
  22134. id: string;
  22135. /**
  22136. * Gets or sets the unique ID of the geometry
  22137. */
  22138. uniqueId: number;
  22139. /**
  22140. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22141. */
  22142. delayLoadState: number;
  22143. /**
  22144. * Gets the file containing the data to load when running in delay load state
  22145. */
  22146. delayLoadingFile: Nullable<string>;
  22147. /**
  22148. * Callback called when the geometry is updated
  22149. */
  22150. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22151. private _scene;
  22152. private _engine;
  22153. private _meshes;
  22154. private _totalVertices;
  22155. /** @hidden */
  22156. _indices: IndicesArray;
  22157. /** @hidden */
  22158. _vertexBuffers: {
  22159. [key: string]: VertexBuffer;
  22160. };
  22161. private _isDisposed;
  22162. private _extend;
  22163. private _boundingBias;
  22164. /** @hidden */
  22165. _delayInfo: Array<string>;
  22166. private _indexBuffer;
  22167. private _indexBufferIsUpdatable;
  22168. /** @hidden */
  22169. _boundingInfo: Nullable<BoundingInfo>;
  22170. /** @hidden */
  22171. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22172. /** @hidden */
  22173. _softwareSkinningFrameId: number;
  22174. private _vertexArrayObjects;
  22175. private _updatable;
  22176. /** @hidden */
  22177. _positions: Nullable<Vector3[]>;
  22178. /**
  22179. * 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
  22180. */
  22181. /**
  22182. * 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
  22183. */
  22184. boundingBias: Vector2;
  22185. /**
  22186. * Static function used to attach a new empty geometry to a mesh
  22187. * @param mesh defines the mesh to attach the geometry to
  22188. * @returns the new Geometry
  22189. */
  22190. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22191. /**
  22192. * Creates a new geometry
  22193. * @param id defines the unique ID
  22194. * @param scene defines the hosting scene
  22195. * @param vertexData defines the VertexData used to get geometry data
  22196. * @param updatable defines if geometry must be updatable (false by default)
  22197. * @param mesh defines the mesh that will be associated with the geometry
  22198. */
  22199. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22200. /**
  22201. * Gets the current extend of the geometry
  22202. */
  22203. readonly extend: {
  22204. minimum: Vector3;
  22205. maximum: Vector3;
  22206. };
  22207. /**
  22208. * Gets the hosting scene
  22209. * @returns the hosting Scene
  22210. */
  22211. getScene(): Scene;
  22212. /**
  22213. * Gets the hosting engine
  22214. * @returns the hosting Engine
  22215. */
  22216. getEngine(): Engine;
  22217. /**
  22218. * Defines if the geometry is ready to use
  22219. * @returns true if the geometry is ready to be used
  22220. */
  22221. isReady(): boolean;
  22222. /**
  22223. * Gets a value indicating that the geometry should not be serialized
  22224. */
  22225. readonly doNotSerialize: boolean;
  22226. /** @hidden */
  22227. _rebuild(): void;
  22228. /**
  22229. * Affects all geometry data in one call
  22230. * @param vertexData defines the geometry data
  22231. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22232. */
  22233. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22234. /**
  22235. * Set specific vertex data
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the vertex data to use
  22238. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22239. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22240. */
  22241. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22242. /**
  22243. * Removes a specific vertex data
  22244. * @param kind defines the data kind (Position, normal, etc...)
  22245. */
  22246. removeVerticesData(kind: string): void;
  22247. /**
  22248. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22249. * @param buffer defines the vertex buffer to use
  22250. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22251. */
  22252. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22253. /**
  22254. * Update a specific vertex buffer
  22255. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22256. * It will do nothing if the buffer is not updatable
  22257. * @param kind defines the data kind (Position, normal, etc...)
  22258. * @param data defines the data to use
  22259. * @param offset defines the offset in the target buffer where to store the data
  22260. * @param useBytes set to true if the offset is in bytes
  22261. */
  22262. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22263. /**
  22264. * Update a specific vertex buffer
  22265. * This function will create a new buffer if the current one is not updatable
  22266. * @param kind defines the data kind (Position, normal, etc...)
  22267. * @param data defines the data to use
  22268. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22269. */
  22270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22271. private _updateBoundingInfo;
  22272. /** @hidden */
  22273. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22274. /**
  22275. * Gets total number of vertices
  22276. * @returns the total number of vertices
  22277. */
  22278. getTotalVertices(): number;
  22279. /**
  22280. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22281. * @param kind defines the data kind (Position, normal, etc...)
  22282. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22284. * @returns a float array containing vertex data
  22285. */
  22286. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22287. /**
  22288. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22289. * @param kind defines the data kind (Position, normal, etc...)
  22290. * @returns true if the vertex buffer with the specified kind is updatable
  22291. */
  22292. isVertexBufferUpdatable(kind: string): boolean;
  22293. /**
  22294. * Gets a specific vertex buffer
  22295. * @param kind defines the data kind (Position, normal, etc...)
  22296. * @returns a VertexBuffer
  22297. */
  22298. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22299. /**
  22300. * Returns all vertex buffers
  22301. * @return an object holding all vertex buffers indexed by kind
  22302. */
  22303. getVertexBuffers(): Nullable<{
  22304. [key: string]: VertexBuffer;
  22305. }>;
  22306. /**
  22307. * Gets a boolean indicating if specific vertex buffer is present
  22308. * @param kind defines the data kind (Position, normal, etc...)
  22309. * @returns true if data is present
  22310. */
  22311. isVerticesDataPresent(kind: string): boolean;
  22312. /**
  22313. * Gets a list of all attached data kinds (Position, normal, etc...)
  22314. * @returns a list of string containing all kinds
  22315. */
  22316. getVerticesDataKinds(): string[];
  22317. /**
  22318. * Update index buffer
  22319. * @param indices defines the indices to store in the index buffer
  22320. * @param offset defines the offset in the target buffer where to store the data
  22321. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22322. */
  22323. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22324. /**
  22325. * Creates a new index buffer
  22326. * @param indices defines the indices to store in the index buffer
  22327. * @param totalVertices defines the total number of vertices (could be null)
  22328. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22329. */
  22330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22331. /**
  22332. * Return the total number of indices
  22333. * @returns the total number of indices
  22334. */
  22335. getTotalIndices(): number;
  22336. /**
  22337. * Gets the index buffer array
  22338. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22339. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22340. * @returns the index buffer array
  22341. */
  22342. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22343. /**
  22344. * Gets the index buffer
  22345. * @return the index buffer
  22346. */
  22347. getIndexBuffer(): Nullable<WebGLBuffer>;
  22348. /** @hidden */
  22349. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22350. /**
  22351. * Release the associated resources for a specific mesh
  22352. * @param mesh defines the source mesh
  22353. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22354. */
  22355. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22356. /**
  22357. * Apply current geometry to a given mesh
  22358. * @param mesh defines the mesh to apply geometry to
  22359. */
  22360. applyToMesh(mesh: Mesh): void;
  22361. private _updateExtend;
  22362. private _applyToMesh;
  22363. private notifyUpdate;
  22364. /**
  22365. * Load the geometry if it was flagged as delay loaded
  22366. * @param scene defines the hosting scene
  22367. * @param onLoaded defines a callback called when the geometry is loaded
  22368. */
  22369. load(scene: Scene, onLoaded?: () => void): void;
  22370. private _queueLoad;
  22371. /**
  22372. * Invert the geometry to move from a right handed system to a left handed one.
  22373. */
  22374. toLeftHanded(): void;
  22375. /** @hidden */
  22376. _resetPointsArrayCache(): void;
  22377. /** @hidden */
  22378. _generatePointsArray(): boolean;
  22379. /**
  22380. * Gets a value indicating if the geometry is disposed
  22381. * @returns true if the geometry was disposed
  22382. */
  22383. isDisposed(): boolean;
  22384. private _disposeVertexArrayObjects;
  22385. /**
  22386. * Free all associated resources
  22387. */
  22388. dispose(): void;
  22389. /**
  22390. * Clone the current geometry into a new geometry
  22391. * @param id defines the unique ID of the new geometry
  22392. * @returns a new geometry object
  22393. */
  22394. copy(id: string): Geometry;
  22395. /**
  22396. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22397. * @return a JSON representation of the current geometry data (without the vertices data)
  22398. */
  22399. serialize(): any;
  22400. private toNumberArray;
  22401. /**
  22402. * Serialize all vertices data into a JSON oject
  22403. * @returns a JSON representation of the current geometry data
  22404. */
  22405. serializeVerticeData(): any;
  22406. /**
  22407. * Extracts a clone of a mesh geometry
  22408. * @param mesh defines the source mesh
  22409. * @param id defines the unique ID of the new geometry object
  22410. * @returns the new geometry object
  22411. */
  22412. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22413. /**
  22414. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22416. * Be aware Math.random() could cause collisions, but:
  22417. * "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"
  22418. * @returns a string containing a new GUID
  22419. */
  22420. static RandomId(): string;
  22421. /** @hidden */
  22422. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22423. private static _CleanMatricesWeights;
  22424. /**
  22425. * Create a new geometry from persisted data (Using .babylon file format)
  22426. * @param parsedVertexData defines the persisted data
  22427. * @param scene defines the hosting scene
  22428. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22429. * @returns the new geometry object
  22430. */
  22431. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Define an interface for all classes that will get and set the data on vertices
  22437. */
  22438. export interface IGetSetVerticesData {
  22439. /**
  22440. * Gets a boolean indicating if specific vertex data is present
  22441. * @param kind defines the vertex data kind to use
  22442. * @returns true is data kind is present
  22443. */
  22444. isVerticesDataPresent(kind: string): boolean;
  22445. /**
  22446. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22447. * @param kind defines the data kind (Position, normal, etc...)
  22448. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22449. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22450. * @returns a float array containing vertex data
  22451. */
  22452. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22453. /**
  22454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22455. * @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.
  22456. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22457. * @returns the indices array or an empty array if the mesh has no geometry
  22458. */
  22459. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22460. /**
  22461. * Set specific vertex data
  22462. * @param kind defines the data kind (Position, normal, etc...)
  22463. * @param data defines the vertex data to use
  22464. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22465. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22466. */
  22467. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22468. /**
  22469. * Update a specific associated vertex buffer
  22470. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22471. * - VertexBuffer.PositionKind
  22472. * - VertexBuffer.UVKind
  22473. * - VertexBuffer.UV2Kind
  22474. * - VertexBuffer.UV3Kind
  22475. * - VertexBuffer.UV4Kind
  22476. * - VertexBuffer.UV5Kind
  22477. * - VertexBuffer.UV6Kind
  22478. * - VertexBuffer.ColorKind
  22479. * - VertexBuffer.MatricesIndicesKind
  22480. * - VertexBuffer.MatricesIndicesExtraKind
  22481. * - VertexBuffer.MatricesWeightsKind
  22482. * - VertexBuffer.MatricesWeightsExtraKind
  22483. * @param data defines the data source
  22484. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22485. * @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)
  22486. */
  22487. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22488. /**
  22489. * Creates a new index buffer
  22490. * @param indices defines the indices to store in the index buffer
  22491. * @param totalVertices defines the total number of vertices (could be null)
  22492. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22493. */
  22494. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22495. }
  22496. /**
  22497. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22498. */
  22499. export class VertexData {
  22500. /**
  22501. * Mesh side orientation : usually the external or front surface
  22502. */
  22503. static readonly FRONTSIDE: number;
  22504. /**
  22505. * Mesh side orientation : usually the internal or back surface
  22506. */
  22507. static readonly BACKSIDE: number;
  22508. /**
  22509. * Mesh side orientation : both internal and external or front and back surfaces
  22510. */
  22511. static readonly DOUBLESIDE: number;
  22512. /**
  22513. * Mesh side orientation : by default, `FRONTSIDE`
  22514. */
  22515. static readonly DEFAULTSIDE: number;
  22516. /**
  22517. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22518. */
  22519. positions: Nullable<FloatArray>;
  22520. /**
  22521. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22522. */
  22523. normals: Nullable<FloatArray>;
  22524. /**
  22525. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22526. */
  22527. tangents: Nullable<FloatArray>;
  22528. /**
  22529. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22530. */
  22531. uvs: Nullable<FloatArray>;
  22532. /**
  22533. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22534. */
  22535. uvs2: Nullable<FloatArray>;
  22536. /**
  22537. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22538. */
  22539. uvs3: Nullable<FloatArray>;
  22540. /**
  22541. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22542. */
  22543. uvs4: Nullable<FloatArray>;
  22544. /**
  22545. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22546. */
  22547. uvs5: Nullable<FloatArray>;
  22548. /**
  22549. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22550. */
  22551. uvs6: Nullable<FloatArray>;
  22552. /**
  22553. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22554. */
  22555. colors: Nullable<FloatArray>;
  22556. /**
  22557. * 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).
  22558. */
  22559. matricesIndices: Nullable<FloatArray>;
  22560. /**
  22561. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22562. */
  22563. matricesWeights: Nullable<FloatArray>;
  22564. /**
  22565. * An array extending the number of possible indices
  22566. */
  22567. matricesIndicesExtra: Nullable<FloatArray>;
  22568. /**
  22569. * An array extending the number of possible weights when the number of indices is extended
  22570. */
  22571. matricesWeightsExtra: Nullable<FloatArray>;
  22572. /**
  22573. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22574. */
  22575. indices: Nullable<IndicesArray>;
  22576. /**
  22577. * Uses the passed data array to set the set the values for the specified kind of data
  22578. * @param data a linear array of floating numbers
  22579. * @param kind the type of data that is being set, eg positions, colors etc
  22580. */
  22581. set(data: FloatArray, kind: string): void;
  22582. /**
  22583. * Associates the vertexData to the passed Mesh.
  22584. * Sets it as updatable or not (default `false`)
  22585. * @param mesh the mesh the vertexData is applied to
  22586. * @param updatable when used and having the value true allows new data to update the vertexData
  22587. * @returns the VertexData
  22588. */
  22589. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22590. /**
  22591. * Associates the vertexData to the passed Geometry.
  22592. * Sets it as updatable or not (default `false`)
  22593. * @param geometry the geometry the vertexData is applied to
  22594. * @param updatable when used and having the value true allows new data to update the vertexData
  22595. * @returns VertexData
  22596. */
  22597. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22598. /**
  22599. * Updates the associated mesh
  22600. * @param mesh the mesh to be updated
  22601. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22602. * @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
  22603. * @returns VertexData
  22604. */
  22605. updateMesh(mesh: Mesh): VertexData;
  22606. /**
  22607. * Updates the associated geometry
  22608. * @param geometry the geometry to be updated
  22609. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22610. * @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
  22611. * @returns VertexData.
  22612. */
  22613. updateGeometry(geometry: Geometry): VertexData;
  22614. private _applyTo;
  22615. private _update;
  22616. /**
  22617. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22618. * @param matrix the transforming matrix
  22619. * @returns the VertexData
  22620. */
  22621. transform(matrix: Matrix): VertexData;
  22622. /**
  22623. * Merges the passed VertexData into the current one
  22624. * @param other the VertexData to be merged into the current one
  22625. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22626. * @returns the modified VertexData
  22627. */
  22628. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22629. private _mergeElement;
  22630. private _validate;
  22631. /**
  22632. * Serializes the VertexData
  22633. * @returns a serialized object
  22634. */
  22635. serialize(): any;
  22636. /**
  22637. * Extracts the vertexData from a mesh
  22638. * @param mesh the mesh from which to extract the VertexData
  22639. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22640. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22641. * @returns the object VertexData associated to the passed mesh
  22642. */
  22643. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22644. /**
  22645. * Extracts the vertexData from the geometry
  22646. * @param geometry the geometry from which to extract the VertexData
  22647. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22648. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22649. * @returns the object VertexData associated to the passed mesh
  22650. */
  22651. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22652. private static _ExtractFrom;
  22653. /**
  22654. * Creates the VertexData for a Ribbon
  22655. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22656. * * pathArray array of paths, each of which an array of successive Vector3
  22657. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22658. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22659. * * 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
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22664. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22665. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22666. * @returns the VertexData of the ribbon
  22667. */
  22668. static CreateRibbon(options: {
  22669. pathArray: Vector3[][];
  22670. closeArray?: boolean;
  22671. closePath?: boolean;
  22672. offset?: number;
  22673. sideOrientation?: number;
  22674. frontUVs?: Vector4;
  22675. backUVs?: Vector4;
  22676. invertUV?: boolean;
  22677. uvs?: Vector2[];
  22678. colors?: Color4[];
  22679. }): VertexData;
  22680. /**
  22681. * Creates the VertexData for a box
  22682. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22683. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22684. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22685. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22686. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22687. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22688. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22690. * * 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)
  22691. * * 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)
  22692. * @returns the VertexData of the box
  22693. */
  22694. static CreateBox(options: {
  22695. size?: number;
  22696. width?: number;
  22697. height?: number;
  22698. depth?: number;
  22699. faceUV?: Vector4[];
  22700. faceColors?: Color4[];
  22701. sideOrientation?: number;
  22702. frontUVs?: Vector4;
  22703. backUVs?: Vector4;
  22704. }): VertexData;
  22705. /**
  22706. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22708. * * segments sets the number of horizontal strips optional, default 32
  22709. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22710. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22711. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22712. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22713. * * 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
  22714. * * 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
  22715. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22716. * * 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)
  22717. * * 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)
  22718. * @returns the VertexData of the ellipsoid
  22719. */
  22720. static CreateSphere(options: {
  22721. segments?: number;
  22722. diameter?: number;
  22723. diameterX?: number;
  22724. diameterY?: number;
  22725. diameterZ?: number;
  22726. arc?: number;
  22727. slice?: number;
  22728. sideOrientation?: number;
  22729. frontUVs?: Vector4;
  22730. backUVs?: Vector4;
  22731. }): VertexData;
  22732. /**
  22733. * Creates the VertexData for a cylinder, cone or prism
  22734. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22735. * * height sets the height (y direction) of the cylinder, optional, default 2
  22736. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22737. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22738. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22739. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22740. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22741. * * 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
  22742. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22743. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22744. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22745. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22747. * * 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)
  22748. * * 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)
  22749. * @returns the VertexData of the cylinder, cone or prism
  22750. */
  22751. static CreateCylinder(options: {
  22752. height?: number;
  22753. diameterTop?: number;
  22754. diameterBottom?: number;
  22755. diameter?: number;
  22756. tessellation?: number;
  22757. subdivisions?: number;
  22758. arc?: number;
  22759. faceColors?: Color4[];
  22760. faceUV?: Vector4[];
  22761. hasRings?: boolean;
  22762. enclose?: boolean;
  22763. sideOrientation?: number;
  22764. frontUVs?: Vector4;
  22765. backUVs?: Vector4;
  22766. }): VertexData;
  22767. /**
  22768. * Creates the VertexData for a torus
  22769. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22770. * * diameter the diameter of the torus, optional default 1
  22771. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22772. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22774. * * 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)
  22775. * * 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)
  22776. * @returns the VertexData of the torus
  22777. */
  22778. static CreateTorus(options: {
  22779. diameter?: number;
  22780. thickness?: number;
  22781. tessellation?: number;
  22782. sideOrientation?: number;
  22783. frontUVs?: Vector4;
  22784. backUVs?: Vector4;
  22785. }): VertexData;
  22786. /**
  22787. * Creates the VertexData of the LineSystem
  22788. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22789. * - lines an array of lines, each line being an array of successive Vector3
  22790. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22791. * @returns the VertexData of the LineSystem
  22792. */
  22793. static CreateLineSystem(options: {
  22794. lines: Vector3[][];
  22795. colors?: Nullable<Color4[][]>;
  22796. }): VertexData;
  22797. /**
  22798. * Create the VertexData for a DashedLines
  22799. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22800. * - points an array successive Vector3
  22801. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22802. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22803. * - dashNb the intended total number of dashes, optional, default 200
  22804. * @returns the VertexData for the DashedLines
  22805. */
  22806. static CreateDashedLines(options: {
  22807. points: Vector3[];
  22808. dashSize?: number;
  22809. gapSize?: number;
  22810. dashNb?: number;
  22811. }): VertexData;
  22812. /**
  22813. * Creates the VertexData for a Ground
  22814. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22815. * - width the width (x direction) of the ground, optional, default 1
  22816. * - height the height (z direction) of the ground, optional, default 1
  22817. * - subdivisions the number of subdivisions per side, optional, default 1
  22818. * @returns the VertexData of the Ground
  22819. */
  22820. static CreateGround(options: {
  22821. width?: number;
  22822. height?: number;
  22823. subdivisions?: number;
  22824. subdivisionsX?: number;
  22825. subdivisionsY?: number;
  22826. }): VertexData;
  22827. /**
  22828. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22829. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22830. * * xmin the ground minimum X coordinate, optional, default -1
  22831. * * zmin the ground minimum Z coordinate, optional, default -1
  22832. * * xmax the ground maximum X coordinate, optional, default 1
  22833. * * zmax the ground maximum Z coordinate, optional, default 1
  22834. * * 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}
  22835. * * 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}
  22836. * @returns the VertexData of the TiledGround
  22837. */
  22838. static CreateTiledGround(options: {
  22839. xmin: number;
  22840. zmin: number;
  22841. xmax: number;
  22842. zmax: number;
  22843. subdivisions?: {
  22844. w: number;
  22845. h: number;
  22846. };
  22847. precision?: {
  22848. w: number;
  22849. h: number;
  22850. };
  22851. }): VertexData;
  22852. /**
  22853. * Creates the VertexData of the Ground designed from a heightmap
  22854. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22855. * * width the width (x direction) of the ground
  22856. * * height the height (z direction) of the ground
  22857. * * subdivisions the number of subdivisions per side
  22858. * * minHeight the minimum altitude on the ground, optional, default 0
  22859. * * maxHeight the maximum altitude on the ground, optional default 1
  22860. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22861. * * buffer the array holding the image color data
  22862. * * bufferWidth the width of image
  22863. * * bufferHeight the height of image
  22864. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22865. * @returns the VertexData of the Ground designed from a heightmap
  22866. */
  22867. static CreateGroundFromHeightMap(options: {
  22868. width: number;
  22869. height: number;
  22870. subdivisions: number;
  22871. minHeight: number;
  22872. maxHeight: number;
  22873. colorFilter: Color3;
  22874. buffer: Uint8Array;
  22875. bufferWidth: number;
  22876. bufferHeight: number;
  22877. alphaFilter: number;
  22878. }): VertexData;
  22879. /**
  22880. * Creates the VertexData for a Plane
  22881. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22882. * * size sets the width and height of the plane to the value of size, optional default 1
  22883. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22884. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22886. * * 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)
  22887. * * 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)
  22888. * @returns the VertexData of the box
  22889. */
  22890. static CreatePlane(options: {
  22891. size?: number;
  22892. width?: number;
  22893. height?: number;
  22894. sideOrientation?: number;
  22895. frontUVs?: Vector4;
  22896. backUVs?: Vector4;
  22897. }): VertexData;
  22898. /**
  22899. * Creates the VertexData of the Disc or regular Polygon
  22900. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22901. * * radius the radius of the disc, optional default 0.5
  22902. * * tessellation the number of polygon sides, optional, default 64
  22903. * * 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
  22904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22905. * * 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)
  22906. * * 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)
  22907. * @returns the VertexData of the box
  22908. */
  22909. static CreateDisc(options: {
  22910. radius?: number;
  22911. tessellation?: number;
  22912. arc?: number;
  22913. sideOrientation?: number;
  22914. frontUVs?: Vector4;
  22915. backUVs?: Vector4;
  22916. }): VertexData;
  22917. /**
  22918. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22919. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22920. * @param polygon a mesh built from polygonTriangulation.build()
  22921. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22922. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22923. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22924. * @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)
  22925. * @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)
  22926. * @returns the VertexData of the Polygon
  22927. */
  22928. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22929. /**
  22930. * Creates the VertexData of the IcoSphere
  22931. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22932. * * radius the radius of the IcoSphere, optional default 1
  22933. * * radiusX allows stretching in the x direction, optional, default radius
  22934. * * radiusY allows stretching in the y direction, optional, default radius
  22935. * * radiusZ allows stretching in the z direction, optional, default radius
  22936. * * flat when true creates a flat shaded mesh, optional, default true
  22937. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  22942. */
  22943. static CreateIcoSphere(options: {
  22944. radius?: number;
  22945. radiusX?: number;
  22946. radiusY?: number;
  22947. radiusZ?: number;
  22948. flat?: boolean;
  22949. subdivisions?: number;
  22950. sideOrientation?: number;
  22951. frontUVs?: Vector4;
  22952. backUVs?: Vector4;
  22953. }): VertexData;
  22954. /**
  22955. * Creates the VertexData for a Polyhedron
  22956. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22957. * * type provided types are:
  22958. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22959. * * 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)
  22960. * * size the size of the IcoSphere, optional default 1
  22961. * * sizeX allows stretching in the x direction, optional, default size
  22962. * * sizeY allows stretching in the y direction, optional, default size
  22963. * * sizeZ allows stretching in the z direction, optional, default size
  22964. * * 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
  22965. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22966. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22967. * * flat when true creates a flat shaded mesh, optional, default true
  22968. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22970. * * 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)
  22971. * * 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)
  22972. * @returns the VertexData of the Polyhedron
  22973. */
  22974. static CreatePolyhedron(options: {
  22975. type?: number;
  22976. size?: number;
  22977. sizeX?: number;
  22978. sizeY?: number;
  22979. sizeZ?: number;
  22980. custom?: any;
  22981. faceUV?: Vector4[];
  22982. faceColors?: Color4[];
  22983. flat?: boolean;
  22984. sideOrientation?: number;
  22985. frontUVs?: Vector4;
  22986. backUVs?: Vector4;
  22987. }): VertexData;
  22988. /**
  22989. * Creates the VertexData for a TorusKnot
  22990. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22991. * * radius the radius of the torus knot, optional, default 2
  22992. * * tube the thickness of the tube, optional, default 0.5
  22993. * * radialSegments the number of sides on each tube segments, optional, default 32
  22994. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22995. * * p the number of windings around the z axis, optional, default 2
  22996. * * q the number of windings around the x axis, optional, default 3
  22997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22998. * * 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)
  22999. * * 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)
  23000. * @returns the VertexData of the Torus Knot
  23001. */
  23002. static CreateTorusKnot(options: {
  23003. radius?: number;
  23004. tube?: number;
  23005. radialSegments?: number;
  23006. tubularSegments?: number;
  23007. p?: number;
  23008. q?: number;
  23009. sideOrientation?: number;
  23010. frontUVs?: Vector4;
  23011. backUVs?: Vector4;
  23012. }): VertexData;
  23013. /**
  23014. * Compute normals for given positions and indices
  23015. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23016. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23017. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23018. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23019. * * facetNormals : optional array of facet normals (vector3)
  23020. * * facetPositions : optional array of facet positions (vector3)
  23021. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23022. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23023. * * bInfo : optional bounding info, required for facetPartitioning computation
  23024. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23025. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23026. * * useRightHandedSystem: optional boolean to for right handed system computation
  23027. * * depthSort : optional boolean to enable the facet depth sort computation
  23028. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23029. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23030. */
  23031. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23032. facetNormals?: any;
  23033. facetPositions?: any;
  23034. facetPartitioning?: any;
  23035. ratio?: number;
  23036. bInfo?: any;
  23037. bbSize?: Vector3;
  23038. subDiv?: any;
  23039. useRightHandedSystem?: boolean;
  23040. depthSort?: boolean;
  23041. distanceTo?: Vector3;
  23042. depthSortedFacets?: any;
  23043. }): void;
  23044. /** @hidden */
  23045. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23046. /**
  23047. * Applies VertexData created from the imported parameters to the geometry
  23048. * @param parsedVertexData the parsed data from an imported file
  23049. * @param geometry the geometry to apply the VertexData to
  23050. */
  23051. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23052. }
  23053. }
  23054. declare module BABYLON {
  23055. /**
  23056. * Class containing static functions to help procedurally build meshes
  23057. */
  23058. export class DiscBuilder {
  23059. /**
  23060. * Creates a plane polygonal mesh. By default, this is a disc
  23061. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23062. * * 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
  23063. * * 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
  23064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23065. * * 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
  23066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23067. * @param name defines the name of the mesh
  23068. * @param options defines the options used to create the mesh
  23069. * @param scene defines the hosting scene
  23070. * @returns the plane polygonal mesh
  23071. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23072. */
  23073. static CreateDisc(name: string, options: {
  23074. radius?: number;
  23075. tessellation?: number;
  23076. arc?: number;
  23077. updatable?: boolean;
  23078. sideOrientation?: number;
  23079. frontUVs?: Vector4;
  23080. backUVs?: Vector4;
  23081. }, scene?: Nullable<Scene>): Mesh;
  23082. }
  23083. }
  23084. declare module BABYLON {
  23085. /**
  23086. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23087. *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.
  23088. * The SPS is also a particle system. It provides some methods to manage the particles.
  23089. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23090. *
  23091. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23092. */
  23093. export class SolidParticleSystem implements IDisposable {
  23094. /**
  23095. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23096. * Example : var p = SPS.particles[i];
  23097. */
  23098. particles: SolidParticle[];
  23099. /**
  23100. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23101. */
  23102. nbParticles: number;
  23103. /**
  23104. * If the particles must ever face the camera (default false). Useful for planar particles.
  23105. */
  23106. billboard: boolean;
  23107. /**
  23108. * Recompute normals when adding a shape
  23109. */
  23110. recomputeNormals: boolean;
  23111. /**
  23112. * This a counter ofr your own usage. It's not set by any SPS functions.
  23113. */
  23114. counter: number;
  23115. /**
  23116. * The SPS name. This name is also given to the underlying mesh.
  23117. */
  23118. name: string;
  23119. /**
  23120. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23121. */
  23122. mesh: Mesh;
  23123. /**
  23124. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23125. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23126. */
  23127. vars: any;
  23128. /**
  23129. * This array is populated when the SPS is set as 'pickable'.
  23130. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23131. * Each element of this array is an object `{idx: int, faceId: int}`.
  23132. * `idx` is the picked particle index in the `SPS.particles` array
  23133. * `faceId` is the picked face index counted within this particle.
  23134. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23135. */
  23136. pickedParticles: {
  23137. idx: number;
  23138. faceId: number;
  23139. }[];
  23140. /**
  23141. * This array is populated when `enableDepthSort` is set to true.
  23142. * Each element of this array is an instance of the class DepthSortedParticle.
  23143. */
  23144. depthSortedParticles: DepthSortedParticle[];
  23145. /**
  23146. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23147. * @hidden
  23148. */
  23149. _bSphereOnly: boolean;
  23150. /**
  23151. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23152. * @hidden
  23153. */
  23154. _bSphereRadiusFactor: number;
  23155. private _scene;
  23156. private _positions;
  23157. private _indices;
  23158. private _normals;
  23159. private _colors;
  23160. private _uvs;
  23161. private _indices32;
  23162. private _positions32;
  23163. private _normals32;
  23164. private _fixedNormal32;
  23165. private _colors32;
  23166. private _uvs32;
  23167. private _index;
  23168. private _updatable;
  23169. private _pickable;
  23170. private _isVisibilityBoxLocked;
  23171. private _alwaysVisible;
  23172. private _depthSort;
  23173. private _shapeCounter;
  23174. private _copy;
  23175. private _color;
  23176. private _computeParticleColor;
  23177. private _computeParticleTexture;
  23178. private _computeParticleRotation;
  23179. private _computeParticleVertex;
  23180. private _computeBoundingBox;
  23181. private _depthSortParticles;
  23182. private _camera;
  23183. private _mustUnrotateFixedNormals;
  23184. private _particlesIntersect;
  23185. private _needs32Bits;
  23186. /**
  23187. * Creates a SPS (Solid Particle System) object.
  23188. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23189. * @param scene (Scene) is the scene in which the SPS is added.
  23190. * @param options defines the options of the sps e.g.
  23191. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23192. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23193. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23194. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23195. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23196. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23197. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23198. */
  23199. constructor(name: string, scene: Scene, options?: {
  23200. updatable?: boolean;
  23201. isPickable?: boolean;
  23202. enableDepthSort?: boolean;
  23203. particleIntersection?: boolean;
  23204. boundingSphereOnly?: boolean;
  23205. bSphereRadiusFactor?: number;
  23206. });
  23207. /**
  23208. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23209. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23210. * @returns the created mesh
  23211. */
  23212. buildMesh(): Mesh;
  23213. /**
  23214. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23215. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23216. * Thus the particles generated from `digest()` have their property `position` set yet.
  23217. * @param mesh ( Mesh ) is the mesh to be digested
  23218. * @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
  23219. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23220. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23221. * @returns the current SPS
  23222. */
  23223. digest(mesh: Mesh, options?: {
  23224. facetNb?: number;
  23225. number?: number;
  23226. delta?: number;
  23227. }): SolidParticleSystem;
  23228. private _unrotateFixedNormals;
  23229. private _resetCopy;
  23230. private _meshBuilder;
  23231. private _posToShape;
  23232. private _uvsToShapeUV;
  23233. private _addParticle;
  23234. /**
  23235. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23236. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23237. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23238. * @param nb (positive integer) the number of particles to be created from this model
  23239. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23240. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23241. * @returns the number of shapes in the system
  23242. */
  23243. addShape(mesh: Mesh, nb: number, options?: {
  23244. positionFunction?: any;
  23245. vertexFunction?: any;
  23246. }): number;
  23247. private _rebuildParticle;
  23248. /**
  23249. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23250. * @returns the SPS.
  23251. */
  23252. rebuildMesh(): SolidParticleSystem;
  23253. /**
  23254. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23255. * This method calls `updateParticle()` for each particle of the SPS.
  23256. * For an animated SPS, it is usually called within the render loop.
  23257. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23258. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23259. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23260. * @returns the SPS.
  23261. */
  23262. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23263. /**
  23264. * Disposes the SPS.
  23265. */
  23266. dispose(): void;
  23267. /**
  23268. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23269. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23270. * @returns the SPS.
  23271. */
  23272. refreshVisibleSize(): SolidParticleSystem;
  23273. /**
  23274. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23275. * @param size the size (float) of the visibility box
  23276. * note : this doesn't lock the SPS mesh bounding box.
  23277. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23278. */
  23279. setVisibilityBox(size: number): void;
  23280. /**
  23281. * Gets whether the SPS as always visible or not
  23282. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23283. */
  23284. /**
  23285. * Sets the SPS as always visible or not
  23286. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23287. */
  23288. isAlwaysVisible: boolean;
  23289. /**
  23290. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23291. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23292. */
  23293. /**
  23294. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23295. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23296. */
  23297. isVisibilityBoxLocked: boolean;
  23298. /**
  23299. * Tells to `setParticles()` to compute the particle rotations or not.
  23300. * Default value : true. The SPS is faster when it's set to false.
  23301. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23302. */
  23303. /**
  23304. * Gets if `setParticles()` computes the particle rotations or not.
  23305. * Default value : true. The SPS is faster when it's set to false.
  23306. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23307. */
  23308. computeParticleRotation: boolean;
  23309. /**
  23310. * Tells to `setParticles()` to compute the particle colors or not.
  23311. * Default value : true. The SPS is faster when it's set to false.
  23312. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23313. */
  23314. /**
  23315. * Gets if `setParticles()` computes the particle colors or not.
  23316. * Default value : true. The SPS is faster when it's set to false.
  23317. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23318. */
  23319. computeParticleColor: boolean;
  23320. /**
  23321. * Gets if `setParticles()` computes the particle textures or not.
  23322. * Default value : true. The SPS is faster when it's set to false.
  23323. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23324. */
  23325. computeParticleTexture: boolean;
  23326. /**
  23327. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23328. * Default value : false. The SPS is faster when it's set to false.
  23329. * Note : the particle custom vertex positions aren't stored values.
  23330. */
  23331. /**
  23332. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23333. * Default value : false. The SPS is faster when it's set to false.
  23334. * Note : the particle custom vertex positions aren't stored values.
  23335. */
  23336. computeParticleVertex: boolean;
  23337. /**
  23338. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23339. */
  23340. /**
  23341. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23342. */
  23343. computeBoundingBox: boolean;
  23344. /**
  23345. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23346. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23347. * Default : `true`
  23348. */
  23349. /**
  23350. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23351. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23352. * Default : `true`
  23353. */
  23354. depthSortParticles: boolean;
  23355. /**
  23356. * This function does nothing. It may be overwritten to set all the particle first values.
  23357. * The SPS doesn't call this function, you may have to call it by your own.
  23358. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23359. */
  23360. initParticles(): void;
  23361. /**
  23362. * This function does nothing. It may be overwritten to recycle a particle.
  23363. * The SPS doesn't call this function, you may have to call it by your own.
  23364. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23365. * @param particle The particle to recycle
  23366. * @returns the recycled particle
  23367. */
  23368. recycleParticle(particle: SolidParticle): SolidParticle;
  23369. /**
  23370. * Updates a particle : this function should be overwritten by the user.
  23371. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23372. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23373. * @example : just set a particle position or velocity and recycle conditions
  23374. * @param particle The particle to update
  23375. * @returns the updated particle
  23376. */
  23377. updateParticle(particle: SolidParticle): SolidParticle;
  23378. /**
  23379. * Updates a vertex of a particle : it can be overwritten by the user.
  23380. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23381. * @param particle the current particle
  23382. * @param vertex the current index of the current particle
  23383. * @param pt the index of the current vertex in the particle shape
  23384. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23385. * @example : just set a vertex particle position
  23386. * @returns the updated vertex
  23387. */
  23388. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23389. /**
  23390. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23391. * This does nothing and may be overwritten by the user.
  23392. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23393. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23394. * @param update the boolean update value actually passed to setParticles()
  23395. */
  23396. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23397. /**
  23398. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23399. * This will be passed three parameters.
  23400. * This does nothing and may be overwritten by the user.
  23401. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23402. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23403. * @param update the boolean update value actually passed to setParticles()
  23404. */
  23405. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23406. }
  23407. }
  23408. declare module BABYLON {
  23409. /**
  23410. * Represents one particle of a solid particle system.
  23411. */
  23412. export class SolidParticle {
  23413. /**
  23414. * particle global index
  23415. */
  23416. idx: number;
  23417. /**
  23418. * The color of the particle
  23419. */
  23420. color: Nullable<Color4>;
  23421. /**
  23422. * The world space position of the particle.
  23423. */
  23424. position: Vector3;
  23425. /**
  23426. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23427. */
  23428. rotation: Vector3;
  23429. /**
  23430. * The world space rotation quaternion of the particle.
  23431. */
  23432. rotationQuaternion: Nullable<Quaternion>;
  23433. /**
  23434. * The scaling of the particle.
  23435. */
  23436. scaling: Vector3;
  23437. /**
  23438. * The uvs of the particle.
  23439. */
  23440. uvs: Vector4;
  23441. /**
  23442. * The current speed of the particle.
  23443. */
  23444. velocity: Vector3;
  23445. /**
  23446. * The pivot point in the particle local space.
  23447. */
  23448. pivot: Vector3;
  23449. /**
  23450. * Must the particle be translated from its pivot point in its local space ?
  23451. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23452. * Default : false
  23453. */
  23454. translateFromPivot: boolean;
  23455. /**
  23456. * Is the particle active or not ?
  23457. */
  23458. alive: boolean;
  23459. /**
  23460. * Is the particle visible or not ?
  23461. */
  23462. isVisible: boolean;
  23463. /**
  23464. * Index of this particle in the global "positions" array (Internal use)
  23465. * @hidden
  23466. */
  23467. _pos: number;
  23468. /**
  23469. * @hidden Index of this particle in the global "indices" array (Internal use)
  23470. */
  23471. _ind: number;
  23472. /**
  23473. * @hidden ModelShape of this particle (Internal use)
  23474. */
  23475. _model: ModelShape;
  23476. /**
  23477. * ModelShape id of this particle
  23478. */
  23479. shapeId: number;
  23480. /**
  23481. * Index of the particle in its shape id (Internal use)
  23482. */
  23483. idxInShape: number;
  23484. /**
  23485. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23486. */
  23487. _modelBoundingInfo: BoundingInfo;
  23488. /**
  23489. * @hidden Particle BoundingInfo object (Internal use)
  23490. */
  23491. _boundingInfo: BoundingInfo;
  23492. /**
  23493. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23494. */
  23495. _sps: SolidParticleSystem;
  23496. /**
  23497. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23498. */
  23499. _stillInvisible: boolean;
  23500. /**
  23501. * @hidden Last computed particle rotation matrix
  23502. */
  23503. _rotationMatrix: number[];
  23504. /**
  23505. * Parent particle Id, if any.
  23506. * Default null.
  23507. */
  23508. parentId: Nullable<number>;
  23509. /**
  23510. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23511. * The possible values are :
  23512. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23513. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23515. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23516. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23517. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23518. * */
  23519. cullingStrategy: number;
  23520. /**
  23521. * @hidden Internal global position in the SPS.
  23522. */
  23523. _globalPosition: Vector3;
  23524. /**
  23525. * Creates a Solid Particle object.
  23526. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23527. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23528. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23529. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23530. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23531. * @param shapeId (integer) is the model shape identifier in the SPS.
  23532. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23533. * @param sps defines the sps it is associated to
  23534. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23535. */
  23536. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23537. /**
  23538. * Legacy support, changed scale to scaling
  23539. */
  23540. /**
  23541. * Legacy support, changed scale to scaling
  23542. */
  23543. scale: Vector3;
  23544. /**
  23545. * Legacy support, changed quaternion to rotationQuaternion
  23546. */
  23547. /**
  23548. * Legacy support, changed quaternion to rotationQuaternion
  23549. */
  23550. quaternion: Nullable<Quaternion>;
  23551. /**
  23552. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23553. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23554. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23555. * @returns true if it intersects
  23556. */
  23557. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23558. /**
  23559. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23560. * A particle is in the frustum if its bounding box intersects the frustum
  23561. * @param frustumPlanes defines the frustum to test
  23562. * @returns true if the particle is in the frustum planes
  23563. */
  23564. isInFrustum(frustumPlanes: Plane[]): boolean;
  23565. /**
  23566. * get the rotation matrix of the particle
  23567. * @hidden
  23568. */
  23569. getRotationMatrix(m: Matrix): void;
  23570. }
  23571. /**
  23572. * Represents the shape of the model used by one particle of a solid particle system.
  23573. * SPS internal tool, don't use it manually.
  23574. */
  23575. export class ModelShape {
  23576. /**
  23577. * The shape id
  23578. * @hidden
  23579. */
  23580. shapeID: number;
  23581. /**
  23582. * flat array of model positions (internal use)
  23583. * @hidden
  23584. */
  23585. _shape: Vector3[];
  23586. /**
  23587. * flat array of model UVs (internal use)
  23588. * @hidden
  23589. */
  23590. _shapeUV: number[];
  23591. /**
  23592. * length of the shape in the model indices array (internal use)
  23593. * @hidden
  23594. */
  23595. _indicesLength: number;
  23596. /**
  23597. * Custom position function (internal use)
  23598. * @hidden
  23599. */
  23600. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23601. /**
  23602. * Custom vertex function (internal use)
  23603. * @hidden
  23604. */
  23605. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23606. /**
  23607. * 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.
  23608. * SPS internal tool, don't use it manually.
  23609. * @hidden
  23610. */
  23611. 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>);
  23612. }
  23613. /**
  23614. * Represents a Depth Sorted Particle in the solid particle system.
  23615. */
  23616. export class DepthSortedParticle {
  23617. /**
  23618. * Index of the particle in the "indices" array
  23619. */
  23620. ind: number;
  23621. /**
  23622. * Length of the particle shape in the "indices" array
  23623. */
  23624. indicesLength: number;
  23625. /**
  23626. * Squared distance from the particle to the camera
  23627. */
  23628. sqDistance: number;
  23629. }
  23630. }
  23631. declare module BABYLON {
  23632. /**
  23633. * Class used to store all common mesh properties
  23634. */
  23635. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23636. /** No occlusion */
  23637. static OCCLUSION_TYPE_NONE: number;
  23638. /** Occlusion set to optimisitic */
  23639. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23640. /** Occlusion set to strict */
  23641. static OCCLUSION_TYPE_STRICT: number;
  23642. /** Use an accurante occlusion algorithm */
  23643. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23644. /** Use a conservative occlusion algorithm */
  23645. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23646. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23647. * Test order :
  23648. * Is the bounding sphere outside the frustum ?
  23649. * If not, are the bounding box vertices outside the frustum ?
  23650. * It not, then the cullable object is in the frustum.
  23651. */
  23652. static readonly CULLINGSTRATEGY_STANDARD: number;
  23653. /** Culling strategy : Bounding Sphere Only.
  23654. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23655. * It's also less accurate than the standard because some not visible objects can still be selected.
  23656. * Test : is the bounding sphere outside the frustum ?
  23657. * If not, then the cullable object is in the frustum.
  23658. */
  23659. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23660. /** Culling strategy : Optimistic Inclusion.
  23661. * This in an inclusion test first, then the standard exclusion test.
  23662. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23663. * 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.
  23664. * Anyway, it's as accurate as the standard strategy.
  23665. * Test :
  23666. * Is the cullable object bounding sphere center in the frustum ?
  23667. * If not, apply the default culling strategy.
  23668. */
  23669. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23670. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23671. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23672. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23673. * 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.
  23674. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23675. * Test :
  23676. * Is the cullable object bounding sphere center in the frustum ?
  23677. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23678. */
  23679. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23680. /**
  23681. * No billboard
  23682. */
  23683. static readonly BILLBOARDMODE_NONE: number;
  23684. /** Billboard on X axis */
  23685. static readonly BILLBOARDMODE_X: number;
  23686. /** Billboard on Y axis */
  23687. static readonly BILLBOARDMODE_Y: number;
  23688. /** Billboard on Z axis */
  23689. static readonly BILLBOARDMODE_Z: number;
  23690. /** Billboard on all axes */
  23691. static readonly BILLBOARDMODE_ALL: number;
  23692. private _facetData;
  23693. /**
  23694. * The culling strategy to use to check whether the mesh must be rendered or not.
  23695. * This value can be changed at any time and will be used on the next render mesh selection.
  23696. * The possible values are :
  23697. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23698. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23699. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23700. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23701. * Please read each static variable documentation to get details about the culling process.
  23702. * */
  23703. cullingStrategy: number;
  23704. /**
  23705. * Gets the number of facets in the mesh
  23706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23707. */
  23708. readonly facetNb: number;
  23709. /**
  23710. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23712. */
  23713. partitioningSubdivisions: number;
  23714. /**
  23715. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23716. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23718. */
  23719. partitioningBBoxRatio: number;
  23720. /**
  23721. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23722. * Works only for updatable meshes.
  23723. * Doesn't work with multi-materials
  23724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23725. */
  23726. mustDepthSortFacets: boolean;
  23727. /**
  23728. * The location (Vector3) where the facet depth sort must be computed from.
  23729. * By default, the active camera position.
  23730. * Used only when facet depth sort is enabled
  23731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23732. */
  23733. facetDepthSortFrom: Vector3;
  23734. /**
  23735. * gets a boolean indicating if facetData is enabled
  23736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23737. */
  23738. readonly isFacetDataEnabled: boolean;
  23739. /** @hidden */
  23740. _updateNonUniformScalingState(value: boolean): boolean;
  23741. /**
  23742. * An event triggered when this mesh collides with another one
  23743. */
  23744. onCollideObservable: Observable<AbstractMesh>;
  23745. private _onCollideObserver;
  23746. /** Set a function to call when this mesh collides with another one */
  23747. onCollide: () => void;
  23748. /**
  23749. * An event triggered when the collision's position changes
  23750. */
  23751. onCollisionPositionChangeObservable: Observable<Vector3>;
  23752. private _onCollisionPositionChangeObserver;
  23753. /** Set a function to call when the collision's position changes */
  23754. onCollisionPositionChange: () => void;
  23755. /**
  23756. * An event triggered when material is changed
  23757. */
  23758. onMaterialChangedObservable: Observable<AbstractMesh>;
  23759. /**
  23760. * Gets or sets the orientation for POV movement & rotation
  23761. */
  23762. definedFacingForward: boolean;
  23763. /** @hidden */
  23764. _occlusionQuery: Nullable<WebGLQuery>;
  23765. private _visibility;
  23766. /**
  23767. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23768. */
  23769. /**
  23770. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23771. */
  23772. visibility: number;
  23773. /** Gets or sets the alpha index used to sort transparent meshes
  23774. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23775. */
  23776. alphaIndex: number;
  23777. /**
  23778. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23779. */
  23780. isVisible: boolean;
  23781. /**
  23782. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23783. */
  23784. isPickable: boolean;
  23785. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23786. showSubMeshesBoundingBox: boolean;
  23787. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23788. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23789. */
  23790. isBlocker: boolean;
  23791. /**
  23792. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23793. */
  23794. enablePointerMoveEvents: boolean;
  23795. /**
  23796. * Specifies the rendering group id for this mesh (0 by default)
  23797. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23798. */
  23799. renderingGroupId: number;
  23800. private _material;
  23801. /** Gets or sets current material */
  23802. material: Nullable<Material>;
  23803. private _receiveShadows;
  23804. /**
  23805. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23806. * @see http://doc.babylonjs.com/babylon101/shadows
  23807. */
  23808. receiveShadows: boolean;
  23809. /** Defines color to use when rendering outline */
  23810. outlineColor: Color3;
  23811. /** Define width to use when rendering outline */
  23812. outlineWidth: number;
  23813. /** Defines color to use when rendering overlay */
  23814. overlayColor: Color3;
  23815. /** Defines alpha to use when rendering overlay */
  23816. overlayAlpha: number;
  23817. private _hasVertexAlpha;
  23818. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23819. hasVertexAlpha: boolean;
  23820. private _useVertexColors;
  23821. /** 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) */
  23822. useVertexColors: boolean;
  23823. private _computeBonesUsingShaders;
  23824. /**
  23825. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23826. */
  23827. computeBonesUsingShaders: boolean;
  23828. private _numBoneInfluencers;
  23829. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23830. numBoneInfluencers: number;
  23831. private _applyFog;
  23832. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23833. applyFog: boolean;
  23834. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23835. useOctreeForRenderingSelection: boolean;
  23836. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23837. useOctreeForPicking: boolean;
  23838. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23839. useOctreeForCollisions: boolean;
  23840. private _layerMask;
  23841. /**
  23842. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23843. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23844. */
  23845. layerMask: number;
  23846. /**
  23847. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23848. */
  23849. alwaysSelectAsActiveMesh: boolean;
  23850. /**
  23851. * Gets or sets the current action manager
  23852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23853. */
  23854. actionManager: Nullable<AbstractActionManager>;
  23855. private _checkCollisions;
  23856. private _collisionMask;
  23857. private _collisionGroup;
  23858. /**
  23859. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23861. */
  23862. ellipsoid: Vector3;
  23863. /**
  23864. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23866. */
  23867. ellipsoidOffset: Vector3;
  23868. private _collider;
  23869. private _oldPositionForCollisions;
  23870. private _diffPositionForCollisions;
  23871. /**
  23872. * Gets or sets a collision mask used to mask collisions (default is -1).
  23873. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23874. */
  23875. collisionMask: number;
  23876. /**
  23877. * Gets or sets the current collision group mask (-1 by default).
  23878. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23879. */
  23880. collisionGroup: number;
  23881. /**
  23882. * Defines edge width used when edgesRenderer is enabled
  23883. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23884. */
  23885. edgesWidth: number;
  23886. /**
  23887. * Defines edge color used when edgesRenderer is enabled
  23888. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23889. */
  23890. edgesColor: Color4;
  23891. /** @hidden */
  23892. _edgesRenderer: Nullable<IEdgesRenderer>;
  23893. /** @hidden */
  23894. _masterMesh: Nullable<AbstractMesh>;
  23895. /** @hidden */
  23896. _boundingInfo: Nullable<BoundingInfo>;
  23897. /** @hidden */
  23898. _renderId: number;
  23899. /**
  23900. * Gets or sets the list of subMeshes
  23901. * @see http://doc.babylonjs.com/how_to/multi_materials
  23902. */
  23903. subMeshes: SubMesh[];
  23904. /** @hidden */
  23905. _intersectionsInProgress: AbstractMesh[];
  23906. /** @hidden */
  23907. _unIndexed: boolean;
  23908. /** @hidden */
  23909. _lightSources: Light[];
  23910. /** @hidden */
  23911. readonly _positions: Nullable<Vector3[]>;
  23912. /** @hidden */
  23913. _waitingActions: any;
  23914. /** @hidden */
  23915. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23916. private _skeleton;
  23917. /** @hidden */
  23918. _bonesTransformMatrices: Nullable<Float32Array>;
  23919. /**
  23920. * Gets or sets a skeleton to apply skining transformations
  23921. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23922. */
  23923. skeleton: Nullable<Skeleton>;
  23924. /**
  23925. * An event triggered when the mesh is rebuilt.
  23926. */
  23927. onRebuildObservable: Observable<AbstractMesh>;
  23928. /**
  23929. * Creates a new AbstractMesh
  23930. * @param name defines the name of the mesh
  23931. * @param scene defines the hosting scene
  23932. */
  23933. constructor(name: string, scene?: Nullable<Scene>);
  23934. /**
  23935. * Returns the string "AbstractMesh"
  23936. * @returns "AbstractMesh"
  23937. */
  23938. getClassName(): string;
  23939. /**
  23940. * Gets a string representation of the current mesh
  23941. * @param fullDetails defines a boolean indicating if full details must be included
  23942. * @returns a string representation of the current mesh
  23943. */
  23944. toString(fullDetails?: boolean): string;
  23945. /** @hidden */
  23946. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23947. /** @hidden */
  23948. _rebuild(): void;
  23949. /** @hidden */
  23950. _resyncLightSources(): void;
  23951. /** @hidden */
  23952. _resyncLighSource(light: Light): void;
  23953. /** @hidden */
  23954. _unBindEffect(): void;
  23955. /** @hidden */
  23956. _removeLightSource(light: Light): void;
  23957. private _markSubMeshesAsDirty;
  23958. /** @hidden */
  23959. _markSubMeshesAsLightDirty(): void;
  23960. /** @hidden */
  23961. _markSubMeshesAsAttributesDirty(): void;
  23962. /** @hidden */
  23963. _markSubMeshesAsMiscDirty(): void;
  23964. /**
  23965. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23966. */
  23967. scaling: Vector3;
  23968. /**
  23969. * Returns true if the mesh is blocked. Implemented by child classes
  23970. */
  23971. readonly isBlocked: boolean;
  23972. /**
  23973. * Returns the mesh itself by default. Implemented by child classes
  23974. * @param camera defines the camera to use to pick the right LOD level
  23975. * @returns the currentAbstractMesh
  23976. */
  23977. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23978. /**
  23979. * Returns 0 by default. Implemented by child classes
  23980. * @returns an integer
  23981. */
  23982. getTotalVertices(): number;
  23983. /**
  23984. * Returns a positive integer : the total number of indices in this mesh geometry.
  23985. * @returns the numner of indices or zero if the mesh has no geometry.
  23986. */
  23987. getTotalIndices(): number;
  23988. /**
  23989. * Returns null by default. Implemented by child classes
  23990. * @returns null
  23991. */
  23992. getIndices(): Nullable<IndicesArray>;
  23993. /**
  23994. * Returns the array of the requested vertex data kind. Implemented by child classes
  23995. * @param kind defines the vertex data kind to use
  23996. * @returns null
  23997. */
  23998. getVerticesData(kind: string): Nullable<FloatArray>;
  23999. /**
  24000. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24001. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24002. * Note that a new underlying VertexBuffer object is created each call.
  24003. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24004. * @param kind defines vertex data kind:
  24005. * * VertexBuffer.PositionKind
  24006. * * VertexBuffer.UVKind
  24007. * * VertexBuffer.UV2Kind
  24008. * * VertexBuffer.UV3Kind
  24009. * * VertexBuffer.UV4Kind
  24010. * * VertexBuffer.UV5Kind
  24011. * * VertexBuffer.UV6Kind
  24012. * * VertexBuffer.ColorKind
  24013. * * VertexBuffer.MatricesIndicesKind
  24014. * * VertexBuffer.MatricesIndicesExtraKind
  24015. * * VertexBuffer.MatricesWeightsKind
  24016. * * VertexBuffer.MatricesWeightsExtraKind
  24017. * @param data defines the data source
  24018. * @param updatable defines if the data must be flagged as updatable (or static)
  24019. * @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
  24020. * @returns the current mesh
  24021. */
  24022. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24023. /**
  24024. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24025. * If the mesh has no geometry, it is simply returned as it is.
  24026. * @param kind defines vertex data kind:
  24027. * * VertexBuffer.PositionKind
  24028. * * VertexBuffer.UVKind
  24029. * * VertexBuffer.UV2Kind
  24030. * * VertexBuffer.UV3Kind
  24031. * * VertexBuffer.UV4Kind
  24032. * * VertexBuffer.UV5Kind
  24033. * * VertexBuffer.UV6Kind
  24034. * * VertexBuffer.ColorKind
  24035. * * VertexBuffer.MatricesIndicesKind
  24036. * * VertexBuffer.MatricesIndicesExtraKind
  24037. * * VertexBuffer.MatricesWeightsKind
  24038. * * VertexBuffer.MatricesWeightsExtraKind
  24039. * @param data defines the data source
  24040. * @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
  24041. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24042. * @returns the current mesh
  24043. */
  24044. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24045. /**
  24046. * Sets the mesh indices,
  24047. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24048. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24049. * @param totalVertices Defines the total number of vertices
  24050. * @returns the current mesh
  24051. */
  24052. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24053. /**
  24054. * Gets a boolean indicating if specific vertex data is present
  24055. * @param kind defines the vertex data kind to use
  24056. * @returns true is data kind is present
  24057. */
  24058. isVerticesDataPresent(kind: string): boolean;
  24059. /**
  24060. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24061. * @returns a BoundingInfo
  24062. */
  24063. getBoundingInfo(): BoundingInfo;
  24064. /**
  24065. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24066. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24067. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24068. * @returns the current mesh
  24069. */
  24070. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24071. /**
  24072. * Overwrite the current bounding info
  24073. * @param boundingInfo defines the new bounding info
  24074. * @returns the current mesh
  24075. */
  24076. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24077. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24078. readonly useBones: boolean;
  24079. /** @hidden */
  24080. _preActivate(): void;
  24081. /** @hidden */
  24082. _preActivateForIntermediateRendering(renderId: number): void;
  24083. /** @hidden */
  24084. _activate(renderId: number): void;
  24085. /**
  24086. * Gets the current world matrix
  24087. * @returns a Matrix
  24088. */
  24089. getWorldMatrix(): Matrix;
  24090. /** @hidden */
  24091. _getWorldMatrixDeterminant(): number;
  24092. /**
  24093. * Perform relative position change from the point of view of behind the front of the mesh.
  24094. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24095. * Supports definition of mesh facing forward or backward
  24096. * @param amountRight defines the distance on the right axis
  24097. * @param amountUp defines the distance on the up axis
  24098. * @param amountForward defines the distance on the forward axis
  24099. * @returns the current mesh
  24100. */
  24101. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24102. /**
  24103. * Calculate relative position change from the point of view of behind the front of the mesh.
  24104. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24105. * Supports definition of mesh facing forward or backward
  24106. * @param amountRight defines the distance on the right axis
  24107. * @param amountUp defines the distance on the up axis
  24108. * @param amountForward defines the distance on the forward axis
  24109. * @returns the new displacement vector
  24110. */
  24111. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24112. /**
  24113. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24114. * Supports definition of mesh facing forward or backward
  24115. * @param flipBack defines the flip
  24116. * @param twirlClockwise defines the twirl
  24117. * @param tiltRight defines the tilt
  24118. * @returns the current mesh
  24119. */
  24120. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24121. /**
  24122. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24123. * Supports definition of mesh facing forward or backward.
  24124. * @param flipBack defines the flip
  24125. * @param twirlClockwise defines the twirl
  24126. * @param tiltRight defines the tilt
  24127. * @returns the new rotation vector
  24128. */
  24129. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24130. /**
  24131. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24132. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24133. * @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
  24134. * @returns the new bounding vectors
  24135. */
  24136. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24137. min: Vector3;
  24138. max: Vector3;
  24139. };
  24140. /**
  24141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24142. * This means the mesh underlying bounding box and sphere are recomputed.
  24143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24144. * @returns the current mesh
  24145. */
  24146. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24147. /** @hidden */
  24148. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24149. /** @hidden */
  24150. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24151. /** @hidden */
  24152. _updateBoundingInfo(): AbstractMesh;
  24153. /** @hidden */
  24154. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24155. /** @hidden */
  24156. protected _afterComputeWorldMatrix(): void;
  24157. /**
  24158. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24159. * A mesh is in the frustum if its bounding box intersects the frustum
  24160. * @param frustumPlanes defines the frustum to test
  24161. * @returns true if the mesh is in the frustum planes
  24162. */
  24163. isInFrustum(frustumPlanes: Plane[]): boolean;
  24164. /**
  24165. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24166. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24167. * @param frustumPlanes defines the frustum to test
  24168. * @returns true if the mesh is completely in the frustum planes
  24169. */
  24170. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24171. /**
  24172. * True if the mesh intersects another mesh or a SolidParticle object
  24173. * @param mesh defines a target mesh or SolidParticle to test
  24174. * @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)
  24175. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24176. * @returns true if there is an intersection
  24177. */
  24178. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24179. /**
  24180. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24181. * @param point defines the point to test
  24182. * @returns true if there is an intersection
  24183. */
  24184. intersectsPoint(point: Vector3): boolean;
  24185. /**
  24186. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24188. */
  24189. checkCollisions: boolean;
  24190. /**
  24191. * Gets Collider object used to compute collisions (not physics)
  24192. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24193. */
  24194. readonly collider: Collider;
  24195. /**
  24196. * Move the mesh using collision engine
  24197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24198. * @param displacement defines the requested displacement vector
  24199. * @returns the current mesh
  24200. */
  24201. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24202. private _onCollisionPositionChange;
  24203. /** @hidden */
  24204. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24205. /** @hidden */
  24206. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24207. /** @hidden */
  24208. _checkCollision(collider: Collider): AbstractMesh;
  24209. /** @hidden */
  24210. _generatePointsArray(): boolean;
  24211. /**
  24212. * Checks if the passed Ray intersects with the mesh
  24213. * @param ray defines the ray to use
  24214. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24216. * @returns the picking info
  24217. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24218. */
  24219. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24220. /**
  24221. * Clones the current mesh
  24222. * @param name defines the mesh name
  24223. * @param newParent defines the new mesh parent
  24224. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24225. * @returns the new mesh
  24226. */
  24227. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24228. /**
  24229. * Disposes all the submeshes of the current meshnp
  24230. * @returns the current mesh
  24231. */
  24232. releaseSubMeshes(): AbstractMesh;
  24233. /**
  24234. * Releases resources associated with this abstract mesh.
  24235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24237. */
  24238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24239. /**
  24240. * Adds the passed mesh as a child to the current mesh
  24241. * @param mesh defines the child mesh
  24242. * @returns the current mesh
  24243. */
  24244. addChild(mesh: AbstractMesh): AbstractMesh;
  24245. /**
  24246. * Removes the passed mesh from the current mesh children list
  24247. * @param mesh defines the child mesh
  24248. * @returns the current mesh
  24249. */
  24250. removeChild(mesh: AbstractMesh): AbstractMesh;
  24251. /** @hidden */
  24252. private _initFacetData;
  24253. /**
  24254. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24255. * This method can be called within the render loop.
  24256. * 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
  24257. * @returns the current mesh
  24258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24259. */
  24260. updateFacetData(): AbstractMesh;
  24261. /**
  24262. * Returns the facetLocalNormals array.
  24263. * The normals are expressed in the mesh local spac
  24264. * @returns an array of Vector3
  24265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24266. */
  24267. getFacetLocalNormals(): Vector3[];
  24268. /**
  24269. * Returns the facetLocalPositions array.
  24270. * The facet positions are expressed in the mesh local space
  24271. * @returns an array of Vector3
  24272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24273. */
  24274. getFacetLocalPositions(): Vector3[];
  24275. /**
  24276. * Returns the facetLocalPartioning array
  24277. * @returns an array of array of numbers
  24278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24279. */
  24280. getFacetLocalPartitioning(): number[][];
  24281. /**
  24282. * Returns the i-th facet position in the world system.
  24283. * This method allocates a new Vector3 per call
  24284. * @param i defines the facet index
  24285. * @returns a new Vector3
  24286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24287. */
  24288. getFacetPosition(i: number): Vector3;
  24289. /**
  24290. * Sets the reference Vector3 with the i-th facet position in the world system
  24291. * @param i defines the facet index
  24292. * @param ref defines the target vector
  24293. * @returns the current mesh
  24294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24295. */
  24296. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24297. /**
  24298. * Returns the i-th facet normal in the world system.
  24299. * This method allocates a new Vector3 per call
  24300. * @param i defines the facet index
  24301. * @returns a new Vector3
  24302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24303. */
  24304. getFacetNormal(i: number): Vector3;
  24305. /**
  24306. * Sets the reference Vector3 with the i-th facet normal in the world system
  24307. * @param i defines the facet index
  24308. * @param ref defines the target vector
  24309. * @returns the current mesh
  24310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24311. */
  24312. getFacetNormalToRef(i: number, ref: Vector3): this;
  24313. /**
  24314. * 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)
  24315. * @param x defines x coordinate
  24316. * @param y defines y coordinate
  24317. * @param z defines z coordinate
  24318. * @returns the array of facet indexes
  24319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24320. */
  24321. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24322. /**
  24323. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24324. * @param projected sets as the (x,y,z) world projection on the facet
  24325. * @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
  24326. * @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
  24327. * @param x defines x coordinate
  24328. * @param y defines y coordinate
  24329. * @param z defines z coordinate
  24330. * @returns the face index if found (or null instead)
  24331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24332. */
  24333. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24334. /**
  24335. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24336. * @param projected sets as the (x,y,z) local projection on the facet
  24337. * @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
  24338. * @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
  24339. * @param x defines x coordinate
  24340. * @param y defines y coordinate
  24341. * @param z defines z coordinate
  24342. * @returns the face index if found (or null instead)
  24343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24344. */
  24345. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24346. /**
  24347. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24348. * @returns the parameters
  24349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24350. */
  24351. getFacetDataParameters(): any;
  24352. /**
  24353. * Disables the feature FacetData and frees the related memory
  24354. * @returns the current mesh
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24356. */
  24357. disableFacetData(): AbstractMesh;
  24358. /**
  24359. * Updates the AbstractMesh indices array
  24360. * @param indices defines the data source
  24361. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24362. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24363. * @returns the current mesh
  24364. */
  24365. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24366. /**
  24367. * Creates new normals data for the mesh
  24368. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24369. * @returns the current mesh
  24370. */
  24371. createNormals(updatable: boolean): AbstractMesh;
  24372. /**
  24373. * Align the mesh with a normal
  24374. * @param normal defines the normal to use
  24375. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24376. * @returns the current mesh
  24377. */
  24378. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24379. /** @hidden */
  24380. _checkOcclusionQuery(): boolean;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * Interface used to define ActionEvent
  24386. */
  24387. export interface IActionEvent {
  24388. /** The mesh or sprite that triggered the action */
  24389. source: any;
  24390. /** The X mouse cursor position at the time of the event */
  24391. pointerX: number;
  24392. /** The Y mouse cursor position at the time of the event */
  24393. pointerY: number;
  24394. /** The mesh that is currently pointed at (can be null) */
  24395. meshUnderPointer: Nullable<AbstractMesh>;
  24396. /** the original (browser) event that triggered the ActionEvent */
  24397. sourceEvent?: any;
  24398. /** additional data for the event */
  24399. additionalData?: any;
  24400. }
  24401. /**
  24402. * ActionEvent is the event being sent when an action is triggered.
  24403. */
  24404. export class ActionEvent implements IActionEvent {
  24405. /** The mesh or sprite that triggered the action */
  24406. source: any;
  24407. /** The X mouse cursor position at the time of the event */
  24408. pointerX: number;
  24409. /** The Y mouse cursor position at the time of the event */
  24410. pointerY: number;
  24411. /** The mesh that is currently pointed at (can be null) */
  24412. meshUnderPointer: Nullable<AbstractMesh>;
  24413. /** the original (browser) event that triggered the ActionEvent */
  24414. sourceEvent?: any;
  24415. /** additional data for the event */
  24416. additionalData?: any;
  24417. /**
  24418. * Creates a new ActionEvent
  24419. * @param source The mesh or sprite that triggered the action
  24420. * @param pointerX The X mouse cursor position at the time of the event
  24421. * @param pointerY The Y mouse cursor position at the time of the event
  24422. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24423. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24424. * @param additionalData additional data for the event
  24425. */
  24426. constructor(
  24427. /** The mesh or sprite that triggered the action */
  24428. source: any,
  24429. /** The X mouse cursor position at the time of the event */
  24430. pointerX: number,
  24431. /** The Y mouse cursor position at the time of the event */
  24432. pointerY: number,
  24433. /** The mesh that is currently pointed at (can be null) */
  24434. meshUnderPointer: Nullable<AbstractMesh>,
  24435. /** the original (browser) event that triggered the ActionEvent */
  24436. sourceEvent?: any,
  24437. /** additional data for the event */
  24438. additionalData?: any);
  24439. /**
  24440. * Helper function to auto-create an ActionEvent from a source mesh.
  24441. * @param source The source mesh that triggered the event
  24442. * @param evt The original (browser) event
  24443. * @param additionalData additional data for the event
  24444. * @returns the new ActionEvent
  24445. */
  24446. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24447. /**
  24448. * Helper function to auto-create an ActionEvent from a source sprite
  24449. * @param source The source sprite that triggered the event
  24450. * @param scene Scene associated with the sprite
  24451. * @param evt The original (browser) event
  24452. * @param additionalData additional data for the event
  24453. * @returns the new ActionEvent
  24454. */
  24455. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24456. /**
  24457. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24458. * @param scene the scene where the event occurred
  24459. * @param evt The original (browser) event
  24460. * @returns the new ActionEvent
  24461. */
  24462. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24463. /**
  24464. * Helper function to auto-create an ActionEvent from a primitive
  24465. * @param prim defines the target primitive
  24466. * @param pointerPos defines the pointer position
  24467. * @param evt The original (browser) event
  24468. * @param additionalData additional data for the event
  24469. * @returns the new ActionEvent
  24470. */
  24471. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24472. }
  24473. }
  24474. declare module BABYLON {
  24475. /**
  24476. * Abstract class used to decouple action Manager from scene and meshes.
  24477. * Do not instantiate.
  24478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24479. */
  24480. export abstract class AbstractActionManager implements IDisposable {
  24481. /** Gets the list of active triggers */
  24482. static Triggers: {
  24483. [key: string]: number;
  24484. };
  24485. /** Gets the cursor to use when hovering items */
  24486. hoverCursor: string;
  24487. /** Gets the list of actions */
  24488. actions: IAction[];
  24489. /**
  24490. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24491. */
  24492. isRecursive: boolean;
  24493. /**
  24494. * Releases all associated resources
  24495. */
  24496. abstract dispose(): void;
  24497. /**
  24498. * Does this action manager has pointer triggers
  24499. */
  24500. abstract readonly hasPointerTriggers: boolean;
  24501. /**
  24502. * Does this action manager has pick triggers
  24503. */
  24504. abstract readonly hasPickTriggers: boolean;
  24505. /**
  24506. * Process a specific trigger
  24507. * @param trigger defines the trigger to process
  24508. * @param evt defines the event details to be processed
  24509. */
  24510. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24511. /**
  24512. * Does this action manager handles actions of any of the given triggers
  24513. * @param triggers defines the triggers to be tested
  24514. * @return a boolean indicating whether one (or more) of the triggers is handled
  24515. */
  24516. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24517. /**
  24518. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24519. * speed.
  24520. * @param triggerA defines the trigger to be tested
  24521. * @param triggerB defines the trigger to be tested
  24522. * @return a boolean indicating whether one (or more) of the triggers is handled
  24523. */
  24524. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24525. /**
  24526. * Does this action manager handles actions of a given trigger
  24527. * @param trigger defines the trigger to be tested
  24528. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24529. * @return whether the trigger is handled
  24530. */
  24531. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24532. /**
  24533. * Serialize this manager to a JSON object
  24534. * @param name defines the property name to store this manager
  24535. * @returns a JSON representation of this manager
  24536. */
  24537. abstract serialize(name: string): any;
  24538. /**
  24539. * Registers an action to this action manager
  24540. * @param action defines the action to be registered
  24541. * @return the action amended (prepared) after registration
  24542. */
  24543. abstract registerAction(action: IAction): Nullable<IAction>;
  24544. /**
  24545. * Unregisters an action to this action manager
  24546. * @param action defines the action to be unregistered
  24547. * @return a boolean indicating whether the action has been unregistered
  24548. */
  24549. abstract unregisterAction(action: IAction): Boolean;
  24550. /**
  24551. * Does exist one action manager with at least one trigger
  24552. **/
  24553. static readonly HasTriggers: boolean;
  24554. /**
  24555. * Does exist one action manager with at least one pick trigger
  24556. **/
  24557. static readonly HasPickTriggers: boolean;
  24558. /**
  24559. * Does exist one action manager that handles actions of a given trigger
  24560. * @param trigger defines the trigger to be tested
  24561. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24562. **/
  24563. static HasSpecificTrigger(trigger: number): boolean;
  24564. }
  24565. }
  24566. declare module BABYLON {
  24567. /**
  24568. * Defines how a node can be built from a string name.
  24569. */
  24570. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24571. /**
  24572. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24573. */
  24574. export class Node implements IBehaviorAware<Node> {
  24575. /** @hidden */
  24576. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24577. private static _NodeConstructors;
  24578. /**
  24579. * Add a new node constructor
  24580. * @param type defines the type name of the node to construct
  24581. * @param constructorFunc defines the constructor function
  24582. */
  24583. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24584. /**
  24585. * Returns a node constructor based on type name
  24586. * @param type defines the type name
  24587. * @param name defines the new node name
  24588. * @param scene defines the hosting scene
  24589. * @param options defines optional options to transmit to constructors
  24590. * @returns the new constructor or null
  24591. */
  24592. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24593. /**
  24594. * Gets or sets the name of the node
  24595. */
  24596. name: string;
  24597. /**
  24598. * Gets or sets the id of the node
  24599. */
  24600. id: string;
  24601. /**
  24602. * Gets or sets the unique id of the node
  24603. */
  24604. uniqueId: number;
  24605. /**
  24606. * Gets or sets a string used to store user defined state for the node
  24607. */
  24608. state: string;
  24609. /**
  24610. * Gets or sets an object used to store user defined information for the node
  24611. */
  24612. metadata: any;
  24613. /**
  24614. * For internal use only. Please do not use.
  24615. */
  24616. reservedDataStore: any;
  24617. /**
  24618. * List of inspectable custom properties (used by the Inspector)
  24619. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24620. */
  24621. inspectableCustomProperties: IInspectable[];
  24622. /**
  24623. * Gets or sets a boolean used to define if the node must be serialized
  24624. */
  24625. doNotSerialize: boolean;
  24626. /** @hidden */
  24627. _isDisposed: boolean;
  24628. /**
  24629. * Gets a list of Animations associated with the node
  24630. */
  24631. animations: Animation[];
  24632. protected _ranges: {
  24633. [name: string]: Nullable<AnimationRange>;
  24634. };
  24635. /**
  24636. * Callback raised when the node is ready to be used
  24637. */
  24638. onReady: (node: Node) => void;
  24639. private _isEnabled;
  24640. private _isParentEnabled;
  24641. private _isReady;
  24642. /** @hidden */
  24643. _currentRenderId: number;
  24644. private _parentRenderId;
  24645. protected _childRenderId: number;
  24646. /** @hidden */
  24647. _waitingParentId: Nullable<string>;
  24648. /** @hidden */
  24649. _scene: Scene;
  24650. /** @hidden */
  24651. _cache: any;
  24652. private _parentNode;
  24653. private _children;
  24654. /** @hidden */
  24655. _worldMatrix: Matrix;
  24656. /** @hidden */
  24657. _worldMatrixDeterminant: number;
  24658. /** @hidden */
  24659. private _sceneRootNodesIndex;
  24660. /**
  24661. * Gets a boolean indicating if the node has been disposed
  24662. * @returns true if the node was disposed
  24663. */
  24664. isDisposed(): boolean;
  24665. /**
  24666. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24667. * @see https://doc.babylonjs.com/how_to/parenting
  24668. */
  24669. parent: Nullable<Node>;
  24670. private addToSceneRootNodes;
  24671. private removeFromSceneRootNodes;
  24672. private _animationPropertiesOverride;
  24673. /**
  24674. * Gets or sets the animation properties override
  24675. */
  24676. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24677. /**
  24678. * Gets a string idenfifying the name of the class
  24679. * @returns "Node" string
  24680. */
  24681. getClassName(): string;
  24682. /** @hidden */
  24683. readonly _isNode: boolean;
  24684. /**
  24685. * An event triggered when the mesh is disposed
  24686. */
  24687. onDisposeObservable: Observable<Node>;
  24688. private _onDisposeObserver;
  24689. /**
  24690. * Sets a callback that will be raised when the node will be disposed
  24691. */
  24692. onDispose: () => void;
  24693. /**
  24694. * Creates a new Node
  24695. * @param name the name and id to be given to this node
  24696. * @param scene the scene this node will be added to
  24697. * @param addToRootNodes the node will be added to scene.rootNodes
  24698. */
  24699. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24700. /**
  24701. * Gets the scene of the node
  24702. * @returns a scene
  24703. */
  24704. getScene(): Scene;
  24705. /**
  24706. * Gets the engine of the node
  24707. * @returns a Engine
  24708. */
  24709. getEngine(): Engine;
  24710. private _behaviors;
  24711. /**
  24712. * Attach a behavior to the node
  24713. * @see http://doc.babylonjs.com/features/behaviour
  24714. * @param behavior defines the behavior to attach
  24715. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24716. * @returns the current Node
  24717. */
  24718. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24719. /**
  24720. * Remove an attached behavior
  24721. * @see http://doc.babylonjs.com/features/behaviour
  24722. * @param behavior defines the behavior to attach
  24723. * @returns the current Node
  24724. */
  24725. removeBehavior(behavior: Behavior<Node>): Node;
  24726. /**
  24727. * Gets the list of attached behaviors
  24728. * @see http://doc.babylonjs.com/features/behaviour
  24729. */
  24730. readonly behaviors: Behavior<Node>[];
  24731. /**
  24732. * Gets an attached behavior by name
  24733. * @param name defines the name of the behavior to look for
  24734. * @see http://doc.babylonjs.com/features/behaviour
  24735. * @returns null if behavior was not found else the requested behavior
  24736. */
  24737. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24738. /**
  24739. * Returns the latest update of the World matrix
  24740. * @returns a Matrix
  24741. */
  24742. getWorldMatrix(): Matrix;
  24743. /** @hidden */
  24744. _getWorldMatrixDeterminant(): number;
  24745. /**
  24746. * Returns directly the latest state of the mesh World matrix.
  24747. * A Matrix is returned.
  24748. */
  24749. readonly worldMatrixFromCache: Matrix;
  24750. /** @hidden */
  24751. _initCache(): void;
  24752. /** @hidden */
  24753. updateCache(force?: boolean): void;
  24754. /** @hidden */
  24755. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24756. /** @hidden */
  24757. _updateCache(ignoreParentClass?: boolean): void;
  24758. /** @hidden */
  24759. _isSynchronized(): boolean;
  24760. /** @hidden */
  24761. _markSyncedWithParent(): void;
  24762. /** @hidden */
  24763. isSynchronizedWithParent(): boolean;
  24764. /** @hidden */
  24765. isSynchronized(): boolean;
  24766. /**
  24767. * Is this node ready to be used/rendered
  24768. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24769. * @return true if the node is ready
  24770. */
  24771. isReady(completeCheck?: boolean): boolean;
  24772. /**
  24773. * Is this node enabled?
  24774. * 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
  24775. * @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
  24776. * @return whether this node (and its parent) is enabled
  24777. */
  24778. isEnabled(checkAncestors?: boolean): boolean;
  24779. /** @hidden */
  24780. protected _syncParentEnabledState(): void;
  24781. /**
  24782. * Set the enabled state of this node
  24783. * @param value defines the new enabled state
  24784. */
  24785. setEnabled(value: boolean): void;
  24786. /**
  24787. * Is this node a descendant of the given node?
  24788. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24789. * @param ancestor defines the parent node to inspect
  24790. * @returns a boolean indicating if this node is a descendant of the given node
  24791. */
  24792. isDescendantOf(ancestor: Node): boolean;
  24793. /** @hidden */
  24794. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24795. /**
  24796. * Will return all nodes that have this node as ascendant
  24797. * @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
  24798. * @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
  24799. * @return all children nodes of all types
  24800. */
  24801. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24802. /**
  24803. * Get all child-meshes of this node
  24804. * @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: false)
  24805. * @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
  24806. * @returns an array of AbstractMesh
  24807. */
  24808. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24809. /**
  24810. * Get all direct children of this node
  24811. * @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
  24812. * @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)
  24813. * @returns an array of Node
  24814. */
  24815. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24816. /** @hidden */
  24817. _setReady(state: boolean): void;
  24818. /**
  24819. * Get an animation by name
  24820. * @param name defines the name of the animation to look for
  24821. * @returns null if not found else the requested animation
  24822. */
  24823. getAnimationByName(name: string): Nullable<Animation>;
  24824. /**
  24825. * Creates an animation range for this node
  24826. * @param name defines the name of the range
  24827. * @param from defines the starting key
  24828. * @param to defines the end key
  24829. */
  24830. createAnimationRange(name: string, from: number, to: number): void;
  24831. /**
  24832. * Delete a specific animation range
  24833. * @param name defines the name of the range to delete
  24834. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24835. */
  24836. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24837. /**
  24838. * Get an animation range by name
  24839. * @param name defines the name of the animation range to look for
  24840. * @returns null if not found else the requested animation range
  24841. */
  24842. getAnimationRange(name: string): Nullable<AnimationRange>;
  24843. /**
  24844. * Gets the list of all animation ranges defined on this node
  24845. * @returns an array
  24846. */
  24847. getAnimationRanges(): Nullable<AnimationRange>[];
  24848. /**
  24849. * Will start the animation sequence
  24850. * @param name defines the range frames for animation sequence
  24851. * @param loop defines if the animation should loop (false by default)
  24852. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24853. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24854. * @returns the object created for this animation. If range does not exist, it will return null
  24855. */
  24856. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24857. /**
  24858. * Serialize animation ranges into a JSON compatible object
  24859. * @returns serialization object
  24860. */
  24861. serializeAnimationRanges(): any;
  24862. /**
  24863. * Computes the world matrix of the node
  24864. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24865. * @returns the world matrix
  24866. */
  24867. computeWorldMatrix(force?: boolean): Matrix;
  24868. /**
  24869. * Releases resources associated with this node.
  24870. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24871. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24872. */
  24873. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24874. /**
  24875. * Parse animation range data from a serialization object and store them into a given node
  24876. * @param node defines where to store the animation ranges
  24877. * @param parsedNode defines the serialization object to read data from
  24878. * @param scene defines the hosting scene
  24879. */
  24880. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24881. }
  24882. }
  24883. declare module BABYLON {
  24884. /**
  24885. * Class used to store any kind of animation
  24886. */
  24887. export class Animation {
  24888. /**Name of the animation */
  24889. name: string;
  24890. /**Property to animate */
  24891. targetProperty: string;
  24892. /**The frames per second of the animation */
  24893. framePerSecond: number;
  24894. /**The data type of the animation */
  24895. dataType: number;
  24896. /**The loop mode of the animation */
  24897. loopMode?: number | undefined;
  24898. /**Specifies if blending should be enabled */
  24899. enableBlending?: boolean | undefined;
  24900. /**
  24901. * Use matrix interpolation instead of using direct key value when animating matrices
  24902. */
  24903. static AllowMatricesInterpolation: boolean;
  24904. /**
  24905. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24906. */
  24907. static AllowMatrixDecomposeForInterpolation: boolean;
  24908. /**
  24909. * Stores the key frames of the animation
  24910. */
  24911. private _keys;
  24912. /**
  24913. * Stores the easing function of the animation
  24914. */
  24915. private _easingFunction;
  24916. /**
  24917. * @hidden Internal use only
  24918. */
  24919. _runtimeAnimations: RuntimeAnimation[];
  24920. /**
  24921. * The set of event that will be linked to this animation
  24922. */
  24923. private _events;
  24924. /**
  24925. * Stores an array of target property paths
  24926. */
  24927. targetPropertyPath: string[];
  24928. /**
  24929. * Stores the blending speed of the animation
  24930. */
  24931. blendingSpeed: number;
  24932. /**
  24933. * Stores the animation ranges for the animation
  24934. */
  24935. private _ranges;
  24936. /**
  24937. * @hidden Internal use
  24938. */
  24939. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24940. /**
  24941. * Sets up an animation
  24942. * @param property The property to animate
  24943. * @param animationType The animation type to apply
  24944. * @param framePerSecond The frames per second of the animation
  24945. * @param easingFunction The easing function used in the animation
  24946. * @returns The created animation
  24947. */
  24948. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24949. /**
  24950. * Create and start an animation on a node
  24951. * @param name defines the name of the global animation that will be run on all nodes
  24952. * @param node defines the root node where the animation will take place
  24953. * @param targetProperty defines property to animate
  24954. * @param framePerSecond defines the number of frame per second yo use
  24955. * @param totalFrame defines the number of frames in total
  24956. * @param from defines the initial value
  24957. * @param to defines the final value
  24958. * @param loopMode defines which loop mode you want to use (off by default)
  24959. * @param easingFunction defines the easing function to use (linear by default)
  24960. * @param onAnimationEnd defines the callback to call when animation end
  24961. * @returns the animatable created for this animation
  24962. */
  24963. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24964. /**
  24965. * Create and start an animation on a node and its descendants
  24966. * @param name defines the name of the global animation that will be run on all nodes
  24967. * @param node defines the root node where the animation will take place
  24968. * @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
  24969. * @param targetProperty defines property to animate
  24970. * @param framePerSecond defines the number of frame per second to use
  24971. * @param totalFrame defines the number of frames in total
  24972. * @param from defines the initial value
  24973. * @param to defines the final value
  24974. * @param loopMode defines which loop mode you want to use (off by default)
  24975. * @param easingFunction defines the easing function to use (linear by default)
  24976. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24977. * @returns the list of animatables created for all nodes
  24978. * @example https://www.babylonjs-playground.com/#MH0VLI
  24979. */
  24980. 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[]>;
  24981. /**
  24982. * Creates a new animation, merges it with the existing animations and starts it
  24983. * @param name Name of the animation
  24984. * @param node Node which contains the scene that begins the animations
  24985. * @param targetProperty Specifies which property to animate
  24986. * @param framePerSecond The frames per second of the animation
  24987. * @param totalFrame The total number of frames
  24988. * @param from The frame at the beginning of the animation
  24989. * @param to The frame at the end of the animation
  24990. * @param loopMode Specifies the loop mode of the animation
  24991. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24992. * @param onAnimationEnd Callback to run once the animation is complete
  24993. * @returns Nullable animation
  24994. */
  24995. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24996. /**
  24997. * Transition property of an host to the target Value
  24998. * @param property The property to transition
  24999. * @param targetValue The target Value of the property
  25000. * @param host The object where the property to animate belongs
  25001. * @param scene Scene used to run the animation
  25002. * @param frameRate Framerate (in frame/s) to use
  25003. * @param transition The transition type we want to use
  25004. * @param duration The duration of the animation, in milliseconds
  25005. * @param onAnimationEnd Callback trigger at the end of the animation
  25006. * @returns Nullable animation
  25007. */
  25008. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25009. /**
  25010. * Return the array of runtime animations currently using this animation
  25011. */
  25012. readonly runtimeAnimations: RuntimeAnimation[];
  25013. /**
  25014. * Specifies if any of the runtime animations are currently running
  25015. */
  25016. readonly hasRunningRuntimeAnimations: boolean;
  25017. /**
  25018. * Initializes the animation
  25019. * @param name Name of the animation
  25020. * @param targetProperty Property to animate
  25021. * @param framePerSecond The frames per second of the animation
  25022. * @param dataType The data type of the animation
  25023. * @param loopMode The loop mode of the animation
  25024. * @param enableBlending Specifies if blending should be enabled
  25025. */
  25026. constructor(
  25027. /**Name of the animation */
  25028. name: string,
  25029. /**Property to animate */
  25030. targetProperty: string,
  25031. /**The frames per second of the animation */
  25032. framePerSecond: number,
  25033. /**The data type of the animation */
  25034. dataType: number,
  25035. /**The loop mode of the animation */
  25036. loopMode?: number | undefined,
  25037. /**Specifies if blending should be enabled */
  25038. enableBlending?: boolean | undefined);
  25039. /**
  25040. * Converts the animation to a string
  25041. * @param fullDetails support for multiple levels of logging within scene loading
  25042. * @returns String form of the animation
  25043. */
  25044. toString(fullDetails?: boolean): string;
  25045. /**
  25046. * Add an event to this animation
  25047. * @param event Event to add
  25048. */
  25049. addEvent(event: AnimationEvent): void;
  25050. /**
  25051. * Remove all events found at the given frame
  25052. * @param frame The frame to remove events from
  25053. */
  25054. removeEvents(frame: number): void;
  25055. /**
  25056. * Retrieves all the events from the animation
  25057. * @returns Events from the animation
  25058. */
  25059. getEvents(): AnimationEvent[];
  25060. /**
  25061. * Creates an animation range
  25062. * @param name Name of the animation range
  25063. * @param from Starting frame of the animation range
  25064. * @param to Ending frame of the animation
  25065. */
  25066. createRange(name: string, from: number, to: number): void;
  25067. /**
  25068. * Deletes an animation range by name
  25069. * @param name Name of the animation range to delete
  25070. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25071. */
  25072. deleteRange(name: string, deleteFrames?: boolean): void;
  25073. /**
  25074. * Gets the animation range by name, or null if not defined
  25075. * @param name Name of the animation range
  25076. * @returns Nullable animation range
  25077. */
  25078. getRange(name: string): Nullable<AnimationRange>;
  25079. /**
  25080. * Gets the key frames from the animation
  25081. * @returns The key frames of the animation
  25082. */
  25083. getKeys(): Array<IAnimationKey>;
  25084. /**
  25085. * Gets the highest frame rate of the animation
  25086. * @returns Highest frame rate of the animation
  25087. */
  25088. getHighestFrame(): number;
  25089. /**
  25090. * Gets the easing function of the animation
  25091. * @returns Easing function of the animation
  25092. */
  25093. getEasingFunction(): IEasingFunction;
  25094. /**
  25095. * Sets the easing function of the animation
  25096. * @param easingFunction A custom mathematical formula for animation
  25097. */
  25098. setEasingFunction(easingFunction: EasingFunction): void;
  25099. /**
  25100. * Interpolates a scalar linearly
  25101. * @param startValue Start value of the animation curve
  25102. * @param endValue End value of the animation curve
  25103. * @param gradient Scalar amount to interpolate
  25104. * @returns Interpolated scalar value
  25105. */
  25106. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25107. /**
  25108. * Interpolates a scalar cubically
  25109. * @param startValue Start value of the animation curve
  25110. * @param outTangent End tangent of the animation
  25111. * @param endValue End value of the animation curve
  25112. * @param inTangent Start tangent of the animation curve
  25113. * @param gradient Scalar amount to interpolate
  25114. * @returns Interpolated scalar value
  25115. */
  25116. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25117. /**
  25118. * Interpolates a quaternion using a spherical linear interpolation
  25119. * @param startValue Start value of the animation curve
  25120. * @param endValue End value of the animation curve
  25121. * @param gradient Scalar amount to interpolate
  25122. * @returns Interpolated quaternion value
  25123. */
  25124. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25125. /**
  25126. * Interpolates a quaternion cubically
  25127. * @param startValue Start value of the animation curve
  25128. * @param outTangent End tangent of the animation curve
  25129. * @param endValue End value of the animation curve
  25130. * @param inTangent Start tangent of the animation curve
  25131. * @param gradient Scalar amount to interpolate
  25132. * @returns Interpolated quaternion value
  25133. */
  25134. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25135. /**
  25136. * Interpolates a Vector3 linearl
  25137. * @param startValue Start value of the animation curve
  25138. * @param endValue End value of the animation curve
  25139. * @param gradient Scalar amount to interpolate
  25140. * @returns Interpolated scalar value
  25141. */
  25142. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25143. /**
  25144. * Interpolates a Vector3 cubically
  25145. * @param startValue Start value of the animation curve
  25146. * @param outTangent End tangent of the animation
  25147. * @param endValue End value of the animation curve
  25148. * @param inTangent Start tangent of the animation curve
  25149. * @param gradient Scalar amount to interpolate
  25150. * @returns InterpolatedVector3 value
  25151. */
  25152. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25153. /**
  25154. * Interpolates a Vector2 linearly
  25155. * @param startValue Start value of the animation curve
  25156. * @param endValue End value of the animation curve
  25157. * @param gradient Scalar amount to interpolate
  25158. * @returns Interpolated Vector2 value
  25159. */
  25160. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25161. /**
  25162. * Interpolates a Vector2 cubically
  25163. * @param startValue Start value of the animation curve
  25164. * @param outTangent End tangent of the animation
  25165. * @param endValue End value of the animation curve
  25166. * @param inTangent Start tangent of the animation curve
  25167. * @param gradient Scalar amount to interpolate
  25168. * @returns Interpolated Vector2 value
  25169. */
  25170. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25171. /**
  25172. * Interpolates a size linearly
  25173. * @param startValue Start value of the animation curve
  25174. * @param endValue End value of the animation curve
  25175. * @param gradient Scalar amount to interpolate
  25176. * @returns Interpolated Size value
  25177. */
  25178. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25179. /**
  25180. * Interpolates a Color3 linearly
  25181. * @param startValue Start value of the animation curve
  25182. * @param endValue End value of the animation curve
  25183. * @param gradient Scalar amount to interpolate
  25184. * @returns Interpolated Color3 value
  25185. */
  25186. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25187. /**
  25188. * @hidden Internal use only
  25189. */
  25190. _getKeyValue(value: any): any;
  25191. /**
  25192. * @hidden Internal use only
  25193. */
  25194. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25195. /**
  25196. * Defines the function to use to interpolate matrices
  25197. * @param startValue defines the start matrix
  25198. * @param endValue defines the end matrix
  25199. * @param gradient defines the gradient between both matrices
  25200. * @param result defines an optional target matrix where to store the interpolation
  25201. * @returns the interpolated matrix
  25202. */
  25203. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25204. /**
  25205. * Makes a copy of the animation
  25206. * @returns Cloned animation
  25207. */
  25208. clone(): Animation;
  25209. /**
  25210. * Sets the key frames of the animation
  25211. * @param values The animation key frames to set
  25212. */
  25213. setKeys(values: Array<IAnimationKey>): void;
  25214. /**
  25215. * Serializes the animation to an object
  25216. * @returns Serialized object
  25217. */
  25218. serialize(): any;
  25219. /**
  25220. * Float animation type
  25221. */
  25222. private static _ANIMATIONTYPE_FLOAT;
  25223. /**
  25224. * Vector3 animation type
  25225. */
  25226. private static _ANIMATIONTYPE_VECTOR3;
  25227. /**
  25228. * Quaternion animation type
  25229. */
  25230. private static _ANIMATIONTYPE_QUATERNION;
  25231. /**
  25232. * Matrix animation type
  25233. */
  25234. private static _ANIMATIONTYPE_MATRIX;
  25235. /**
  25236. * Color3 animation type
  25237. */
  25238. private static _ANIMATIONTYPE_COLOR3;
  25239. /**
  25240. * Vector2 animation type
  25241. */
  25242. private static _ANIMATIONTYPE_VECTOR2;
  25243. /**
  25244. * Size animation type
  25245. */
  25246. private static _ANIMATIONTYPE_SIZE;
  25247. /**
  25248. * Relative Loop Mode
  25249. */
  25250. private static _ANIMATIONLOOPMODE_RELATIVE;
  25251. /**
  25252. * Cycle Loop Mode
  25253. */
  25254. private static _ANIMATIONLOOPMODE_CYCLE;
  25255. /**
  25256. * Constant Loop Mode
  25257. */
  25258. private static _ANIMATIONLOOPMODE_CONSTANT;
  25259. /**
  25260. * Get the float animation type
  25261. */
  25262. static readonly ANIMATIONTYPE_FLOAT: number;
  25263. /**
  25264. * Get the Vector3 animation type
  25265. */
  25266. static readonly ANIMATIONTYPE_VECTOR3: number;
  25267. /**
  25268. * Get the Vector2 animation type
  25269. */
  25270. static readonly ANIMATIONTYPE_VECTOR2: number;
  25271. /**
  25272. * Get the Size animation type
  25273. */
  25274. static readonly ANIMATIONTYPE_SIZE: number;
  25275. /**
  25276. * Get the Quaternion animation type
  25277. */
  25278. static readonly ANIMATIONTYPE_QUATERNION: number;
  25279. /**
  25280. * Get the Matrix animation type
  25281. */
  25282. static readonly ANIMATIONTYPE_MATRIX: number;
  25283. /**
  25284. * Get the Color3 animation type
  25285. */
  25286. static readonly ANIMATIONTYPE_COLOR3: number;
  25287. /**
  25288. * Get the Relative Loop Mode
  25289. */
  25290. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25291. /**
  25292. * Get the Cycle Loop Mode
  25293. */
  25294. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25295. /**
  25296. * Get the Constant Loop Mode
  25297. */
  25298. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25299. /** @hidden */
  25300. static _UniversalLerp(left: any, right: any, amount: number): any;
  25301. /**
  25302. * Parses an animation object and creates an animation
  25303. * @param parsedAnimation Parsed animation object
  25304. * @returns Animation object
  25305. */
  25306. static Parse(parsedAnimation: any): Animation;
  25307. /**
  25308. * Appends the serialized animations from the source animations
  25309. * @param source Source containing the animations
  25310. * @param destination Target to store the animations
  25311. */
  25312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25313. }
  25314. }
  25315. declare module BABYLON {
  25316. /**
  25317. * Base class of all the textures in babylon.
  25318. * It groups all the common properties the materials, post process, lights... might need
  25319. * in order to make a correct use of the texture.
  25320. */
  25321. export class BaseTexture implements IAnimatable {
  25322. /**
  25323. * Default anisotropic filtering level for the application.
  25324. * It is set to 4 as a good tradeoff between perf and quality.
  25325. */
  25326. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25327. /**
  25328. * Gets or sets the unique id of the texture
  25329. */
  25330. uniqueId: number;
  25331. /**
  25332. * Define the name of the texture.
  25333. */
  25334. name: string;
  25335. /**
  25336. * Gets or sets an object used to store user defined information.
  25337. */
  25338. metadata: any;
  25339. /**
  25340. * For internal use only. Please do not use.
  25341. */
  25342. reservedDataStore: any;
  25343. private _hasAlpha;
  25344. /**
  25345. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25346. */
  25347. hasAlpha: boolean;
  25348. /**
  25349. * Defines if the alpha value should be determined via the rgb values.
  25350. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25351. */
  25352. getAlphaFromRGB: boolean;
  25353. /**
  25354. * Intensity or strength of the texture.
  25355. * It is commonly used by materials to fine tune the intensity of the texture
  25356. */
  25357. level: number;
  25358. /**
  25359. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25360. * This is part of the texture as textures usually maps to one uv set.
  25361. */
  25362. coordinatesIndex: number;
  25363. private _coordinatesMode;
  25364. /**
  25365. * How a texture is mapped.
  25366. *
  25367. * | Value | Type | Description |
  25368. * | ----- | ----------------------------------- | ----------- |
  25369. * | 0 | EXPLICIT_MODE | |
  25370. * | 1 | SPHERICAL_MODE | |
  25371. * | 2 | PLANAR_MODE | |
  25372. * | 3 | CUBIC_MODE | |
  25373. * | 4 | PROJECTION_MODE | |
  25374. * | 5 | SKYBOX_MODE | |
  25375. * | 6 | INVCUBIC_MODE | |
  25376. * | 7 | EQUIRECTANGULAR_MODE | |
  25377. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25378. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25379. */
  25380. coordinatesMode: number;
  25381. /**
  25382. * | Value | Type | Description |
  25383. * | ----- | ------------------ | ----------- |
  25384. * | 0 | CLAMP_ADDRESSMODE | |
  25385. * | 1 | WRAP_ADDRESSMODE | |
  25386. * | 2 | MIRROR_ADDRESSMODE | |
  25387. */
  25388. wrapU: number;
  25389. /**
  25390. * | Value | Type | Description |
  25391. * | ----- | ------------------ | ----------- |
  25392. * | 0 | CLAMP_ADDRESSMODE | |
  25393. * | 1 | WRAP_ADDRESSMODE | |
  25394. * | 2 | MIRROR_ADDRESSMODE | |
  25395. */
  25396. wrapV: number;
  25397. /**
  25398. * | Value | Type | Description |
  25399. * | ----- | ------------------ | ----------- |
  25400. * | 0 | CLAMP_ADDRESSMODE | |
  25401. * | 1 | WRAP_ADDRESSMODE | |
  25402. * | 2 | MIRROR_ADDRESSMODE | |
  25403. */
  25404. wrapR: number;
  25405. /**
  25406. * With compliant hardware and browser (supporting anisotropic filtering)
  25407. * this defines the level of anisotropic filtering in the texture.
  25408. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25409. */
  25410. anisotropicFilteringLevel: number;
  25411. /**
  25412. * Define if the texture is a cube texture or if false a 2d texture.
  25413. */
  25414. isCube: boolean;
  25415. /**
  25416. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25417. */
  25418. is3D: boolean;
  25419. /**
  25420. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25421. * HDR texture are usually stored in linear space.
  25422. * This only impacts the PBR and Background materials
  25423. */
  25424. gammaSpace: boolean;
  25425. /**
  25426. * Gets whether or not the texture contains RGBD data.
  25427. */
  25428. readonly isRGBD: boolean;
  25429. /**
  25430. * Is Z inverted in the texture (useful in a cube texture).
  25431. */
  25432. invertZ: boolean;
  25433. /**
  25434. * Are mip maps generated for this texture or not.
  25435. */
  25436. readonly noMipmap: boolean;
  25437. /**
  25438. * @hidden
  25439. */
  25440. lodLevelInAlpha: boolean;
  25441. /**
  25442. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25443. */
  25444. lodGenerationOffset: number;
  25445. /**
  25446. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25447. */
  25448. lodGenerationScale: number;
  25449. /**
  25450. * Define if the texture is a render target.
  25451. */
  25452. isRenderTarget: boolean;
  25453. /**
  25454. * Define the unique id of the texture in the scene.
  25455. */
  25456. readonly uid: string;
  25457. /**
  25458. * Return a string representation of the texture.
  25459. * @returns the texture as a string
  25460. */
  25461. toString(): string;
  25462. /**
  25463. * Get the class name of the texture.
  25464. * @returns "BaseTexture"
  25465. */
  25466. getClassName(): string;
  25467. /**
  25468. * Define the list of animation attached to the texture.
  25469. */
  25470. animations: Animation[];
  25471. /**
  25472. * An event triggered when the texture is disposed.
  25473. */
  25474. onDisposeObservable: Observable<BaseTexture>;
  25475. private _onDisposeObserver;
  25476. /**
  25477. * Callback triggered when the texture has been disposed.
  25478. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25479. */
  25480. onDispose: () => void;
  25481. /**
  25482. * Define the current state of the loading sequence when in delayed load mode.
  25483. */
  25484. delayLoadState: number;
  25485. private _scene;
  25486. /** @hidden */
  25487. _texture: Nullable<InternalTexture>;
  25488. private _uid;
  25489. /**
  25490. * Define if the texture is preventinga material to render or not.
  25491. * If not and the texture is not ready, the engine will use a default black texture instead.
  25492. */
  25493. readonly isBlocking: boolean;
  25494. /**
  25495. * Instantiates a new BaseTexture.
  25496. * Base class of all the textures in babylon.
  25497. * It groups all the common properties the materials, post process, lights... might need
  25498. * in order to make a correct use of the texture.
  25499. * @param scene Define the scene the texture blongs to
  25500. */
  25501. constructor(scene: Nullable<Scene>);
  25502. /**
  25503. * Get the scene the texture belongs to.
  25504. * @returns the scene or null if undefined
  25505. */
  25506. getScene(): Nullable<Scene>;
  25507. /**
  25508. * Get the texture transform matrix used to offset tile the texture for istance.
  25509. * @returns the transformation matrix
  25510. */
  25511. getTextureMatrix(): Matrix;
  25512. /**
  25513. * Get the texture reflection matrix used to rotate/transform the reflection.
  25514. * @returns the reflection matrix
  25515. */
  25516. getReflectionTextureMatrix(): Matrix;
  25517. /**
  25518. * Get the underlying lower level texture from Babylon.
  25519. * @returns the insternal texture
  25520. */
  25521. getInternalTexture(): Nullable<InternalTexture>;
  25522. /**
  25523. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25524. * @returns true if ready or not blocking
  25525. */
  25526. isReadyOrNotBlocking(): boolean;
  25527. /**
  25528. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25529. * @returns true if fully ready
  25530. */
  25531. isReady(): boolean;
  25532. private _cachedSize;
  25533. /**
  25534. * Get the size of the texture.
  25535. * @returns the texture size.
  25536. */
  25537. getSize(): ISize;
  25538. /**
  25539. * Get the base size of the texture.
  25540. * It can be different from the size if the texture has been resized for POT for instance
  25541. * @returns the base size
  25542. */
  25543. getBaseSize(): ISize;
  25544. /**
  25545. * Update the sampling mode of the texture.
  25546. * Default is Trilinear mode.
  25547. *
  25548. * | Value | Type | Description |
  25549. * | ----- | ------------------ | ----------- |
  25550. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25551. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25552. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25553. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25554. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25555. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25556. * | 7 | NEAREST_LINEAR | |
  25557. * | 8 | NEAREST_NEAREST | |
  25558. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25559. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25560. * | 11 | LINEAR_LINEAR | |
  25561. * | 12 | LINEAR_NEAREST | |
  25562. *
  25563. * > _mag_: magnification filter (close to the viewer)
  25564. * > _min_: minification filter (far from the viewer)
  25565. * > _mip_: filter used between mip map levels
  25566. *@param samplingMode Define the new sampling mode of the texture
  25567. */
  25568. updateSamplingMode(samplingMode: number): void;
  25569. /**
  25570. * Scales the texture if is `canRescale()`
  25571. * @param ratio the resize factor we want to use to rescale
  25572. */
  25573. scale(ratio: number): void;
  25574. /**
  25575. * Get if the texture can rescale.
  25576. */
  25577. readonly canRescale: boolean;
  25578. /** @hidden */
  25579. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25580. /** @hidden */
  25581. _rebuild(): void;
  25582. /**
  25583. * Triggers the load sequence in delayed load mode.
  25584. */
  25585. delayLoad(): void;
  25586. /**
  25587. * Clones the texture.
  25588. * @returns the cloned texture
  25589. */
  25590. clone(): Nullable<BaseTexture>;
  25591. /**
  25592. * Get the texture underlying type (INT, FLOAT...)
  25593. */
  25594. readonly textureType: number;
  25595. /**
  25596. * Get the texture underlying format (RGB, RGBA...)
  25597. */
  25598. readonly textureFormat: number;
  25599. /**
  25600. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25601. * This will returns an RGBA array buffer containing either in values (0-255) or
  25602. * float values (0-1) depending of the underlying buffer type.
  25603. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25604. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25605. * @param buffer defines a user defined buffer to fill with data (can be null)
  25606. * @returns The Array buffer containing the pixels data.
  25607. */
  25608. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25609. /**
  25610. * Release and destroy the underlying lower level texture aka internalTexture.
  25611. */
  25612. releaseInternalTexture(): void;
  25613. /**
  25614. * Get the polynomial representation of the texture data.
  25615. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25616. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25617. */
  25618. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25619. /** @hidden */
  25620. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25621. /** @hidden */
  25622. readonly _lodTextureMid: Nullable<BaseTexture>;
  25623. /** @hidden */
  25624. readonly _lodTextureLow: Nullable<BaseTexture>;
  25625. /**
  25626. * Dispose the texture and release its associated resources.
  25627. */
  25628. dispose(): void;
  25629. /**
  25630. * Serialize the texture into a JSON representation that can be parsed later on.
  25631. * @returns the JSON representation of the texture
  25632. */
  25633. serialize(): any;
  25634. /**
  25635. * Helper function to be called back once a list of texture contains only ready textures.
  25636. * @param textures Define the list of textures to wait for
  25637. * @param callback Define the callback triggered once the entire list will be ready
  25638. */
  25639. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25640. }
  25641. }
  25642. declare module BABYLON {
  25643. /**
  25644. * Uniform buffer objects.
  25645. *
  25646. * Handles blocks of uniform on the GPU.
  25647. *
  25648. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25649. *
  25650. * For more information, please refer to :
  25651. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25652. */
  25653. export class UniformBuffer {
  25654. private _engine;
  25655. private _buffer;
  25656. private _data;
  25657. private _bufferData;
  25658. private _dynamic?;
  25659. private _uniformLocations;
  25660. private _uniformSizes;
  25661. private _uniformLocationPointer;
  25662. private _needSync;
  25663. private _noUBO;
  25664. private _currentEffect;
  25665. private static _MAX_UNIFORM_SIZE;
  25666. private static _tempBuffer;
  25667. /**
  25668. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25669. * This is dynamic to allow compat with webgl 1 and 2.
  25670. * You will need to pass the name of the uniform as well as the value.
  25671. */
  25672. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25673. /**
  25674. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25675. * This is dynamic to allow compat with webgl 1 and 2.
  25676. * You will need to pass the name of the uniform as well as the value.
  25677. */
  25678. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25679. /**
  25680. * Lambda to Update a single float in a uniform buffer.
  25681. * This is dynamic to allow compat with webgl 1 and 2.
  25682. * You will need to pass the name of the uniform as well as the value.
  25683. */
  25684. updateFloat: (name: string, x: number) => void;
  25685. /**
  25686. * Lambda to Update a vec2 of float in a uniform buffer.
  25687. * This is dynamic to allow compat with webgl 1 and 2.
  25688. * You will need to pass the name of the uniform as well as the value.
  25689. */
  25690. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25691. /**
  25692. * Lambda to Update a vec3 of float in a uniform buffer.
  25693. * This is dynamic to allow compat with webgl 1 and 2.
  25694. * You will need to pass the name of the uniform as well as the value.
  25695. */
  25696. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25697. /**
  25698. * Lambda to Update a vec4 of float in a uniform buffer.
  25699. * This is dynamic to allow compat with webgl 1 and 2.
  25700. * You will need to pass the name of the uniform as well as the value.
  25701. */
  25702. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25703. /**
  25704. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25705. * This is dynamic to allow compat with webgl 1 and 2.
  25706. * You will need to pass the name of the uniform as well as the value.
  25707. */
  25708. updateMatrix: (name: string, mat: Matrix) => void;
  25709. /**
  25710. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25711. * This is dynamic to allow compat with webgl 1 and 2.
  25712. * You will need to pass the name of the uniform as well as the value.
  25713. */
  25714. updateVector3: (name: string, vector: Vector3) => void;
  25715. /**
  25716. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25717. * This is dynamic to allow compat with webgl 1 and 2.
  25718. * You will need to pass the name of the uniform as well as the value.
  25719. */
  25720. updateVector4: (name: string, vector: Vector4) => void;
  25721. /**
  25722. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25723. * This is dynamic to allow compat with webgl 1 and 2.
  25724. * You will need to pass the name of the uniform as well as the value.
  25725. */
  25726. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25727. /**
  25728. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25729. * This is dynamic to allow compat with webgl 1 and 2.
  25730. * You will need to pass the name of the uniform as well as the value.
  25731. */
  25732. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25733. /**
  25734. * Instantiates a new Uniform buffer objects.
  25735. *
  25736. * Handles blocks of uniform on the GPU.
  25737. *
  25738. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25739. *
  25740. * For more information, please refer to :
  25741. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25742. * @param engine Define the engine the buffer is associated with
  25743. * @param data Define the data contained in the buffer
  25744. * @param dynamic Define if the buffer is updatable
  25745. */
  25746. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25747. /**
  25748. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25749. * or just falling back on setUniformXXX calls.
  25750. */
  25751. readonly useUbo: boolean;
  25752. /**
  25753. * Indicates if the WebGL underlying uniform buffer is in sync
  25754. * with the javascript cache data.
  25755. */
  25756. readonly isSync: boolean;
  25757. /**
  25758. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25759. * Also, a dynamic UniformBuffer will disable cache verification and always
  25760. * update the underlying WebGL uniform buffer to the GPU.
  25761. * @returns if Dynamic, otherwise false
  25762. */
  25763. isDynamic(): boolean;
  25764. /**
  25765. * The data cache on JS side.
  25766. * @returns the underlying data as a float array
  25767. */
  25768. getData(): Float32Array;
  25769. /**
  25770. * The underlying WebGL Uniform buffer.
  25771. * @returns the webgl buffer
  25772. */
  25773. getBuffer(): Nullable<WebGLBuffer>;
  25774. /**
  25775. * std140 layout specifies how to align data within an UBO structure.
  25776. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25777. * for specs.
  25778. */
  25779. private _fillAlignment;
  25780. /**
  25781. * Adds an uniform in the buffer.
  25782. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25783. * for the layout to be correct !
  25784. * @param name Name of the uniform, as used in the uniform block in the shader.
  25785. * @param size Data size, or data directly.
  25786. */
  25787. addUniform(name: string, size: number | number[]): void;
  25788. /**
  25789. * Adds a Matrix 4x4 to the uniform buffer.
  25790. * @param name Name of the uniform, as used in the uniform block in the shader.
  25791. * @param mat A 4x4 matrix.
  25792. */
  25793. addMatrix(name: string, mat: Matrix): void;
  25794. /**
  25795. * Adds a vec2 to the uniform buffer.
  25796. * @param name Name of the uniform, as used in the uniform block in the shader.
  25797. * @param x Define the x component value of the vec2
  25798. * @param y Define the y component value of the vec2
  25799. */
  25800. addFloat2(name: string, x: number, y: number): void;
  25801. /**
  25802. * Adds a vec3 to the uniform buffer.
  25803. * @param name Name of the uniform, as used in the uniform block in the shader.
  25804. * @param x Define the x component value of the vec3
  25805. * @param y Define the y component value of the vec3
  25806. * @param z Define the z component value of the vec3
  25807. */
  25808. addFloat3(name: string, x: number, y: number, z: number): void;
  25809. /**
  25810. * Adds a vec3 to the uniform buffer.
  25811. * @param name Name of the uniform, as used in the uniform block in the shader.
  25812. * @param color Define the vec3 from a Color
  25813. */
  25814. addColor3(name: string, color: Color3): void;
  25815. /**
  25816. * Adds a vec4 to the uniform buffer.
  25817. * @param name Name of the uniform, as used in the uniform block in the shader.
  25818. * @param color Define the rgb components from a Color
  25819. * @param alpha Define the a component of the vec4
  25820. */
  25821. addColor4(name: string, color: Color3, alpha: number): void;
  25822. /**
  25823. * Adds a vec3 to the uniform buffer.
  25824. * @param name Name of the uniform, as used in the uniform block in the shader.
  25825. * @param vector Define the vec3 components from a Vector
  25826. */
  25827. addVector3(name: string, vector: Vector3): void;
  25828. /**
  25829. * Adds a Matrix 3x3 to the uniform buffer.
  25830. * @param name Name of the uniform, as used in the uniform block in the shader.
  25831. */
  25832. addMatrix3x3(name: string): void;
  25833. /**
  25834. * Adds a Matrix 2x2 to the uniform buffer.
  25835. * @param name Name of the uniform, as used in the uniform block in the shader.
  25836. */
  25837. addMatrix2x2(name: string): void;
  25838. /**
  25839. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25840. */
  25841. create(): void;
  25842. /** @hidden */
  25843. _rebuild(): void;
  25844. /**
  25845. * Updates the WebGL Uniform Buffer on the GPU.
  25846. * If the `dynamic` flag is set to true, no cache comparison is done.
  25847. * Otherwise, the buffer will be updated only if the cache differs.
  25848. */
  25849. update(): void;
  25850. /**
  25851. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25852. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25853. * @param data Define the flattened data
  25854. * @param size Define the size of the data.
  25855. */
  25856. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25857. private _updateMatrix3x3ForUniform;
  25858. private _updateMatrix3x3ForEffect;
  25859. private _updateMatrix2x2ForEffect;
  25860. private _updateMatrix2x2ForUniform;
  25861. private _updateFloatForEffect;
  25862. private _updateFloatForUniform;
  25863. private _updateFloat2ForEffect;
  25864. private _updateFloat2ForUniform;
  25865. private _updateFloat3ForEffect;
  25866. private _updateFloat3ForUniform;
  25867. private _updateFloat4ForEffect;
  25868. private _updateFloat4ForUniform;
  25869. private _updateMatrixForEffect;
  25870. private _updateMatrixForUniform;
  25871. private _updateVector3ForEffect;
  25872. private _updateVector3ForUniform;
  25873. private _updateVector4ForEffect;
  25874. private _updateVector4ForUniform;
  25875. private _updateColor3ForEffect;
  25876. private _updateColor3ForUniform;
  25877. private _updateColor4ForEffect;
  25878. private _updateColor4ForUniform;
  25879. /**
  25880. * Sets a sampler uniform on the effect.
  25881. * @param name Define the name of the sampler.
  25882. * @param texture Define the texture to set in the sampler
  25883. */
  25884. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25885. /**
  25886. * Directly updates the value of the uniform in the cache AND on the GPU.
  25887. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25888. * @param data Define the flattened data
  25889. */
  25890. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25891. /**
  25892. * Binds this uniform buffer to an effect.
  25893. * @param effect Define the effect to bind the buffer to
  25894. * @param name Name of the uniform block in the shader.
  25895. */
  25896. bindToEffect(effect: Effect, name: string): void;
  25897. /**
  25898. * Disposes the uniform buffer.
  25899. */
  25900. dispose(): void;
  25901. }
  25902. }
  25903. declare module BABYLON {
  25904. /**
  25905. * This represents the required contract to create a new type of texture loader.
  25906. */
  25907. export interface IInternalTextureLoader {
  25908. /**
  25909. * Defines wether the loader supports cascade loading the different faces.
  25910. */
  25911. supportCascades: boolean;
  25912. /**
  25913. * This returns if the loader support the current file information.
  25914. * @param extension defines the file extension of the file being loaded
  25915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25916. * @param fallback defines the fallback internal texture if any
  25917. * @param isBase64 defines whether the texture is encoded as a base64
  25918. * @param isBuffer defines whether the texture data are stored as a buffer
  25919. * @returns true if the loader can load the specified file
  25920. */
  25921. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25922. /**
  25923. * Transform the url before loading if required.
  25924. * @param rootUrl the url of the texture
  25925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25926. * @returns the transformed texture
  25927. */
  25928. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25929. /**
  25930. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25931. * @param rootUrl the url of the texture
  25932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25933. * @returns the fallback texture
  25934. */
  25935. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25936. /**
  25937. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25938. * @param data contains the texture data
  25939. * @param texture defines the BabylonJS internal texture
  25940. * @param createPolynomials will be true if polynomials have been requested
  25941. * @param onLoad defines the callback to trigger once the texture is ready
  25942. * @param onError defines the callback to trigger in case of error
  25943. */
  25944. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25945. /**
  25946. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25947. * @param data contains the texture data
  25948. * @param texture defines the BabylonJS internal texture
  25949. * @param callback defines the method to call once ready to upload
  25950. */
  25951. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25952. }
  25953. }
  25954. declare module BABYLON {
  25955. /**
  25956. * Creation options of the multi render target texture.
  25957. */
  25958. export interface IMultiRenderTargetOptions {
  25959. /**
  25960. * Define if the texture needs to create mip maps after render.
  25961. */
  25962. generateMipMaps?: boolean;
  25963. /**
  25964. * Define the types of all the draw buffers we want to create
  25965. */
  25966. types?: number[];
  25967. /**
  25968. * Define the sampling modes of all the draw buffers we want to create
  25969. */
  25970. samplingModes?: number[];
  25971. /**
  25972. * Define if a depth buffer is required
  25973. */
  25974. generateDepthBuffer?: boolean;
  25975. /**
  25976. * Define if a stencil buffer is required
  25977. */
  25978. generateStencilBuffer?: boolean;
  25979. /**
  25980. * Define if a depth texture is required instead of a depth buffer
  25981. */
  25982. generateDepthTexture?: boolean;
  25983. /**
  25984. * Define the number of desired draw buffers
  25985. */
  25986. textureCount?: number;
  25987. /**
  25988. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25989. */
  25990. doNotChangeAspectRatio?: boolean;
  25991. /**
  25992. * Define the default type of the buffers we are creating
  25993. */
  25994. defaultType?: number;
  25995. }
  25996. /**
  25997. * A multi render target, like a render target provides the ability to render to a texture.
  25998. * Unlike the render target, it can render to several draw buffers in one draw.
  25999. * This is specially interesting in deferred rendering or for any effects requiring more than
  26000. * just one color from a single pass.
  26001. */
  26002. export class MultiRenderTarget extends RenderTargetTexture {
  26003. private _internalTextures;
  26004. private _textures;
  26005. private _multiRenderTargetOptions;
  26006. /**
  26007. * Get if draw buffers are currently supported by the used hardware and browser.
  26008. */
  26009. readonly isSupported: boolean;
  26010. /**
  26011. * Get the list of textures generated by the multi render target.
  26012. */
  26013. readonly textures: Texture[];
  26014. /**
  26015. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26016. */
  26017. readonly depthTexture: Texture;
  26018. /**
  26019. * Set the wrapping mode on U of all the textures we are rendering to.
  26020. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26021. */
  26022. wrapU: number;
  26023. /**
  26024. * Set the wrapping mode on V of all the textures we are rendering to.
  26025. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26026. */
  26027. wrapV: number;
  26028. /**
  26029. * Instantiate a new multi render target texture.
  26030. * A multi render target, like a render target provides the ability to render to a texture.
  26031. * Unlike the render target, it can render to several draw buffers in one draw.
  26032. * This is specially interesting in deferred rendering or for any effects requiring more than
  26033. * just one color from a single pass.
  26034. * @param name Define the name of the texture
  26035. * @param size Define the size of the buffers to render to
  26036. * @param count Define the number of target we are rendering into
  26037. * @param scene Define the scene the texture belongs to
  26038. * @param options Define the options used to create the multi render target
  26039. */
  26040. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26041. /** @hidden */
  26042. _rebuild(): void;
  26043. private _createInternalTextures;
  26044. private _createTextures;
  26045. /**
  26046. * Define the number of samples used if MSAA is enabled.
  26047. */
  26048. samples: number;
  26049. /**
  26050. * Resize all the textures in the multi render target.
  26051. * Be carrefull as it will recreate all the data in the new texture.
  26052. * @param size Define the new size
  26053. */
  26054. resize(size: any): void;
  26055. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26056. /**
  26057. * Dispose the render targets and their associated resources
  26058. */
  26059. dispose(): void;
  26060. /**
  26061. * Release all the underlying texture used as draw buffers.
  26062. */
  26063. releaseInternalTextures(): void;
  26064. }
  26065. }
  26066. declare module BABYLON {
  26067. /**
  26068. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26070. */
  26071. export class Analyser {
  26072. /**
  26073. * Gets or sets the smoothing
  26074. * @ignorenaming
  26075. */
  26076. SMOOTHING: number;
  26077. /**
  26078. * Gets or sets the FFT table size
  26079. * @ignorenaming
  26080. */
  26081. FFT_SIZE: number;
  26082. /**
  26083. * Gets or sets the bar graph amplitude
  26084. * @ignorenaming
  26085. */
  26086. BARGRAPHAMPLITUDE: number;
  26087. /**
  26088. * Gets or sets the position of the debug canvas
  26089. * @ignorenaming
  26090. */
  26091. DEBUGCANVASPOS: {
  26092. x: number;
  26093. y: number;
  26094. };
  26095. /**
  26096. * Gets or sets the debug canvas size
  26097. * @ignorenaming
  26098. */
  26099. DEBUGCANVASSIZE: {
  26100. width: number;
  26101. height: number;
  26102. };
  26103. private _byteFreqs;
  26104. private _byteTime;
  26105. private _floatFreqs;
  26106. private _webAudioAnalyser;
  26107. private _debugCanvas;
  26108. private _debugCanvasContext;
  26109. private _scene;
  26110. private _registerFunc;
  26111. private _audioEngine;
  26112. /**
  26113. * Creates a new analyser
  26114. * @param scene defines hosting scene
  26115. */
  26116. constructor(scene: Scene);
  26117. /**
  26118. * Get the number of data values you will have to play with for the visualization
  26119. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26120. * @returns a number
  26121. */
  26122. getFrequencyBinCount(): number;
  26123. /**
  26124. * Gets the current frequency data as a byte array
  26125. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26126. * @returns a Uint8Array
  26127. */
  26128. getByteFrequencyData(): Uint8Array;
  26129. /**
  26130. * Gets the current waveform as a byte array
  26131. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26132. * @returns a Uint8Array
  26133. */
  26134. getByteTimeDomainData(): Uint8Array;
  26135. /**
  26136. * Gets the current frequency data as a float array
  26137. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26138. * @returns a Float32Array
  26139. */
  26140. getFloatFrequencyData(): Float32Array;
  26141. /**
  26142. * Renders the debug canvas
  26143. */
  26144. drawDebugCanvas(): void;
  26145. /**
  26146. * Stops rendering the debug canvas and removes it
  26147. */
  26148. stopDebugCanvas(): void;
  26149. /**
  26150. * Connects two audio nodes
  26151. * @param inputAudioNode defines first node to connect
  26152. * @param outputAudioNode defines second node to connect
  26153. */
  26154. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26155. /**
  26156. * Releases all associated resources
  26157. */
  26158. dispose(): void;
  26159. }
  26160. }
  26161. declare module BABYLON {
  26162. /**
  26163. * This represents an audio engine and it is responsible
  26164. * to play, synchronize and analyse sounds throughout the application.
  26165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26166. */
  26167. export interface IAudioEngine extends IDisposable {
  26168. /**
  26169. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26170. */
  26171. readonly canUseWebAudio: boolean;
  26172. /**
  26173. * Gets the current AudioContext if available.
  26174. */
  26175. readonly audioContext: Nullable<AudioContext>;
  26176. /**
  26177. * The master gain node defines the global audio volume of your audio engine.
  26178. */
  26179. readonly masterGain: GainNode;
  26180. /**
  26181. * Gets whether or not mp3 are supported by your browser.
  26182. */
  26183. readonly isMP3supported: boolean;
  26184. /**
  26185. * Gets whether or not ogg are supported by your browser.
  26186. */
  26187. readonly isOGGsupported: boolean;
  26188. /**
  26189. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26190. * @ignoreNaming
  26191. */
  26192. WarnedWebAudioUnsupported: boolean;
  26193. /**
  26194. * Defines if the audio engine relies on a custom unlocked button.
  26195. * In this case, the embedded button will not be displayed.
  26196. */
  26197. useCustomUnlockedButton: boolean;
  26198. /**
  26199. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26200. */
  26201. readonly unlocked: boolean;
  26202. /**
  26203. * Event raised when audio has been unlocked on the browser.
  26204. */
  26205. onAudioUnlockedObservable: Observable<AudioEngine>;
  26206. /**
  26207. * Event raised when audio has been locked on the browser.
  26208. */
  26209. onAudioLockedObservable: Observable<AudioEngine>;
  26210. /**
  26211. * Flags the audio engine in Locked state.
  26212. * This happens due to new browser policies preventing audio to autoplay.
  26213. */
  26214. lock(): void;
  26215. /**
  26216. * Unlocks the audio engine once a user action has been done on the dom.
  26217. * This is helpful to resume play once browser policies have been satisfied.
  26218. */
  26219. unlock(): void;
  26220. }
  26221. /**
  26222. * This represents the default audio engine used in babylon.
  26223. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26225. */
  26226. export class AudioEngine implements IAudioEngine {
  26227. private _audioContext;
  26228. private _audioContextInitialized;
  26229. private _muteButton;
  26230. private _hostElement;
  26231. /**
  26232. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26233. */
  26234. canUseWebAudio: boolean;
  26235. /**
  26236. * The master gain node defines the global audio volume of your audio engine.
  26237. */
  26238. masterGain: GainNode;
  26239. /**
  26240. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26241. * @ignoreNaming
  26242. */
  26243. WarnedWebAudioUnsupported: boolean;
  26244. /**
  26245. * Gets whether or not mp3 are supported by your browser.
  26246. */
  26247. isMP3supported: boolean;
  26248. /**
  26249. * Gets whether or not ogg are supported by your browser.
  26250. */
  26251. isOGGsupported: boolean;
  26252. /**
  26253. * Gets whether audio has been unlocked on the device.
  26254. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26255. * a user interaction has happened.
  26256. */
  26257. unlocked: boolean;
  26258. /**
  26259. * Defines if the audio engine relies on a custom unlocked button.
  26260. * In this case, the embedded button will not be displayed.
  26261. */
  26262. useCustomUnlockedButton: boolean;
  26263. /**
  26264. * Event raised when audio has been unlocked on the browser.
  26265. */
  26266. onAudioUnlockedObservable: Observable<AudioEngine>;
  26267. /**
  26268. * Event raised when audio has been locked on the browser.
  26269. */
  26270. onAudioLockedObservable: Observable<AudioEngine>;
  26271. /**
  26272. * Gets the current AudioContext if available.
  26273. */
  26274. readonly audioContext: Nullable<AudioContext>;
  26275. private _connectedAnalyser;
  26276. /**
  26277. * Instantiates a new audio engine.
  26278. *
  26279. * There should be only one per page as some browsers restrict the number
  26280. * of audio contexts you can create.
  26281. * @param hostElement defines the host element where to display the mute icon if necessary
  26282. */
  26283. constructor(hostElement?: Nullable<HTMLElement>);
  26284. /**
  26285. * Flags the audio engine in Locked state.
  26286. * This happens due to new browser policies preventing audio to autoplay.
  26287. */
  26288. lock(): void;
  26289. /**
  26290. * Unlocks the audio engine once a user action has been done on the dom.
  26291. * This is helpful to resume play once browser policies have been satisfied.
  26292. */
  26293. unlock(): void;
  26294. private _resumeAudioContext;
  26295. private _initializeAudioContext;
  26296. private _tryToRun;
  26297. private _triggerRunningState;
  26298. private _triggerSuspendedState;
  26299. private _displayMuteButton;
  26300. private _moveButtonToTopLeft;
  26301. private _onResize;
  26302. private _hideMuteButton;
  26303. /**
  26304. * Destroy and release the resources associated with the audio ccontext.
  26305. */
  26306. dispose(): void;
  26307. /**
  26308. * Gets the global volume sets on the master gain.
  26309. * @returns the global volume if set or -1 otherwise
  26310. */
  26311. getGlobalVolume(): number;
  26312. /**
  26313. * Sets the global volume of your experience (sets on the master gain).
  26314. * @param newVolume Defines the new global volume of the application
  26315. */
  26316. setGlobalVolume(newVolume: number): void;
  26317. /**
  26318. * Connect the audio engine to an audio analyser allowing some amazing
  26319. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26321. * @param analyser The analyser to connect to the engine
  26322. */
  26323. connectToAnalyser(analyser: Analyser): void;
  26324. }
  26325. }
  26326. declare module BABYLON {
  26327. /**
  26328. * Interface used to present a loading screen while loading a scene
  26329. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26330. */
  26331. export interface ILoadingScreen {
  26332. /**
  26333. * Function called to display the loading screen
  26334. */
  26335. displayLoadingUI: () => void;
  26336. /**
  26337. * Function called to hide the loading screen
  26338. */
  26339. hideLoadingUI: () => void;
  26340. /**
  26341. * Gets or sets the color to use for the background
  26342. */
  26343. loadingUIBackgroundColor: string;
  26344. /**
  26345. * Gets or sets the text to display while loading
  26346. */
  26347. loadingUIText: string;
  26348. }
  26349. /**
  26350. * Class used for the default loading screen
  26351. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26352. */
  26353. export class DefaultLoadingScreen implements ILoadingScreen {
  26354. private _renderingCanvas;
  26355. private _loadingText;
  26356. private _loadingDivBackgroundColor;
  26357. private _loadingDiv;
  26358. private _loadingTextDiv;
  26359. /**
  26360. * Creates a new default loading screen
  26361. * @param _renderingCanvas defines the canvas used to render the scene
  26362. * @param _loadingText defines the default text to display
  26363. * @param _loadingDivBackgroundColor defines the default background color
  26364. */
  26365. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26366. /**
  26367. * Function called to display the loading screen
  26368. */
  26369. displayLoadingUI(): void;
  26370. /**
  26371. * Function called to hide the loading screen
  26372. */
  26373. hideLoadingUI(): void;
  26374. /**
  26375. * Gets or sets the text to display while loading
  26376. */
  26377. loadingUIText: string;
  26378. /**
  26379. * Gets or sets the color to use for the background
  26380. */
  26381. loadingUIBackgroundColor: string;
  26382. private _resizeLoadingUI;
  26383. }
  26384. }
  26385. declare module BABYLON {
  26386. /**
  26387. * Settings for finer control over video usage
  26388. */
  26389. export interface VideoTextureSettings {
  26390. /**
  26391. * Applies `autoplay` to video, if specified
  26392. */
  26393. autoPlay?: boolean;
  26394. /**
  26395. * Applies `loop` to video, if specified
  26396. */
  26397. loop?: boolean;
  26398. /**
  26399. * Automatically updates internal texture from video at every frame in the render loop
  26400. */
  26401. autoUpdateTexture: boolean;
  26402. /**
  26403. * Image src displayed during the video loading or until the user interacts with the video.
  26404. */
  26405. poster?: string;
  26406. }
  26407. /**
  26408. * If you want to display a video in your scene, this is the special texture for that.
  26409. * This special texture works similar to other textures, with the exception of a few parameters.
  26410. * @see https://doc.babylonjs.com/how_to/video_texture
  26411. */
  26412. export class VideoTexture extends Texture {
  26413. /**
  26414. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26415. */
  26416. readonly autoUpdateTexture: boolean;
  26417. /**
  26418. * The video instance used by the texture internally
  26419. */
  26420. readonly video: HTMLVideoElement;
  26421. private _onUserActionRequestedObservable;
  26422. /**
  26423. * Event triggerd when a dom action is required by the user to play the video.
  26424. * This happens due to recent changes in browser policies preventing video to auto start.
  26425. */
  26426. readonly onUserActionRequestedObservable: Observable<Texture>;
  26427. private _generateMipMaps;
  26428. private _engine;
  26429. private _stillImageCaptured;
  26430. private _displayingPosterTexture;
  26431. private _settings;
  26432. private _createInternalTextureOnEvent;
  26433. /**
  26434. * Creates a video texture.
  26435. * If you want to display a video in your scene, this is the special texture for that.
  26436. * This special texture works similar to other textures, with the exception of a few parameters.
  26437. * @see https://doc.babylonjs.com/how_to/video_texture
  26438. * @param name optional name, will detect from video source, if not defined
  26439. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26440. * @param scene is obviously the current scene.
  26441. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26442. * @param invertY is false by default but can be used to invert video on Y axis
  26443. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26444. * @param settings allows finer control over video usage
  26445. */
  26446. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26447. private _getName;
  26448. private _getVideo;
  26449. private _createInternalTexture;
  26450. private reset;
  26451. /**
  26452. * @hidden Internal method to initiate `update`.
  26453. */
  26454. _rebuild(): void;
  26455. /**
  26456. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26457. */
  26458. update(): void;
  26459. /**
  26460. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26461. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26462. */
  26463. updateTexture(isVisible: boolean): void;
  26464. protected _updateInternalTexture: () => void;
  26465. /**
  26466. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26467. * @param url New url.
  26468. */
  26469. updateURL(url: string): void;
  26470. /**
  26471. * Dispose the texture and release its associated resources.
  26472. */
  26473. dispose(): void;
  26474. /**
  26475. * Creates a video texture straight from a stream.
  26476. * @param scene Define the scene the texture should be created in
  26477. * @param stream Define the stream the texture should be created from
  26478. * @returns The created video texture as a promise
  26479. */
  26480. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26481. /**
  26482. * Creates a video texture straight from your WebCam video feed.
  26483. * @param scene Define the scene the texture should be created in
  26484. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26485. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26486. * @returns The created video texture as a promise
  26487. */
  26488. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26489. minWidth: number;
  26490. maxWidth: number;
  26491. minHeight: number;
  26492. maxHeight: number;
  26493. deviceId: string;
  26494. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26495. /**
  26496. * Creates a video texture straight from your WebCam video feed.
  26497. * @param scene Define the scene the texture should be created in
  26498. * @param onReady Define a callback to triggered once the texture will be ready
  26499. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26500. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26501. */
  26502. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26503. minWidth: number;
  26504. maxWidth: number;
  26505. minHeight: number;
  26506. maxHeight: number;
  26507. deviceId: string;
  26508. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26509. }
  26510. }
  26511. declare module BABYLON {
  26512. /**
  26513. * Interface for attribute information associated with buffer instanciation
  26514. */
  26515. export class InstancingAttributeInfo {
  26516. /**
  26517. * Index/offset of the attribute in the vertex shader
  26518. */
  26519. index: number;
  26520. /**
  26521. * size of the attribute, 1, 2, 3 or 4
  26522. */
  26523. attributeSize: number;
  26524. /**
  26525. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26526. * default is FLOAT
  26527. */
  26528. attribyteType: number;
  26529. /**
  26530. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26531. */
  26532. normalized: boolean;
  26533. /**
  26534. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26535. */
  26536. offset: number;
  26537. /**
  26538. * Name of the GLSL attribute, for debugging purpose only
  26539. */
  26540. attributeName: string;
  26541. }
  26542. /**
  26543. * Define options used to create a depth texture
  26544. */
  26545. export class DepthTextureCreationOptions {
  26546. /** Specifies whether or not a stencil should be allocated in the texture */
  26547. generateStencil?: boolean;
  26548. /** Specifies whether or not bilinear filtering is enable on the texture */
  26549. bilinearFiltering?: boolean;
  26550. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26551. comparisonFunction?: number;
  26552. /** Specifies if the created texture is a cube texture */
  26553. isCube?: boolean;
  26554. }
  26555. /**
  26556. * Class used to describe the capabilities of the engine relatively to the current browser
  26557. */
  26558. export class EngineCapabilities {
  26559. /** Maximum textures units per fragment shader */
  26560. maxTexturesImageUnits: number;
  26561. /** Maximum texture units per vertex shader */
  26562. maxVertexTextureImageUnits: number;
  26563. /** Maximum textures units in the entire pipeline */
  26564. maxCombinedTexturesImageUnits: number;
  26565. /** Maximum texture size */
  26566. maxTextureSize: number;
  26567. /** Maximum cube texture size */
  26568. maxCubemapTextureSize: number;
  26569. /** Maximum render texture size */
  26570. maxRenderTextureSize: number;
  26571. /** Maximum number of vertex attributes */
  26572. maxVertexAttribs: number;
  26573. /** Maximum number of varyings */
  26574. maxVaryingVectors: number;
  26575. /** Maximum number of uniforms per vertex shader */
  26576. maxVertexUniformVectors: number;
  26577. /** Maximum number of uniforms per fragment shader */
  26578. maxFragmentUniformVectors: number;
  26579. /** Defines if standard derivates (dx/dy) are supported */
  26580. standardDerivatives: boolean;
  26581. /** Defines if s3tc texture compression is supported */
  26582. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26583. /** Defines if pvrtc texture compression is supported */
  26584. pvrtc: any;
  26585. /** Defines if etc1 texture compression is supported */
  26586. etc1: any;
  26587. /** Defines if etc2 texture compression is supported */
  26588. etc2: any;
  26589. /** Defines if astc texture compression is supported */
  26590. astc: any;
  26591. /** Defines if float textures are supported */
  26592. textureFloat: boolean;
  26593. /** Defines if vertex array objects are supported */
  26594. vertexArrayObject: boolean;
  26595. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26596. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26597. /** Gets the maximum level of anisotropy supported */
  26598. maxAnisotropy: number;
  26599. /** Defines if instancing is supported */
  26600. instancedArrays: boolean;
  26601. /** Defines if 32 bits indices are supported */
  26602. uintIndices: boolean;
  26603. /** Defines if high precision shaders are supported */
  26604. highPrecisionShaderSupported: boolean;
  26605. /** Defines if depth reading in the fragment shader is supported */
  26606. fragmentDepthSupported: boolean;
  26607. /** Defines if float texture linear filtering is supported*/
  26608. textureFloatLinearFiltering: boolean;
  26609. /** Defines if rendering to float textures is supported */
  26610. textureFloatRender: boolean;
  26611. /** Defines if half float textures are supported*/
  26612. textureHalfFloat: boolean;
  26613. /** Defines if half float texture linear filtering is supported*/
  26614. textureHalfFloatLinearFiltering: boolean;
  26615. /** Defines if rendering to half float textures is supported */
  26616. textureHalfFloatRender: boolean;
  26617. /** Defines if textureLOD shader command is supported */
  26618. textureLOD: boolean;
  26619. /** Defines if draw buffers extension is supported */
  26620. drawBuffersExtension: boolean;
  26621. /** Defines if depth textures are supported */
  26622. depthTextureExtension: boolean;
  26623. /** Defines if float color buffer are supported */
  26624. colorBufferFloat: boolean;
  26625. /** Gets disjoint timer query extension (null if not supported) */
  26626. timerQuery: EXT_disjoint_timer_query;
  26627. /** Defines if timestamp can be used with timer query */
  26628. canUseTimestampForTimerQuery: boolean;
  26629. /** Function used to let the system compiles shaders in background */
  26630. parallelShaderCompile: {
  26631. COMPLETION_STATUS_KHR: number;
  26632. };
  26633. }
  26634. /** Interface defining initialization parameters for Engine class */
  26635. export interface EngineOptions extends WebGLContextAttributes {
  26636. /**
  26637. * Defines if the engine should no exceed a specified device ratio
  26638. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26639. */
  26640. limitDeviceRatio?: number;
  26641. /**
  26642. * Defines if webvr should be enabled automatically
  26643. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26644. */
  26645. autoEnableWebVR?: boolean;
  26646. /**
  26647. * Defines if webgl2 should be turned off even if supported
  26648. * @see http://doc.babylonjs.com/features/webgl2
  26649. */
  26650. disableWebGL2Support?: boolean;
  26651. /**
  26652. * Defines if webaudio should be initialized as well
  26653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26654. */
  26655. audioEngine?: boolean;
  26656. /**
  26657. * Defines if animations should run using a deterministic lock step
  26658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26659. */
  26660. deterministicLockstep?: boolean;
  26661. /** Defines the maximum steps to use with deterministic lock step mode */
  26662. lockstepMaxSteps?: number;
  26663. /**
  26664. * Defines that engine should ignore context lost events
  26665. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26666. */
  26667. doNotHandleContextLost?: boolean;
  26668. /**
  26669. * Defines that engine should ignore modifying touch action attribute and style
  26670. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26671. */
  26672. doNotHandleTouchAction?: boolean;
  26673. /**
  26674. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26675. */
  26676. useHighPrecisionFloats?: boolean;
  26677. }
  26678. /**
  26679. * Defines the interface used by display changed events
  26680. */
  26681. export interface IDisplayChangedEventArgs {
  26682. /** Gets the vrDisplay object (if any) */
  26683. vrDisplay: Nullable<any>;
  26684. /** Gets a boolean indicating if webVR is supported */
  26685. vrSupported: boolean;
  26686. }
  26687. /**
  26688. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26689. */
  26690. export class Engine {
  26691. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26692. static ExceptionList: ({
  26693. key: string;
  26694. capture: string;
  26695. captureConstraint: number;
  26696. targets: string[];
  26697. } | {
  26698. key: string;
  26699. capture: null;
  26700. captureConstraint: null;
  26701. targets: string[];
  26702. })[];
  26703. /** Gets the list of created engines */
  26704. static readonly Instances: Engine[];
  26705. /**
  26706. * Gets the latest created engine
  26707. */
  26708. static readonly LastCreatedEngine: Nullable<Engine>;
  26709. /**
  26710. * Gets the latest created scene
  26711. */
  26712. static readonly LastCreatedScene: Nullable<Scene>;
  26713. /**
  26714. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26715. * @param flag defines which part of the materials must be marked as dirty
  26716. * @param predicate defines a predicate used to filter which materials should be affected
  26717. */
  26718. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26719. /**
  26720. * Hidden
  26721. */
  26722. static _TextureLoaders: IInternalTextureLoader[];
  26723. /** Defines that alpha blending is disabled */
  26724. static readonly ALPHA_DISABLE: number;
  26725. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26726. static readonly ALPHA_ADD: number;
  26727. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26728. static readonly ALPHA_COMBINE: number;
  26729. /** Defines that alpha blending to DEST - SRC * DEST */
  26730. static readonly ALPHA_SUBTRACT: number;
  26731. /** Defines that alpha blending to SRC * DEST */
  26732. static readonly ALPHA_MULTIPLY: number;
  26733. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26734. static readonly ALPHA_MAXIMIZED: number;
  26735. /** Defines that alpha blending to SRC + DEST */
  26736. static readonly ALPHA_ONEONE: number;
  26737. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26738. static readonly ALPHA_PREMULTIPLIED: number;
  26739. /**
  26740. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26741. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26742. */
  26743. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26744. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26745. static readonly ALPHA_INTERPOLATE: number;
  26746. /**
  26747. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26748. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26749. */
  26750. static readonly ALPHA_SCREENMODE: number;
  26751. /** Defines that the ressource is not delayed*/
  26752. static readonly DELAYLOADSTATE_NONE: number;
  26753. /** Defines that the ressource was successfully delay loaded */
  26754. static readonly DELAYLOADSTATE_LOADED: number;
  26755. /** Defines that the ressource is currently delay loading */
  26756. static readonly DELAYLOADSTATE_LOADING: number;
  26757. /** Defines that the ressource is delayed and has not started loading */
  26758. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26759. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26760. static readonly NEVER: number;
  26761. /** 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 */
  26762. static readonly ALWAYS: number;
  26763. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26764. static readonly LESS: number;
  26765. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26766. static readonly EQUAL: number;
  26767. /** 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 */
  26768. static readonly LEQUAL: number;
  26769. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26770. static readonly GREATER: number;
  26771. /** 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 */
  26772. static readonly GEQUAL: number;
  26773. /** 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 */
  26774. static readonly NOTEQUAL: number;
  26775. /** Passed to stencilOperation to specify that stencil value must be kept */
  26776. static readonly KEEP: number;
  26777. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26778. static readonly REPLACE: number;
  26779. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26780. static readonly INCR: number;
  26781. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26782. static readonly DECR: number;
  26783. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26784. static readonly INVERT: number;
  26785. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26786. static readonly INCR_WRAP: number;
  26787. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26788. static readonly DECR_WRAP: number;
  26789. /** Texture is not repeating outside of 0..1 UVs */
  26790. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26791. /** Texture is repeating outside of 0..1 UVs */
  26792. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26793. /** Texture is repeating and mirrored */
  26794. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26795. /** ALPHA */
  26796. static readonly TEXTUREFORMAT_ALPHA: number;
  26797. /** LUMINANCE */
  26798. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26799. /** LUMINANCE_ALPHA */
  26800. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26801. /** RGB */
  26802. static readonly TEXTUREFORMAT_RGB: number;
  26803. /** RGBA */
  26804. static readonly TEXTUREFORMAT_RGBA: number;
  26805. /** RED */
  26806. static readonly TEXTUREFORMAT_RED: number;
  26807. /** RED (2nd reference) */
  26808. static readonly TEXTUREFORMAT_R: number;
  26809. /** RG */
  26810. static readonly TEXTUREFORMAT_RG: number;
  26811. /** RED_INTEGER */
  26812. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26813. /** RED_INTEGER (2nd reference) */
  26814. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26815. /** RG_INTEGER */
  26816. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26817. /** RGB_INTEGER */
  26818. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26819. /** RGBA_INTEGER */
  26820. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26821. /** UNSIGNED_BYTE */
  26822. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26823. /** UNSIGNED_BYTE (2nd reference) */
  26824. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26825. /** FLOAT */
  26826. static readonly TEXTURETYPE_FLOAT: number;
  26827. /** HALF_FLOAT */
  26828. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26829. /** BYTE */
  26830. static readonly TEXTURETYPE_BYTE: number;
  26831. /** SHORT */
  26832. static readonly TEXTURETYPE_SHORT: number;
  26833. /** UNSIGNED_SHORT */
  26834. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26835. /** INT */
  26836. static readonly TEXTURETYPE_INT: number;
  26837. /** UNSIGNED_INT */
  26838. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26839. /** UNSIGNED_SHORT_4_4_4_4 */
  26840. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26841. /** UNSIGNED_SHORT_5_5_5_1 */
  26842. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26843. /** UNSIGNED_SHORT_5_6_5 */
  26844. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26845. /** UNSIGNED_INT_2_10_10_10_REV */
  26846. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26847. /** UNSIGNED_INT_24_8 */
  26848. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26849. /** UNSIGNED_INT_10F_11F_11F_REV */
  26850. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26851. /** UNSIGNED_INT_5_9_9_9_REV */
  26852. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26853. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26854. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26855. /** nearest is mag = nearest and min = nearest and mip = linear */
  26856. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26858. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26859. /** Trilinear is mag = linear and min = linear and mip = linear */
  26860. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26861. /** nearest is mag = nearest and min = nearest and mip = linear */
  26862. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26863. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26864. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26865. /** Trilinear is mag = linear and min = linear and mip = linear */
  26866. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26867. /** mag = nearest and min = nearest and mip = nearest */
  26868. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26869. /** mag = nearest and min = linear and mip = nearest */
  26870. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26871. /** mag = nearest and min = linear and mip = linear */
  26872. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26873. /** mag = nearest and min = linear and mip = none */
  26874. static readonly TEXTURE_NEAREST_LINEAR: number;
  26875. /** mag = nearest and min = nearest and mip = none */
  26876. static readonly TEXTURE_NEAREST_NEAREST: number;
  26877. /** mag = linear and min = nearest and mip = nearest */
  26878. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26879. /** mag = linear and min = nearest and mip = linear */
  26880. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26881. /** mag = linear and min = linear and mip = none */
  26882. static readonly TEXTURE_LINEAR_LINEAR: number;
  26883. /** mag = linear and min = nearest and mip = none */
  26884. static readonly TEXTURE_LINEAR_NEAREST: number;
  26885. /** Explicit coordinates mode */
  26886. static readonly TEXTURE_EXPLICIT_MODE: number;
  26887. /** Spherical coordinates mode */
  26888. static readonly TEXTURE_SPHERICAL_MODE: number;
  26889. /** Planar coordinates mode */
  26890. static readonly TEXTURE_PLANAR_MODE: number;
  26891. /** Cubic coordinates mode */
  26892. static readonly TEXTURE_CUBIC_MODE: number;
  26893. /** Projection coordinates mode */
  26894. static readonly TEXTURE_PROJECTION_MODE: number;
  26895. /** Skybox coordinates mode */
  26896. static readonly TEXTURE_SKYBOX_MODE: number;
  26897. /** Inverse Cubic coordinates mode */
  26898. static readonly TEXTURE_INVCUBIC_MODE: number;
  26899. /** Equirectangular coordinates mode */
  26900. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26901. /** Equirectangular Fixed coordinates mode */
  26902. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26903. /** Equirectangular Fixed Mirrored coordinates mode */
  26904. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26905. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26906. static readonly SCALEMODE_FLOOR: number;
  26907. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26908. static readonly SCALEMODE_NEAREST: number;
  26909. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26910. static readonly SCALEMODE_CEILING: number;
  26911. /**
  26912. * Returns the current npm package of the sdk
  26913. */
  26914. static readonly NpmPackage: string;
  26915. /**
  26916. * Returns the current version of the framework
  26917. */
  26918. static readonly Version: string;
  26919. /**
  26920. * Returns a string describing the current engine
  26921. */
  26922. readonly description: string;
  26923. /**
  26924. * Gets or sets the epsilon value used by collision engine
  26925. */
  26926. static CollisionsEpsilon: number;
  26927. /**
  26928. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26929. */
  26930. static ShadersRepository: string;
  26931. /**
  26932. * Method called to create the default loading screen.
  26933. * This can be overriden in your own app.
  26934. * @param canvas The rendering canvas element
  26935. * @returns The loading screen
  26936. */
  26937. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26938. /**
  26939. * Method called to create the default rescale post process on each engine.
  26940. */
  26941. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26942. /**
  26943. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26944. */
  26945. forcePOTTextures: boolean;
  26946. /**
  26947. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26948. */
  26949. isFullscreen: boolean;
  26950. /**
  26951. * Gets a boolean indicating if the pointer is currently locked
  26952. */
  26953. isPointerLock: boolean;
  26954. /**
  26955. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26956. */
  26957. cullBackFaces: boolean;
  26958. /**
  26959. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26960. */
  26961. renderEvenInBackground: boolean;
  26962. /**
  26963. * Gets or sets a boolean indicating that cache can be kept between frames
  26964. */
  26965. preventCacheWipeBetweenFrames: boolean;
  26966. /**
  26967. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26968. **/
  26969. enableOfflineSupport: boolean;
  26970. /**
  26971. * 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)
  26972. **/
  26973. disableManifestCheck: boolean;
  26974. /**
  26975. * Gets the list of created scenes
  26976. */
  26977. scenes: Scene[];
  26978. /**
  26979. * Event raised when a new scene is created
  26980. */
  26981. onNewSceneAddedObservable: Observable<Scene>;
  26982. /**
  26983. * Gets the list of created postprocesses
  26984. */
  26985. postProcesses: PostProcess[];
  26986. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26987. validateShaderPrograms: boolean;
  26988. /**
  26989. * Observable event triggered each time the rendering canvas is resized
  26990. */
  26991. onResizeObservable: Observable<Engine>;
  26992. /**
  26993. * Observable event triggered each time the canvas loses focus
  26994. */
  26995. onCanvasBlurObservable: Observable<Engine>;
  26996. /**
  26997. * Observable event triggered each time the canvas gains focus
  26998. */
  26999. onCanvasFocusObservable: Observable<Engine>;
  27000. /**
  27001. * Observable event triggered each time the canvas receives pointerout event
  27002. */
  27003. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27004. /**
  27005. * Observable event triggered before each texture is initialized
  27006. */
  27007. onBeforeTextureInitObservable: Observable<Texture>;
  27008. private _vrDisplay;
  27009. private _vrSupported;
  27010. private _oldSize;
  27011. private _oldHardwareScaleFactor;
  27012. private _vrExclusivePointerMode;
  27013. private _webVRInitPromise;
  27014. /**
  27015. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27016. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27017. */
  27018. readonly isInVRExclusivePointerMode: boolean;
  27019. /**
  27020. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27021. */
  27022. disableUniformBuffers: boolean;
  27023. /** @hidden */
  27024. _uniformBuffers: UniformBuffer[];
  27025. /**
  27026. * Gets a boolean indicating that the engine supports uniform buffers
  27027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27028. */
  27029. readonly supportsUniformBuffers: boolean;
  27030. /**
  27031. * Observable raised when the engine begins a new frame
  27032. */
  27033. onBeginFrameObservable: Observable<Engine>;
  27034. /**
  27035. * If set, will be used to request the next animation frame for the render loop
  27036. */
  27037. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27038. /**
  27039. * Observable raised when the engine ends the current frame
  27040. */
  27041. onEndFrameObservable: Observable<Engine>;
  27042. /**
  27043. * Observable raised when the engine is about to compile a shader
  27044. */
  27045. onBeforeShaderCompilationObservable: Observable<Engine>;
  27046. /**
  27047. * Observable raised when the engine has jsut compiled a shader
  27048. */
  27049. onAfterShaderCompilationObservable: Observable<Engine>;
  27050. /** @hidden */
  27051. _gl: WebGLRenderingContext;
  27052. private _renderingCanvas;
  27053. private _windowIsBackground;
  27054. private _webGLVersion;
  27055. protected _highPrecisionShadersAllowed: boolean;
  27056. /** @hidden */
  27057. readonly _shouldUseHighPrecisionShader: boolean;
  27058. /**
  27059. * Gets a boolean indicating that only power of 2 textures are supported
  27060. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27061. */
  27062. readonly needPOTTextures: boolean;
  27063. /** @hidden */
  27064. _badOS: boolean;
  27065. /** @hidden */
  27066. _badDesktopOS: boolean;
  27067. /**
  27068. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27069. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27070. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27071. */
  27072. disableTextureBindingOptimization: boolean;
  27073. /**
  27074. * Gets the audio engine
  27075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27076. * @ignorenaming
  27077. */
  27078. static audioEngine: IAudioEngine;
  27079. /**
  27080. * Default AudioEngine factory responsible of creating the Audio Engine.
  27081. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27082. */
  27083. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27084. /**
  27085. * Default offline support factory responsible of creating a tool used to store data locally.
  27086. * By default, this will create a Database object if the workload has been embedded.
  27087. */
  27088. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27089. private _onFocus;
  27090. private _onBlur;
  27091. private _onCanvasPointerOut;
  27092. private _onCanvasBlur;
  27093. private _onCanvasFocus;
  27094. private _onFullscreenChange;
  27095. private _onPointerLockChange;
  27096. private _onVRDisplayPointerRestricted;
  27097. private _onVRDisplayPointerUnrestricted;
  27098. private _onVrDisplayConnect;
  27099. private _onVrDisplayDisconnect;
  27100. private _onVrDisplayPresentChange;
  27101. /**
  27102. * Observable signaled when VR display mode changes
  27103. */
  27104. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27105. /**
  27106. * Observable signaled when VR request present is complete
  27107. */
  27108. onVRRequestPresentComplete: Observable<boolean>;
  27109. /**
  27110. * Observable signaled when VR request present starts
  27111. */
  27112. onVRRequestPresentStart: Observable<Engine>;
  27113. private _hardwareScalingLevel;
  27114. /** @hidden */
  27115. protected _caps: EngineCapabilities;
  27116. private _pointerLockRequested;
  27117. private _isStencilEnable;
  27118. private _colorWrite;
  27119. private _loadingScreen;
  27120. /** @hidden */
  27121. _drawCalls: PerfCounter;
  27122. /** @hidden */
  27123. _textureCollisions: PerfCounter;
  27124. private _glVersion;
  27125. private _glRenderer;
  27126. private _glVendor;
  27127. private _videoTextureSupported;
  27128. private _renderingQueueLaunched;
  27129. private _activeRenderLoops;
  27130. private _deterministicLockstep;
  27131. private _lockstepMaxSteps;
  27132. /**
  27133. * Observable signaled when a context lost event is raised
  27134. */
  27135. onContextLostObservable: Observable<Engine>;
  27136. /**
  27137. * Observable signaled when a context restored event is raised
  27138. */
  27139. onContextRestoredObservable: Observable<Engine>;
  27140. private _onContextLost;
  27141. private _onContextRestored;
  27142. private _contextWasLost;
  27143. private _doNotHandleContextLost;
  27144. /**
  27145. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27147. */
  27148. doNotHandleContextLost: boolean;
  27149. private _performanceMonitor;
  27150. private _fps;
  27151. private _deltaTime;
  27152. /**
  27153. * Turn this value on if you want to pause FPS computation when in background
  27154. */
  27155. disablePerformanceMonitorInBackground: boolean;
  27156. /**
  27157. * Gets the performance monitor attached to this engine
  27158. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27159. */
  27160. readonly performanceMonitor: PerformanceMonitor;
  27161. /** @hidden */
  27162. protected _depthCullingState: _DepthCullingState;
  27163. /** @hidden */
  27164. protected _stencilState: _StencilState;
  27165. /** @hidden */
  27166. protected _alphaState: _AlphaState;
  27167. /** @hidden */
  27168. protected _alphaMode: number;
  27169. protected _internalTexturesCache: InternalTexture[];
  27170. /** @hidden */
  27171. protected _activeChannel: number;
  27172. private _currentTextureChannel;
  27173. /** @hidden */
  27174. protected _boundTexturesCache: {
  27175. [key: string]: Nullable<InternalTexture>;
  27176. };
  27177. /** @hidden */
  27178. protected _currentEffect: Nullable<Effect>;
  27179. /** @hidden */
  27180. protected _currentProgram: Nullable<WebGLProgram>;
  27181. private _compiledEffects;
  27182. private _vertexAttribArraysEnabled;
  27183. /** @hidden */
  27184. protected _cachedViewport: Nullable<Viewport>;
  27185. private _cachedVertexArrayObject;
  27186. /** @hidden */
  27187. protected _cachedVertexBuffers: any;
  27188. /** @hidden */
  27189. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27190. /** @hidden */
  27191. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27192. /** @hidden */
  27193. protected _currentRenderTarget: Nullable<InternalTexture>;
  27194. private _uintIndicesCurrentlySet;
  27195. private _currentBoundBuffer;
  27196. /** @hidden */
  27197. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27198. private _currentBufferPointers;
  27199. private _currentInstanceLocations;
  27200. private _currentInstanceBuffers;
  27201. private _textureUnits;
  27202. private _firstBoundInternalTextureTracker;
  27203. private _lastBoundInternalTextureTracker;
  27204. private _workingCanvas;
  27205. private _workingContext;
  27206. private _rescalePostProcess;
  27207. private _dummyFramebuffer;
  27208. private _externalData;
  27209. private _bindedRenderFunction;
  27210. private _vaoRecordInProgress;
  27211. private _mustWipeVertexAttributes;
  27212. private _emptyTexture;
  27213. private _emptyCubeTexture;
  27214. private _emptyTexture3D;
  27215. /** @hidden */
  27216. _frameHandler: number;
  27217. private _nextFreeTextureSlots;
  27218. private _maxSimultaneousTextures;
  27219. private _activeRequests;
  27220. private _texturesSupported;
  27221. private _textureFormatInUse;
  27222. /**
  27223. * Gets the list of texture formats supported
  27224. */
  27225. readonly texturesSupported: Array<string>;
  27226. /**
  27227. * Gets the list of texture formats in use
  27228. */
  27229. readonly textureFormatInUse: Nullable<string>;
  27230. /**
  27231. * Gets the current viewport
  27232. */
  27233. readonly currentViewport: Nullable<Viewport>;
  27234. /**
  27235. * Gets the default empty texture
  27236. */
  27237. readonly emptyTexture: InternalTexture;
  27238. /**
  27239. * Gets the default empty 3D texture
  27240. */
  27241. readonly emptyTexture3D: InternalTexture;
  27242. /**
  27243. * Gets the default empty cube texture
  27244. */
  27245. readonly emptyCubeTexture: InternalTexture;
  27246. /**
  27247. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27248. */
  27249. readonly premultipliedAlpha: boolean;
  27250. /**
  27251. * Creates a new engine
  27252. * @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
  27253. * @param antialias defines enable antialiasing (default: false)
  27254. * @param options defines further options to be sent to the getContext() function
  27255. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27256. */
  27257. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27258. private _disableTouchAction;
  27259. private _rebuildInternalTextures;
  27260. private _rebuildEffects;
  27261. /**
  27262. * Gets a boolean indicating if all created effects are ready
  27263. * @returns true if all effects are ready
  27264. */
  27265. areAllEffectsReady(): boolean;
  27266. private _rebuildBuffers;
  27267. private _initGLContext;
  27268. /**
  27269. * Gets version of the current webGL context
  27270. */
  27271. readonly webGLVersion: number;
  27272. /**
  27273. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27274. */
  27275. readonly isStencilEnable: boolean;
  27276. private _prepareWorkingCanvas;
  27277. /**
  27278. * Reset the texture cache to empty state
  27279. */
  27280. resetTextureCache(): void;
  27281. /**
  27282. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27284. * @returns true if engine is in deterministic lock step mode
  27285. */
  27286. isDeterministicLockStep(): boolean;
  27287. /**
  27288. * Gets the max steps when engine is running in deterministic lock step
  27289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27290. * @returns the max steps
  27291. */
  27292. getLockstepMaxSteps(): number;
  27293. /**
  27294. * Gets an object containing information about the current webGL context
  27295. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27296. */
  27297. getGlInfo(): {
  27298. vendor: string;
  27299. renderer: string;
  27300. version: string;
  27301. };
  27302. /**
  27303. * Gets current aspect ratio
  27304. * @param camera defines the camera to use to get the aspect ratio
  27305. * @param useScreen defines if screen size must be used (or the current render target if any)
  27306. * @returns a number defining the aspect ratio
  27307. */
  27308. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27309. /**
  27310. * Gets current screen aspect ratio
  27311. * @returns a number defining the aspect ratio
  27312. */
  27313. getScreenAspectRatio(): number;
  27314. /**
  27315. * Gets the current render width
  27316. * @param useScreen defines if screen size must be used (or the current render target if any)
  27317. * @returns a number defining the current render width
  27318. */
  27319. getRenderWidth(useScreen?: boolean): number;
  27320. /**
  27321. * Gets the current render height
  27322. * @param useScreen defines if screen size must be used (or the current render target if any)
  27323. * @returns a number defining the current render height
  27324. */
  27325. getRenderHeight(useScreen?: boolean): number;
  27326. /**
  27327. * Gets the HTML canvas attached with the current webGL context
  27328. * @returns a HTML canvas
  27329. */
  27330. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27331. /**
  27332. * Gets the client rect of the HTML canvas attached with the current webGL context
  27333. * @returns a client rectanglee
  27334. */
  27335. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27336. /**
  27337. * Defines the hardware scaling level.
  27338. * By default the hardware scaling level is computed from the window device ratio.
  27339. * 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.
  27340. * @param level defines the level to use
  27341. */
  27342. setHardwareScalingLevel(level: number): void;
  27343. /**
  27344. * Gets the current hardware scaling level.
  27345. * By default the hardware scaling level is computed from the window device ratio.
  27346. * 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.
  27347. * @returns a number indicating the current hardware scaling level
  27348. */
  27349. getHardwareScalingLevel(): number;
  27350. /**
  27351. * Gets the list of loaded textures
  27352. * @returns an array containing all loaded textures
  27353. */
  27354. getLoadedTexturesCache(): InternalTexture[];
  27355. /**
  27356. * Gets the object containing all engine capabilities
  27357. * @returns the EngineCapabilities object
  27358. */
  27359. getCaps(): EngineCapabilities;
  27360. /**
  27361. * Gets the current depth function
  27362. * @returns a number defining the depth function
  27363. */
  27364. getDepthFunction(): Nullable<number>;
  27365. /**
  27366. * Sets the current depth function
  27367. * @param depthFunc defines the function to use
  27368. */
  27369. setDepthFunction(depthFunc: number): void;
  27370. /**
  27371. * Sets the current depth function to GREATER
  27372. */
  27373. setDepthFunctionToGreater(): void;
  27374. /**
  27375. * Sets the current depth function to GEQUAL
  27376. */
  27377. setDepthFunctionToGreaterOrEqual(): void;
  27378. /**
  27379. * Sets the current depth function to LESS
  27380. */
  27381. setDepthFunctionToLess(): void;
  27382. private _cachedStencilBuffer;
  27383. private _cachedStencilFunction;
  27384. private _cachedStencilMask;
  27385. private _cachedStencilOperationPass;
  27386. private _cachedStencilOperationFail;
  27387. private _cachedStencilOperationDepthFail;
  27388. private _cachedStencilReference;
  27389. /**
  27390. * Caches the the state of the stencil buffer
  27391. */
  27392. cacheStencilState(): void;
  27393. /**
  27394. * Restores the state of the stencil buffer
  27395. */
  27396. restoreStencilState(): void;
  27397. /**
  27398. * Sets the current depth function to LEQUAL
  27399. */
  27400. setDepthFunctionToLessOrEqual(): void;
  27401. /**
  27402. * Gets a boolean indicating if stencil buffer is enabled
  27403. * @returns the current stencil buffer state
  27404. */
  27405. getStencilBuffer(): boolean;
  27406. /**
  27407. * Enable or disable the stencil buffer
  27408. * @param enable defines if the stencil buffer must be enabled or disabled
  27409. */
  27410. setStencilBuffer(enable: boolean): void;
  27411. /**
  27412. * Gets the current stencil mask
  27413. * @returns a number defining the new stencil mask to use
  27414. */
  27415. getStencilMask(): number;
  27416. /**
  27417. * Sets the current stencil mask
  27418. * @param mask defines the new stencil mask to use
  27419. */
  27420. setStencilMask(mask: number): void;
  27421. /**
  27422. * Gets the current stencil function
  27423. * @returns a number defining the stencil function to use
  27424. */
  27425. getStencilFunction(): number;
  27426. /**
  27427. * Gets the current stencil reference value
  27428. * @returns a number defining the stencil reference value to use
  27429. */
  27430. getStencilFunctionReference(): number;
  27431. /**
  27432. * Gets the current stencil mask
  27433. * @returns a number defining the stencil mask to use
  27434. */
  27435. getStencilFunctionMask(): number;
  27436. /**
  27437. * Sets the current stencil function
  27438. * @param stencilFunc defines the new stencil function to use
  27439. */
  27440. setStencilFunction(stencilFunc: number): void;
  27441. /**
  27442. * Sets the current stencil reference
  27443. * @param reference defines the new stencil reference to use
  27444. */
  27445. setStencilFunctionReference(reference: number): void;
  27446. /**
  27447. * Sets the current stencil mask
  27448. * @param mask defines the new stencil mask to use
  27449. */
  27450. setStencilFunctionMask(mask: number): void;
  27451. /**
  27452. * Gets the current stencil operation when stencil fails
  27453. * @returns a number defining stencil operation to use when stencil fails
  27454. */
  27455. getStencilOperationFail(): number;
  27456. /**
  27457. * Gets the current stencil operation when depth fails
  27458. * @returns a number defining stencil operation to use when depth fails
  27459. */
  27460. getStencilOperationDepthFail(): number;
  27461. /**
  27462. * Gets the current stencil operation when stencil passes
  27463. * @returns a number defining stencil operation to use when stencil passes
  27464. */
  27465. getStencilOperationPass(): number;
  27466. /**
  27467. * Sets the stencil operation to use when stencil fails
  27468. * @param operation defines the stencil operation to use when stencil fails
  27469. */
  27470. setStencilOperationFail(operation: number): void;
  27471. /**
  27472. * Sets the stencil operation to use when depth fails
  27473. * @param operation defines the stencil operation to use when depth fails
  27474. */
  27475. setStencilOperationDepthFail(operation: number): void;
  27476. /**
  27477. * Sets the stencil operation to use when stencil passes
  27478. * @param operation defines the stencil operation to use when stencil passes
  27479. */
  27480. setStencilOperationPass(operation: number): void;
  27481. /**
  27482. * Sets a boolean indicating if the dithering state is enabled or disabled
  27483. * @param value defines the dithering state
  27484. */
  27485. setDitheringState(value: boolean): void;
  27486. /**
  27487. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27488. * @param value defines the rasterizer state
  27489. */
  27490. setRasterizerState(value: boolean): void;
  27491. /**
  27492. * stop executing a render loop function and remove it from the execution array
  27493. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27494. */
  27495. stopRenderLoop(renderFunction?: () => void): void;
  27496. /** @hidden */
  27497. _renderLoop(): void;
  27498. /**
  27499. * Register and execute a render loop. The engine can have more than one render function
  27500. * @param renderFunction defines the function to continuously execute
  27501. */
  27502. runRenderLoop(renderFunction: () => void): void;
  27503. /**
  27504. * Toggle full screen mode
  27505. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27506. */
  27507. switchFullscreen(requestPointerLock: boolean): void;
  27508. /**
  27509. * Enters full screen mode
  27510. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27511. */
  27512. enterFullscreen(requestPointerLock: boolean): void;
  27513. /**
  27514. * Exits full screen mode
  27515. */
  27516. exitFullscreen(): void;
  27517. /**
  27518. * Clear the current render buffer or the current render target (if any is set up)
  27519. * @param color defines the color to use
  27520. * @param backBuffer defines if the back buffer must be cleared
  27521. * @param depth defines if the depth buffer must be cleared
  27522. * @param stencil defines if the stencil buffer must be cleared
  27523. */
  27524. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27525. /**
  27526. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27527. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27528. * @param y defines the y-coordinate of the corner of the clear rectangle
  27529. * @param width defines the width of the clear rectangle
  27530. * @param height defines the height of the clear rectangle
  27531. * @param clearColor defines the clear color
  27532. */
  27533. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27534. /**
  27535. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27536. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27537. * @param y defines the y-coordinate of the corner of the clear rectangle
  27538. * @param width defines the width of the clear rectangle
  27539. * @param height defines the height of the clear rectangle
  27540. */
  27541. enableScissor(x: number, y: number, width: number, height: number): void;
  27542. /**
  27543. * Disable previously set scissor test rectangle
  27544. */
  27545. disableScissor(): void;
  27546. private _viewportCached;
  27547. /** @hidden */
  27548. _viewport(x: number, y: number, width: number, height: number): void;
  27549. /**
  27550. * Set the WebGL's viewport
  27551. * @param viewport defines the viewport element to be used
  27552. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27553. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27554. */
  27555. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27556. /**
  27557. * Directly set the WebGL Viewport
  27558. * @param x defines the x coordinate of the viewport (in screen space)
  27559. * @param y defines the y coordinate of the viewport (in screen space)
  27560. * @param width defines the width of the viewport (in screen space)
  27561. * @param height defines the height of the viewport (in screen space)
  27562. * @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
  27563. */
  27564. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27565. /**
  27566. * Begin a new frame
  27567. */
  27568. beginFrame(): void;
  27569. /**
  27570. * Enf the current frame
  27571. */
  27572. endFrame(): void;
  27573. /**
  27574. * Resize the view according to the canvas' size
  27575. */
  27576. resize(): void;
  27577. /**
  27578. * Force a specific size of the canvas
  27579. * @param width defines the new canvas' width
  27580. * @param height defines the new canvas' height
  27581. */
  27582. setSize(width: number, height: number): void;
  27583. /**
  27584. * Gets a boolean indicating if a webVR device was detected
  27585. * @returns true if a webVR device was detected
  27586. */
  27587. isVRDevicePresent(): boolean;
  27588. /**
  27589. * Gets the current webVR device
  27590. * @returns the current webVR device (or null)
  27591. */
  27592. getVRDevice(): any;
  27593. /**
  27594. * Initializes a webVR display and starts listening to display change events
  27595. * The onVRDisplayChangedObservable will be notified upon these changes
  27596. * @returns The onVRDisplayChangedObservable
  27597. */
  27598. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27599. /**
  27600. * Initializes a webVR display and starts listening to display change events
  27601. * The onVRDisplayChangedObservable will be notified upon these changes
  27602. * @returns A promise containing a VRDisplay and if vr is supported
  27603. */
  27604. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27605. /**
  27606. * Call this function to switch to webVR mode
  27607. * Will do nothing if webVR is not supported or if there is no webVR device
  27608. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27609. */
  27610. enableVR(): void;
  27611. /**
  27612. * Call this function to leave webVR mode
  27613. * Will do nothing if webVR is not supported or if there is no webVR device
  27614. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27615. */
  27616. disableVR(): void;
  27617. private _onVRFullScreenTriggered;
  27618. private _getVRDisplaysAsync;
  27619. /**
  27620. * Binds the frame buffer to the specified texture.
  27621. * @param texture The texture to render to or null for the default canvas
  27622. * @param faceIndex The face of the texture to render to in case of cube texture
  27623. * @param requiredWidth The width of the target to render to
  27624. * @param requiredHeight The height of the target to render to
  27625. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27626. * @param depthStencilTexture The depth stencil texture to use to render
  27627. * @param lodLevel defines le lod level to bind to the frame buffer
  27628. */
  27629. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27630. private bindUnboundFramebuffer;
  27631. /**
  27632. * Unbind the current render target texture from the webGL context
  27633. * @param texture defines the render target texture to unbind
  27634. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27635. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27636. */
  27637. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27638. /**
  27639. * Unbind a list of render target textures from the webGL context
  27640. * This is used only when drawBuffer extension or webGL2 are active
  27641. * @param textures defines the render target textures to unbind
  27642. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27643. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27644. */
  27645. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27646. /**
  27647. * Force the mipmap generation for the given render target texture
  27648. * @param texture defines the render target texture to use
  27649. */
  27650. generateMipMapsForCubemap(texture: InternalTexture): void;
  27651. /**
  27652. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27653. */
  27654. flushFramebuffer(): void;
  27655. /**
  27656. * Unbind the current render target and bind the default framebuffer
  27657. */
  27658. restoreDefaultFramebuffer(): void;
  27659. /**
  27660. * Create an uniform buffer
  27661. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27662. * @param elements defines the content of the uniform buffer
  27663. * @returns the webGL uniform buffer
  27664. */
  27665. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27666. /**
  27667. * Create a dynamic uniform buffer
  27668. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27669. * @param elements defines the content of the uniform buffer
  27670. * @returns the webGL uniform buffer
  27671. */
  27672. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27673. /**
  27674. * Update an existing uniform buffer
  27675. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27676. * @param uniformBuffer defines the target uniform buffer
  27677. * @param elements defines the content to update
  27678. * @param offset defines the offset in the uniform buffer where update should start
  27679. * @param count defines the size of the data to update
  27680. */
  27681. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27682. private _resetVertexBufferBinding;
  27683. /**
  27684. * Creates a vertex buffer
  27685. * @param data the data for the vertex buffer
  27686. * @returns the new WebGL static buffer
  27687. */
  27688. createVertexBuffer(data: DataArray): WebGLBuffer;
  27689. /**
  27690. * Creates a dynamic vertex buffer
  27691. * @param data the data for the dynamic vertex buffer
  27692. * @returns the new WebGL dynamic buffer
  27693. */
  27694. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27695. /**
  27696. * Update a dynamic index buffer
  27697. * @param indexBuffer defines the target index buffer
  27698. * @param indices defines the data to update
  27699. * @param offset defines the offset in the target index buffer where update should start
  27700. */
  27701. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27702. /**
  27703. * Updates a dynamic vertex buffer.
  27704. * @param vertexBuffer the vertex buffer to update
  27705. * @param data the data used to update the vertex buffer
  27706. * @param byteOffset the byte offset of the data
  27707. * @param byteLength the byte length of the data
  27708. */
  27709. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27710. private _resetIndexBufferBinding;
  27711. /**
  27712. * Creates a new index buffer
  27713. * @param indices defines the content of the index buffer
  27714. * @param updatable defines if the index buffer must be updatable
  27715. * @returns a new webGL buffer
  27716. */
  27717. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27718. /**
  27719. * Bind a webGL buffer to the webGL context
  27720. * @param buffer defines the buffer to bind
  27721. */
  27722. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27723. /**
  27724. * Bind an uniform buffer to the current webGL context
  27725. * @param buffer defines the buffer to bind
  27726. */
  27727. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27728. /**
  27729. * Bind a buffer to the current webGL context at a given location
  27730. * @param buffer defines the buffer to bind
  27731. * @param location defines the index where to bind the buffer
  27732. */
  27733. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27734. /**
  27735. * Bind a specific block at a given index in a specific shader program
  27736. * @param shaderProgram defines the shader program
  27737. * @param blockName defines the block name
  27738. * @param index defines the index where to bind the block
  27739. */
  27740. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27741. private bindIndexBuffer;
  27742. private bindBuffer;
  27743. /**
  27744. * update the bound buffer with the given data
  27745. * @param data defines the data to update
  27746. */
  27747. updateArrayBuffer(data: Float32Array): void;
  27748. private _vertexAttribPointer;
  27749. private _bindIndexBufferWithCache;
  27750. private _bindVertexBuffersAttributes;
  27751. /**
  27752. * Records a vertex array object
  27753. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27754. * @param vertexBuffers defines the list of vertex buffers to store
  27755. * @param indexBuffer defines the index buffer to store
  27756. * @param effect defines the effect to store
  27757. * @returns the new vertex array object
  27758. */
  27759. recordVertexArrayObject(vertexBuffers: {
  27760. [key: string]: VertexBuffer;
  27761. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27762. /**
  27763. * Bind a specific vertex array object
  27764. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27765. * @param vertexArrayObject defines the vertex array object to bind
  27766. * @param indexBuffer defines the index buffer to bind
  27767. */
  27768. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27769. /**
  27770. * Bind webGl buffers directly to the webGL context
  27771. * @param vertexBuffer defines the vertex buffer to bind
  27772. * @param indexBuffer defines the index buffer to bind
  27773. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27774. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27775. * @param effect defines the effect associated with the vertex buffer
  27776. */
  27777. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27778. private _unbindVertexArrayObject;
  27779. /**
  27780. * Bind a list of vertex buffers to the webGL context
  27781. * @param vertexBuffers defines the list of vertex buffers to bind
  27782. * @param indexBuffer defines the index buffer to bind
  27783. * @param effect defines the effect associated with the vertex buffers
  27784. */
  27785. bindBuffers(vertexBuffers: {
  27786. [key: string]: Nullable<VertexBuffer>;
  27787. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27788. /**
  27789. * Unbind all instance attributes
  27790. */
  27791. unbindInstanceAttributes(): void;
  27792. /**
  27793. * Release and free the memory of a vertex array object
  27794. * @param vao defines the vertex array object to delete
  27795. */
  27796. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27797. /** @hidden */
  27798. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27799. /**
  27800. * Creates a webGL buffer to use with instanciation
  27801. * @param capacity defines the size of the buffer
  27802. * @returns the webGL buffer
  27803. */
  27804. createInstancesBuffer(capacity: number): WebGLBuffer;
  27805. /**
  27806. * Delete a webGL buffer used with instanciation
  27807. * @param buffer defines the webGL buffer to delete
  27808. */
  27809. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27810. /**
  27811. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27812. * @param instancesBuffer defines the webGL buffer to update and bind
  27813. * @param data defines the data to store in the buffer
  27814. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27815. */
  27816. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27817. /**
  27818. * Apply all cached states (depth, culling, stencil and alpha)
  27819. */
  27820. applyStates(): void;
  27821. /**
  27822. * Send a draw order
  27823. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27824. * @param indexStart defines the starting index
  27825. * @param indexCount defines the number of index to draw
  27826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27827. */
  27828. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27829. /**
  27830. * Draw a list of points
  27831. * @param verticesStart defines the index of first vertex to draw
  27832. * @param verticesCount defines the count of vertices to draw
  27833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27834. */
  27835. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27836. /**
  27837. * Draw a list of unindexed primitives
  27838. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27839. * @param verticesStart defines the index of first vertex to draw
  27840. * @param verticesCount defines the count of vertices to draw
  27841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27842. */
  27843. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27844. /**
  27845. * Draw a list of indexed primitives
  27846. * @param fillMode defines the primitive to use
  27847. * @param indexStart defines the starting index
  27848. * @param indexCount defines the number of index to draw
  27849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27850. */
  27851. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27852. /**
  27853. * Draw a list of unindexed primitives
  27854. * @param fillMode defines the primitive to use
  27855. * @param verticesStart defines the index of first vertex to draw
  27856. * @param verticesCount defines the count of vertices to draw
  27857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27858. */
  27859. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27860. private _drawMode;
  27861. /** @hidden */
  27862. _releaseEffect(effect: Effect): void;
  27863. /** @hidden */
  27864. _deleteProgram(program: WebGLProgram): void;
  27865. /**
  27866. * Create a new effect (used to store vertex/fragment shaders)
  27867. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27868. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27869. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27870. * @param samplers defines an array of string used to represent textures
  27871. * @param defines defines the string containing the defines to use to compile the shaders
  27872. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27873. * @param onCompiled defines a function to call when the effect creation is successful
  27874. * @param onError defines a function to call when the effect creation has failed
  27875. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27876. * @returns the new Effect
  27877. */
  27878. 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;
  27879. private _compileShader;
  27880. private _compileRawShader;
  27881. /**
  27882. * Directly creates a webGL program
  27883. * @param vertexCode defines the vertex shader code to use
  27884. * @param fragmentCode defines the fragment shader code to use
  27885. * @param context defines the webGL context to use (if not set, the current one will be used)
  27886. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27887. * @returns the new webGL program
  27888. */
  27889. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27890. /**
  27891. * Creates a webGL program
  27892. * @param vertexCode defines the vertex shader code to use
  27893. * @param fragmentCode defines the fragment shader code to use
  27894. * @param defines defines the string containing the defines to use to compile the shaders
  27895. * @param context defines the webGL context to use (if not set, the current one will be used)
  27896. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27897. * @returns the new webGL program
  27898. */
  27899. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27900. private _createShaderProgram;
  27901. private _finalizeProgram;
  27902. /** @hidden */
  27903. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27904. /** @hidden */
  27905. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27906. /**
  27907. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27908. * @param shaderProgram defines the webGL program to use
  27909. * @param uniformsNames defines the list of uniform names
  27910. * @returns an array of webGL uniform locations
  27911. */
  27912. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27913. /**
  27914. * Gets the lsit of active attributes for a given webGL program
  27915. * @param shaderProgram defines the webGL program to use
  27916. * @param attributesNames defines the list of attribute names to get
  27917. * @returns an array of indices indicating the offset of each attribute
  27918. */
  27919. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27920. /**
  27921. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27922. * @param effect defines the effect to activate
  27923. */
  27924. enableEffect(effect: Nullable<Effect>): void;
  27925. /**
  27926. * Set the value of an uniform to an array of int32
  27927. * @param uniform defines the webGL uniform location where to store the value
  27928. * @param array defines the array of int32 to store
  27929. */
  27930. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27931. /**
  27932. * Set the value of an uniform to an array of int32 (stored as vec2)
  27933. * @param uniform defines the webGL uniform location where to store the value
  27934. * @param array defines the array of int32 to store
  27935. */
  27936. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27937. /**
  27938. * Set the value of an uniform to an array of int32 (stored as vec3)
  27939. * @param uniform defines the webGL uniform location where to store the value
  27940. * @param array defines the array of int32 to store
  27941. */
  27942. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27943. /**
  27944. * Set the value of an uniform to an array of int32 (stored as vec4)
  27945. * @param uniform defines the webGL uniform location where to store the value
  27946. * @param array defines the array of int32 to store
  27947. */
  27948. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27949. /**
  27950. * Set the value of an uniform to an array of float32
  27951. * @param uniform defines the webGL uniform location where to store the value
  27952. * @param array defines the array of float32 to store
  27953. */
  27954. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27955. /**
  27956. * Set the value of an uniform to an array of float32 (stored as vec2)
  27957. * @param uniform defines the webGL uniform location where to store the value
  27958. * @param array defines the array of float32 to store
  27959. */
  27960. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27961. /**
  27962. * Set the value of an uniform to an array of float32 (stored as vec3)
  27963. * @param uniform defines the webGL uniform location where to store the value
  27964. * @param array defines the array of float32 to store
  27965. */
  27966. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27967. /**
  27968. * Set the value of an uniform to an array of float32 (stored as vec4)
  27969. * @param uniform defines the webGL uniform location where to store the value
  27970. * @param array defines the array of float32 to store
  27971. */
  27972. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27973. /**
  27974. * Set the value of an uniform to an array of number
  27975. * @param uniform defines the webGL uniform location where to store the value
  27976. * @param array defines the array of number to store
  27977. */
  27978. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27979. /**
  27980. * Set the value of an uniform to an array of number (stored as vec2)
  27981. * @param uniform defines the webGL uniform location where to store the value
  27982. * @param array defines the array of number to store
  27983. */
  27984. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27985. /**
  27986. * Set the value of an uniform to an array of number (stored as vec3)
  27987. * @param uniform defines the webGL uniform location where to store the value
  27988. * @param array defines the array of number to store
  27989. */
  27990. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27991. /**
  27992. * Set the value of an uniform to an array of number (stored as vec4)
  27993. * @param uniform defines the webGL uniform location where to store the value
  27994. * @param array defines the array of number to store
  27995. */
  27996. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27997. /**
  27998. * Set the value of an uniform to an array of float32 (stored as matrices)
  27999. * @param uniform defines the webGL uniform location where to store the value
  28000. * @param matrices defines the array of float32 to store
  28001. */
  28002. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28003. /**
  28004. * Set the value of an uniform to a matrix
  28005. * @param uniform defines the webGL uniform location where to store the value
  28006. * @param matrix defines the matrix to store
  28007. */
  28008. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28009. /**
  28010. * Set the value of an uniform to a matrix (3x3)
  28011. * @param uniform defines the webGL uniform location where to store the value
  28012. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28013. */
  28014. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28015. /**
  28016. * Set the value of an uniform to a matrix (2x2)
  28017. * @param uniform defines the webGL uniform location where to store the value
  28018. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28019. */
  28020. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28021. /**
  28022. * Set the value of an uniform to a number (int)
  28023. * @param uniform defines the webGL uniform location where to store the value
  28024. * @param value defines the int number to store
  28025. */
  28026. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28027. /**
  28028. * Set the value of an uniform to a number (float)
  28029. * @param uniform defines the webGL uniform location where to store the value
  28030. * @param value defines the float number to store
  28031. */
  28032. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28033. /**
  28034. * Set the value of an uniform to a vec2
  28035. * @param uniform defines the webGL uniform location where to store the value
  28036. * @param x defines the 1st component of the value
  28037. * @param y defines the 2nd component of the value
  28038. */
  28039. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28040. /**
  28041. * Set the value of an uniform to a vec3
  28042. * @param uniform defines the webGL uniform location where to store the value
  28043. * @param x defines the 1st component of the value
  28044. * @param y defines the 2nd component of the value
  28045. * @param z defines the 3rd component of the value
  28046. */
  28047. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28048. /**
  28049. * Set the value of an uniform to a boolean
  28050. * @param uniform defines the webGL uniform location where to store the value
  28051. * @param bool defines the boolean to store
  28052. */
  28053. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28054. /**
  28055. * Set the value of an uniform to a vec4
  28056. * @param uniform defines the webGL uniform location where to store the value
  28057. * @param x defines the 1st component of the value
  28058. * @param y defines the 2nd component of the value
  28059. * @param z defines the 3rd component of the value
  28060. * @param w defines the 4th component of the value
  28061. */
  28062. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28063. /**
  28064. * Set the value of an uniform to a Color3
  28065. * @param uniform defines the webGL uniform location where to store the value
  28066. * @param color3 defines the color to store
  28067. */
  28068. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28069. /**
  28070. * Set the value of an uniform to a Color3 and an alpha value
  28071. * @param uniform defines the webGL uniform location where to store the value
  28072. * @param color3 defines the color to store
  28073. * @param alpha defines the alpha component to store
  28074. */
  28075. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28076. /**
  28077. * Sets a Color4 on a uniform variable
  28078. * @param uniform defines the uniform location
  28079. * @param color4 defines the value to be set
  28080. */
  28081. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28082. /**
  28083. * Set various states to the webGL context
  28084. * @param culling defines backface culling state
  28085. * @param zOffset defines the value to apply to zOffset (0 by default)
  28086. * @param force defines if states must be applied even if cache is up to date
  28087. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28088. */
  28089. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28090. /**
  28091. * Set the z offset to apply to current rendering
  28092. * @param value defines the offset to apply
  28093. */
  28094. setZOffset(value: number): void;
  28095. /**
  28096. * Gets the current value of the zOffset
  28097. * @returns the current zOffset state
  28098. */
  28099. getZOffset(): number;
  28100. /**
  28101. * Enable or disable depth buffering
  28102. * @param enable defines the state to set
  28103. */
  28104. setDepthBuffer(enable: boolean): void;
  28105. /**
  28106. * Gets a boolean indicating if depth writing is enabled
  28107. * @returns the current depth writing state
  28108. */
  28109. getDepthWrite(): boolean;
  28110. /**
  28111. * Enable or disable depth writing
  28112. * @param enable defines the state to set
  28113. */
  28114. setDepthWrite(enable: boolean): void;
  28115. /**
  28116. * Enable or disable color writing
  28117. * @param enable defines the state to set
  28118. */
  28119. setColorWrite(enable: boolean): void;
  28120. /**
  28121. * Gets a boolean indicating if color writing is enabled
  28122. * @returns the current color writing state
  28123. */
  28124. getColorWrite(): boolean;
  28125. /**
  28126. * Sets alpha constants used by some alpha blending modes
  28127. * @param r defines the red component
  28128. * @param g defines the green component
  28129. * @param b defines the blue component
  28130. * @param a defines the alpha component
  28131. */
  28132. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28133. /**
  28134. * Sets the current alpha mode
  28135. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28136. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28137. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28138. */
  28139. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28140. /**
  28141. * Gets the current alpha mode
  28142. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28143. * @returns the current alpha mode
  28144. */
  28145. getAlphaMode(): number;
  28146. /**
  28147. * Clears the list of texture accessible through engine.
  28148. * This can help preventing texture load conflict due to name collision.
  28149. */
  28150. clearInternalTexturesCache(): void;
  28151. /**
  28152. * Force the entire cache to be cleared
  28153. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28154. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28155. */
  28156. wipeCaches(bruteForce?: boolean): void;
  28157. /**
  28158. * Set the compressed texture format to use, based on the formats you have, and the formats
  28159. * supported by the hardware / browser.
  28160. *
  28161. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28162. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28163. * to API arguments needed to compressed textures. This puts the burden on the container
  28164. * generator to house the arcane code for determining these for current & future formats.
  28165. *
  28166. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28167. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28168. *
  28169. * Note: The result of this call is not taken into account when a texture is base64.
  28170. *
  28171. * @param formatsAvailable defines the list of those format families you have created
  28172. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28173. *
  28174. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28175. * @returns The extension selected.
  28176. */
  28177. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28178. private _getSamplingParameters;
  28179. private _partialLoadImg;
  28180. private _cascadeLoadImgs;
  28181. /** @hidden */
  28182. _createTexture(): WebGLTexture;
  28183. /**
  28184. * Usually called from Texture.ts.
  28185. * Passed information to create a WebGLTexture
  28186. * @param urlArg defines a value which contains one of the following:
  28187. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28188. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28189. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28190. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28191. * @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)
  28192. * @param scene needed for loading to the correct scene
  28193. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28194. * @param onLoad optional callback to be called upon successful completion
  28195. * @param onError optional callback to be called upon failure
  28196. * @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
  28197. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28198. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28199. * @param forcedExtension defines the extension to use to pick the right loader
  28200. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28201. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28202. */
  28203. 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;
  28204. private _rescaleTexture;
  28205. /**
  28206. * Update a raw texture
  28207. * @param texture defines the texture to update
  28208. * @param data defines the data to store in the texture
  28209. * @param format defines the format of the data
  28210. * @param invertY defines if data must be stored with Y axis inverted
  28211. * @param compression defines the compression used (null by default)
  28212. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28213. */
  28214. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28215. /**
  28216. * Creates a raw texture
  28217. * @param data defines the data to store in the texture
  28218. * @param width defines the width of the texture
  28219. * @param height defines the height of the texture
  28220. * @param format defines the format of the data
  28221. * @param generateMipMaps defines if the engine should generate the mip levels
  28222. * @param invertY defines if data must be stored with Y axis inverted
  28223. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28224. * @param compression defines the compression used (null by default)
  28225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28226. * @returns the raw texture inside an InternalTexture
  28227. */
  28228. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28229. private _unpackFlipYCached;
  28230. /**
  28231. * In case you are sharing the context with other applications, it might
  28232. * be interested to not cache the unpack flip y state to ensure a consistent
  28233. * value would be set.
  28234. */
  28235. enableUnpackFlipYCached: boolean;
  28236. /** @hidden */
  28237. _unpackFlipY(value: boolean): void;
  28238. /** @hidden */
  28239. _getUnpackAlignement(): number;
  28240. /**
  28241. * Creates a dynamic texture
  28242. * @param width defines the width of the texture
  28243. * @param height defines the height of the texture
  28244. * @param generateMipMaps defines if the engine should generate the mip levels
  28245. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28246. * @returns the dynamic texture inside an InternalTexture
  28247. */
  28248. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28249. /**
  28250. * Update the sampling mode of a given texture
  28251. * @param samplingMode defines the required sampling mode
  28252. * @param texture defines the texture to update
  28253. */
  28254. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28255. /**
  28256. * Update the content of a dynamic texture
  28257. * @param texture defines the texture to update
  28258. * @param canvas defines the canvas containing the source
  28259. * @param invertY defines if data must be stored with Y axis inverted
  28260. * @param premulAlpha defines if alpha is stored as premultiplied
  28261. * @param format defines the format of the data
  28262. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28263. */
  28264. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28265. /**
  28266. * Update a video texture
  28267. * @param texture defines the texture to update
  28268. * @param video defines the video element to use
  28269. * @param invertY defines if data must be stored with Y axis inverted
  28270. */
  28271. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28272. /**
  28273. * Updates a depth texture Comparison Mode and Function.
  28274. * If the comparison Function is equal to 0, the mode will be set to none.
  28275. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28276. * @param texture The texture to set the comparison function for
  28277. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28278. */
  28279. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28280. private _setupDepthStencilTexture;
  28281. /**
  28282. * Creates a depth stencil texture.
  28283. * This is only available in WebGL 2 or with the depth texture extension available.
  28284. * @param size The size of face edge in the texture.
  28285. * @param options The options defining the texture.
  28286. * @returns The texture
  28287. */
  28288. createDepthStencilTexture(size: number | {
  28289. width: number;
  28290. height: number;
  28291. }, options: DepthTextureCreationOptions): InternalTexture;
  28292. /**
  28293. * Creates a depth stencil texture.
  28294. * This is only available in WebGL 2 or with the depth texture extension available.
  28295. * @param size The size of face edge in the texture.
  28296. * @param options The options defining the texture.
  28297. * @returns The texture
  28298. */
  28299. private _createDepthStencilTexture;
  28300. /**
  28301. * Creates a depth stencil cube texture.
  28302. * This is only available in WebGL 2.
  28303. * @param size The size of face edge in the cube texture.
  28304. * @param options The options defining the cube texture.
  28305. * @returns The cube texture
  28306. */
  28307. private _createDepthStencilCubeTexture;
  28308. /**
  28309. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28310. * @param renderTarget The render target to set the frame buffer for
  28311. */
  28312. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28313. /**
  28314. * Creates a new render target texture
  28315. * @param size defines the size of the texture
  28316. * @param options defines the options used to create the texture
  28317. * @returns a new render target texture stored in an InternalTexture
  28318. */
  28319. createRenderTargetTexture(size: number | {
  28320. width: number;
  28321. height: number;
  28322. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28323. /**
  28324. * Create a multi render target texture
  28325. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28326. * @param size defines the size of the texture
  28327. * @param options defines the creation options
  28328. * @returns the cube texture as an InternalTexture
  28329. */
  28330. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28331. private _setupFramebufferDepthAttachments;
  28332. /**
  28333. * Updates the sample count of a render target texture
  28334. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28335. * @param texture defines the texture to update
  28336. * @param samples defines the sample count to set
  28337. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28338. */
  28339. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28340. /**
  28341. * Update the sample count for a given multiple render target texture
  28342. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28343. * @param textures defines the textures to update
  28344. * @param samples defines the sample count to set
  28345. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28346. */
  28347. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28348. /** @hidden */
  28349. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28350. /** @hidden */
  28351. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28352. /** @hidden */
  28353. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28354. /** @hidden */
  28355. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28356. /**
  28357. * Creates a new render target cube texture
  28358. * @param size defines the size of the texture
  28359. * @param options defines the options used to create the texture
  28360. * @returns a new render target cube texture stored in an InternalTexture
  28361. */
  28362. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28363. /**
  28364. * Creates a cube texture
  28365. * @param rootUrl defines the url where the files to load is located
  28366. * @param scene defines the current scene
  28367. * @param files defines the list of files to load (1 per face)
  28368. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28369. * @param onLoad defines an optional callback raised when the texture is loaded
  28370. * @param onError defines an optional callback raised if there is an issue to load the texture
  28371. * @param format defines the format of the data
  28372. * @param forcedExtension defines the extension to use to pick the right loader
  28373. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28374. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28375. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28376. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28377. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28378. * @returns the cube texture as an InternalTexture
  28379. */
  28380. 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;
  28381. /**
  28382. * @hidden
  28383. */
  28384. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28385. /**
  28386. * Update a raw cube texture
  28387. * @param texture defines the texture to udpdate
  28388. * @param data defines the data to store
  28389. * @param format defines the data format
  28390. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28391. * @param invertY defines if data must be stored with Y axis inverted
  28392. * @param compression defines the compression used (null by default)
  28393. * @param level defines which level of the texture to update
  28394. */
  28395. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28396. /**
  28397. * Creates a new raw cube texture
  28398. * @param data defines the array of data to use to create each face
  28399. * @param size defines the size of the textures
  28400. * @param format defines the format of the data
  28401. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28402. * @param generateMipMaps defines if the engine should generate the mip levels
  28403. * @param invertY defines if data must be stored with Y axis inverted
  28404. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28405. * @param compression defines the compression used (null by default)
  28406. * @returns the cube texture as an InternalTexture
  28407. */
  28408. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28409. /**
  28410. * Creates a new raw cube texture from a specified url
  28411. * @param url defines the url where the data is located
  28412. * @param scene defines the current scene
  28413. * @param size defines the size of the textures
  28414. * @param format defines the format of the data
  28415. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28416. * @param noMipmap defines if the engine should avoid generating the mip levels
  28417. * @param callback defines a callback used to extract texture data from loaded data
  28418. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28419. * @param onLoad defines a callback called when texture is loaded
  28420. * @param onError defines a callback called if there is an error
  28421. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28422. * @param invertY defines if data must be stored with Y axis inverted
  28423. * @returns the cube texture as an InternalTexture
  28424. */
  28425. 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;
  28426. /**
  28427. * Update a raw 3D texture
  28428. * @param texture defines the texture to update
  28429. * @param data defines the data to store
  28430. * @param format defines the data format
  28431. * @param invertY defines if data must be stored with Y axis inverted
  28432. * @param compression defines the used compression (can be null)
  28433. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28434. */
  28435. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28436. /**
  28437. * Creates a new raw 3D texture
  28438. * @param data defines the data used to create the texture
  28439. * @param width defines the width of the texture
  28440. * @param height defines the height of the texture
  28441. * @param depth defines the depth of the texture
  28442. * @param format defines the format of the texture
  28443. * @param generateMipMaps defines if the engine must generate mip levels
  28444. * @param invertY defines if data must be stored with Y axis inverted
  28445. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28446. * @param compression defines the compressed used (can be null)
  28447. * @param textureType defines the compressed used (can be null)
  28448. * @returns a new raw 3D texture (stored in an InternalTexture)
  28449. */
  28450. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28451. private _prepareWebGLTextureContinuation;
  28452. private _prepareWebGLTexture;
  28453. private _convertRGBtoRGBATextureData;
  28454. /** @hidden */
  28455. _releaseFramebufferObjects(texture: InternalTexture): void;
  28456. /** @hidden */
  28457. _releaseTexture(texture: InternalTexture): void;
  28458. private setProgram;
  28459. private _boundUniforms;
  28460. /**
  28461. * Binds an effect to the webGL context
  28462. * @param effect defines the effect to bind
  28463. */
  28464. bindSamplers(effect: Effect): void;
  28465. private _moveBoundTextureOnTop;
  28466. private _getCorrectTextureChannel;
  28467. private _linkTrackers;
  28468. private _removeDesignatedSlot;
  28469. private _activateCurrentTexture;
  28470. /** @hidden */
  28471. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28472. /** @hidden */
  28473. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28474. /**
  28475. * Sets a texture to the webGL context from a postprocess
  28476. * @param channel defines the channel to use
  28477. * @param postProcess defines the source postprocess
  28478. */
  28479. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28480. /**
  28481. * Binds the output of the passed in post process to the texture channel specified
  28482. * @param channel The channel the texture should be bound to
  28483. * @param postProcess The post process which's output should be bound
  28484. */
  28485. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28486. /**
  28487. * Unbind all textures from the webGL context
  28488. */
  28489. unbindAllTextures(): void;
  28490. /**
  28491. * Sets a texture to the according uniform.
  28492. * @param channel The texture channel
  28493. * @param uniform The uniform to set
  28494. * @param texture The texture to apply
  28495. */
  28496. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28497. /**
  28498. * Sets a depth stencil texture from a render target to the according uniform.
  28499. * @param channel The texture channel
  28500. * @param uniform The uniform to set
  28501. * @param texture The render target texture containing the depth stencil texture to apply
  28502. */
  28503. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28504. private _bindSamplerUniformToChannel;
  28505. private _getTextureWrapMode;
  28506. private _setTexture;
  28507. /**
  28508. * Sets an array of texture to the webGL context
  28509. * @param channel defines the channel where the texture array must be set
  28510. * @param uniform defines the associated uniform location
  28511. * @param textures defines the array of textures to bind
  28512. */
  28513. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28514. /** @hidden */
  28515. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28516. private _setTextureParameterFloat;
  28517. private _setTextureParameterInteger;
  28518. /**
  28519. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28520. * @param x defines the x coordinate of the rectangle where pixels must be read
  28521. * @param y defines the y coordinate of the rectangle where pixels must be read
  28522. * @param width defines the width of the rectangle where pixels must be read
  28523. * @param height defines the height of the rectangle where pixels must be read
  28524. * @returns a Uint8Array containing RGBA colors
  28525. */
  28526. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28527. /**
  28528. * Add an externaly attached data from its key.
  28529. * This method call will fail and return false, if such key already exists.
  28530. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28531. * @param key the unique key that identifies the data
  28532. * @param data the data object to associate to the key for this Engine instance
  28533. * @return true if no such key were already present and the data was added successfully, false otherwise
  28534. */
  28535. addExternalData<T>(key: string, data: T): boolean;
  28536. /**
  28537. * Get an externaly attached data from its key
  28538. * @param key the unique key that identifies the data
  28539. * @return the associated data, if present (can be null), or undefined if not present
  28540. */
  28541. getExternalData<T>(key: string): T;
  28542. /**
  28543. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28544. * @param key the unique key that identifies the data
  28545. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28546. * @return the associated data, can be null if the factory returned null.
  28547. */
  28548. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28549. /**
  28550. * Remove an externaly attached data from the Engine instance
  28551. * @param key the unique key that identifies the data
  28552. * @return true if the data was successfully removed, false if it doesn't exist
  28553. */
  28554. removeExternalData(key: string): boolean;
  28555. /**
  28556. * Unbind all vertex attributes from the webGL context
  28557. */
  28558. unbindAllAttributes(): void;
  28559. /**
  28560. * 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
  28561. */
  28562. releaseEffects(): void;
  28563. /**
  28564. * Dispose and release all associated resources
  28565. */
  28566. dispose(): void;
  28567. /**
  28568. * Display the loading screen
  28569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28570. */
  28571. displayLoadingUI(): void;
  28572. /**
  28573. * Hide the loading screen
  28574. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28575. */
  28576. hideLoadingUI(): void;
  28577. /**
  28578. * Gets the current loading screen object
  28579. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28580. */
  28581. /**
  28582. * Sets the current loading screen object
  28583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28584. */
  28585. loadingScreen: ILoadingScreen;
  28586. /**
  28587. * Sets the current loading screen text
  28588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28589. */
  28590. loadingUIText: string;
  28591. /**
  28592. * Sets the current loading screen background color
  28593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28594. */
  28595. loadingUIBackgroundColor: string;
  28596. /**
  28597. * Attach a new callback raised when context lost event is fired
  28598. * @param callback defines the callback to call
  28599. */
  28600. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28601. /**
  28602. * Attach a new callback raised when context restored event is fired
  28603. * @param callback defines the callback to call
  28604. */
  28605. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28606. /**
  28607. * Gets the source code of the vertex shader associated with a specific webGL program
  28608. * @param program defines the program to use
  28609. * @returns a string containing the source code of the vertex shader associated with the program
  28610. */
  28611. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28612. /**
  28613. * Gets the source code of the fragment shader associated with a specific webGL program
  28614. * @param program defines the program to use
  28615. * @returns a string containing the source code of the fragment shader associated with the program
  28616. */
  28617. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28618. /**
  28619. * Get the current error code of the webGL context
  28620. * @returns the error code
  28621. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28622. */
  28623. getError(): number;
  28624. /**
  28625. * Gets the current framerate
  28626. * @returns a number representing the framerate
  28627. */
  28628. getFps(): number;
  28629. /**
  28630. * Gets the time spent between current and previous frame
  28631. * @returns a number representing the delta time in ms
  28632. */
  28633. getDeltaTime(): number;
  28634. private _measureFps;
  28635. /** @hidden */
  28636. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28637. private _canRenderToFloatFramebuffer;
  28638. private _canRenderToHalfFloatFramebuffer;
  28639. private _canRenderToFramebuffer;
  28640. /** @hidden */
  28641. _getWebGLTextureType(type: number): number;
  28642. private _getInternalFormat;
  28643. /** @hidden */
  28644. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28645. /** @hidden */
  28646. _getRGBAMultiSampleBufferFormat(type: number): number;
  28647. /** @hidden */
  28648. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28649. /** @hidden */
  28650. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28651. private _partialLoadFile;
  28652. private _cascadeLoadFiles;
  28653. /**
  28654. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28655. * @returns true if the engine can be created
  28656. * @ignorenaming
  28657. */
  28658. static isSupported(): boolean;
  28659. }
  28660. }
  28661. declare module BABYLON {
  28662. /**
  28663. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28664. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28665. */
  28666. export class EffectFallbacks {
  28667. private _defines;
  28668. private _currentRank;
  28669. private _maxRank;
  28670. private _mesh;
  28671. /**
  28672. * Removes the fallback from the bound mesh.
  28673. */
  28674. unBindMesh(): void;
  28675. /**
  28676. * Adds a fallback on the specified property.
  28677. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28678. * @param define The name of the define in the shader
  28679. */
  28680. addFallback(rank: number, define: string): void;
  28681. /**
  28682. * Sets the mesh to use CPU skinning when needing to fallback.
  28683. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28684. * @param mesh The mesh to use the fallbacks.
  28685. */
  28686. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28687. /**
  28688. * Checks to see if more fallbacks are still availible.
  28689. */
  28690. readonly isMoreFallbacks: boolean;
  28691. /**
  28692. * Removes the defines that shoould be removed when falling back.
  28693. * @param currentDefines defines the current define statements for the shader.
  28694. * @param effect defines the current effect we try to compile
  28695. * @returns The resulting defines with defines of the current rank removed.
  28696. */
  28697. reduce(currentDefines: string, effect: Effect): string;
  28698. }
  28699. /**
  28700. * Options to be used when creating an effect.
  28701. */
  28702. export class EffectCreationOptions {
  28703. /**
  28704. * Atrributes that will be used in the shader.
  28705. */
  28706. attributes: string[];
  28707. /**
  28708. * Uniform varible names that will be set in the shader.
  28709. */
  28710. uniformsNames: string[];
  28711. /**
  28712. * Uniform buffer varible names that will be set in the shader.
  28713. */
  28714. uniformBuffersNames: string[];
  28715. /**
  28716. * Sampler texture variable names that will be set in the shader.
  28717. */
  28718. samplers: string[];
  28719. /**
  28720. * Define statements that will be set in the shader.
  28721. */
  28722. defines: any;
  28723. /**
  28724. * Possible fallbacks for this effect to improve performance when needed.
  28725. */
  28726. fallbacks: Nullable<EffectFallbacks>;
  28727. /**
  28728. * Callback that will be called when the shader is compiled.
  28729. */
  28730. onCompiled: Nullable<(effect: Effect) => void>;
  28731. /**
  28732. * Callback that will be called if an error occurs during shader compilation.
  28733. */
  28734. onError: Nullable<(effect: Effect, errors: string) => void>;
  28735. /**
  28736. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28737. */
  28738. indexParameters: any;
  28739. /**
  28740. * Max number of lights that can be used in the shader.
  28741. */
  28742. maxSimultaneousLights: number;
  28743. /**
  28744. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28745. */
  28746. transformFeedbackVaryings: Nullable<string[]>;
  28747. }
  28748. /**
  28749. * Effect containing vertex and fragment shader that can be executed on an object.
  28750. */
  28751. export class Effect {
  28752. /**
  28753. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28754. */
  28755. static ShadersRepository: string;
  28756. /**
  28757. * Name of the effect.
  28758. */
  28759. name: any;
  28760. /**
  28761. * String container all the define statements that should be set on the shader.
  28762. */
  28763. defines: string;
  28764. /**
  28765. * Callback that will be called when the shader is compiled.
  28766. */
  28767. onCompiled: Nullable<(effect: Effect) => void>;
  28768. /**
  28769. * Callback that will be called if an error occurs during shader compilation.
  28770. */
  28771. onError: Nullable<(effect: Effect, errors: string) => void>;
  28772. /**
  28773. * Callback that will be called when effect is bound.
  28774. */
  28775. onBind: Nullable<(effect: Effect) => void>;
  28776. /**
  28777. * Unique ID of the effect.
  28778. */
  28779. uniqueId: number;
  28780. /**
  28781. * Observable that will be called when the shader is compiled.
  28782. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28783. */
  28784. onCompileObservable: Observable<Effect>;
  28785. /**
  28786. * Observable that will be called if an error occurs during shader compilation.
  28787. */
  28788. onErrorObservable: Observable<Effect>;
  28789. /** @hidden */
  28790. _onBindObservable: Nullable<Observable<Effect>>;
  28791. /**
  28792. * Observable that will be called when effect is bound.
  28793. */
  28794. readonly onBindObservable: Observable<Effect>;
  28795. /** @hidden */
  28796. _bonesComputationForcedToCPU: boolean;
  28797. private static _uniqueIdSeed;
  28798. private _engine;
  28799. private _uniformBuffersNames;
  28800. private _uniformsNames;
  28801. private _samplers;
  28802. private _isReady;
  28803. private _compilationError;
  28804. private _attributesNames;
  28805. private _attributes;
  28806. private _uniforms;
  28807. /**
  28808. * Key for the effect.
  28809. * @hidden
  28810. */
  28811. _key: string;
  28812. private _indexParameters;
  28813. private _fallbacks;
  28814. private _vertexSourceCode;
  28815. private _fragmentSourceCode;
  28816. private _vertexSourceCodeOverride;
  28817. private _fragmentSourceCodeOverride;
  28818. private _transformFeedbackVaryings;
  28819. /**
  28820. * Compiled shader to webGL program.
  28821. * @hidden
  28822. */
  28823. _program: WebGLProgram;
  28824. private _valueCache;
  28825. private static _baseCache;
  28826. /**
  28827. * Instantiates an effect.
  28828. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28829. * @param baseName Name of the effect.
  28830. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28831. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28832. * @param samplers List of sampler variables that will be passed to the shader.
  28833. * @param engine Engine to be used to render the effect
  28834. * @param defines Define statements to be added to the shader.
  28835. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28836. * @param onCompiled Callback that will be called when the shader is compiled.
  28837. * @param onError Callback that will be called if an error occurs during shader compilation.
  28838. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28839. */
  28840. 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);
  28841. /**
  28842. * Unique key for this effect
  28843. */
  28844. readonly key: string;
  28845. /**
  28846. * If the effect has been compiled and prepared.
  28847. * @returns if the effect is compiled and prepared.
  28848. */
  28849. isReady(): boolean;
  28850. /**
  28851. * The engine the effect was initialized with.
  28852. * @returns the engine.
  28853. */
  28854. getEngine(): Engine;
  28855. /**
  28856. * The compiled webGL program for the effect
  28857. * @returns the webGL program.
  28858. */
  28859. getProgram(): WebGLProgram;
  28860. /**
  28861. * The set of names of attribute variables for the shader.
  28862. * @returns An array of attribute names.
  28863. */
  28864. getAttributesNames(): string[];
  28865. /**
  28866. * Returns the attribute at the given index.
  28867. * @param index The index of the attribute.
  28868. * @returns The location of the attribute.
  28869. */
  28870. getAttributeLocation(index: number): number;
  28871. /**
  28872. * Returns the attribute based on the name of the variable.
  28873. * @param name of the attribute to look up.
  28874. * @returns the attribute location.
  28875. */
  28876. getAttributeLocationByName(name: string): number;
  28877. /**
  28878. * The number of attributes.
  28879. * @returns the numnber of attributes.
  28880. */
  28881. getAttributesCount(): number;
  28882. /**
  28883. * Gets the index of a uniform variable.
  28884. * @param uniformName of the uniform to look up.
  28885. * @returns the index.
  28886. */
  28887. getUniformIndex(uniformName: string): number;
  28888. /**
  28889. * Returns the attribute based on the name of the variable.
  28890. * @param uniformName of the uniform to look up.
  28891. * @returns the location of the uniform.
  28892. */
  28893. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28894. /**
  28895. * Returns an array of sampler variable names
  28896. * @returns The array of sampler variable neames.
  28897. */
  28898. getSamplers(): string[];
  28899. /**
  28900. * The error from the last compilation.
  28901. * @returns the error string.
  28902. */
  28903. getCompilationError(): string;
  28904. /**
  28905. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28906. * @param func The callback to be used.
  28907. */
  28908. executeWhenCompiled(func: (effect: Effect) => void): void;
  28909. private _checkIsReady;
  28910. /** @hidden */
  28911. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28912. /** @hidden */
  28913. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28914. /** @hidden */
  28915. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28916. private _processShaderConversion;
  28917. private _processIncludes;
  28918. private _processPrecision;
  28919. /**
  28920. * Recompiles the webGL program
  28921. * @param vertexSourceCode The source code for the vertex shader.
  28922. * @param fragmentSourceCode The source code for the fragment shader.
  28923. * @param onCompiled Callback called when completed.
  28924. * @param onError Callback called on error.
  28925. * @hidden
  28926. */
  28927. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28928. /**
  28929. * Gets the uniform locations of the the specified variable names
  28930. * @param names THe names of the variables to lookup.
  28931. * @returns Array of locations in the same order as variable names.
  28932. */
  28933. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28934. /**
  28935. * Prepares the effect
  28936. * @hidden
  28937. */
  28938. _prepareEffect(): void;
  28939. /**
  28940. * Checks if the effect is supported. (Must be called after compilation)
  28941. */
  28942. readonly isSupported: boolean;
  28943. /**
  28944. * Binds a texture to the engine to be used as output of the shader.
  28945. * @param channel Name of the output variable.
  28946. * @param texture Texture to bind.
  28947. * @hidden
  28948. */
  28949. _bindTexture(channel: string, texture: InternalTexture): void;
  28950. /**
  28951. * Sets a texture on the engine to be used in the shader.
  28952. * @param channel Name of the sampler variable.
  28953. * @param texture Texture to set.
  28954. */
  28955. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28956. /**
  28957. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28958. * @param channel Name of the sampler variable.
  28959. * @param texture Texture to set.
  28960. */
  28961. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28962. /**
  28963. * Sets an array of textures on the engine to be used in the shader.
  28964. * @param channel Name of the variable.
  28965. * @param textures Textures to set.
  28966. */
  28967. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28968. /**
  28969. * 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)
  28970. * @param channel Name of the sampler variable.
  28971. * @param postProcess Post process to get the input texture from.
  28972. */
  28973. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28974. /**
  28975. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28976. * 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)
  28977. * @param channel Name of the sampler variable.
  28978. * @param postProcess Post process to get the output texture from.
  28979. */
  28980. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28981. /** @hidden */
  28982. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28983. /** @hidden */
  28984. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28985. /** @hidden */
  28986. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28987. /** @hidden */
  28988. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28989. /**
  28990. * Binds a buffer to a uniform.
  28991. * @param buffer Buffer to bind.
  28992. * @param name Name of the uniform variable to bind to.
  28993. */
  28994. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28995. /**
  28996. * Binds block to a uniform.
  28997. * @param blockName Name of the block to bind.
  28998. * @param index Index to bind.
  28999. */
  29000. bindUniformBlock(blockName: string, index: number): void;
  29001. /**
  29002. * Sets an interger value on a uniform variable.
  29003. * @param uniformName Name of the variable.
  29004. * @param value Value to be set.
  29005. * @returns this effect.
  29006. */
  29007. setInt(uniformName: string, value: number): Effect;
  29008. /**
  29009. * Sets an int array on a uniform variable.
  29010. * @param uniformName Name of the variable.
  29011. * @param array array to be set.
  29012. * @returns this effect.
  29013. */
  29014. setIntArray(uniformName: string, array: Int32Array): Effect;
  29015. /**
  29016. * 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)
  29017. * @param uniformName Name of the variable.
  29018. * @param array array to be set.
  29019. * @returns this effect.
  29020. */
  29021. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29022. /**
  29023. * 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)
  29024. * @param uniformName Name of the variable.
  29025. * @param array array to be set.
  29026. * @returns this effect.
  29027. */
  29028. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29029. /**
  29030. * 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)
  29031. * @param uniformName Name of the variable.
  29032. * @param array array to be set.
  29033. * @returns this effect.
  29034. */
  29035. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29036. /**
  29037. * Sets an float array on a uniform variable.
  29038. * @param uniformName Name of the variable.
  29039. * @param array array to be set.
  29040. * @returns this effect.
  29041. */
  29042. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29043. /**
  29044. * 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)
  29045. * @param uniformName Name of the variable.
  29046. * @param array array to be set.
  29047. * @returns this effect.
  29048. */
  29049. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29050. /**
  29051. * 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)
  29052. * @param uniformName Name of the variable.
  29053. * @param array array to be set.
  29054. * @returns this effect.
  29055. */
  29056. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29057. /**
  29058. * 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)
  29059. * @param uniformName Name of the variable.
  29060. * @param array array to be set.
  29061. * @returns this effect.
  29062. */
  29063. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29064. /**
  29065. * Sets an array on a uniform variable.
  29066. * @param uniformName Name of the variable.
  29067. * @param array array to be set.
  29068. * @returns this effect.
  29069. */
  29070. setArray(uniformName: string, array: number[]): Effect;
  29071. /**
  29072. * 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)
  29073. * @param uniformName Name of the variable.
  29074. * @param array array to be set.
  29075. * @returns this effect.
  29076. */
  29077. setArray2(uniformName: string, array: number[]): Effect;
  29078. /**
  29079. * 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)
  29080. * @param uniformName Name of the variable.
  29081. * @param array array to be set.
  29082. * @returns this effect.
  29083. */
  29084. setArray3(uniformName: string, array: number[]): Effect;
  29085. /**
  29086. * 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)
  29087. * @param uniformName Name of the variable.
  29088. * @param array array to be set.
  29089. * @returns this effect.
  29090. */
  29091. setArray4(uniformName: string, array: number[]): Effect;
  29092. /**
  29093. * Sets matrices on a uniform variable.
  29094. * @param uniformName Name of the variable.
  29095. * @param matrices matrices to be set.
  29096. * @returns this effect.
  29097. */
  29098. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29099. /**
  29100. * Sets matrix on a uniform variable.
  29101. * @param uniformName Name of the variable.
  29102. * @param matrix matrix to be set.
  29103. * @returns this effect.
  29104. */
  29105. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29106. /**
  29107. * 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)
  29108. * @param uniformName Name of the variable.
  29109. * @param matrix matrix to be set.
  29110. * @returns this effect.
  29111. */
  29112. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29113. /**
  29114. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29115. * @param uniformName Name of the variable.
  29116. * @param matrix matrix to be set.
  29117. * @returns this effect.
  29118. */
  29119. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29120. /**
  29121. * Sets a float on a uniform variable.
  29122. * @param uniformName Name of the variable.
  29123. * @param value value to be set.
  29124. * @returns this effect.
  29125. */
  29126. setFloat(uniformName: string, value: number): Effect;
  29127. /**
  29128. * Sets a boolean on a uniform variable.
  29129. * @param uniformName Name of the variable.
  29130. * @param bool value to be set.
  29131. * @returns this effect.
  29132. */
  29133. setBool(uniformName: string, bool: boolean): Effect;
  29134. /**
  29135. * Sets a Vector2 on a uniform variable.
  29136. * @param uniformName Name of the variable.
  29137. * @param vector2 vector2 to be set.
  29138. * @returns this effect.
  29139. */
  29140. setVector2(uniformName: string, vector2: Vector2): Effect;
  29141. /**
  29142. * Sets a float2 on a uniform variable.
  29143. * @param uniformName Name of the variable.
  29144. * @param x First float in float2.
  29145. * @param y Second float in float2.
  29146. * @returns this effect.
  29147. */
  29148. setFloat2(uniformName: string, x: number, y: number): Effect;
  29149. /**
  29150. * Sets a Vector3 on a uniform variable.
  29151. * @param uniformName Name of the variable.
  29152. * @param vector3 Value to be set.
  29153. * @returns this effect.
  29154. */
  29155. setVector3(uniformName: string, vector3: Vector3): Effect;
  29156. /**
  29157. * Sets a float3 on a uniform variable.
  29158. * @param uniformName Name of the variable.
  29159. * @param x First float in float3.
  29160. * @param y Second float in float3.
  29161. * @param z Third float in float3.
  29162. * @returns this effect.
  29163. */
  29164. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29165. /**
  29166. * Sets a Vector4 on a uniform variable.
  29167. * @param uniformName Name of the variable.
  29168. * @param vector4 Value to be set.
  29169. * @returns this effect.
  29170. */
  29171. setVector4(uniformName: string, vector4: Vector4): Effect;
  29172. /**
  29173. * Sets a float4 on a uniform variable.
  29174. * @param uniformName Name of the variable.
  29175. * @param x First float in float4.
  29176. * @param y Second float in float4.
  29177. * @param z Third float in float4.
  29178. * @param w Fourth float in float4.
  29179. * @returns this effect.
  29180. */
  29181. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29182. /**
  29183. * Sets a Color3 on a uniform variable.
  29184. * @param uniformName Name of the variable.
  29185. * @param color3 Value to be set.
  29186. * @returns this effect.
  29187. */
  29188. setColor3(uniformName: string, color3: Color3): Effect;
  29189. /**
  29190. * Sets a Color4 on a uniform variable.
  29191. * @param uniformName Name of the variable.
  29192. * @param color3 Value to be set.
  29193. * @param alpha Alpha value to be set.
  29194. * @returns this effect.
  29195. */
  29196. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29197. /**
  29198. * Sets a Color4 on a uniform variable
  29199. * @param uniformName defines the name of the variable
  29200. * @param color4 defines the value to be set
  29201. * @returns this effect.
  29202. */
  29203. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29204. /**
  29205. * This function will add a new shader to the shader store
  29206. * @param name the name of the shader
  29207. * @param pixelShader optional pixel shader content
  29208. * @param vertexShader optional vertex shader content
  29209. */
  29210. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29211. /**
  29212. * Store of each shader (The can be looked up using effect.key)
  29213. */
  29214. static ShadersStore: {
  29215. [key: string]: string;
  29216. };
  29217. /**
  29218. * Store of each included file for a shader (The can be looked up using effect.key)
  29219. */
  29220. static IncludesShadersStore: {
  29221. [key: string]: string;
  29222. };
  29223. /**
  29224. * Resets the cache of effects.
  29225. */
  29226. static ResetCache(): void;
  29227. }
  29228. }
  29229. declare module BABYLON {
  29230. /**
  29231. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29232. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29233. * 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;
  29234. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29235. */
  29236. export class ColorCurves {
  29237. private _dirty;
  29238. private _tempColor;
  29239. private _globalCurve;
  29240. private _highlightsCurve;
  29241. private _midtonesCurve;
  29242. private _shadowsCurve;
  29243. private _positiveCurve;
  29244. private _negativeCurve;
  29245. private _globalHue;
  29246. private _globalDensity;
  29247. private _globalSaturation;
  29248. private _globalExposure;
  29249. /**
  29250. * Gets the global Hue value.
  29251. * 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).
  29252. */
  29253. /**
  29254. * Sets the global Hue value.
  29255. * 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).
  29256. */
  29257. globalHue: number;
  29258. /**
  29259. * Gets the global Density value.
  29260. * 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.
  29261. * Values less than zero provide a filter of opposite hue.
  29262. */
  29263. /**
  29264. * Sets the global Density value.
  29265. * 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.
  29266. * Values less than zero provide a filter of opposite hue.
  29267. */
  29268. globalDensity: number;
  29269. /**
  29270. * Gets the global Saturation value.
  29271. * 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.
  29272. */
  29273. /**
  29274. * Sets the global Saturation value.
  29275. * 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.
  29276. */
  29277. globalSaturation: number;
  29278. /**
  29279. * Gets the global Exposure value.
  29280. * 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.
  29281. */
  29282. /**
  29283. * Sets the global Exposure value.
  29284. * 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.
  29285. */
  29286. globalExposure: number;
  29287. private _highlightsHue;
  29288. private _highlightsDensity;
  29289. private _highlightsSaturation;
  29290. private _highlightsExposure;
  29291. /**
  29292. * Gets the highlights Hue value.
  29293. * 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).
  29294. */
  29295. /**
  29296. * Sets the highlights Hue value.
  29297. * 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).
  29298. */
  29299. highlightsHue: number;
  29300. /**
  29301. * Gets the highlights Density value.
  29302. * 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.
  29303. * Values less than zero provide a filter of opposite hue.
  29304. */
  29305. /**
  29306. * Sets the highlights Density value.
  29307. * 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.
  29308. * Values less than zero provide a filter of opposite hue.
  29309. */
  29310. highlightsDensity: number;
  29311. /**
  29312. * Gets the highlights Saturation value.
  29313. * 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.
  29314. */
  29315. /**
  29316. * Sets the highlights Saturation value.
  29317. * 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.
  29318. */
  29319. highlightsSaturation: number;
  29320. /**
  29321. * Gets the highlights Exposure value.
  29322. * 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.
  29323. */
  29324. /**
  29325. * Sets the highlights Exposure value.
  29326. * 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.
  29327. */
  29328. highlightsExposure: number;
  29329. private _midtonesHue;
  29330. private _midtonesDensity;
  29331. private _midtonesSaturation;
  29332. private _midtonesExposure;
  29333. /**
  29334. * Gets the midtones Hue value.
  29335. * 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).
  29336. */
  29337. /**
  29338. * Sets the midtones Hue value.
  29339. * 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).
  29340. */
  29341. midtonesHue: number;
  29342. /**
  29343. * Gets the midtones Density value.
  29344. * 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.
  29345. * Values less than zero provide a filter of opposite hue.
  29346. */
  29347. /**
  29348. * Sets the midtones Density value.
  29349. * 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.
  29350. * Values less than zero provide a filter of opposite hue.
  29351. */
  29352. midtonesDensity: number;
  29353. /**
  29354. * Gets the midtones Saturation value.
  29355. * 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.
  29356. */
  29357. /**
  29358. * Sets the midtones Saturation value.
  29359. * 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.
  29360. */
  29361. midtonesSaturation: number;
  29362. /**
  29363. * Gets the midtones Exposure value.
  29364. * 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.
  29365. */
  29366. /**
  29367. * Sets the midtones Exposure value.
  29368. * 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.
  29369. */
  29370. midtonesExposure: number;
  29371. private _shadowsHue;
  29372. private _shadowsDensity;
  29373. private _shadowsSaturation;
  29374. private _shadowsExposure;
  29375. /**
  29376. * Gets the shadows Hue value.
  29377. * 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).
  29378. */
  29379. /**
  29380. * Sets the shadows Hue value.
  29381. * 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).
  29382. */
  29383. shadowsHue: number;
  29384. /**
  29385. * Gets the shadows Density value.
  29386. * 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.
  29387. * Values less than zero provide a filter of opposite hue.
  29388. */
  29389. /**
  29390. * Sets the shadows Density value.
  29391. * 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.
  29392. * Values less than zero provide a filter of opposite hue.
  29393. */
  29394. shadowsDensity: number;
  29395. /**
  29396. * Gets the shadows Saturation value.
  29397. * 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.
  29398. */
  29399. /**
  29400. * Sets the shadows Saturation value.
  29401. * 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.
  29402. */
  29403. shadowsSaturation: number;
  29404. /**
  29405. * Gets the shadows Exposure value.
  29406. * 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.
  29407. */
  29408. /**
  29409. * Sets the shadows Exposure value.
  29410. * 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.
  29411. */
  29412. shadowsExposure: number;
  29413. /**
  29414. * Returns the class name
  29415. * @returns The class name
  29416. */
  29417. getClassName(): string;
  29418. /**
  29419. * Binds the color curves to the shader.
  29420. * @param colorCurves The color curve to bind
  29421. * @param effect The effect to bind to
  29422. * @param positiveUniform The positive uniform shader parameter
  29423. * @param neutralUniform The neutral uniform shader parameter
  29424. * @param negativeUniform The negative uniform shader parameter
  29425. */
  29426. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29427. /**
  29428. * Prepare the list of uniforms associated with the ColorCurves effects.
  29429. * @param uniformsList The list of uniforms used in the effect
  29430. */
  29431. static PrepareUniforms(uniformsList: string[]): void;
  29432. /**
  29433. * Returns color grading data based on a hue, density, saturation and exposure value.
  29434. * @param filterHue The hue of the color filter.
  29435. * @param filterDensity The density of the color filter.
  29436. * @param saturation The saturation.
  29437. * @param exposure The exposure.
  29438. * @param result The result data container.
  29439. */
  29440. private getColorGradingDataToRef;
  29441. /**
  29442. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29443. * @param value The input slider value in range [-100,100].
  29444. * @returns Adjusted value.
  29445. */
  29446. private static applyColorGradingSliderNonlinear;
  29447. /**
  29448. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29449. * @param hue The hue (H) input.
  29450. * @param saturation The saturation (S) input.
  29451. * @param brightness The brightness (B) input.
  29452. * @result An RGBA color represented as Vector4.
  29453. */
  29454. private static fromHSBToRef;
  29455. /**
  29456. * Returns a value clamped between min and max
  29457. * @param value The value to clamp
  29458. * @param min The minimum of value
  29459. * @param max The maximum of value
  29460. * @returns The clamped value.
  29461. */
  29462. private static clamp;
  29463. /**
  29464. * Clones the current color curve instance.
  29465. * @return The cloned curves
  29466. */
  29467. clone(): ColorCurves;
  29468. /**
  29469. * Serializes the current color curve instance to a json representation.
  29470. * @return a JSON representation
  29471. */
  29472. serialize(): any;
  29473. /**
  29474. * Parses the color curve from a json representation.
  29475. * @param source the JSON source to parse
  29476. * @return The parsed curves
  29477. */
  29478. static Parse(source: any): ColorCurves;
  29479. }
  29480. }
  29481. declare module BABYLON {
  29482. /**
  29483. * Interface to follow in your material defines to integrate easily the
  29484. * Image proccessing functions.
  29485. * @hidden
  29486. */
  29487. export interface IImageProcessingConfigurationDefines {
  29488. IMAGEPROCESSING: boolean;
  29489. VIGNETTE: boolean;
  29490. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29491. VIGNETTEBLENDMODEOPAQUE: boolean;
  29492. TONEMAPPING: boolean;
  29493. TONEMAPPING_ACES: boolean;
  29494. CONTRAST: boolean;
  29495. EXPOSURE: boolean;
  29496. COLORCURVES: boolean;
  29497. COLORGRADING: boolean;
  29498. COLORGRADING3D: boolean;
  29499. SAMPLER3DGREENDEPTH: boolean;
  29500. SAMPLER3DBGRMAP: boolean;
  29501. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29502. }
  29503. /**
  29504. * @hidden
  29505. */
  29506. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29507. IMAGEPROCESSING: boolean;
  29508. VIGNETTE: boolean;
  29509. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29510. VIGNETTEBLENDMODEOPAQUE: boolean;
  29511. TONEMAPPING: boolean;
  29512. TONEMAPPING_ACES: boolean;
  29513. CONTRAST: boolean;
  29514. COLORCURVES: boolean;
  29515. COLORGRADING: boolean;
  29516. COLORGRADING3D: boolean;
  29517. SAMPLER3DGREENDEPTH: boolean;
  29518. SAMPLER3DBGRMAP: boolean;
  29519. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29520. EXPOSURE: boolean;
  29521. constructor();
  29522. }
  29523. /**
  29524. * This groups together the common properties used for image processing either in direct forward pass
  29525. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29526. * or not.
  29527. */
  29528. export class ImageProcessingConfiguration {
  29529. /**
  29530. * Default tone mapping applied in BabylonJS.
  29531. */
  29532. static readonly TONEMAPPING_STANDARD: number;
  29533. /**
  29534. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29535. * to other engines rendering to increase portability.
  29536. */
  29537. static readonly TONEMAPPING_ACES: number;
  29538. /**
  29539. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29540. */
  29541. colorCurves: Nullable<ColorCurves>;
  29542. private _colorCurvesEnabled;
  29543. /**
  29544. * Gets wether the color curves effect is enabled.
  29545. */
  29546. /**
  29547. * Sets wether the color curves effect is enabled.
  29548. */
  29549. colorCurvesEnabled: boolean;
  29550. private _colorGradingTexture;
  29551. /**
  29552. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29553. */
  29554. /**
  29555. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29556. */
  29557. colorGradingTexture: Nullable<BaseTexture>;
  29558. private _colorGradingEnabled;
  29559. /**
  29560. * Gets wether the color grading effect is enabled.
  29561. */
  29562. /**
  29563. * Sets wether the color grading effect is enabled.
  29564. */
  29565. colorGradingEnabled: boolean;
  29566. private _colorGradingWithGreenDepth;
  29567. /**
  29568. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29569. */
  29570. /**
  29571. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29572. */
  29573. colorGradingWithGreenDepth: boolean;
  29574. private _colorGradingBGR;
  29575. /**
  29576. * Gets wether the color grading texture contains BGR values.
  29577. */
  29578. /**
  29579. * Sets wether the color grading texture contains BGR values.
  29580. */
  29581. colorGradingBGR: boolean;
  29582. /** @hidden */
  29583. _exposure: number;
  29584. /**
  29585. * Gets the Exposure used in the effect.
  29586. */
  29587. /**
  29588. * Sets the Exposure used in the effect.
  29589. */
  29590. exposure: number;
  29591. private _toneMappingEnabled;
  29592. /**
  29593. * Gets wether the tone mapping effect is enabled.
  29594. */
  29595. /**
  29596. * Sets wether the tone mapping effect is enabled.
  29597. */
  29598. toneMappingEnabled: boolean;
  29599. private _toneMappingType;
  29600. /**
  29601. * Gets the type of tone mapping effect.
  29602. */
  29603. /**
  29604. * Sets the type of tone mapping effect used in BabylonJS.
  29605. */
  29606. toneMappingType: number;
  29607. protected _contrast: number;
  29608. /**
  29609. * Gets the contrast used in the effect.
  29610. */
  29611. /**
  29612. * Sets the contrast used in the effect.
  29613. */
  29614. contrast: number;
  29615. /**
  29616. * Vignette stretch size.
  29617. */
  29618. vignetteStretch: number;
  29619. /**
  29620. * Vignette centre X Offset.
  29621. */
  29622. vignetteCentreX: number;
  29623. /**
  29624. * Vignette centre Y Offset.
  29625. */
  29626. vignetteCentreY: number;
  29627. /**
  29628. * Vignette weight or intensity of the vignette effect.
  29629. */
  29630. vignetteWeight: number;
  29631. /**
  29632. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29633. * if vignetteEnabled is set to true.
  29634. */
  29635. vignetteColor: Color4;
  29636. /**
  29637. * Camera field of view used by the Vignette effect.
  29638. */
  29639. vignetteCameraFov: number;
  29640. private _vignetteBlendMode;
  29641. /**
  29642. * Gets the vignette blend mode allowing different kind of effect.
  29643. */
  29644. /**
  29645. * Sets the vignette blend mode allowing different kind of effect.
  29646. */
  29647. vignetteBlendMode: number;
  29648. private _vignetteEnabled;
  29649. /**
  29650. * Gets wether the vignette effect is enabled.
  29651. */
  29652. /**
  29653. * Sets wether the vignette effect is enabled.
  29654. */
  29655. vignetteEnabled: boolean;
  29656. private _applyByPostProcess;
  29657. /**
  29658. * Gets wether the image processing is applied through a post process or not.
  29659. */
  29660. /**
  29661. * Sets wether the image processing is applied through a post process or not.
  29662. */
  29663. applyByPostProcess: boolean;
  29664. private _isEnabled;
  29665. /**
  29666. * Gets wether the image processing is enabled or not.
  29667. */
  29668. /**
  29669. * Sets wether the image processing is enabled or not.
  29670. */
  29671. isEnabled: boolean;
  29672. /**
  29673. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29674. */
  29675. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29676. /**
  29677. * Method called each time the image processing information changes requires to recompile the effect.
  29678. */
  29679. protected _updateParameters(): void;
  29680. /**
  29681. * Gets the current class name.
  29682. * @return "ImageProcessingConfiguration"
  29683. */
  29684. getClassName(): string;
  29685. /**
  29686. * Prepare the list of uniforms associated with the Image Processing effects.
  29687. * @param uniforms The list of uniforms used in the effect
  29688. * @param defines the list of defines currently in use
  29689. */
  29690. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29691. /**
  29692. * Prepare the list of samplers associated with the Image Processing effects.
  29693. * @param samplersList The list of uniforms used in the effect
  29694. * @param defines the list of defines currently in use
  29695. */
  29696. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29697. /**
  29698. * Prepare the list of defines associated to the shader.
  29699. * @param defines the list of defines to complete
  29700. * @param forPostProcess Define if we are currently in post process mode or not
  29701. */
  29702. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29703. /**
  29704. * Returns true if all the image processing information are ready.
  29705. * @returns True if ready, otherwise, false
  29706. */
  29707. isReady(): boolean;
  29708. /**
  29709. * Binds the image processing to the shader.
  29710. * @param effect The effect to bind to
  29711. * @param aspectRatio Define the current aspect ratio of the effect
  29712. */
  29713. bind(effect: Effect, aspectRatio?: number): void;
  29714. /**
  29715. * Clones the current image processing instance.
  29716. * @return The cloned image processing
  29717. */
  29718. clone(): ImageProcessingConfiguration;
  29719. /**
  29720. * Serializes the current image processing instance to a json representation.
  29721. * @return a JSON representation
  29722. */
  29723. serialize(): any;
  29724. /**
  29725. * Parses the image processing from a json representation.
  29726. * @param source the JSON source to parse
  29727. * @return The parsed image processing
  29728. */
  29729. static Parse(source: any): ImageProcessingConfiguration;
  29730. private static _VIGNETTEMODE_MULTIPLY;
  29731. private static _VIGNETTEMODE_OPAQUE;
  29732. /**
  29733. * Used to apply the vignette as a mix with the pixel color.
  29734. */
  29735. static readonly VIGNETTEMODE_MULTIPLY: number;
  29736. /**
  29737. * Used to apply the vignette as a replacement of the pixel color.
  29738. */
  29739. static readonly VIGNETTEMODE_OPAQUE: number;
  29740. }
  29741. }
  29742. declare module BABYLON {
  29743. /**
  29744. * This represents all the required information to add a fresnel effect on a material:
  29745. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29746. */
  29747. export class FresnelParameters {
  29748. private _isEnabled;
  29749. /**
  29750. * Define if the fresnel effect is enable or not.
  29751. */
  29752. isEnabled: boolean;
  29753. /**
  29754. * Define the color used on edges (grazing angle)
  29755. */
  29756. leftColor: Color3;
  29757. /**
  29758. * Define the color used on center
  29759. */
  29760. rightColor: Color3;
  29761. /**
  29762. * Define bias applied to computed fresnel term
  29763. */
  29764. bias: number;
  29765. /**
  29766. * Defined the power exponent applied to fresnel term
  29767. */
  29768. power: number;
  29769. /**
  29770. * Clones the current fresnel and its valuues
  29771. * @returns a clone fresnel configuration
  29772. */
  29773. clone(): FresnelParameters;
  29774. /**
  29775. * Serializes the current fresnel parameters to a JSON representation.
  29776. * @return the JSON serialization
  29777. */
  29778. serialize(): any;
  29779. /**
  29780. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29781. * @param parsedFresnelParameters Define the JSON representation
  29782. * @returns the parsed parameters
  29783. */
  29784. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29785. }
  29786. }
  29787. declare module BABYLON {
  29788. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29789. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29790. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29791. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29792. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29793. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29794. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29795. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29796. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29797. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29798. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29799. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29800. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29801. /**
  29802. * Decorator used to define property that can be serialized as reference to a camera
  29803. * @param sourceName defines the name of the property to decorate
  29804. */
  29805. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29806. /**
  29807. * Class used to help serialization objects
  29808. */
  29809. export class SerializationHelper {
  29810. /** hidden */
  29811. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29812. /** hidden */
  29813. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29814. /** hidden */
  29815. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29816. /** hidden */
  29817. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29818. /**
  29819. * Appends the serialized animations from the source animations
  29820. * @param source Source containing the animations
  29821. * @param destination Target to store the animations
  29822. */
  29823. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29824. /**
  29825. * Static function used to serialized a specific entity
  29826. * @param entity defines the entity to serialize
  29827. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29828. * @returns a JSON compatible object representing the serialization of the entity
  29829. */
  29830. static Serialize<T>(entity: T, serializationObject?: any): any;
  29831. /**
  29832. * Creates a new entity from a serialization data object
  29833. * @param creationFunction defines a function used to instanciated the new entity
  29834. * @param source defines the source serialization data
  29835. * @param scene defines the hosting scene
  29836. * @param rootUrl defines the root url for resources
  29837. * @returns a new entity
  29838. */
  29839. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29840. /**
  29841. * Clones an object
  29842. * @param creationFunction defines the function used to instanciate the new object
  29843. * @param source defines the source object
  29844. * @returns the cloned object
  29845. */
  29846. static Clone<T>(creationFunction: () => T, source: T): T;
  29847. /**
  29848. * Instanciates a new object based on a source one (some data will be shared between both object)
  29849. * @param creationFunction defines the function used to instanciate the new object
  29850. * @param source defines the source object
  29851. * @returns the new object
  29852. */
  29853. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29854. }
  29855. }
  29856. declare module BABYLON {
  29857. /**
  29858. * This is the base class of all the camera used in the application.
  29859. * @see http://doc.babylonjs.com/features/cameras
  29860. */
  29861. export class Camera extends Node {
  29862. /** @hidden */
  29863. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29864. /**
  29865. * This is the default projection mode used by the cameras.
  29866. * It helps recreating a feeling of perspective and better appreciate depth.
  29867. * This is the best way to simulate real life cameras.
  29868. */
  29869. static readonly PERSPECTIVE_CAMERA: number;
  29870. /**
  29871. * This helps creating camera with an orthographic mode.
  29872. * 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.
  29873. */
  29874. static readonly ORTHOGRAPHIC_CAMERA: number;
  29875. /**
  29876. * This is the default FOV mode for perspective cameras.
  29877. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29878. */
  29879. static readonly FOVMODE_VERTICAL_FIXED: number;
  29880. /**
  29881. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29882. */
  29883. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29884. /**
  29885. * This specifies ther is no need for a camera rig.
  29886. * Basically only one eye is rendered corresponding to the camera.
  29887. */
  29888. static readonly RIG_MODE_NONE: number;
  29889. /**
  29890. * Simulates a camera Rig with one blue eye and one red eye.
  29891. * This can be use with 3d blue and red glasses.
  29892. */
  29893. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29894. /**
  29895. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29896. */
  29897. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29898. /**
  29899. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29900. */
  29901. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29902. /**
  29903. * Defines that both eyes of the camera will be rendered over under each other.
  29904. */
  29905. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29906. /**
  29907. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29908. */
  29909. static readonly RIG_MODE_VR: number;
  29910. /**
  29911. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29912. */
  29913. static readonly RIG_MODE_WEBVR: number;
  29914. /**
  29915. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29916. */
  29917. static readonly RIG_MODE_CUSTOM: number;
  29918. /**
  29919. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29920. */
  29921. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29922. /**
  29923. * @hidden
  29924. * Might be removed once multiview will be a thing
  29925. */
  29926. static UseAlternateWebVRRendering: boolean;
  29927. /**
  29928. * Define the input manager associated with the camera.
  29929. */
  29930. inputs: CameraInputsManager<Camera>;
  29931. /** @hidden */
  29932. _position: Vector3;
  29933. /**
  29934. * Define the current local position of the camera in the scene
  29935. */
  29936. position: Vector3;
  29937. /**
  29938. * The vector the camera should consider as up.
  29939. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29940. */
  29941. upVector: Vector3;
  29942. /**
  29943. * Define the current limit on the left side for an orthographic camera
  29944. * In scene unit
  29945. */
  29946. orthoLeft: Nullable<number>;
  29947. /**
  29948. * Define the current limit on the right side for an orthographic camera
  29949. * In scene unit
  29950. */
  29951. orthoRight: Nullable<number>;
  29952. /**
  29953. * Define the current limit on the bottom side for an orthographic camera
  29954. * In scene unit
  29955. */
  29956. orthoBottom: Nullable<number>;
  29957. /**
  29958. * Define the current limit on the top side for an orthographic camera
  29959. * In scene unit
  29960. */
  29961. orthoTop: Nullable<number>;
  29962. /**
  29963. * Field Of View is set in Radians. (default is 0.8)
  29964. */
  29965. fov: number;
  29966. /**
  29967. * Define the minimum distance the camera can see from.
  29968. * This is important to note that the depth buffer are not infinite and the closer it starts
  29969. * the more your scene might encounter depth fighting issue.
  29970. */
  29971. minZ: number;
  29972. /**
  29973. * Define the maximum distance the camera can see to.
  29974. * This is important to note that the depth buffer are not infinite and the further it end
  29975. * the more your scene might encounter depth fighting issue.
  29976. */
  29977. maxZ: number;
  29978. /**
  29979. * Define the default inertia of the camera.
  29980. * This helps giving a smooth feeling to the camera movement.
  29981. */
  29982. inertia: number;
  29983. /**
  29984. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29985. */
  29986. mode: number;
  29987. /**
  29988. * Define wether the camera is intermediate.
  29989. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29990. */
  29991. isIntermediate: boolean;
  29992. /**
  29993. * Define the viewport of the camera.
  29994. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29995. */
  29996. viewport: Viewport;
  29997. /**
  29998. * Restricts the camera to viewing objects with the same layerMask.
  29999. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30000. */
  30001. layerMask: number;
  30002. /**
  30003. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30004. */
  30005. fovMode: number;
  30006. /**
  30007. * Rig mode of the camera.
  30008. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30009. * This is normally controlled byt the camera themselves as internal use.
  30010. */
  30011. cameraRigMode: number;
  30012. /**
  30013. * Defines the distance between both "eyes" in case of a RIG
  30014. */
  30015. interaxialDistance: number;
  30016. /**
  30017. * Defines if stereoscopic rendering is done side by side or over under.
  30018. */
  30019. isStereoscopicSideBySide: boolean;
  30020. /**
  30021. * 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
  30022. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30023. * else in the scene.
  30024. */
  30025. customRenderTargets: RenderTargetTexture[];
  30026. /**
  30027. * When set, the camera will render to this render target instead of the default canvas
  30028. */
  30029. outputRenderTarget: Nullable<RenderTargetTexture>;
  30030. /**
  30031. * Observable triggered when the camera view matrix has changed.
  30032. */
  30033. onViewMatrixChangedObservable: Observable<Camera>;
  30034. /**
  30035. * Observable triggered when the camera Projection matrix has changed.
  30036. */
  30037. onProjectionMatrixChangedObservable: Observable<Camera>;
  30038. /**
  30039. * Observable triggered when the inputs have been processed.
  30040. */
  30041. onAfterCheckInputsObservable: Observable<Camera>;
  30042. /**
  30043. * Observable triggered when reset has been called and applied to the camera.
  30044. */
  30045. onRestoreStateObservable: Observable<Camera>;
  30046. /** @hidden */
  30047. _cameraRigParams: any;
  30048. /** @hidden */
  30049. _rigCameras: Camera[];
  30050. /** @hidden */
  30051. _rigPostProcess: Nullable<PostProcess>;
  30052. protected _webvrViewMatrix: Matrix;
  30053. /** @hidden */
  30054. _skipRendering: boolean;
  30055. /** @hidden */
  30056. _alternateCamera: Camera;
  30057. /** @hidden */
  30058. _projectionMatrix: Matrix;
  30059. /** @hidden */
  30060. _postProcesses: Nullable<PostProcess>[];
  30061. /** @hidden */
  30062. _activeMeshes: SmartArray<AbstractMesh>;
  30063. protected _globalPosition: Vector3;
  30064. /** hidden */
  30065. _computedViewMatrix: Matrix;
  30066. private _doNotComputeProjectionMatrix;
  30067. private _transformMatrix;
  30068. private _frustumPlanes;
  30069. private _refreshFrustumPlanes;
  30070. private _storedFov;
  30071. private _stateStored;
  30072. /**
  30073. * Instantiates a new camera object.
  30074. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30075. * @see http://doc.babylonjs.com/features/cameras
  30076. * @param name Defines the name of the camera in the scene
  30077. * @param position Defines the position of the camera
  30078. * @param scene Defines the scene the camera belongs too
  30079. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30080. */
  30081. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30082. /**
  30083. * Store current camera state (fov, position, etc..)
  30084. * @returns the camera
  30085. */
  30086. storeState(): Camera;
  30087. /**
  30088. * Restores the camera state values if it has been stored. You must call storeState() first
  30089. */
  30090. protected _restoreStateValues(): boolean;
  30091. /**
  30092. * Restored camera state. You must call storeState() first.
  30093. * @returns true if restored and false otherwise
  30094. */
  30095. restoreState(): boolean;
  30096. /**
  30097. * Gets the class name of the camera.
  30098. * @returns the class name
  30099. */
  30100. getClassName(): string;
  30101. /** @hidden */
  30102. readonly _isCamera: boolean;
  30103. /**
  30104. * Gets a string representation of the camera useful for debug purpose.
  30105. * @param fullDetails Defines that a more verboe level of logging is required
  30106. * @returns the string representation
  30107. */
  30108. toString(fullDetails?: boolean): string;
  30109. /**
  30110. * Gets the current world space position of the camera.
  30111. */
  30112. readonly globalPosition: Vector3;
  30113. /**
  30114. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30115. * @returns the active meshe list
  30116. */
  30117. getActiveMeshes(): SmartArray<AbstractMesh>;
  30118. /**
  30119. * Check wether a mesh is part of the current active mesh list of the camera
  30120. * @param mesh Defines the mesh to check
  30121. * @returns true if active, false otherwise
  30122. */
  30123. isActiveMesh(mesh: Mesh): boolean;
  30124. /**
  30125. * Is this camera ready to be used/rendered
  30126. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30127. * @return true if the camera is ready
  30128. */
  30129. isReady(completeCheck?: boolean): boolean;
  30130. /** @hidden */
  30131. _initCache(): void;
  30132. /** @hidden */
  30133. _updateCache(ignoreParentClass?: boolean): void;
  30134. /** @hidden */
  30135. _isSynchronized(): boolean;
  30136. /** @hidden */
  30137. _isSynchronizedViewMatrix(): boolean;
  30138. /** @hidden */
  30139. _isSynchronizedProjectionMatrix(): boolean;
  30140. /**
  30141. * Attach the input controls to a specific dom element to get the input from.
  30142. * @param element Defines the element the controls should be listened from
  30143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30144. */
  30145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30146. /**
  30147. * Detach the current controls from the specified dom element.
  30148. * @param element Defines the element to stop listening the inputs from
  30149. */
  30150. detachControl(element: HTMLElement): void;
  30151. /**
  30152. * Update the camera state according to the different inputs gathered during the frame.
  30153. */
  30154. update(): void;
  30155. /** @hidden */
  30156. _checkInputs(): void;
  30157. /** @hidden */
  30158. readonly rigCameras: Camera[];
  30159. /**
  30160. * Gets the post process used by the rig cameras
  30161. */
  30162. readonly rigPostProcess: Nullable<PostProcess>;
  30163. /**
  30164. * Internal, gets the first post proces.
  30165. * @returns the first post process to be run on this camera.
  30166. */
  30167. _getFirstPostProcess(): Nullable<PostProcess>;
  30168. private _cascadePostProcessesToRigCams;
  30169. /**
  30170. * Attach a post process to the camera.
  30171. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30172. * @param postProcess The post process to attach to the camera
  30173. * @param insertAt The position of the post process in case several of them are in use in the scene
  30174. * @returns the position the post process has been inserted at
  30175. */
  30176. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30177. /**
  30178. * Detach a post process to the camera.
  30179. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30180. * @param postProcess The post process to detach from the camera
  30181. */
  30182. detachPostProcess(postProcess: PostProcess): void;
  30183. /**
  30184. * Gets the current world matrix of the camera
  30185. */
  30186. getWorldMatrix(): Matrix;
  30187. /** @hidden */
  30188. _getViewMatrix(): Matrix;
  30189. /**
  30190. * Gets the current view matrix of the camera.
  30191. * @param force forces the camera to recompute the matrix without looking at the cached state
  30192. * @returns the view matrix
  30193. */
  30194. getViewMatrix(force?: boolean): Matrix;
  30195. /**
  30196. * Freeze the projection matrix.
  30197. * It will prevent the cache check of the camera projection compute and can speed up perf
  30198. * if no parameter of the camera are meant to change
  30199. * @param projection Defines manually a projection if necessary
  30200. */
  30201. freezeProjectionMatrix(projection?: Matrix): void;
  30202. /**
  30203. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30204. */
  30205. unfreezeProjectionMatrix(): void;
  30206. /**
  30207. * Gets the current projection matrix of the camera.
  30208. * @param force forces the camera to recompute the matrix without looking at the cached state
  30209. * @returns the projection matrix
  30210. */
  30211. getProjectionMatrix(force?: boolean): Matrix;
  30212. /**
  30213. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30214. * @returns a Matrix
  30215. */
  30216. getTransformationMatrix(): Matrix;
  30217. private _updateFrustumPlanes;
  30218. /**
  30219. * Checks if a cullable object (mesh...) is in the camera frustum
  30220. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30221. * @param target The object to check
  30222. * @returns true if the object is in frustum otherwise false
  30223. */
  30224. isInFrustum(target: ICullable): boolean;
  30225. /**
  30226. * Checks if a cullable object (mesh...) is in the camera frustum
  30227. * Unlike isInFrustum this cheks the full bounding box
  30228. * @param target The object to check
  30229. * @returns true if the object is in frustum otherwise false
  30230. */
  30231. isCompletelyInFrustum(target: ICullable): boolean;
  30232. /**
  30233. * Gets a ray in the forward direction from the camera.
  30234. * @param length Defines the length of the ray to create
  30235. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30236. * @param origin Defines the start point of the ray which defaults to the camera position
  30237. * @returns the forward ray
  30238. */
  30239. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30240. /**
  30241. * Releases resources associated with this node.
  30242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30244. */
  30245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30246. /** @hidden */
  30247. _isLeftCamera: boolean;
  30248. /**
  30249. * Gets the left camera of a rig setup in case of Rigged Camera
  30250. */
  30251. readonly isLeftCamera: boolean;
  30252. /** @hidden */
  30253. _isRightCamera: boolean;
  30254. /**
  30255. * Gets the right camera of a rig setup in case of Rigged Camera
  30256. */
  30257. readonly isRightCamera: boolean;
  30258. /**
  30259. * Gets the left camera of a rig setup in case of Rigged Camera
  30260. */
  30261. readonly leftCamera: Nullable<FreeCamera>;
  30262. /**
  30263. * Gets the right camera of a rig setup in case of Rigged Camera
  30264. */
  30265. readonly rightCamera: Nullable<FreeCamera>;
  30266. /**
  30267. * Gets the left camera target of a rig setup in case of Rigged Camera
  30268. * @returns the target position
  30269. */
  30270. getLeftTarget(): Nullable<Vector3>;
  30271. /**
  30272. * Gets the right camera target of a rig setup in case of Rigged Camera
  30273. * @returns the target position
  30274. */
  30275. getRightTarget(): Nullable<Vector3>;
  30276. /**
  30277. * @hidden
  30278. */
  30279. setCameraRigMode(mode: number, rigParams: any): void;
  30280. /** @hidden */
  30281. static _setStereoscopicRigMode(camera: Camera): void;
  30282. /** @hidden */
  30283. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30284. /** @hidden */
  30285. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30286. /** @hidden */
  30287. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30288. /** @hidden */
  30289. _getVRProjectionMatrix(): Matrix;
  30290. protected _updateCameraRotationMatrix(): void;
  30291. protected _updateWebVRCameraRotationMatrix(): void;
  30292. /**
  30293. * This function MUST be overwritten by the different WebVR cameras available.
  30294. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30295. * @hidden
  30296. */
  30297. _getWebVRProjectionMatrix(): Matrix;
  30298. /**
  30299. * This function MUST be overwritten by the different WebVR cameras available.
  30300. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30301. * @hidden
  30302. */
  30303. _getWebVRViewMatrix(): Matrix;
  30304. /** @hidden */
  30305. setCameraRigParameter(name: string, value: any): void;
  30306. /**
  30307. * needs to be overridden by children so sub has required properties to be copied
  30308. * @hidden
  30309. */
  30310. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30311. /**
  30312. * May need to be overridden by children
  30313. * @hidden
  30314. */
  30315. _updateRigCameras(): void;
  30316. /** @hidden */
  30317. _setupInputs(): void;
  30318. /**
  30319. * Serialiaze the camera setup to a json represention
  30320. * @returns the JSON representation
  30321. */
  30322. serialize(): any;
  30323. /**
  30324. * Clones the current camera.
  30325. * @param name The cloned camera name
  30326. * @returns the cloned camera
  30327. */
  30328. clone(name: string): Camera;
  30329. /**
  30330. * Gets the direction of the camera relative to a given local axis.
  30331. * @param localAxis Defines the reference axis to provide a relative direction.
  30332. * @return the direction
  30333. */
  30334. getDirection(localAxis: Vector3): Vector3;
  30335. /**
  30336. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30337. * @param localAxis Defines the reference axis to provide a relative direction.
  30338. * @param result Defines the vector to store the result in
  30339. */
  30340. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30341. /**
  30342. * Gets a camera constructor for a given camera type
  30343. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30344. * @param name The name of the camera the result will be able to instantiate
  30345. * @param scene The scene the result will construct the camera in
  30346. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30347. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30348. * @returns a factory method to construc the camera
  30349. */
  30350. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30351. /**
  30352. * Compute the world matrix of the camera.
  30353. * @returns the camera workd matrix
  30354. */
  30355. computeWorldMatrix(): Matrix;
  30356. /**
  30357. * Parse a JSON and creates the camera from the parsed information
  30358. * @param parsedCamera The JSON to parse
  30359. * @param scene The scene to instantiate the camera in
  30360. * @returns the newly constructed camera
  30361. */
  30362. static Parse(parsedCamera: any, scene: Scene): Camera;
  30363. }
  30364. }
  30365. declare module BABYLON {
  30366. /**
  30367. * Interface for any object that can request an animation frame
  30368. */
  30369. export interface ICustomAnimationFrameRequester {
  30370. /**
  30371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30372. */
  30373. renderFunction?: Function;
  30374. /**
  30375. * Called to request the next frame to render to
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30377. */
  30378. requestAnimationFrame: Function;
  30379. /**
  30380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30382. */
  30383. requestID?: number;
  30384. }
  30385. /**
  30386. * Interface containing an array of animations
  30387. */
  30388. export interface IAnimatable {
  30389. /**
  30390. * Array of animations
  30391. */
  30392. animations: Array<Animation>;
  30393. }
  30394. /** Interface used by value gradients (color, factor, ...) */
  30395. export interface IValueGradient {
  30396. /**
  30397. * Gets or sets the gradient value (between 0 and 1)
  30398. */
  30399. gradient: number;
  30400. }
  30401. /** Class used to store color4 gradient */
  30402. export class ColorGradient implements IValueGradient {
  30403. /**
  30404. * Gets or sets the gradient value (between 0 and 1)
  30405. */
  30406. gradient: number;
  30407. /**
  30408. * Gets or sets first associated color
  30409. */
  30410. color1: Color4;
  30411. /**
  30412. * Gets or sets second associated color
  30413. */
  30414. color2?: Color4;
  30415. /**
  30416. * Will get a color picked randomly between color1 and color2.
  30417. * If color2 is undefined then color1 will be used
  30418. * @param result defines the target Color4 to store the result in
  30419. */
  30420. getColorToRef(result: Color4): void;
  30421. }
  30422. /** Class used to store color 3 gradient */
  30423. export class Color3Gradient implements IValueGradient {
  30424. /**
  30425. * Gets or sets the gradient value (between 0 and 1)
  30426. */
  30427. gradient: number;
  30428. /**
  30429. * Gets or sets the associated color
  30430. */
  30431. color: Color3;
  30432. }
  30433. /** Class used to store factor gradient */
  30434. export class FactorGradient implements IValueGradient {
  30435. /**
  30436. * Gets or sets the gradient value (between 0 and 1)
  30437. */
  30438. gradient: number;
  30439. /**
  30440. * Gets or sets first associated factor
  30441. */
  30442. factor1: number;
  30443. /**
  30444. * Gets or sets second associated factor
  30445. */
  30446. factor2?: number;
  30447. /**
  30448. * Will get a number picked randomly between factor1 and factor2.
  30449. * If factor2 is undefined then factor1 will be used
  30450. * @returns the picked number
  30451. */
  30452. getFactor(): number;
  30453. }
  30454. /**
  30455. * @ignore
  30456. * Application error to support additional information when loading a file
  30457. */
  30458. export class LoadFileError extends Error {
  30459. /** defines the optional web request */
  30460. request?: WebRequest | undefined;
  30461. private static _setPrototypeOf;
  30462. /**
  30463. * Creates a new LoadFileError
  30464. * @param message defines the message of the error
  30465. * @param request defines the optional web request
  30466. */
  30467. constructor(message: string,
  30468. /** defines the optional web request */
  30469. request?: WebRequest | undefined);
  30470. }
  30471. /**
  30472. * Class used to define a retry strategy when error happens while loading assets
  30473. */
  30474. export class RetryStrategy {
  30475. /**
  30476. * Function used to defines an exponential back off strategy
  30477. * @param maxRetries defines the maximum number of retries (3 by default)
  30478. * @param baseInterval defines the interval between retries
  30479. * @returns the strategy function to use
  30480. */
  30481. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30482. }
  30483. /**
  30484. * File request interface
  30485. */
  30486. export interface IFileRequest {
  30487. /**
  30488. * Raised when the request is complete (success or error).
  30489. */
  30490. onCompleteObservable: Observable<IFileRequest>;
  30491. /**
  30492. * Aborts the request for a file.
  30493. */
  30494. abort: () => void;
  30495. }
  30496. /**
  30497. * Class containing a set of static utilities functions
  30498. */
  30499. export class Tools {
  30500. /**
  30501. * Gets or sets the base URL to use to load assets
  30502. */
  30503. static BaseUrl: string;
  30504. /**
  30505. * Enable/Disable Custom HTTP Request Headers globally.
  30506. * default = false
  30507. * @see CustomRequestHeaders
  30508. */
  30509. static UseCustomRequestHeaders: boolean;
  30510. /**
  30511. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30512. * i.e. when loading files, where the server/service expects an Authorization header
  30513. */
  30514. static CustomRequestHeaders: {
  30515. [key: string]: string;
  30516. };
  30517. /**
  30518. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30519. */
  30520. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30521. /**
  30522. * Default behaviour for cors in the application.
  30523. * It can be a string if the expected behavior is identical in the entire app.
  30524. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30525. */
  30526. static CorsBehavior: string | ((url: string | string[]) => string);
  30527. /**
  30528. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30529. * @ignorenaming
  30530. */
  30531. static UseFallbackTexture: boolean;
  30532. /**
  30533. * Use this object to register external classes like custom textures or material
  30534. * to allow the laoders to instantiate them
  30535. */
  30536. static RegisteredExternalClasses: {
  30537. [key: string]: Object;
  30538. };
  30539. /**
  30540. * Texture content used if a texture cannot loaded
  30541. * @ignorenaming
  30542. */
  30543. static fallbackTexture: string;
  30544. /**
  30545. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30546. * @param u defines the coordinate on X axis
  30547. * @param v defines the coordinate on Y axis
  30548. * @param width defines the width of the source data
  30549. * @param height defines the height of the source data
  30550. * @param pixels defines the source byte array
  30551. * @param color defines the output color
  30552. */
  30553. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30554. /**
  30555. * Interpolates between a and b via alpha
  30556. * @param a The lower value (returned when alpha = 0)
  30557. * @param b The upper value (returned when alpha = 1)
  30558. * @param alpha The interpolation-factor
  30559. * @return The mixed value
  30560. */
  30561. static Mix(a: number, b: number, alpha: number): number;
  30562. /**
  30563. * Tries to instantiate a new object from a given class name
  30564. * @param className defines the class name to instantiate
  30565. * @returns the new object or null if the system was not able to do the instantiation
  30566. */
  30567. static Instantiate(className: string): any;
  30568. /**
  30569. * Provides a slice function that will work even on IE
  30570. * @param data defines the array to slice
  30571. * @param start defines the start of the data (optional)
  30572. * @param end defines the end of the data (optional)
  30573. * @returns the new sliced array
  30574. */
  30575. static Slice<T>(data: T, start?: number, end?: number): T;
  30576. /**
  30577. * Polyfill for setImmediate
  30578. * @param action defines the action to execute after the current execution block
  30579. */
  30580. static SetImmediate(action: () => void): void;
  30581. /**
  30582. * Function indicating if a number is an exponent of 2
  30583. * @param value defines the value to test
  30584. * @returns true if the value is an exponent of 2
  30585. */
  30586. static IsExponentOfTwo(value: number): boolean;
  30587. private static _tmpFloatArray;
  30588. /**
  30589. * Returns the nearest 32-bit single precision float representation of a Number
  30590. * @param value A Number. If the parameter is of a different type, it will get converted
  30591. * to a number or to NaN if it cannot be converted
  30592. * @returns number
  30593. */
  30594. static FloatRound(value: number): number;
  30595. /**
  30596. * Find the next highest power of two.
  30597. * @param x Number to start search from.
  30598. * @return Next highest power of two.
  30599. */
  30600. static CeilingPOT(x: number): number;
  30601. /**
  30602. * Find the next lowest power of two.
  30603. * @param x Number to start search from.
  30604. * @return Next lowest power of two.
  30605. */
  30606. static FloorPOT(x: number): number;
  30607. /**
  30608. * Find the nearest power of two.
  30609. * @param x Number to start search from.
  30610. * @return Next nearest power of two.
  30611. */
  30612. static NearestPOT(x: number): number;
  30613. /**
  30614. * Get the closest exponent of two
  30615. * @param value defines the value to approximate
  30616. * @param max defines the maximum value to return
  30617. * @param mode defines how to define the closest value
  30618. * @returns closest exponent of two of the given value
  30619. */
  30620. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30621. /**
  30622. * Extracts the filename from a path
  30623. * @param path defines the path to use
  30624. * @returns the filename
  30625. */
  30626. static GetFilename(path: string): string;
  30627. /**
  30628. * Extracts the "folder" part of a path (everything before the filename).
  30629. * @param uri The URI to extract the info from
  30630. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30631. * @returns The "folder" part of the path
  30632. */
  30633. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30634. /**
  30635. * Extracts text content from a DOM element hierarchy
  30636. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30637. */
  30638. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30639. /**
  30640. * Convert an angle in radians to degrees
  30641. * @param angle defines the angle to convert
  30642. * @returns the angle in degrees
  30643. */
  30644. static ToDegrees(angle: number): number;
  30645. /**
  30646. * Convert an angle in degrees to radians
  30647. * @param angle defines the angle to convert
  30648. * @returns the angle in radians
  30649. */
  30650. static ToRadians(angle: number): number;
  30651. /**
  30652. * Encode a buffer to a base64 string
  30653. * @param buffer defines the buffer to encode
  30654. * @returns the encoded string
  30655. */
  30656. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30657. /**
  30658. * Extracts minimum and maximum values from a list of indexed positions
  30659. * @param positions defines the positions to use
  30660. * @param indices defines the indices to the positions
  30661. * @param indexStart defines the start index
  30662. * @param indexCount defines the end index
  30663. * @param bias defines bias value to add to the result
  30664. * @return minimum and maximum values
  30665. */
  30666. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30667. minimum: Vector3;
  30668. maximum: Vector3;
  30669. };
  30670. /**
  30671. * Extracts minimum and maximum values from a list of positions
  30672. * @param positions defines the positions to use
  30673. * @param start defines the start index in the positions array
  30674. * @param count defines the number of positions to handle
  30675. * @param bias defines bias value to add to the result
  30676. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30677. * @return minimum and maximum values
  30678. */
  30679. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30680. minimum: Vector3;
  30681. maximum: Vector3;
  30682. };
  30683. /**
  30684. * Returns an array if obj is not an array
  30685. * @param obj defines the object to evaluate as an array
  30686. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30687. * @returns either obj directly if obj is an array or a new array containing obj
  30688. */
  30689. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30690. /**
  30691. * Gets the pointer prefix to use
  30692. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30693. */
  30694. static GetPointerPrefix(): string;
  30695. /**
  30696. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30697. * @param func - the function to be called
  30698. * @param requester - the object that will request the next frame. Falls back to window.
  30699. * @returns frame number
  30700. */
  30701. static QueueNewFrame(func: () => void, requester?: any): number;
  30702. /**
  30703. * Ask the browser to promote the current element to fullscreen rendering mode
  30704. * @param element defines the DOM element to promote
  30705. */
  30706. static RequestFullscreen(element: HTMLElement): void;
  30707. /**
  30708. * Asks the browser to exit fullscreen mode
  30709. */
  30710. static ExitFullscreen(): void;
  30711. /**
  30712. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30713. * @param url define the url we are trying
  30714. * @param element define the dom element where to configure the cors policy
  30715. */
  30716. static SetCorsBehavior(url: string | string[], element: {
  30717. crossOrigin: string | null;
  30718. }): void;
  30719. /**
  30720. * Removes unwanted characters from an url
  30721. * @param url defines the url to clean
  30722. * @returns the cleaned url
  30723. */
  30724. static CleanUrl(url: string): string;
  30725. /**
  30726. * Gets or sets a function used to pre-process url before using them to load assets
  30727. */
  30728. static PreprocessUrl: (url: string) => string;
  30729. /**
  30730. * Loads an image as an HTMLImageElement.
  30731. * @param input url string, ArrayBuffer, or Blob to load
  30732. * @param onLoad callback called when the image successfully loads
  30733. * @param onError callback called when the image fails to load
  30734. * @param offlineProvider offline provider for caching
  30735. * @returns the HTMLImageElement of the loaded image
  30736. */
  30737. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30738. /**
  30739. * Loads a file
  30740. * @param url url string, ArrayBuffer, or Blob to load
  30741. * @param onSuccess callback called when the file successfully loads
  30742. * @param onProgress callback called while file is loading (if the server supports this mode)
  30743. * @param offlineProvider defines the offline provider for caching
  30744. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30745. * @param onError callback called when the file fails to load
  30746. * @returns a file request object
  30747. */
  30748. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30749. /**
  30750. * Load a script (identified by an url). When the url returns, the
  30751. * content of this file is added into a new script element, attached to the DOM (body element)
  30752. * @param scriptUrl defines the url of the script to laod
  30753. * @param onSuccess defines the callback called when the script is loaded
  30754. * @param onError defines the callback to call if an error occurs
  30755. */
  30756. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30757. /**
  30758. * Loads a file from a blob
  30759. * @param fileToLoad defines the blob to use
  30760. * @param callback defines the callback to call when data is loaded
  30761. * @param progressCallback defines the callback to call during loading process
  30762. * @returns a file request object
  30763. */
  30764. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30765. /**
  30766. * Loads a file
  30767. * @param fileToLoad defines the file to load
  30768. * @param callback defines the callback to call when data is loaded
  30769. * @param progressCallBack defines the callback to call during loading process
  30770. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30771. * @returns a file request object
  30772. */
  30773. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30774. /**
  30775. * Creates a data url from a given string content
  30776. * @param content defines the content to convert
  30777. * @returns the new data url link
  30778. */
  30779. static FileAsURL(content: string): string;
  30780. /**
  30781. * Format the given number to a specific decimal format
  30782. * @param value defines the number to format
  30783. * @param decimals defines the number of decimals to use
  30784. * @returns the formatted string
  30785. */
  30786. static Format(value: number, decimals?: number): string;
  30787. /**
  30788. * Checks if a given vector is inside a specific range
  30789. * @param v defines the vector to test
  30790. * @param min defines the minimum range
  30791. * @param max defines the maximum range
  30792. */
  30793. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30794. /**
  30795. * Tries to copy an object by duplicating every property
  30796. * @param source defines the source object
  30797. * @param destination defines the target object
  30798. * @param doNotCopyList defines a list of properties to avoid
  30799. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30800. */
  30801. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30802. /**
  30803. * Gets a boolean indicating if the given object has no own property
  30804. * @param obj defines the object to test
  30805. * @returns true if object has no own property
  30806. */
  30807. static IsEmpty(obj: any): boolean;
  30808. /**
  30809. * Function used to register events at window level
  30810. * @param events defines the events to register
  30811. */
  30812. static RegisterTopRootEvents(events: {
  30813. name: string;
  30814. handler: Nullable<(e: FocusEvent) => any>;
  30815. }[]): void;
  30816. /**
  30817. * Function used to unregister events from window level
  30818. * @param events defines the events to unregister
  30819. */
  30820. static UnregisterTopRootEvents(events: {
  30821. name: string;
  30822. handler: Nullable<(e: FocusEvent) => any>;
  30823. }[]): void;
  30824. /**
  30825. * @ignore
  30826. */
  30827. static _ScreenshotCanvas: HTMLCanvasElement;
  30828. /**
  30829. * Dumps the current bound framebuffer
  30830. * @param width defines the rendering width
  30831. * @param height defines the rendering height
  30832. * @param engine defines the hosting engine
  30833. * @param successCallback defines the callback triggered once the data are available
  30834. * @param mimeType defines the mime type of the result
  30835. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30836. */
  30837. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30838. /**
  30839. * Converts the canvas data to blob.
  30840. * This acts as a polyfill for browsers not supporting the to blob function.
  30841. * @param canvas Defines the canvas to extract the data from
  30842. * @param successCallback Defines the callback triggered once the data are available
  30843. * @param mimeType Defines the mime type of the result
  30844. */
  30845. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30846. /**
  30847. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30848. * @param successCallback defines the callback triggered once the data are available
  30849. * @param mimeType defines the mime type of the result
  30850. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30851. */
  30852. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30853. /**
  30854. * Downloads a blob in the browser
  30855. * @param blob defines the blob to download
  30856. * @param fileName defines the name of the downloaded file
  30857. */
  30858. static Download(blob: Blob, fileName: string): void;
  30859. /**
  30860. * Captures a screenshot of the current rendering
  30861. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30862. * @param engine defines the rendering engine
  30863. * @param camera defines the source camera
  30864. * @param size This parameter can be set to a single number or to an object with the
  30865. * following (optional) properties: precision, width, height. If a single number is passed,
  30866. * it will be used for both width and height. If an object is passed, the screenshot size
  30867. * will be derived from the parameters. The precision property is a multiplier allowing
  30868. * rendering at a higher or lower resolution
  30869. * @param successCallback defines the callback receives a single parameter which contains the
  30870. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30871. * src parameter of an <img> to display it
  30872. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30873. * Check your browser for supported MIME types
  30874. */
  30875. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30876. /**
  30877. * Generates an image screenshot from the specified camera.
  30878. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30879. * @param engine The engine to use for rendering
  30880. * @param camera The camera to use for rendering
  30881. * @param size This parameter can be set to a single number or to an object with the
  30882. * following (optional) properties: precision, width, height. If a single number is passed,
  30883. * it will be used for both width and height. If an object is passed, the screenshot size
  30884. * will be derived from the parameters. The precision property is a multiplier allowing
  30885. * rendering at a higher or lower resolution
  30886. * @param successCallback The callback receives a single parameter which contains the
  30887. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30888. * src parameter of an <img> to display it
  30889. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30890. * Check your browser for supported MIME types
  30891. * @param samples Texture samples (default: 1)
  30892. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30893. * @param fileName A name for for the downloaded file.
  30894. */
  30895. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30896. /**
  30897. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30898. * Be aware Math.random() could cause collisions, but:
  30899. * "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"
  30900. * @returns a pseudo random id
  30901. */
  30902. static RandomId(): string;
  30903. /**
  30904. * Test if the given uri is a base64 string
  30905. * @param uri The uri to test
  30906. * @return True if the uri is a base64 string or false otherwise
  30907. */
  30908. static IsBase64(uri: string): boolean;
  30909. /**
  30910. * Decode the given base64 uri.
  30911. * @param uri The uri to decode
  30912. * @return The decoded base64 data.
  30913. */
  30914. static DecodeBase64(uri: string): ArrayBuffer;
  30915. /**
  30916. * No log
  30917. */
  30918. static readonly NoneLogLevel: number;
  30919. /**
  30920. * Only message logs
  30921. */
  30922. static readonly MessageLogLevel: number;
  30923. /**
  30924. * Only warning logs
  30925. */
  30926. static readonly WarningLogLevel: number;
  30927. /**
  30928. * Only error logs
  30929. */
  30930. static readonly ErrorLogLevel: number;
  30931. /**
  30932. * All logs
  30933. */
  30934. static readonly AllLogLevel: number;
  30935. /**
  30936. * Gets a value indicating the number of loading errors
  30937. * @ignorenaming
  30938. */
  30939. static readonly errorsCount: number;
  30940. /**
  30941. * Callback called when a new log is added
  30942. */
  30943. static OnNewCacheEntry: (entry: string) => void;
  30944. /**
  30945. * Log a message to the console
  30946. * @param message defines the message to log
  30947. */
  30948. static Log(message: string): void;
  30949. /**
  30950. * Write a warning message to the console
  30951. * @param message defines the message to log
  30952. */
  30953. static Warn(message: string): void;
  30954. /**
  30955. * Write an error message to the console
  30956. * @param message defines the message to log
  30957. */
  30958. static Error(message: string): void;
  30959. /**
  30960. * Gets current log cache (list of logs)
  30961. */
  30962. static readonly LogCache: string;
  30963. /**
  30964. * Clears the log cache
  30965. */
  30966. static ClearLogCache(): void;
  30967. /**
  30968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30969. */
  30970. static LogLevels: number;
  30971. /**
  30972. * Checks if the loaded document was accessed via `file:`-Protocol.
  30973. * @returns boolean
  30974. */
  30975. static IsFileURL(): boolean;
  30976. /**
  30977. * Checks if the window object exists
  30978. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30979. */
  30980. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30981. /**
  30982. * No performance log
  30983. */
  30984. static readonly PerformanceNoneLogLevel: number;
  30985. /**
  30986. * Use user marks to log performance
  30987. */
  30988. static readonly PerformanceUserMarkLogLevel: number;
  30989. /**
  30990. * Log performance to the console
  30991. */
  30992. static readonly PerformanceConsoleLogLevel: number;
  30993. private static _performance;
  30994. /**
  30995. * Sets the current performance log level
  30996. */
  30997. static PerformanceLogLevel: number;
  30998. private static _StartPerformanceCounterDisabled;
  30999. private static _EndPerformanceCounterDisabled;
  31000. private static _StartUserMark;
  31001. private static _EndUserMark;
  31002. private static _StartPerformanceConsole;
  31003. private static _EndPerformanceConsole;
  31004. /**
  31005. * Starts a performance counter
  31006. */
  31007. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31008. /**
  31009. * Ends a specific performance coutner
  31010. */
  31011. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31012. /**
  31013. * Gets either window.performance.now() if supported or Date.now() else
  31014. */
  31015. static readonly Now: number;
  31016. /**
  31017. * This method will return the name of the class used to create the instance of the given object.
  31018. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31019. * @param object the object to get the class name from
  31020. * @param isType defines if the object is actually a type
  31021. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31022. */
  31023. static GetClassName(object: any, isType?: boolean): string;
  31024. /**
  31025. * Gets the first element of an array satisfying a given predicate
  31026. * @param array defines the array to browse
  31027. * @param predicate defines the predicate to use
  31028. * @returns null if not found or the element
  31029. */
  31030. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31031. /**
  31032. * This method will return the name of the full name of the class, including its owning module (if any).
  31033. * 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).
  31034. * @param object the object to get the class name from
  31035. * @param isType defines if the object is actually a type
  31036. * @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.
  31037. * @ignorenaming
  31038. */
  31039. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31040. /**
  31041. * Returns a promise that resolves after the given amount of time.
  31042. * @param delay Number of milliseconds to delay
  31043. * @returns Promise that resolves after the given amount of time
  31044. */
  31045. static DelayAsync(delay: number): Promise<void>;
  31046. /**
  31047. * Gets the current gradient from an array of IValueGradient
  31048. * @param ratio defines the current ratio to get
  31049. * @param gradients defines the array of IValueGradient
  31050. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31051. */
  31052. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31053. }
  31054. /**
  31055. * This class is used to track a performance counter which is number based.
  31056. * The user has access to many properties which give statistics of different nature.
  31057. *
  31058. * The implementer can track two kinds of Performance Counter: time and count.
  31059. * 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.
  31060. * 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.
  31061. */
  31062. export class PerfCounter {
  31063. /**
  31064. * Gets or sets a global boolean to turn on and off all the counters
  31065. */
  31066. static Enabled: boolean;
  31067. /**
  31068. * Returns the smallest value ever
  31069. */
  31070. readonly min: number;
  31071. /**
  31072. * Returns the biggest value ever
  31073. */
  31074. readonly max: number;
  31075. /**
  31076. * Returns the average value since the performance counter is running
  31077. */
  31078. readonly average: number;
  31079. /**
  31080. * Returns the average value of the last second the counter was monitored
  31081. */
  31082. readonly lastSecAverage: number;
  31083. /**
  31084. * Returns the current value
  31085. */
  31086. readonly current: number;
  31087. /**
  31088. * Gets the accumulated total
  31089. */
  31090. readonly total: number;
  31091. /**
  31092. * Gets the total value count
  31093. */
  31094. readonly count: number;
  31095. /**
  31096. * Creates a new counter
  31097. */
  31098. constructor();
  31099. /**
  31100. * Call this method to start monitoring a new frame.
  31101. * 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.
  31102. */
  31103. fetchNewFrame(): void;
  31104. /**
  31105. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31106. * @param newCount the count value to add to the monitored count
  31107. * @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.
  31108. */
  31109. addCount(newCount: number, fetchResult: boolean): void;
  31110. /**
  31111. * Start monitoring this performance counter
  31112. */
  31113. beginMonitoring(): void;
  31114. /**
  31115. * Compute the time lapsed since the previous beginMonitoring() call.
  31116. * @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
  31117. */
  31118. endMonitoring(newFrame?: boolean): void;
  31119. private _fetchResult;
  31120. private _startMonitoringTime;
  31121. private _min;
  31122. private _max;
  31123. private _average;
  31124. private _current;
  31125. private _totalValueCount;
  31126. private _totalAccumulated;
  31127. private _lastSecAverage;
  31128. private _lastSecAccumulated;
  31129. private _lastSecTime;
  31130. private _lastSecValueCount;
  31131. }
  31132. /**
  31133. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31134. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31135. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31136. * @param name The name of the class, case should be preserved
  31137. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31138. */
  31139. export function className(name: string, module?: string): (target: Object) => void;
  31140. /**
  31141. * An implementation of a loop for asynchronous functions.
  31142. */
  31143. export class AsyncLoop {
  31144. /**
  31145. * Defines the number of iterations for the loop
  31146. */
  31147. iterations: number;
  31148. /**
  31149. * Defines the current index of the loop.
  31150. */
  31151. index: number;
  31152. private _done;
  31153. private _fn;
  31154. private _successCallback;
  31155. /**
  31156. * Constructor.
  31157. * @param iterations the number of iterations.
  31158. * @param func the function to run each iteration
  31159. * @param successCallback the callback that will be called upon succesful execution
  31160. * @param offset starting offset.
  31161. */
  31162. constructor(
  31163. /**
  31164. * Defines the number of iterations for the loop
  31165. */
  31166. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31167. /**
  31168. * Execute the next iteration. Must be called after the last iteration was finished.
  31169. */
  31170. executeNext(): void;
  31171. /**
  31172. * Break the loop and run the success callback.
  31173. */
  31174. breakLoop(): void;
  31175. /**
  31176. * Create and run an async loop.
  31177. * @param iterations the number of iterations.
  31178. * @param fn the function to run each iteration
  31179. * @param successCallback the callback that will be called upon succesful execution
  31180. * @param offset starting offset.
  31181. * @returns the created async loop object
  31182. */
  31183. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31184. /**
  31185. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31186. * @param iterations total number of iterations
  31187. * @param syncedIterations number of synchronous iterations in each async iteration.
  31188. * @param fn the function to call each iteration.
  31189. * @param callback a success call back that will be called when iterating stops.
  31190. * @param breakFunction a break condition (optional)
  31191. * @param timeout timeout settings for the setTimeout function. default - 0.
  31192. * @returns the created async loop object
  31193. */
  31194. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31195. }
  31196. }
  31197. declare module BABYLON {
  31198. /** @hidden */
  31199. export interface ICollisionCoordinator {
  31200. createCollider(): Collider;
  31201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31202. init(scene: Scene): void;
  31203. }
  31204. /** @hidden */
  31205. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31206. private _scene;
  31207. private _scaledPosition;
  31208. private _scaledVelocity;
  31209. private _finalPosition;
  31210. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31211. createCollider(): Collider;
  31212. init(scene: Scene): void;
  31213. private _collideWithWorld;
  31214. }
  31215. }
  31216. declare module BABYLON {
  31217. /**
  31218. * This class defines the direct association between an animation and a target
  31219. */
  31220. export class TargetedAnimation {
  31221. /**
  31222. * Animation to perform
  31223. */
  31224. animation: Animation;
  31225. /**
  31226. * Target to animate
  31227. */
  31228. target: any;
  31229. }
  31230. /**
  31231. * Use this class to create coordinated animations on multiple targets
  31232. */
  31233. export class AnimationGroup implements IDisposable {
  31234. /** The name of the animation group */
  31235. name: string;
  31236. private _scene;
  31237. private _targetedAnimations;
  31238. private _animatables;
  31239. private _from;
  31240. private _to;
  31241. private _isStarted;
  31242. private _isPaused;
  31243. private _speedRatio;
  31244. /**
  31245. * Gets or sets the unique id of the node
  31246. */
  31247. uniqueId: number;
  31248. /**
  31249. * This observable will notify when one animation have ended
  31250. */
  31251. onAnimationEndObservable: Observable<TargetedAnimation>;
  31252. /**
  31253. * Observer raised when one animation loops
  31254. */
  31255. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31256. /**
  31257. * This observable will notify when all animations have ended.
  31258. */
  31259. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31260. /**
  31261. * This observable will notify when all animations have paused.
  31262. */
  31263. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31264. /**
  31265. * This observable will notify when all animations are playing.
  31266. */
  31267. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31268. /**
  31269. * Gets the first frame
  31270. */
  31271. readonly from: number;
  31272. /**
  31273. * Gets the last frame
  31274. */
  31275. readonly to: number;
  31276. /**
  31277. * Define if the animations are started
  31278. */
  31279. readonly isStarted: boolean;
  31280. /**
  31281. * Gets a value indicating that the current group is playing
  31282. */
  31283. readonly isPlaying: boolean;
  31284. /**
  31285. * Gets or sets the speed ratio to use for all animations
  31286. */
  31287. /**
  31288. * Gets or sets the speed ratio to use for all animations
  31289. */
  31290. speedRatio: number;
  31291. /**
  31292. * Gets the targeted animations for this animation group
  31293. */
  31294. readonly targetedAnimations: Array<TargetedAnimation>;
  31295. /**
  31296. * returning the list of animatables controlled by this animation group.
  31297. */
  31298. readonly animatables: Array<Animatable>;
  31299. /**
  31300. * Instantiates a new Animation Group.
  31301. * This helps managing several animations at once.
  31302. * @see http://doc.babylonjs.com/how_to/group
  31303. * @param name Defines the name of the group
  31304. * @param scene Defines the scene the group belongs to
  31305. */
  31306. constructor(
  31307. /** The name of the animation group */
  31308. name: string, scene?: Nullable<Scene>);
  31309. /**
  31310. * Add an animation (with its target) in the group
  31311. * @param animation defines the animation we want to add
  31312. * @param target defines the target of the animation
  31313. * @returns the TargetedAnimation object
  31314. */
  31315. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31316. /**
  31317. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31318. * It can add constant keys at begin or end
  31319. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31320. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31321. * @returns the animation group
  31322. */
  31323. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31324. /**
  31325. * Start all animations on given targets
  31326. * @param loop defines if animations must loop
  31327. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31328. * @param from defines the from key (optional)
  31329. * @param to defines the to key (optional)
  31330. * @returns the current animation group
  31331. */
  31332. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31333. /**
  31334. * Pause all animations
  31335. * @returns the animation group
  31336. */
  31337. pause(): AnimationGroup;
  31338. /**
  31339. * Play all animations to initial state
  31340. * This function will start() the animations if they were not started or will restart() them if they were paused
  31341. * @param loop defines if animations must loop
  31342. * @returns the animation group
  31343. */
  31344. play(loop?: boolean): AnimationGroup;
  31345. /**
  31346. * Reset all animations to initial state
  31347. * @returns the animation group
  31348. */
  31349. reset(): AnimationGroup;
  31350. /**
  31351. * Restart animations from key 0
  31352. * @returns the animation group
  31353. */
  31354. restart(): AnimationGroup;
  31355. /**
  31356. * Stop all animations
  31357. * @returns the animation group
  31358. */
  31359. stop(): AnimationGroup;
  31360. /**
  31361. * Set animation weight for all animatables
  31362. * @param weight defines the weight to use
  31363. * @return the animationGroup
  31364. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31365. */
  31366. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31367. /**
  31368. * Synchronize and normalize all animatables with a source animatable
  31369. * @param root defines the root animatable to synchronize with
  31370. * @return the animationGroup
  31371. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31372. */
  31373. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31374. /**
  31375. * Goes to a specific frame in this animation group
  31376. * @param frame the frame number to go to
  31377. * @return the animationGroup
  31378. */
  31379. goToFrame(frame: number): AnimationGroup;
  31380. /**
  31381. * Dispose all associated resources
  31382. */
  31383. dispose(): void;
  31384. private _checkAnimationGroupEnded;
  31385. /**
  31386. * Clone the current animation group and returns a copy
  31387. * @param newName defines the name of the new group
  31388. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31389. * @returns the new aniamtion group
  31390. */
  31391. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31392. /**
  31393. * Returns a new AnimationGroup object parsed from the source provided.
  31394. * @param parsedAnimationGroup defines the source
  31395. * @param scene defines the scene that will receive the animationGroup
  31396. * @returns a new AnimationGroup
  31397. */
  31398. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31399. /**
  31400. * Returns the string "AnimationGroup"
  31401. * @returns "AnimationGroup"
  31402. */
  31403. getClassName(): string;
  31404. /**
  31405. * Creates a detailled string about the object
  31406. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31407. * @returns a string representing the object
  31408. */
  31409. toString(fullDetails?: boolean): string;
  31410. }
  31411. }
  31412. declare module BABYLON {
  31413. /**
  31414. * Define an interface for all classes that will hold resources
  31415. */
  31416. export interface IDisposable {
  31417. /**
  31418. * Releases all held resources
  31419. */
  31420. dispose(): void;
  31421. }
  31422. /** Interface defining initialization parameters for Scene class */
  31423. export interface SceneOptions {
  31424. /**
  31425. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31426. * It will improve performance when the number of geometries becomes important.
  31427. */
  31428. useGeometryUniqueIdsMap?: boolean;
  31429. /**
  31430. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31431. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31432. */
  31433. useMaterialMeshMap?: boolean;
  31434. /**
  31435. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31436. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31437. */
  31438. useClonedMeshhMap?: boolean;
  31439. }
  31440. /**
  31441. * Represents a scene to be rendered by the engine.
  31442. * @see http://doc.babylonjs.com/features/scene
  31443. */
  31444. export class Scene extends AbstractScene implements IAnimatable {
  31445. private static _uniqueIdCounter;
  31446. /** The fog is deactivated */
  31447. static readonly FOGMODE_NONE: number;
  31448. /** The fog density is following an exponential function */
  31449. static readonly FOGMODE_EXP: number;
  31450. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31451. static readonly FOGMODE_EXP2: number;
  31452. /** The fog density is following a linear function. */
  31453. static readonly FOGMODE_LINEAR: number;
  31454. /**
  31455. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31457. */
  31458. static MinDeltaTime: number;
  31459. /**
  31460. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31462. */
  31463. static MaxDeltaTime: number;
  31464. /**
  31465. * Factory used to create the default material.
  31466. * @param name The name of the material to create
  31467. * @param scene The scene to create the material for
  31468. * @returns The default material
  31469. */
  31470. static DefaultMaterialFactory(scene: Scene): Material;
  31471. /**
  31472. * Factory used to create the a collision coordinator.
  31473. * @returns The collision coordinator
  31474. */
  31475. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31476. /** @hidden */
  31477. readonly _isScene: boolean;
  31478. /**
  31479. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31480. */
  31481. autoClear: boolean;
  31482. /**
  31483. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31484. */
  31485. autoClearDepthAndStencil: boolean;
  31486. /**
  31487. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31488. */
  31489. clearColor: Color4;
  31490. /**
  31491. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31492. */
  31493. ambientColor: Color3;
  31494. /** @hidden */
  31495. _environmentBRDFTexture: BaseTexture;
  31496. /** @hidden */
  31497. protected _environmentTexture: Nullable<BaseTexture>;
  31498. /**
  31499. * Texture used in all pbr material as the reflection texture.
  31500. * As in the majority of the scene they are the same (exception for multi room and so on),
  31501. * this is easier to reference from here than from all the materials.
  31502. */
  31503. /**
  31504. * Texture used in all pbr material as the reflection texture.
  31505. * As in the majority of the scene they are the same (exception for multi room and so on),
  31506. * this is easier to set here than in all the materials.
  31507. */
  31508. environmentTexture: Nullable<BaseTexture>;
  31509. /** @hidden */
  31510. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31511. /**
  31512. * Default image processing configuration used either in the rendering
  31513. * Forward main pass or through the imageProcessingPostProcess if present.
  31514. * As in the majority of the scene they are the same (exception for multi camera),
  31515. * this is easier to reference from here than from all the materials and post process.
  31516. *
  31517. * No setter as we it is a shared configuration, you can set the values instead.
  31518. */
  31519. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31520. private _forceWireframe;
  31521. /**
  31522. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31523. */
  31524. forceWireframe: boolean;
  31525. private _forcePointsCloud;
  31526. /**
  31527. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31528. */
  31529. forcePointsCloud: boolean;
  31530. /**
  31531. * Gets or sets the active clipplane 1
  31532. */
  31533. clipPlane: Nullable<Plane>;
  31534. /**
  31535. * Gets or sets the active clipplane 2
  31536. */
  31537. clipPlane2: Nullable<Plane>;
  31538. /**
  31539. * Gets or sets the active clipplane 3
  31540. */
  31541. clipPlane3: Nullable<Plane>;
  31542. /**
  31543. * Gets or sets the active clipplane 4
  31544. */
  31545. clipPlane4: Nullable<Plane>;
  31546. /**
  31547. * Gets or sets a boolean indicating if animations are enabled
  31548. */
  31549. animationsEnabled: boolean;
  31550. private _animationPropertiesOverride;
  31551. /**
  31552. * Gets or sets the animation properties override
  31553. */
  31554. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31555. /**
  31556. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31557. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31558. */
  31559. useConstantAnimationDeltaTime: boolean;
  31560. /**
  31561. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31562. * Please note that it requires to run a ray cast through the scene on every frame
  31563. */
  31564. constantlyUpdateMeshUnderPointer: boolean;
  31565. /**
  31566. * Defines the HTML cursor to use when hovering over interactive elements
  31567. */
  31568. hoverCursor: string;
  31569. /**
  31570. * Defines the HTML default cursor to use (empty by default)
  31571. */
  31572. defaultCursor: string;
  31573. /**
  31574. * This is used to call preventDefault() on pointer down
  31575. * in order to block unwanted artifacts like system double clicks
  31576. */
  31577. preventDefaultOnPointerDown: boolean;
  31578. /**
  31579. * This is used to call preventDefault() on pointer up
  31580. * in order to block unwanted artifacts like system double clicks
  31581. */
  31582. preventDefaultOnPointerUp: boolean;
  31583. /**
  31584. * Gets or sets user defined metadata
  31585. */
  31586. metadata: any;
  31587. /**
  31588. * For internal use only. Please do not use.
  31589. */
  31590. reservedDataStore: any;
  31591. /**
  31592. * Gets the name of the plugin used to load this scene (null by default)
  31593. */
  31594. loadingPluginName: string;
  31595. /**
  31596. * Use this array to add regular expressions used to disable offline support for specific urls
  31597. */
  31598. disableOfflineSupportExceptionRules: RegExp[];
  31599. /**
  31600. * An event triggered when the scene is disposed.
  31601. */
  31602. onDisposeObservable: Observable<Scene>;
  31603. private _onDisposeObserver;
  31604. /** Sets a function to be executed when this scene is disposed. */
  31605. onDispose: () => void;
  31606. /**
  31607. * An event triggered before rendering the scene (right after animations and physics)
  31608. */
  31609. onBeforeRenderObservable: Observable<Scene>;
  31610. private _onBeforeRenderObserver;
  31611. /** Sets a function to be executed before rendering this scene */
  31612. beforeRender: Nullable<() => void>;
  31613. /**
  31614. * An event triggered after rendering the scene
  31615. */
  31616. onAfterRenderObservable: Observable<Scene>;
  31617. private _onAfterRenderObserver;
  31618. /** Sets a function to be executed after rendering this scene */
  31619. afterRender: Nullable<() => void>;
  31620. /**
  31621. * An event triggered before animating the scene
  31622. */
  31623. onBeforeAnimationsObservable: Observable<Scene>;
  31624. /**
  31625. * An event triggered after animations processing
  31626. */
  31627. onAfterAnimationsObservable: Observable<Scene>;
  31628. /**
  31629. * An event triggered before draw calls are ready to be sent
  31630. */
  31631. onBeforeDrawPhaseObservable: Observable<Scene>;
  31632. /**
  31633. * An event triggered after draw calls have been sent
  31634. */
  31635. onAfterDrawPhaseObservable: Observable<Scene>;
  31636. /**
  31637. * An event triggered when the scene is ready
  31638. */
  31639. onReadyObservable: Observable<Scene>;
  31640. /**
  31641. * An event triggered before rendering a camera
  31642. */
  31643. onBeforeCameraRenderObservable: Observable<Camera>;
  31644. private _onBeforeCameraRenderObserver;
  31645. /** Sets a function to be executed before rendering a camera*/
  31646. beforeCameraRender: () => void;
  31647. /**
  31648. * An event triggered after rendering a camera
  31649. */
  31650. onAfterCameraRenderObservable: Observable<Camera>;
  31651. private _onAfterCameraRenderObserver;
  31652. /** Sets a function to be executed after rendering a camera*/
  31653. afterCameraRender: () => void;
  31654. /**
  31655. * An event triggered when active meshes evaluation is about to start
  31656. */
  31657. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31658. /**
  31659. * An event triggered when active meshes evaluation is done
  31660. */
  31661. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31662. /**
  31663. * An event triggered when particles rendering is about to start
  31664. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31665. */
  31666. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31667. /**
  31668. * An event triggered when particles rendering is done
  31669. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31670. */
  31671. onAfterParticlesRenderingObservable: Observable<Scene>;
  31672. /**
  31673. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31674. */
  31675. onDataLoadedObservable: Observable<Scene>;
  31676. /**
  31677. * An event triggered when a camera is created
  31678. */
  31679. onNewCameraAddedObservable: Observable<Camera>;
  31680. /**
  31681. * An event triggered when a camera is removed
  31682. */
  31683. onCameraRemovedObservable: Observable<Camera>;
  31684. /**
  31685. * An event triggered when a light is created
  31686. */
  31687. onNewLightAddedObservable: Observable<Light>;
  31688. /**
  31689. * An event triggered when a light is removed
  31690. */
  31691. onLightRemovedObservable: Observable<Light>;
  31692. /**
  31693. * An event triggered when a geometry is created
  31694. */
  31695. onNewGeometryAddedObservable: Observable<Geometry>;
  31696. /**
  31697. * An event triggered when a geometry is removed
  31698. */
  31699. onGeometryRemovedObservable: Observable<Geometry>;
  31700. /**
  31701. * An event triggered when a transform node is created
  31702. */
  31703. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31704. /**
  31705. * An event triggered when a transform node is removed
  31706. */
  31707. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31708. /**
  31709. * An event triggered when a mesh is created
  31710. */
  31711. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31712. /**
  31713. * An event triggered when a mesh is removed
  31714. */
  31715. onMeshRemovedObservable: Observable<AbstractMesh>;
  31716. /**
  31717. * An event triggered when a skeleton is created
  31718. */
  31719. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31720. /**
  31721. * An event triggered when a skeleton is removed
  31722. */
  31723. onSkeletonRemovedObservable: Observable<Skeleton>;
  31724. /**
  31725. * An event triggered when a material is created
  31726. */
  31727. onNewMaterialAddedObservable: Observable<Material>;
  31728. /**
  31729. * An event triggered when a material is removed
  31730. */
  31731. onMaterialRemovedObservable: Observable<Material>;
  31732. /**
  31733. * An event triggered when a texture is created
  31734. */
  31735. onNewTextureAddedObservable: Observable<BaseTexture>;
  31736. /**
  31737. * An event triggered when a texture is removed
  31738. */
  31739. onTextureRemovedObservable: Observable<BaseTexture>;
  31740. /**
  31741. * An event triggered when render targets are about to be rendered
  31742. * Can happen multiple times per frame.
  31743. */
  31744. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31745. /**
  31746. * An event triggered when render targets were rendered.
  31747. * Can happen multiple times per frame.
  31748. */
  31749. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31750. /**
  31751. * An event triggered before calculating deterministic simulation step
  31752. */
  31753. onBeforeStepObservable: Observable<Scene>;
  31754. /**
  31755. * An event triggered after calculating deterministic simulation step
  31756. */
  31757. onAfterStepObservable: Observable<Scene>;
  31758. /**
  31759. * An event triggered when the activeCamera property is updated
  31760. */
  31761. onActiveCameraChanged: Observable<Scene>;
  31762. /**
  31763. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31764. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31765. * 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)
  31766. */
  31767. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31768. /**
  31769. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31770. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31771. * 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)
  31772. */
  31773. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31774. /**
  31775. * This Observable will when a mesh has been imported into the scene.
  31776. */
  31777. onMeshImportedObservable: Observable<AbstractMesh>;
  31778. /**
  31779. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31780. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31781. */
  31782. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31783. /** @hidden */
  31784. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31785. /**
  31786. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31787. */
  31788. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31789. /**
  31790. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31791. */
  31792. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31793. /**
  31794. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31795. */
  31796. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31797. private _onPointerMove;
  31798. private _onPointerDown;
  31799. private _onPointerUp;
  31800. /** Callback called when a pointer move is detected */
  31801. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31802. /** Callback called when a pointer down is detected */
  31803. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31804. /** Callback called when a pointer up is detected */
  31805. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31806. /** Callback called when a pointer pick is detected */
  31807. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31808. /**
  31809. * 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).
  31810. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31811. */
  31812. onPrePointerObservable: Observable<PointerInfoPre>;
  31813. /**
  31814. * Observable event triggered each time an input event is received from the rendering canvas
  31815. */
  31816. onPointerObservable: Observable<PointerInfo>;
  31817. /**
  31818. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31819. */
  31820. readonly unTranslatedPointer: Vector2;
  31821. /** The distance in pixel that you have to move to prevent some events */
  31822. static DragMovementThreshold: number;
  31823. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31824. static LongPressDelay: number;
  31825. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31826. static DoubleClickDelay: number;
  31827. /** If you need to check double click without raising a single click at first click, enable this flag */
  31828. static ExclusiveDoubleClickMode: boolean;
  31829. private _initClickEvent;
  31830. private _initActionManager;
  31831. private _delayedSimpleClick;
  31832. private _delayedSimpleClickTimeout;
  31833. private _previousDelayedSimpleClickTimeout;
  31834. private _meshPickProceed;
  31835. private _previousButtonPressed;
  31836. private _currentPickResult;
  31837. private _previousPickResult;
  31838. private _totalPointersPressed;
  31839. private _doubleClickOccured;
  31840. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31841. cameraToUseForPointers: Nullable<Camera>;
  31842. private _pointerX;
  31843. private _pointerY;
  31844. private _unTranslatedPointerX;
  31845. private _unTranslatedPointerY;
  31846. private _startingPointerPosition;
  31847. private _previousStartingPointerPosition;
  31848. private _startingPointerTime;
  31849. private _previousStartingPointerTime;
  31850. private _pointerCaptures;
  31851. private _timeAccumulator;
  31852. private _currentStepId;
  31853. private _currentInternalStep;
  31854. /** @hidden */
  31855. _mirroredCameraPosition: Nullable<Vector3>;
  31856. /**
  31857. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31858. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31859. */
  31860. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31861. /**
  31862. * Observable event triggered each time an keyboard event is received from the hosting window
  31863. */
  31864. onKeyboardObservable: Observable<KeyboardInfo>;
  31865. private _onKeyDown;
  31866. private _onKeyUp;
  31867. private _onCanvasFocusObserver;
  31868. private _onCanvasBlurObserver;
  31869. private _useRightHandedSystem;
  31870. /**
  31871. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31872. */
  31873. useRightHandedSystem: boolean;
  31874. /**
  31875. * Sets the step Id used by deterministic lock step
  31876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31877. * @param newStepId defines the step Id
  31878. */
  31879. setStepId(newStepId: number): void;
  31880. /**
  31881. * Gets the step Id used by deterministic lock step
  31882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31883. * @returns the step Id
  31884. */
  31885. getStepId(): number;
  31886. /**
  31887. * Gets the internal step used by deterministic lock step
  31888. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31889. * @returns the internal step
  31890. */
  31891. getInternalStep(): number;
  31892. private _fogEnabled;
  31893. /**
  31894. * Gets or sets a boolean indicating if fog is enabled on this scene
  31895. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31896. * (Default is true)
  31897. */
  31898. fogEnabled: boolean;
  31899. private _fogMode;
  31900. /**
  31901. * Gets or sets the fog mode to use
  31902. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31903. * | mode | value |
  31904. * | --- | --- |
  31905. * | FOGMODE_NONE | 0 |
  31906. * | FOGMODE_EXP | 1 |
  31907. * | FOGMODE_EXP2 | 2 |
  31908. * | FOGMODE_LINEAR | 3 |
  31909. */
  31910. fogMode: number;
  31911. /**
  31912. * Gets or sets the fog color to use
  31913. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31914. * (Default is Color3(0.2, 0.2, 0.3))
  31915. */
  31916. fogColor: Color3;
  31917. /**
  31918. * Gets or sets the fog density to use
  31919. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31920. * (Default is 0.1)
  31921. */
  31922. fogDensity: number;
  31923. /**
  31924. * Gets or sets the fog start distance to use
  31925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31926. * (Default is 0)
  31927. */
  31928. fogStart: number;
  31929. /**
  31930. * Gets or sets the fog end distance to use
  31931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31932. * (Default is 1000)
  31933. */
  31934. fogEnd: number;
  31935. private _shadowsEnabled;
  31936. /**
  31937. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31938. */
  31939. shadowsEnabled: boolean;
  31940. private _lightsEnabled;
  31941. /**
  31942. * Gets or sets a boolean indicating if lights are enabled on this scene
  31943. */
  31944. lightsEnabled: boolean;
  31945. /** All of the active cameras added to this scene. */
  31946. activeCameras: Camera[];
  31947. private _activeCamera;
  31948. /** Gets or sets the current active camera */
  31949. activeCamera: Nullable<Camera>;
  31950. private _defaultMaterial;
  31951. /** The default material used on meshes when no material is affected */
  31952. /** The default material used on meshes when no material is affected */
  31953. defaultMaterial: Material;
  31954. private _texturesEnabled;
  31955. /**
  31956. * Gets or sets a boolean indicating if textures are enabled on this scene
  31957. */
  31958. texturesEnabled: boolean;
  31959. /**
  31960. * Gets or sets a boolean indicating if particles are enabled on this scene
  31961. */
  31962. particlesEnabled: boolean;
  31963. /**
  31964. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31965. */
  31966. spritesEnabled: boolean;
  31967. private _skeletonsEnabled;
  31968. /**
  31969. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31970. */
  31971. skeletonsEnabled: boolean;
  31972. /**
  31973. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31974. */
  31975. lensFlaresEnabled: boolean;
  31976. /**
  31977. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31979. */
  31980. collisionsEnabled: boolean;
  31981. private _collisionCoordinator;
  31982. /** @hidden */
  31983. readonly collisionCoordinator: ICollisionCoordinator;
  31984. /**
  31985. * Defines the gravity applied to this scene (used only for collisions)
  31986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31987. */
  31988. gravity: Vector3;
  31989. /**
  31990. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31991. */
  31992. postProcessesEnabled: boolean;
  31993. /**
  31994. * The list of postprocesses added to the scene
  31995. */
  31996. postProcesses: PostProcess[];
  31997. /**
  31998. * Gets the current postprocess manager
  31999. */
  32000. postProcessManager: PostProcessManager;
  32001. /**
  32002. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32003. */
  32004. renderTargetsEnabled: boolean;
  32005. /**
  32006. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32007. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32008. */
  32009. dumpNextRenderTargets: boolean;
  32010. /**
  32011. * The list of user defined render targets added to the scene
  32012. */
  32013. customRenderTargets: RenderTargetTexture[];
  32014. /**
  32015. * Defines if texture loading must be delayed
  32016. * If true, textures will only be loaded when they need to be rendered
  32017. */
  32018. useDelayedTextureLoading: boolean;
  32019. /**
  32020. * Gets the list of meshes imported to the scene through SceneLoader
  32021. */
  32022. importedMeshesFiles: String[];
  32023. /**
  32024. * Gets or sets a boolean indicating if probes are enabled on this scene
  32025. */
  32026. probesEnabled: boolean;
  32027. /**
  32028. * Gets or sets the current offline provider to use to store scene data
  32029. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32030. */
  32031. offlineProvider: IOfflineProvider;
  32032. /**
  32033. * Gets or sets the action manager associated with the scene
  32034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32035. */
  32036. actionManager: AbstractActionManager;
  32037. private _meshesForIntersections;
  32038. /**
  32039. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32040. */
  32041. proceduralTexturesEnabled: boolean;
  32042. private _engine;
  32043. private _totalVertices;
  32044. /** @hidden */
  32045. _activeIndices: PerfCounter;
  32046. /** @hidden */
  32047. _activeParticles: PerfCounter;
  32048. /** @hidden */
  32049. _activeBones: PerfCounter;
  32050. private _animationRatio;
  32051. /** @hidden */
  32052. _animationTimeLast: number;
  32053. /** @hidden */
  32054. _animationTime: number;
  32055. /**
  32056. * Gets or sets a general scale for animation speed
  32057. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32058. */
  32059. animationTimeScale: number;
  32060. /** @hidden */
  32061. _cachedMaterial: Nullable<Material>;
  32062. /** @hidden */
  32063. _cachedEffect: Nullable<Effect>;
  32064. /** @hidden */
  32065. _cachedVisibility: Nullable<number>;
  32066. private _renderId;
  32067. private _frameId;
  32068. private _executeWhenReadyTimeoutId;
  32069. private _intermediateRendering;
  32070. private _viewUpdateFlag;
  32071. private _projectionUpdateFlag;
  32072. private _alternateViewUpdateFlag;
  32073. private _alternateProjectionUpdateFlag;
  32074. /** @hidden */
  32075. _toBeDisposed: Nullable<IDisposable>[];
  32076. private _activeRequests;
  32077. /** @hidden */
  32078. _pendingData: any[];
  32079. private _isDisposed;
  32080. /**
  32081. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32082. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32083. */
  32084. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32085. private _activeMeshes;
  32086. private _processedMaterials;
  32087. private _renderTargets;
  32088. /** @hidden */
  32089. _activeParticleSystems: SmartArray<IParticleSystem>;
  32090. private _activeSkeletons;
  32091. private _softwareSkinnedMeshes;
  32092. private _renderingManager;
  32093. /** @hidden */
  32094. _activeAnimatables: Animatable[];
  32095. private _transformMatrix;
  32096. private _sceneUbo;
  32097. private _alternateSceneUbo;
  32098. private _viewMatrix;
  32099. private _projectionMatrix;
  32100. private _alternateViewMatrix;
  32101. private _alternateProjectionMatrix;
  32102. private _alternateTransformMatrix;
  32103. private _useAlternateCameraConfiguration;
  32104. private _alternateRendering;
  32105. private _wheelEventName;
  32106. /** @hidden */
  32107. _forcedViewPosition: Nullable<Vector3>;
  32108. /** @hidden */
  32109. readonly _isAlternateRenderingEnabled: boolean;
  32110. private _frustumPlanes;
  32111. /**
  32112. * Gets the list of frustum planes (built from the active camera)
  32113. */
  32114. readonly frustumPlanes: Plane[];
  32115. /**
  32116. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32117. * This is useful if there are more lights that the maximum simulteanous authorized
  32118. */
  32119. requireLightSorting: boolean;
  32120. /** @hidden */
  32121. readonly useMaterialMeshMap: boolean;
  32122. /** @hidden */
  32123. readonly useClonedMeshhMap: boolean;
  32124. private _pointerOverMesh;
  32125. private _pickedDownMesh;
  32126. private _pickedUpMesh;
  32127. private _externalData;
  32128. private _uid;
  32129. /**
  32130. * @hidden
  32131. * Backing store of defined scene components.
  32132. */
  32133. _components: ISceneComponent[];
  32134. /**
  32135. * @hidden
  32136. * Backing store of defined scene components.
  32137. */
  32138. _serializableComponents: ISceneSerializableComponent[];
  32139. /**
  32140. * List of components to register on the next registration step.
  32141. */
  32142. private _transientComponents;
  32143. /**
  32144. * Registers the transient components if needed.
  32145. */
  32146. private _registerTransientComponents;
  32147. /**
  32148. * @hidden
  32149. * Add a component to the scene.
  32150. * Note that the ccomponent could be registered on th next frame if this is called after
  32151. * the register component stage.
  32152. * @param component Defines the component to add to the scene
  32153. */
  32154. _addComponent(component: ISceneComponent): void;
  32155. /**
  32156. * @hidden
  32157. * Gets a component from the scene.
  32158. * @param name defines the name of the component to retrieve
  32159. * @returns the component or null if not present
  32160. */
  32161. _getComponent(name: string): Nullable<ISceneComponent>;
  32162. /**
  32163. * @hidden
  32164. * Defines the actions happening before camera updates.
  32165. */
  32166. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32167. /**
  32168. * @hidden
  32169. * Defines the actions happening before clear the canvas.
  32170. */
  32171. _beforeClearStage: Stage<SimpleStageAction>;
  32172. /**
  32173. * @hidden
  32174. * Defines the actions when collecting render targets for the frame.
  32175. */
  32176. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32177. /**
  32178. * @hidden
  32179. * Defines the actions happening for one camera in the frame.
  32180. */
  32181. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32182. /**
  32183. * @hidden
  32184. * Defines the actions happening during the per mesh ready checks.
  32185. */
  32186. _isReadyForMeshStage: Stage<MeshStageAction>;
  32187. /**
  32188. * @hidden
  32189. * Defines the actions happening before evaluate active mesh checks.
  32190. */
  32191. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32192. /**
  32193. * @hidden
  32194. * Defines the actions happening during the evaluate sub mesh checks.
  32195. */
  32196. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32197. /**
  32198. * @hidden
  32199. * Defines the actions happening during the active mesh stage.
  32200. */
  32201. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32202. /**
  32203. * @hidden
  32204. * Defines the actions happening during the per camera render target step.
  32205. */
  32206. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32207. /**
  32208. * @hidden
  32209. * Defines the actions happening just before the active camera is drawing.
  32210. */
  32211. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32212. /**
  32213. * @hidden
  32214. * Defines the actions happening just before a render target is drawing.
  32215. */
  32216. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32217. /**
  32218. * @hidden
  32219. * Defines the actions happening just before a rendering group is drawing.
  32220. */
  32221. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32222. /**
  32223. * @hidden
  32224. * Defines the actions happening just before a mesh is drawing.
  32225. */
  32226. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32227. /**
  32228. * @hidden
  32229. * Defines the actions happening just after a mesh has been drawn.
  32230. */
  32231. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32232. /**
  32233. * @hidden
  32234. * Defines the actions happening just after a rendering group has been drawn.
  32235. */
  32236. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32237. /**
  32238. * @hidden
  32239. * Defines the actions happening just after the active camera has been drawn.
  32240. */
  32241. _afterCameraDrawStage: Stage<CameraStageAction>;
  32242. /**
  32243. * @hidden
  32244. * Defines the actions happening just after a render target has been drawn.
  32245. */
  32246. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32247. /**
  32248. * @hidden
  32249. * Defines the actions happening just after rendering all cameras and computing intersections.
  32250. */
  32251. _afterRenderStage: Stage<SimpleStageAction>;
  32252. /**
  32253. * @hidden
  32254. * Defines the actions happening when a pointer move event happens.
  32255. */
  32256. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32257. /**
  32258. * @hidden
  32259. * Defines the actions happening when a pointer down event happens.
  32260. */
  32261. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32262. /**
  32263. * @hidden
  32264. * Defines the actions happening when a pointer up event happens.
  32265. */
  32266. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32267. /**
  32268. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32269. */
  32270. private geometriesByUniqueId;
  32271. /**
  32272. * Creates a new Scene
  32273. * @param engine defines the engine to use to render this scene
  32274. * @param options defines the scene options
  32275. */
  32276. constructor(engine: Engine, options?: SceneOptions);
  32277. private _defaultMeshCandidates;
  32278. /**
  32279. * @hidden
  32280. */
  32281. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32282. private _defaultSubMeshCandidates;
  32283. /**
  32284. * @hidden
  32285. */
  32286. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32287. /**
  32288. * Sets the default candidate providers for the scene.
  32289. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32290. * and getCollidingSubMeshCandidates to their default function
  32291. */
  32292. setDefaultCandidateProviders(): void;
  32293. /**
  32294. * Gets the mesh that is currently under the pointer
  32295. */
  32296. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32297. /**
  32298. * Gets or sets the current on-screen X position of the pointer
  32299. */
  32300. pointerX: number;
  32301. /**
  32302. * Gets or sets the current on-screen Y position of the pointer
  32303. */
  32304. pointerY: number;
  32305. /**
  32306. * Gets the cached material (ie. the latest rendered one)
  32307. * @returns the cached material
  32308. */
  32309. getCachedMaterial(): Nullable<Material>;
  32310. /**
  32311. * Gets the cached effect (ie. the latest rendered one)
  32312. * @returns the cached effect
  32313. */
  32314. getCachedEffect(): Nullable<Effect>;
  32315. /**
  32316. * Gets the cached visibility state (ie. the latest rendered one)
  32317. * @returns the cached visibility state
  32318. */
  32319. getCachedVisibility(): Nullable<number>;
  32320. /**
  32321. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32322. * @param material defines the current material
  32323. * @param effect defines the current effect
  32324. * @param visibility defines the current visibility state
  32325. * @returns true if one parameter is not cached
  32326. */
  32327. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32328. /**
  32329. * Gets the engine associated with the scene
  32330. * @returns an Engine
  32331. */
  32332. getEngine(): Engine;
  32333. /**
  32334. * Gets the total number of vertices rendered per frame
  32335. * @returns the total number of vertices rendered per frame
  32336. */
  32337. getTotalVertices(): number;
  32338. /**
  32339. * Gets the performance counter for total vertices
  32340. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32341. */
  32342. readonly totalVerticesPerfCounter: PerfCounter;
  32343. /**
  32344. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32345. * @returns the total number of active indices rendered per frame
  32346. */
  32347. getActiveIndices(): number;
  32348. /**
  32349. * Gets the performance counter for active indices
  32350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32351. */
  32352. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32353. /**
  32354. * Gets the total number of active particles rendered per frame
  32355. * @returns the total number of active particles rendered per frame
  32356. */
  32357. getActiveParticles(): number;
  32358. /**
  32359. * Gets the performance counter for active particles
  32360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32361. */
  32362. readonly activeParticlesPerfCounter: PerfCounter;
  32363. /**
  32364. * Gets the total number of active bones rendered per frame
  32365. * @returns the total number of active bones rendered per frame
  32366. */
  32367. getActiveBones(): number;
  32368. /**
  32369. * Gets the performance counter for active bones
  32370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32371. */
  32372. readonly activeBonesPerfCounter: PerfCounter;
  32373. /**
  32374. * Gets the array of active meshes
  32375. * @returns an array of AbstractMesh
  32376. */
  32377. getActiveMeshes(): SmartArray<AbstractMesh>;
  32378. /**
  32379. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32380. * @returns a number
  32381. */
  32382. getAnimationRatio(): number;
  32383. /**
  32384. * Gets an unique Id for the current render phase
  32385. * @returns a number
  32386. */
  32387. getRenderId(): number;
  32388. /**
  32389. * Gets an unique Id for the current frame
  32390. * @returns a number
  32391. */
  32392. getFrameId(): number;
  32393. /** Call this function if you want to manually increment the render Id*/
  32394. incrementRenderId(): void;
  32395. private _updatePointerPosition;
  32396. private _createUbo;
  32397. private _createAlternateUbo;
  32398. private _setRayOnPointerInfo;
  32399. /**
  32400. * Use this method to simulate a pointer move on a mesh
  32401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32404. * @returns the current scene
  32405. */
  32406. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32407. private _processPointerMove;
  32408. private _checkPrePointerObservable;
  32409. /**
  32410. * Use this method to simulate a pointer down on a mesh
  32411. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32412. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32413. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32414. * @returns the current scene
  32415. */
  32416. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32417. private _processPointerDown;
  32418. /**
  32419. * Use this method to simulate a pointer up on a mesh
  32420. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32421. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32422. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32423. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32424. * @returns the current scene
  32425. */
  32426. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32427. private _processPointerUp;
  32428. /**
  32429. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32430. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32431. * @returns true if the pointer was captured
  32432. */
  32433. isPointerCaptured(pointerId?: number): boolean;
  32434. /** @hidden */
  32435. _isPointerSwiping(): boolean;
  32436. /**
  32437. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32438. * @param attachUp defines if you want to attach events to pointerup
  32439. * @param attachDown defines if you want to attach events to pointerdown
  32440. * @param attachMove defines if you want to attach events to pointermove
  32441. */
  32442. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32443. /** Detaches all event handlers*/
  32444. detachControl(): void;
  32445. /**
  32446. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32447. * Delay loaded resources are not taking in account
  32448. * @return true if all required resources are ready
  32449. */
  32450. isReady(): boolean;
  32451. /** Resets all cached information relative to material (including effect and visibility) */
  32452. resetCachedMaterial(): void;
  32453. /**
  32454. * Registers a function to be called before every frame render
  32455. * @param func defines the function to register
  32456. */
  32457. registerBeforeRender(func: () => void): void;
  32458. /**
  32459. * Unregisters a function called before every frame render
  32460. * @param func defines the function to unregister
  32461. */
  32462. unregisterBeforeRender(func: () => void): void;
  32463. /**
  32464. * Registers a function to be called after every frame render
  32465. * @param func defines the function to register
  32466. */
  32467. registerAfterRender(func: () => void): void;
  32468. /**
  32469. * Unregisters a function called after every frame render
  32470. * @param func defines the function to unregister
  32471. */
  32472. unregisterAfterRender(func: () => void): void;
  32473. private _executeOnceBeforeRender;
  32474. /**
  32475. * The provided function will run before render once and will be disposed afterwards.
  32476. * A timeout delay can be provided so that the function will be executed in N ms.
  32477. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32478. * @param func The function to be executed.
  32479. * @param timeout optional delay in ms
  32480. */
  32481. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32482. /** @hidden */
  32483. _addPendingData(data: any): void;
  32484. /** @hidden */
  32485. _removePendingData(data: any): void;
  32486. /**
  32487. * Returns the number of items waiting to be loaded
  32488. * @returns the number of items waiting to be loaded
  32489. */
  32490. getWaitingItemsCount(): number;
  32491. /**
  32492. * Returns a boolean indicating if the scene is still loading data
  32493. */
  32494. readonly isLoading: boolean;
  32495. /**
  32496. * Registers a function to be executed when the scene is ready
  32497. * @param {Function} func - the function to be executed
  32498. */
  32499. executeWhenReady(func: () => void): void;
  32500. /**
  32501. * Returns a promise that resolves when the scene is ready
  32502. * @returns A promise that resolves when the scene is ready
  32503. */
  32504. whenReadyAsync(): Promise<void>;
  32505. /** @hidden */
  32506. _checkIsReady(): void;
  32507. /**
  32508. * Gets all animatable attached to the scene
  32509. */
  32510. readonly animatables: Animatable[];
  32511. /**
  32512. * Resets the last animation time frame.
  32513. * Useful to override when animations start running when loading a scene for the first time.
  32514. */
  32515. resetLastAnimationTimeFrame(): void;
  32516. /** @hidden */
  32517. _switchToAlternateCameraConfiguration(active: boolean): void;
  32518. /**
  32519. * Gets the current view matrix
  32520. * @returns a Matrix
  32521. */
  32522. getViewMatrix(): Matrix;
  32523. /**
  32524. * Gets the current projection matrix
  32525. * @returns a Matrix
  32526. */
  32527. getProjectionMatrix(): Matrix;
  32528. /**
  32529. * Gets the current transform matrix
  32530. * @returns a Matrix made of View * Projection
  32531. */
  32532. getTransformMatrix(): Matrix;
  32533. /**
  32534. * Sets the current transform matrix
  32535. * @param view defines the View matrix to use
  32536. * @param projection defines the Projection matrix to use
  32537. */
  32538. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32539. /** @hidden */
  32540. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32541. /**
  32542. * Gets the uniform buffer used to store scene data
  32543. * @returns a UniformBuffer
  32544. */
  32545. getSceneUniformBuffer(): UniformBuffer;
  32546. /**
  32547. * Gets an unique (relatively to the current scene) Id
  32548. * @returns an unique number for the scene
  32549. */
  32550. getUniqueId(): number;
  32551. /**
  32552. * Add a mesh to the list of scene's meshes
  32553. * @param newMesh defines the mesh to add
  32554. * @param recursive if all child meshes should also be added to the scene
  32555. */
  32556. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32557. /**
  32558. * Remove a mesh for the list of scene's meshes
  32559. * @param toRemove defines the mesh to remove
  32560. * @param recursive if all child meshes should also be removed from the scene
  32561. * @returns the index where the mesh was in the mesh list
  32562. */
  32563. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32564. /**
  32565. * Add a transform node to the list of scene's transform nodes
  32566. * @param newTransformNode defines the transform node to add
  32567. */
  32568. addTransformNode(newTransformNode: TransformNode): void;
  32569. /**
  32570. * Remove a transform node for the list of scene's transform nodes
  32571. * @param toRemove defines the transform node to remove
  32572. * @returns the index where the transform node was in the transform node list
  32573. */
  32574. removeTransformNode(toRemove: TransformNode): number;
  32575. /**
  32576. * Remove a skeleton for the list of scene's skeletons
  32577. * @param toRemove defines the skeleton to remove
  32578. * @returns the index where the skeleton was in the skeleton list
  32579. */
  32580. removeSkeleton(toRemove: Skeleton): number;
  32581. /**
  32582. * Remove a morph target for the list of scene's morph targets
  32583. * @param toRemove defines the morph target to remove
  32584. * @returns the index where the morph target was in the morph target list
  32585. */
  32586. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32587. /**
  32588. * Remove a light for the list of scene's lights
  32589. * @param toRemove defines the light to remove
  32590. * @returns the index where the light was in the light list
  32591. */
  32592. removeLight(toRemove: Light): number;
  32593. /**
  32594. * Remove a camera for the list of scene's cameras
  32595. * @param toRemove defines the camera to remove
  32596. * @returns the index where the camera was in the camera list
  32597. */
  32598. removeCamera(toRemove: Camera): number;
  32599. /**
  32600. * Remove a particle system for the list of scene's particle systems
  32601. * @param toRemove defines the particle system to remove
  32602. * @returns the index where the particle system was in the particle system list
  32603. */
  32604. removeParticleSystem(toRemove: IParticleSystem): number;
  32605. /**
  32606. * Remove a animation for the list of scene's animations
  32607. * @param toRemove defines the animation to remove
  32608. * @returns the index where the animation was in the animation list
  32609. */
  32610. removeAnimation(toRemove: Animation): number;
  32611. /**
  32612. * Removes the given animation group from this scene.
  32613. * @param toRemove The animation group to remove
  32614. * @returns The index of the removed animation group
  32615. */
  32616. removeAnimationGroup(toRemove: AnimationGroup): number;
  32617. /**
  32618. * Removes the given multi-material from this scene.
  32619. * @param toRemove The multi-material to remove
  32620. * @returns The index of the removed multi-material
  32621. */
  32622. removeMultiMaterial(toRemove: MultiMaterial): number;
  32623. /**
  32624. * Removes the given material from this scene.
  32625. * @param toRemove The material to remove
  32626. * @returns The index of the removed material
  32627. */
  32628. removeMaterial(toRemove: Material): number;
  32629. /**
  32630. * Removes the given action manager from this scene.
  32631. * @param toRemove The action manager to remove
  32632. * @returns The index of the removed action manager
  32633. */
  32634. removeActionManager(toRemove: AbstractActionManager): number;
  32635. /**
  32636. * Removes the given texture from this scene.
  32637. * @param toRemove The texture to remove
  32638. * @returns The index of the removed texture
  32639. */
  32640. removeTexture(toRemove: BaseTexture): number;
  32641. /**
  32642. * Adds the given light to this scene
  32643. * @param newLight The light to add
  32644. */
  32645. addLight(newLight: Light): void;
  32646. /**
  32647. * Sorts the list list based on light priorities
  32648. */
  32649. sortLightsByPriority(): void;
  32650. /**
  32651. * Adds the given camera to this scene
  32652. * @param newCamera The camera to add
  32653. */
  32654. addCamera(newCamera: Camera): void;
  32655. /**
  32656. * Adds the given skeleton to this scene
  32657. * @param newSkeleton The skeleton to add
  32658. */
  32659. addSkeleton(newSkeleton: Skeleton): void;
  32660. /**
  32661. * Adds the given particle system to this scene
  32662. * @param newParticleSystem The particle system to add
  32663. */
  32664. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32665. /**
  32666. * Adds the given animation to this scene
  32667. * @param newAnimation The animation to add
  32668. */
  32669. addAnimation(newAnimation: Animation): void;
  32670. /**
  32671. * Adds the given animation group to this scene.
  32672. * @param newAnimationGroup The animation group to add
  32673. */
  32674. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32675. /**
  32676. * Adds the given multi-material to this scene
  32677. * @param newMultiMaterial The multi-material to add
  32678. */
  32679. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32680. /**
  32681. * Adds the given material to this scene
  32682. * @param newMaterial The material to add
  32683. */
  32684. addMaterial(newMaterial: Material): void;
  32685. /**
  32686. * Adds the given morph target to this scene
  32687. * @param newMorphTargetManager The morph target to add
  32688. */
  32689. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32690. /**
  32691. * Adds the given geometry to this scene
  32692. * @param newGeometry The geometry to add
  32693. */
  32694. addGeometry(newGeometry: Geometry): void;
  32695. /**
  32696. * Adds the given action manager to this scene
  32697. * @param newActionManager The action manager to add
  32698. */
  32699. addActionManager(newActionManager: AbstractActionManager): void;
  32700. /**
  32701. * Adds the given texture to this scene.
  32702. * @param newTexture The texture to add
  32703. */
  32704. addTexture(newTexture: BaseTexture): void;
  32705. /**
  32706. * Switch active camera
  32707. * @param newCamera defines the new active camera
  32708. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32709. */
  32710. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32711. /**
  32712. * sets the active camera of the scene using its ID
  32713. * @param id defines the camera's ID
  32714. * @return the new active camera or null if none found.
  32715. */
  32716. setActiveCameraByID(id: string): Nullable<Camera>;
  32717. /**
  32718. * sets the active camera of the scene using its name
  32719. * @param name defines the camera's name
  32720. * @returns the new active camera or null if none found.
  32721. */
  32722. setActiveCameraByName(name: string): Nullable<Camera>;
  32723. /**
  32724. * get an animation group using its name
  32725. * @param name defines the material's name
  32726. * @return the animation group or null if none found.
  32727. */
  32728. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32729. /**
  32730. * Get a material using its unique id
  32731. * @param uniqueId defines the material's unique id
  32732. * @return the material or null if none found.
  32733. */
  32734. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32735. /**
  32736. * get a material using its id
  32737. * @param id defines the material's ID
  32738. * @return the material or null if none found.
  32739. */
  32740. getMaterialByID(id: string): Nullable<Material>;
  32741. /**
  32742. * Gets a material using its name
  32743. * @param name defines the material's name
  32744. * @return the material or null if none found.
  32745. */
  32746. getMaterialByName(name: string): Nullable<Material>;
  32747. /**
  32748. * Gets a camera using its id
  32749. * @param id defines the id to look for
  32750. * @returns the camera or null if not found
  32751. */
  32752. getCameraByID(id: string): Nullable<Camera>;
  32753. /**
  32754. * Gets a camera using its unique id
  32755. * @param uniqueId defines the unique id to look for
  32756. * @returns the camera or null if not found
  32757. */
  32758. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32759. /**
  32760. * Gets a camera using its name
  32761. * @param name defines the camera's name
  32762. * @return the camera or null if none found.
  32763. */
  32764. getCameraByName(name: string): Nullable<Camera>;
  32765. /**
  32766. * Gets a bone using its id
  32767. * @param id defines the bone's id
  32768. * @return the bone or null if not found
  32769. */
  32770. getBoneByID(id: string): Nullable<Bone>;
  32771. /**
  32772. * Gets a bone using its id
  32773. * @param name defines the bone's name
  32774. * @return the bone or null if not found
  32775. */
  32776. getBoneByName(name: string): Nullable<Bone>;
  32777. /**
  32778. * Gets a light node using its name
  32779. * @param name defines the the light's name
  32780. * @return the light or null if none found.
  32781. */
  32782. getLightByName(name: string): Nullable<Light>;
  32783. /**
  32784. * Gets a light node using its id
  32785. * @param id defines the light's id
  32786. * @return the light or null if none found.
  32787. */
  32788. getLightByID(id: string): Nullable<Light>;
  32789. /**
  32790. * Gets a light node using its scene-generated unique ID
  32791. * @param uniqueId defines the light's unique id
  32792. * @return the light or null if none found.
  32793. */
  32794. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32795. /**
  32796. * Gets a particle system by id
  32797. * @param id defines the particle system id
  32798. * @return the corresponding system or null if none found
  32799. */
  32800. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32801. /**
  32802. * Gets a geometry using its ID
  32803. * @param id defines the geometry's id
  32804. * @return the geometry or null if none found.
  32805. */
  32806. getGeometryByID(id: string): Nullable<Geometry>;
  32807. private _getGeometryByUniqueID;
  32808. /**
  32809. * Add a new geometry to this scene
  32810. * @param geometry defines the geometry to be added to the scene.
  32811. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32812. * @return a boolean defining if the geometry was added or not
  32813. */
  32814. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32815. /**
  32816. * Removes an existing geometry
  32817. * @param geometry defines the geometry to be removed from the scene
  32818. * @return a boolean defining if the geometry was removed or not
  32819. */
  32820. removeGeometry(geometry: Geometry): boolean;
  32821. /**
  32822. * Gets the list of geometries attached to the scene
  32823. * @returns an array of Geometry
  32824. */
  32825. getGeometries(): Geometry[];
  32826. /**
  32827. * Gets the first added mesh found of a given ID
  32828. * @param id defines the id to search for
  32829. * @return the mesh found or null if not found at all
  32830. */
  32831. getMeshByID(id: string): Nullable<AbstractMesh>;
  32832. /**
  32833. * Gets a list of meshes using their id
  32834. * @param id defines the id to search for
  32835. * @returns a list of meshes
  32836. */
  32837. getMeshesByID(id: string): Array<AbstractMesh>;
  32838. /**
  32839. * Gets the first added transform node found of a given ID
  32840. * @param id defines the id to search for
  32841. * @return the found transform node or null if not found at all.
  32842. */
  32843. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32844. /**
  32845. * Gets a transform node with its auto-generated unique id
  32846. * @param uniqueId efines the unique id to search for
  32847. * @return the found transform node or null if not found at all.
  32848. */
  32849. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32850. /**
  32851. * Gets a list of transform nodes using their id
  32852. * @param id defines the id to search for
  32853. * @returns a list of transform nodes
  32854. */
  32855. getTransformNodesByID(id: string): Array<TransformNode>;
  32856. /**
  32857. * Gets a mesh with its auto-generated unique id
  32858. * @param uniqueId defines the unique id to search for
  32859. * @return the found mesh or null if not found at all.
  32860. */
  32861. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32862. /**
  32863. * Gets a the last added mesh using a given id
  32864. * @param id defines the id to search for
  32865. * @return the found mesh or null if not found at all.
  32866. */
  32867. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32868. /**
  32869. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32870. * @param id defines the id to search for
  32871. * @return the found node or null if not found at all
  32872. */
  32873. getLastEntryByID(id: string): Nullable<Node>;
  32874. /**
  32875. * Gets a node (Mesh, Camera, Light) using a given id
  32876. * @param id defines the id to search for
  32877. * @return the found node or null if not found at all
  32878. */
  32879. getNodeByID(id: string): Nullable<Node>;
  32880. /**
  32881. * Gets a node (Mesh, Camera, Light) using a given name
  32882. * @param name defines the name to search for
  32883. * @return the found node or null if not found at all.
  32884. */
  32885. getNodeByName(name: string): Nullable<Node>;
  32886. /**
  32887. * Gets a mesh using a given name
  32888. * @param name defines the name to search for
  32889. * @return the found mesh or null if not found at all.
  32890. */
  32891. getMeshByName(name: string): Nullable<AbstractMesh>;
  32892. /**
  32893. * Gets a transform node using a given name
  32894. * @param name defines the name to search for
  32895. * @return the found transform node or null if not found at all.
  32896. */
  32897. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32898. /**
  32899. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32900. * @param id defines the id to search for
  32901. * @return the found skeleton or null if not found at all.
  32902. */
  32903. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32904. /**
  32905. * Gets a skeleton using a given auto generated unique id
  32906. * @param uniqueId defines the unique id to search for
  32907. * @return the found skeleton or null if not found at all.
  32908. */
  32909. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32910. /**
  32911. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32912. * @param id defines the id to search for
  32913. * @return the found skeleton or null if not found at all.
  32914. */
  32915. getSkeletonById(id: string): Nullable<Skeleton>;
  32916. /**
  32917. * Gets a skeleton using a given name
  32918. * @param name defines the name to search for
  32919. * @return the found skeleton or null if not found at all.
  32920. */
  32921. getSkeletonByName(name: string): Nullable<Skeleton>;
  32922. /**
  32923. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32924. * @param id defines the id to search for
  32925. * @return the found morph target manager or null if not found at all.
  32926. */
  32927. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32928. /**
  32929. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32930. * @param id defines the id to search for
  32931. * @return the found morph target or null if not found at all.
  32932. */
  32933. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32934. /**
  32935. * Gets a boolean indicating if the given mesh is active
  32936. * @param mesh defines the mesh to look for
  32937. * @returns true if the mesh is in the active list
  32938. */
  32939. isActiveMesh(mesh: AbstractMesh): boolean;
  32940. /**
  32941. * Return a unique id as a string which can serve as an identifier for the scene
  32942. */
  32943. readonly uid: string;
  32944. /**
  32945. * Add an externaly attached data from its key.
  32946. * This method call will fail and return false, if such key already exists.
  32947. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32948. * @param key the unique key that identifies the data
  32949. * @param data the data object to associate to the key for this Engine instance
  32950. * @return true if no such key were already present and the data was added successfully, false otherwise
  32951. */
  32952. addExternalData<T>(key: string, data: T): boolean;
  32953. /**
  32954. * Get an externaly attached data from its key
  32955. * @param key the unique key that identifies the data
  32956. * @return the associated data, if present (can be null), or undefined if not present
  32957. */
  32958. getExternalData<T>(key: string): Nullable<T>;
  32959. /**
  32960. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32961. * @param key the unique key that identifies the data
  32962. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32963. * @return the associated data, can be null if the factory returned null.
  32964. */
  32965. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32966. /**
  32967. * Remove an externaly attached data from the Engine instance
  32968. * @param key the unique key that identifies the data
  32969. * @return true if the data was successfully removed, false if it doesn't exist
  32970. */
  32971. removeExternalData(key: string): boolean;
  32972. private _evaluateSubMesh;
  32973. /**
  32974. * Clear the processed materials smart array preventing retention point in material dispose.
  32975. */
  32976. freeProcessedMaterials(): void;
  32977. private _preventFreeActiveMeshesAndRenderingGroups;
  32978. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32979. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32980. * when disposing several meshes in a row or a hierarchy of meshes.
  32981. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32982. */
  32983. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32984. /**
  32985. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32986. */
  32987. freeActiveMeshes(): void;
  32988. /**
  32989. * Clear the info related to rendering groups preventing retention points during dispose.
  32990. */
  32991. freeRenderingGroups(): void;
  32992. /** @hidden */
  32993. _isInIntermediateRendering(): boolean;
  32994. /**
  32995. * Lambda returning the list of potentially active meshes.
  32996. */
  32997. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32998. /**
  32999. * Lambda returning the list of potentially active sub meshes.
  33000. */
  33001. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33002. /**
  33003. * Lambda returning the list of potentially intersecting sub meshes.
  33004. */
  33005. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33006. /**
  33007. * Lambda returning the list of potentially colliding sub meshes.
  33008. */
  33009. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33010. private _activeMeshesFrozen;
  33011. /**
  33012. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33013. * @returns the current scene
  33014. */
  33015. freezeActiveMeshes(): Scene;
  33016. /**
  33017. * Use this function to restart evaluating active meshes on every frame
  33018. * @returns the current scene
  33019. */
  33020. unfreezeActiveMeshes(): Scene;
  33021. private _evaluateActiveMeshes;
  33022. private _activeMesh;
  33023. /**
  33024. * Update the transform matrix to update from the current active camera
  33025. * @param force defines a boolean used to force the update even if cache is up to date
  33026. */
  33027. updateTransformMatrix(force?: boolean): void;
  33028. /**
  33029. * 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)
  33030. * @param alternateCamera defines the camera to use
  33031. */
  33032. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33033. /** @hidden */
  33034. _allowPostProcessClearColor: boolean;
  33035. private _renderForCamera;
  33036. private _processSubCameras;
  33037. private _checkIntersections;
  33038. /** @hidden */
  33039. _advancePhysicsEngineStep(step: number): void;
  33040. /**
  33041. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33042. */
  33043. getDeterministicFrameTime: () => number;
  33044. /** @hidden */
  33045. _animate(): void;
  33046. /**
  33047. * Render the scene
  33048. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33049. */
  33050. render(updateCameras?: boolean): void;
  33051. /**
  33052. * Freeze all materials
  33053. * A frozen material will not be updatable but should be faster to render
  33054. */
  33055. freezeMaterials(): void;
  33056. /**
  33057. * Unfreeze all materials
  33058. * A frozen material will not be updatable but should be faster to render
  33059. */
  33060. unfreezeMaterials(): void;
  33061. /**
  33062. * Releases all held ressources
  33063. */
  33064. dispose(): void;
  33065. /**
  33066. * Gets if the scene is already disposed
  33067. */
  33068. readonly isDisposed: boolean;
  33069. /**
  33070. * Call this function to reduce memory footprint of the scene.
  33071. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33072. */
  33073. clearCachedVertexData(): void;
  33074. /**
  33075. * This function will remove the local cached buffer data from texture.
  33076. * It will save memory but will prevent the texture from being rebuilt
  33077. */
  33078. cleanCachedTextureBuffer(): void;
  33079. /**
  33080. * Get the world extend vectors with an optional filter
  33081. *
  33082. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33083. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33084. */
  33085. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33086. min: Vector3;
  33087. max: Vector3;
  33088. };
  33089. /**
  33090. * Creates a ray that can be used to pick in the scene
  33091. * @param x defines the x coordinate of the origin (on-screen)
  33092. * @param y defines the y coordinate of the origin (on-screen)
  33093. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33094. * @param camera defines the camera to use for the picking
  33095. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33096. * @returns a Ray
  33097. */
  33098. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33099. /**
  33100. * Creates a ray that can be used to pick in the scene
  33101. * @param x defines the x coordinate of the origin (on-screen)
  33102. * @param y defines the y coordinate of the origin (on-screen)
  33103. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33104. * @param result defines the ray where to store the picking ray
  33105. * @param camera defines the camera to use for the picking
  33106. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33107. * @returns the current scene
  33108. */
  33109. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33110. /**
  33111. * Creates a ray that can be used to pick in the scene
  33112. * @param x defines the x coordinate of the origin (on-screen)
  33113. * @param y defines the y coordinate of the origin (on-screen)
  33114. * @param camera defines the camera to use for the picking
  33115. * @returns a Ray
  33116. */
  33117. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33118. /**
  33119. * Creates a ray that can be used to pick in the scene
  33120. * @param x defines the x coordinate of the origin (on-screen)
  33121. * @param y defines the y coordinate of the origin (on-screen)
  33122. * @param result defines the ray where to store the picking ray
  33123. * @param camera defines the camera to use for the picking
  33124. * @returns the current scene
  33125. */
  33126. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33127. /** Launch a ray to try to pick a mesh in the scene
  33128. * @param x position on screen
  33129. * @param y position on screen
  33130. * @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
  33131. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33132. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33133. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33134. * @returns a PickingInfo
  33135. */
  33136. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33137. /** Use the given ray to pick a mesh in the scene
  33138. * @param ray The ray to use to pick meshes
  33139. * @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
  33140. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33141. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33142. * @returns a PickingInfo
  33143. */
  33144. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33145. /**
  33146. * Launch a ray to try to pick a mesh in the scene
  33147. * @param x X position on screen
  33148. * @param y Y position on screen
  33149. * @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
  33150. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33151. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33152. * @returns an array of PickingInfo
  33153. */
  33154. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33155. /**
  33156. * Launch a ray to try to pick a mesh in the scene
  33157. * @param ray Ray to use
  33158. * @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
  33159. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33160. * @returns an array of PickingInfo
  33161. */
  33162. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33163. /**
  33164. * Force the value of meshUnderPointer
  33165. * @param mesh defines the mesh to use
  33166. */
  33167. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33168. /**
  33169. * Gets the mesh under the pointer
  33170. * @returns a Mesh or null if no mesh is under the pointer
  33171. */
  33172. getPointerOverMesh(): Nullable<AbstractMesh>;
  33173. /** @hidden */
  33174. _rebuildGeometries(): void;
  33175. /** @hidden */
  33176. _rebuildTextures(): void;
  33177. private _getByTags;
  33178. /**
  33179. * Get a list of meshes by tags
  33180. * @param tagsQuery defines the tags query to use
  33181. * @param forEach defines a predicate used to filter results
  33182. * @returns an array of Mesh
  33183. */
  33184. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33185. /**
  33186. * Get a list of cameras by tags
  33187. * @param tagsQuery defines the tags query to use
  33188. * @param forEach defines a predicate used to filter results
  33189. * @returns an array of Camera
  33190. */
  33191. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33192. /**
  33193. * Get a list of lights by tags
  33194. * @param tagsQuery defines the tags query to use
  33195. * @param forEach defines a predicate used to filter results
  33196. * @returns an array of Light
  33197. */
  33198. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33199. /**
  33200. * Get a list of materials by tags
  33201. * @param tagsQuery defines the tags query to use
  33202. * @param forEach defines a predicate used to filter results
  33203. * @returns an array of Material
  33204. */
  33205. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33206. /**
  33207. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33208. * This allowed control for front to back rendering or reversly depending of the special needs.
  33209. *
  33210. * @param renderingGroupId The rendering group id corresponding to its index
  33211. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33212. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33213. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33214. */
  33215. 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;
  33216. /**
  33217. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33218. *
  33219. * @param renderingGroupId The rendering group id corresponding to its index
  33220. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33221. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33222. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33223. */
  33224. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33225. /**
  33226. * Gets the current auto clear configuration for one rendering group of the rendering
  33227. * manager.
  33228. * @param index the rendering group index to get the information for
  33229. * @returns The auto clear setup for the requested rendering group
  33230. */
  33231. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33232. private _blockMaterialDirtyMechanism;
  33233. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33234. blockMaterialDirtyMechanism: boolean;
  33235. /**
  33236. * Will flag all materials as dirty to trigger new shader compilation
  33237. * @param flag defines the flag used to specify which material part must be marked as dirty
  33238. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33239. */
  33240. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33241. /** @hidden */
  33242. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33243. /** @hidden */
  33244. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33245. }
  33246. }
  33247. declare module BABYLON {
  33248. /**
  33249. * Set of assets to keep when moving a scene into an asset container.
  33250. */
  33251. export class KeepAssets extends AbstractScene {
  33252. }
  33253. /**
  33254. * Container with a set of assets that can be added or removed from a scene.
  33255. */
  33256. export class AssetContainer extends AbstractScene {
  33257. /**
  33258. * The scene the AssetContainer belongs to.
  33259. */
  33260. scene: Scene;
  33261. /**
  33262. * Instantiates an AssetContainer.
  33263. * @param scene The scene the AssetContainer belongs to.
  33264. */
  33265. constructor(scene: Scene);
  33266. /**
  33267. * Adds all the assets from the container to the scene.
  33268. */
  33269. addAllToScene(): void;
  33270. /**
  33271. * Removes all the assets in the container from the scene
  33272. */
  33273. removeAllFromScene(): void;
  33274. /**
  33275. * Disposes all the assets in the container
  33276. */
  33277. dispose(): void;
  33278. private _moveAssets;
  33279. /**
  33280. * Removes all the assets contained in the scene and adds them to the container.
  33281. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33282. */
  33283. moveAllFromScene(keepAssets?: KeepAssets): void;
  33284. /**
  33285. * 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.
  33286. * @returns the root mesh
  33287. */
  33288. createRootMesh(): Mesh;
  33289. }
  33290. }
  33291. declare module BABYLON {
  33292. /**
  33293. * Defines how the parser contract is defined.
  33294. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33295. */
  33296. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33297. /**
  33298. * Defines how the individual parser contract is defined.
  33299. * These parser can parse an individual asset
  33300. */
  33301. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33302. /**
  33303. * Base class of the scene acting as a container for the different elements composing a scene.
  33304. * This class is dynamically extended by the different components of the scene increasing
  33305. * flexibility and reducing coupling
  33306. */
  33307. export abstract class AbstractScene {
  33308. /**
  33309. * Stores the list of available parsers in the application.
  33310. */
  33311. private static _BabylonFileParsers;
  33312. /**
  33313. * Stores the list of available individual parsers in the application.
  33314. */
  33315. private static _IndividualBabylonFileParsers;
  33316. /**
  33317. * Adds a parser in the list of available ones
  33318. * @param name Defines the name of the parser
  33319. * @param parser Defines the parser to add
  33320. */
  33321. static AddParser(name: string, parser: BabylonFileParser): void;
  33322. /**
  33323. * Gets a general parser from the list of avaialble ones
  33324. * @param name Defines the name of the parser
  33325. * @returns the requested parser or null
  33326. */
  33327. static GetParser(name: string): Nullable<BabylonFileParser>;
  33328. /**
  33329. * Adds n individual parser in the list of available ones
  33330. * @param name Defines the name of the parser
  33331. * @param parser Defines the parser to add
  33332. */
  33333. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33334. /**
  33335. * Gets an individual parser from the list of avaialble ones
  33336. * @param name Defines the name of the parser
  33337. * @returns the requested parser or null
  33338. */
  33339. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33340. /**
  33341. * Parser json data and populate both a scene and its associated container object
  33342. * @param jsonData Defines the data to parse
  33343. * @param scene Defines the scene to parse the data for
  33344. * @param container Defines the container attached to the parsing sequence
  33345. * @param rootUrl Defines the root url of the data
  33346. */
  33347. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33348. /**
  33349. * Gets the list of root nodes (ie. nodes with no parent)
  33350. */
  33351. rootNodes: Node[];
  33352. /** All of the cameras added to this scene
  33353. * @see http://doc.babylonjs.com/babylon101/cameras
  33354. */
  33355. cameras: Camera[];
  33356. /**
  33357. * All of the lights added to this scene
  33358. * @see http://doc.babylonjs.com/babylon101/lights
  33359. */
  33360. lights: Light[];
  33361. /**
  33362. * All of the (abstract) meshes added to this scene
  33363. */
  33364. meshes: AbstractMesh[];
  33365. /**
  33366. * The list of skeletons added to the scene
  33367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33368. */
  33369. skeletons: Skeleton[];
  33370. /**
  33371. * All of the particle systems added to this scene
  33372. * @see http://doc.babylonjs.com/babylon101/particles
  33373. */
  33374. particleSystems: IParticleSystem[];
  33375. /**
  33376. * Gets a list of Animations associated with the scene
  33377. */
  33378. animations: Animation[];
  33379. /**
  33380. * All of the animation groups added to this scene
  33381. * @see http://doc.babylonjs.com/how_to/group
  33382. */
  33383. animationGroups: AnimationGroup[];
  33384. /**
  33385. * All of the multi-materials added to this scene
  33386. * @see http://doc.babylonjs.com/how_to/multi_materials
  33387. */
  33388. multiMaterials: MultiMaterial[];
  33389. /**
  33390. * All of the materials added to this scene
  33391. * In the context of a Scene, it is not supposed to be modified manually.
  33392. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33393. * Note also that the order of the Material wihin the array is not significant and might change.
  33394. * @see http://doc.babylonjs.com/babylon101/materials
  33395. */
  33396. materials: Material[];
  33397. /**
  33398. * The list of morph target managers added to the scene
  33399. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33400. */
  33401. morphTargetManagers: MorphTargetManager[];
  33402. /**
  33403. * The list of geometries used in the scene.
  33404. */
  33405. geometries: Geometry[];
  33406. /**
  33407. * All of the tranform nodes added to this scene
  33408. * In the context of a Scene, it is not supposed to be modified manually.
  33409. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33410. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33411. * @see http://doc.babylonjs.com/how_to/transformnode
  33412. */
  33413. transformNodes: TransformNode[];
  33414. /**
  33415. * ActionManagers available on the scene.
  33416. */
  33417. actionManagers: AbstractActionManager[];
  33418. /**
  33419. * Textures to keep.
  33420. */
  33421. textures: BaseTexture[];
  33422. }
  33423. }
  33424. declare module BABYLON {
  33425. /**
  33426. * Defines a sound that can be played in the application.
  33427. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33429. */
  33430. export class Sound {
  33431. /**
  33432. * The name of the sound in the scene.
  33433. */
  33434. name: string;
  33435. /**
  33436. * Does the sound autoplay once loaded.
  33437. */
  33438. autoplay: boolean;
  33439. /**
  33440. * Does the sound loop after it finishes playing once.
  33441. */
  33442. loop: boolean;
  33443. /**
  33444. * Does the sound use a custom attenuation curve to simulate the falloff
  33445. * happening when the source gets further away from the camera.
  33446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33447. */
  33448. useCustomAttenuation: boolean;
  33449. /**
  33450. * The sound track id this sound belongs to.
  33451. */
  33452. soundTrackId: number;
  33453. /**
  33454. * Is this sound currently played.
  33455. */
  33456. isPlaying: boolean;
  33457. /**
  33458. * Is this sound currently paused.
  33459. */
  33460. isPaused: boolean;
  33461. /**
  33462. * Does this sound enables spatial sound.
  33463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33464. */
  33465. spatialSound: boolean;
  33466. /**
  33467. * Define the reference distance the sound should be heard perfectly.
  33468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33469. */
  33470. refDistance: number;
  33471. /**
  33472. * Define the roll off factor of spatial sounds.
  33473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33474. */
  33475. rolloffFactor: number;
  33476. /**
  33477. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33479. */
  33480. maxDistance: number;
  33481. /**
  33482. * Define the distance attenuation model the sound will follow.
  33483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33484. */
  33485. distanceModel: string;
  33486. /**
  33487. * @hidden
  33488. * Back Compat
  33489. **/
  33490. onended: () => any;
  33491. /**
  33492. * Observable event when the current playing sound finishes.
  33493. */
  33494. onEndedObservable: Observable<Sound>;
  33495. private _panningModel;
  33496. private _playbackRate;
  33497. private _streaming;
  33498. private _startTime;
  33499. private _startOffset;
  33500. private _position;
  33501. /** @hidden */
  33502. _positionInEmitterSpace: boolean;
  33503. private _localDirection;
  33504. private _volume;
  33505. private _isReadyToPlay;
  33506. private _isDirectional;
  33507. private _readyToPlayCallback;
  33508. private _audioBuffer;
  33509. private _soundSource;
  33510. private _streamingSource;
  33511. private _soundPanner;
  33512. private _soundGain;
  33513. private _inputAudioNode;
  33514. private _outputAudioNode;
  33515. private _coneInnerAngle;
  33516. private _coneOuterAngle;
  33517. private _coneOuterGain;
  33518. private _scene;
  33519. private _connectedTransformNode;
  33520. private _customAttenuationFunction;
  33521. private _registerFunc;
  33522. private _isOutputConnected;
  33523. private _htmlAudioElement;
  33524. private _urlType;
  33525. /** @hidden */
  33526. static _SceneComponentInitialization: (scene: Scene) => void;
  33527. /**
  33528. * Create a sound and attach it to a scene
  33529. * @param name Name of your sound
  33530. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33531. * @param scene defines the scene the sound belongs to
  33532. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33533. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33534. */
  33535. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33536. /**
  33537. * Release the sound and its associated resources
  33538. */
  33539. dispose(): void;
  33540. /**
  33541. * Gets if the sounds is ready to be played or not.
  33542. * @returns true if ready, otherwise false
  33543. */
  33544. isReady(): boolean;
  33545. private _soundLoaded;
  33546. /**
  33547. * Sets the data of the sound from an audiobuffer
  33548. * @param audioBuffer The audioBuffer containing the data
  33549. */
  33550. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33551. /**
  33552. * Updates the current sounds options such as maxdistance, loop...
  33553. * @param options A JSON object containing values named as the object properties
  33554. */
  33555. updateOptions(options: any): void;
  33556. private _createSpatialParameters;
  33557. private _updateSpatialParameters;
  33558. /**
  33559. * Switch the panning model to HRTF:
  33560. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33562. */
  33563. switchPanningModelToHRTF(): void;
  33564. /**
  33565. * Switch the panning model to Equal Power:
  33566. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33568. */
  33569. switchPanningModelToEqualPower(): void;
  33570. private _switchPanningModel;
  33571. /**
  33572. * Connect this sound to a sound track audio node like gain...
  33573. * @param soundTrackAudioNode the sound track audio node to connect to
  33574. */
  33575. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33576. /**
  33577. * Transform this sound into a directional source
  33578. * @param coneInnerAngle Size of the inner cone in degree
  33579. * @param coneOuterAngle Size of the outer cone in degree
  33580. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33581. */
  33582. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33583. /**
  33584. * Gets or sets the inner angle for the directional cone.
  33585. */
  33586. /**
  33587. * Gets or sets the inner angle for the directional cone.
  33588. */
  33589. directionalConeInnerAngle: number;
  33590. /**
  33591. * Gets or sets the outer angle for the directional cone.
  33592. */
  33593. /**
  33594. * Gets or sets the outer angle for the directional cone.
  33595. */
  33596. directionalConeOuterAngle: number;
  33597. /**
  33598. * Sets the position of the emitter if spatial sound is enabled
  33599. * @param newPosition Defines the new posisiton
  33600. */
  33601. setPosition(newPosition: Vector3): void;
  33602. /**
  33603. * Sets the local direction of the emitter if spatial sound is enabled
  33604. * @param newLocalDirection Defines the new local direction
  33605. */
  33606. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33607. private _updateDirection;
  33608. /** @hidden */
  33609. updateDistanceFromListener(): void;
  33610. /**
  33611. * Sets a new custom attenuation function for the sound.
  33612. * @param callback Defines the function used for the attenuation
  33613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33614. */
  33615. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33616. /**
  33617. * Play the sound
  33618. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33619. * @param offset (optional) Start the sound setting it at a specific time
  33620. */
  33621. play(time?: number, offset?: number): void;
  33622. private _onended;
  33623. /**
  33624. * Stop the sound
  33625. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33626. */
  33627. stop(time?: number): void;
  33628. /**
  33629. * Put the sound in pause
  33630. */
  33631. pause(): void;
  33632. /**
  33633. * Sets a dedicated volume for this sounds
  33634. * @param newVolume Define the new volume of the sound
  33635. * @param time Define in how long the sound should be at this value
  33636. */
  33637. setVolume(newVolume: number, time?: number): void;
  33638. /**
  33639. * Set the sound play back rate
  33640. * @param newPlaybackRate Define the playback rate the sound should be played at
  33641. */
  33642. setPlaybackRate(newPlaybackRate: number): void;
  33643. /**
  33644. * Gets the volume of the sound.
  33645. * @returns the volume of the sound
  33646. */
  33647. getVolume(): number;
  33648. /**
  33649. * Attach the sound to a dedicated mesh
  33650. * @param transformNode The transform node to connect the sound with
  33651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33652. */
  33653. attachToMesh(transformNode: TransformNode): void;
  33654. /**
  33655. * Detach the sound from the previously attached mesh
  33656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33657. */
  33658. detachFromMesh(): void;
  33659. private _onRegisterAfterWorldMatrixUpdate;
  33660. /**
  33661. * Clone the current sound in the scene.
  33662. * @returns the new sound clone
  33663. */
  33664. clone(): Nullable<Sound>;
  33665. /**
  33666. * Gets the current underlying audio buffer containing the data
  33667. * @returns the audio buffer
  33668. */
  33669. getAudioBuffer(): Nullable<AudioBuffer>;
  33670. /**
  33671. * Serializes the Sound in a JSON representation
  33672. * @returns the JSON representation of the sound
  33673. */
  33674. serialize(): any;
  33675. /**
  33676. * Parse a JSON representation of a sound to innstantiate in a given scene
  33677. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33678. * @param scene Define the scene the new parsed sound should be created in
  33679. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33680. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33681. * @returns the newly parsed sound
  33682. */
  33683. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33684. }
  33685. }
  33686. declare module BABYLON {
  33687. /**
  33688. * This defines an action helpful to play a defined sound on a triggered action.
  33689. */
  33690. export class PlaySoundAction extends Action {
  33691. private _sound;
  33692. /**
  33693. * Instantiate the action
  33694. * @param triggerOptions defines the trigger options
  33695. * @param sound defines the sound to play
  33696. * @param condition defines the trigger related conditions
  33697. */
  33698. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33699. /** @hidden */
  33700. _prepare(): void;
  33701. /**
  33702. * Execute the action and play the sound.
  33703. */
  33704. execute(): void;
  33705. /**
  33706. * Serializes the actions and its related information.
  33707. * @param parent defines the object to serialize in
  33708. * @returns the serialized object
  33709. */
  33710. serialize(parent: any): any;
  33711. }
  33712. /**
  33713. * This defines an action helpful to stop a defined sound on a triggered action.
  33714. */
  33715. export class StopSoundAction extends Action {
  33716. private _sound;
  33717. /**
  33718. * Instantiate the action
  33719. * @param triggerOptions defines the trigger options
  33720. * @param sound defines the sound to stop
  33721. * @param condition defines the trigger related conditions
  33722. */
  33723. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33724. /** @hidden */
  33725. _prepare(): void;
  33726. /**
  33727. * Execute the action and stop the sound.
  33728. */
  33729. execute(): void;
  33730. /**
  33731. * Serializes the actions and its related information.
  33732. * @param parent defines the object to serialize in
  33733. * @returns the serialized object
  33734. */
  33735. serialize(parent: any): any;
  33736. }
  33737. }
  33738. declare module BABYLON {
  33739. /**
  33740. * This defines an action responsible to change the value of a property
  33741. * by interpolating between its current value and the newly set one once triggered.
  33742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33743. */
  33744. export class InterpolateValueAction extends Action {
  33745. /**
  33746. * Defines the path of the property where the value should be interpolated
  33747. */
  33748. propertyPath: string;
  33749. /**
  33750. * Defines the target value at the end of the interpolation.
  33751. */
  33752. value: any;
  33753. /**
  33754. * Defines the time it will take for the property to interpolate to the value.
  33755. */
  33756. duration: number;
  33757. /**
  33758. * Defines if the other scene animations should be stopped when the action has been triggered
  33759. */
  33760. stopOtherAnimations?: boolean;
  33761. /**
  33762. * Defines a callback raised once the interpolation animation has been done.
  33763. */
  33764. onInterpolationDone?: () => void;
  33765. /**
  33766. * Observable triggered once the interpolation animation has been done.
  33767. */
  33768. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33769. private _target;
  33770. private _effectiveTarget;
  33771. private _property;
  33772. /**
  33773. * Instantiate the action
  33774. * @param triggerOptions defines the trigger options
  33775. * @param target defines the object containing the value to interpolate
  33776. * @param propertyPath defines the path to the property in the target object
  33777. * @param value defines the target value at the end of the interpolation
  33778. * @param duration deines the time it will take for the property to interpolate to the value.
  33779. * @param condition defines the trigger related conditions
  33780. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33781. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33782. */
  33783. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33784. /** @hidden */
  33785. _prepare(): void;
  33786. /**
  33787. * Execute the action starts the value interpolation.
  33788. */
  33789. execute(): void;
  33790. /**
  33791. * Serializes the actions and its related information.
  33792. * @param parent defines the object to serialize in
  33793. * @returns the serialized object
  33794. */
  33795. serialize(parent: any): any;
  33796. }
  33797. }
  33798. declare module BABYLON {
  33799. /**
  33800. * Options allowed during the creation of a sound track.
  33801. */
  33802. export interface ISoundTrackOptions {
  33803. /**
  33804. * The volume the sound track should take during creation
  33805. */
  33806. volume?: number;
  33807. /**
  33808. * Define if the sound track is the main sound track of the scene
  33809. */
  33810. mainTrack?: boolean;
  33811. }
  33812. /**
  33813. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33814. * It will be also used in a future release to apply effects on a specific track.
  33815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33816. */
  33817. export class SoundTrack {
  33818. /**
  33819. * The unique identifier of the sound track in the scene.
  33820. */
  33821. id: number;
  33822. /**
  33823. * The list of sounds included in the sound track.
  33824. */
  33825. soundCollection: Array<Sound>;
  33826. private _outputAudioNode;
  33827. private _scene;
  33828. private _isMainTrack;
  33829. private _connectedAnalyser;
  33830. private _options;
  33831. private _isInitialized;
  33832. /**
  33833. * Creates a new sound track.
  33834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33835. * @param scene Define the scene the sound track belongs to
  33836. * @param options
  33837. */
  33838. constructor(scene: Scene, options?: ISoundTrackOptions);
  33839. private _initializeSoundTrackAudioGraph;
  33840. /**
  33841. * Release the sound track and its associated resources
  33842. */
  33843. dispose(): void;
  33844. /**
  33845. * Adds a sound to this sound track
  33846. * @param sound define the cound to add
  33847. * @ignoreNaming
  33848. */
  33849. AddSound(sound: Sound): void;
  33850. /**
  33851. * Removes a sound to this sound track
  33852. * @param sound define the cound to remove
  33853. * @ignoreNaming
  33854. */
  33855. RemoveSound(sound: Sound): void;
  33856. /**
  33857. * Set a global volume for the full sound track.
  33858. * @param newVolume Define the new volume of the sound track
  33859. */
  33860. setVolume(newVolume: number): void;
  33861. /**
  33862. * Switch the panning model to HRTF:
  33863. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33865. */
  33866. switchPanningModelToHRTF(): void;
  33867. /**
  33868. * Switch the panning model to Equal Power:
  33869. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33871. */
  33872. switchPanningModelToEqualPower(): void;
  33873. /**
  33874. * Connect the sound track to an audio analyser allowing some amazing
  33875. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33877. * @param analyser The analyser to connect to the engine
  33878. */
  33879. connectToAnalyser(analyser: Analyser): void;
  33880. }
  33881. }
  33882. declare module BABYLON {
  33883. interface AbstractScene {
  33884. /**
  33885. * The list of sounds used in the scene.
  33886. */
  33887. sounds: Nullable<Array<Sound>>;
  33888. }
  33889. interface Scene {
  33890. /**
  33891. * @hidden
  33892. * Backing field
  33893. */
  33894. _mainSoundTrack: SoundTrack;
  33895. /**
  33896. * The main sound track played by the scene.
  33897. * It cotains your primary collection of sounds.
  33898. */
  33899. mainSoundTrack: SoundTrack;
  33900. /**
  33901. * The list of sound tracks added to the scene
  33902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33903. */
  33904. soundTracks: Nullable<Array<SoundTrack>>;
  33905. /**
  33906. * Gets a sound using a given name
  33907. * @param name defines the name to search for
  33908. * @return the found sound or null if not found at all.
  33909. */
  33910. getSoundByName(name: string): Nullable<Sound>;
  33911. /**
  33912. * Gets or sets if audio support is enabled
  33913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33914. */
  33915. audioEnabled: boolean;
  33916. /**
  33917. * Gets or sets if audio will be output to headphones
  33918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33919. */
  33920. headphone: boolean;
  33921. }
  33922. /**
  33923. * Defines the sound scene component responsible to manage any sounds
  33924. * in a given scene.
  33925. */
  33926. export class AudioSceneComponent implements ISceneSerializableComponent {
  33927. /**
  33928. * The component name helpfull to identify the component in the list of scene components.
  33929. */
  33930. readonly name: string;
  33931. /**
  33932. * The scene the component belongs to.
  33933. */
  33934. scene: Scene;
  33935. private _audioEnabled;
  33936. /**
  33937. * Gets whether audio is enabled or not.
  33938. * Please use related enable/disable method to switch state.
  33939. */
  33940. readonly audioEnabled: boolean;
  33941. private _headphone;
  33942. /**
  33943. * Gets whether audio is outputing to headphone or not.
  33944. * Please use the according Switch methods to change output.
  33945. */
  33946. readonly headphone: boolean;
  33947. /**
  33948. * Creates a new instance of the component for the given scene
  33949. * @param scene Defines the scene to register the component in
  33950. */
  33951. constructor(scene: Scene);
  33952. /**
  33953. * Registers the component in a given scene
  33954. */
  33955. register(): void;
  33956. /**
  33957. * Rebuilds the elements related to this component in case of
  33958. * context lost for instance.
  33959. */
  33960. rebuild(): void;
  33961. /**
  33962. * Serializes the component data to the specified json object
  33963. * @param serializationObject The object to serialize to
  33964. */
  33965. serialize(serializationObject: any): void;
  33966. /**
  33967. * Adds all the element from the container to the scene
  33968. * @param container the container holding the elements
  33969. */
  33970. addFromContainer(container: AbstractScene): void;
  33971. /**
  33972. * Removes all the elements in the container from the scene
  33973. * @param container contains the elements to remove
  33974. */
  33975. removeFromContainer(container: AbstractScene): void;
  33976. /**
  33977. * Disposes the component and the associated ressources.
  33978. */
  33979. dispose(): void;
  33980. /**
  33981. * Disables audio in the associated scene.
  33982. */
  33983. disableAudio(): void;
  33984. /**
  33985. * Enables audio in the associated scene.
  33986. */
  33987. enableAudio(): void;
  33988. /**
  33989. * Switch audio to headphone output.
  33990. */
  33991. switchAudioModeForHeadphones(): void;
  33992. /**
  33993. * Switch audio to normal speakers.
  33994. */
  33995. switchAudioModeForNormalSpeakers(): void;
  33996. private _afterRender;
  33997. }
  33998. }
  33999. declare module BABYLON {
  34000. /**
  34001. * Wraps one or more Sound objects and selects one with random weight for playback.
  34002. */
  34003. export class WeightedSound {
  34004. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34005. loop: boolean;
  34006. private _coneInnerAngle;
  34007. private _coneOuterAngle;
  34008. private _volume;
  34009. /** A Sound is currently playing. */
  34010. isPlaying: boolean;
  34011. /** A Sound is currently paused. */
  34012. isPaused: boolean;
  34013. private _sounds;
  34014. private _weights;
  34015. private _currentIndex?;
  34016. /**
  34017. * Creates a new WeightedSound from the list of sounds given.
  34018. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34019. * @param sounds Array of Sounds that will be selected from.
  34020. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34021. */
  34022. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34023. /**
  34024. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34025. */
  34026. /**
  34027. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34028. */
  34029. directionalConeInnerAngle: number;
  34030. /**
  34031. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34032. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34033. */
  34034. /**
  34035. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34036. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34037. */
  34038. directionalConeOuterAngle: number;
  34039. /**
  34040. * Playback volume.
  34041. */
  34042. /**
  34043. * Playback volume.
  34044. */
  34045. volume: number;
  34046. private _onended;
  34047. /**
  34048. * Suspend playback
  34049. */
  34050. pause(): void;
  34051. /**
  34052. * Stop playback
  34053. */
  34054. stop(): void;
  34055. /**
  34056. * Start playback.
  34057. * @param startOffset Position the clip head at a specific time in seconds.
  34058. */
  34059. play(startOffset?: number): void;
  34060. }
  34061. }
  34062. declare module BABYLON {
  34063. /**
  34064. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34065. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34066. */
  34067. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34068. /**
  34069. * Gets the name of the behavior.
  34070. */
  34071. readonly name: string;
  34072. /**
  34073. * The easing function used by animations
  34074. */
  34075. static EasingFunction: BackEase;
  34076. /**
  34077. * The easing mode used by animations
  34078. */
  34079. static EasingMode: number;
  34080. /**
  34081. * The duration of the animation, in milliseconds
  34082. */
  34083. transitionDuration: number;
  34084. /**
  34085. * Length of the distance animated by the transition when lower radius is reached
  34086. */
  34087. lowerRadiusTransitionRange: number;
  34088. /**
  34089. * Length of the distance animated by the transition when upper radius is reached
  34090. */
  34091. upperRadiusTransitionRange: number;
  34092. private _autoTransitionRange;
  34093. /**
  34094. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34095. */
  34096. /**
  34097. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34098. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34099. */
  34100. autoTransitionRange: boolean;
  34101. private _attachedCamera;
  34102. private _onAfterCheckInputsObserver;
  34103. private _onMeshTargetChangedObserver;
  34104. /**
  34105. * Initializes the behavior.
  34106. */
  34107. init(): void;
  34108. /**
  34109. * Attaches the behavior to its arc rotate camera.
  34110. * @param camera Defines the camera to attach the behavior to
  34111. */
  34112. attach(camera: ArcRotateCamera): void;
  34113. /**
  34114. * Detaches the behavior from its current arc rotate camera.
  34115. */
  34116. detach(): void;
  34117. private _radiusIsAnimating;
  34118. private _radiusBounceTransition;
  34119. private _animatables;
  34120. private _cachedWheelPrecision;
  34121. /**
  34122. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34123. * @param radiusLimit The limit to check against.
  34124. * @return Bool to indicate if at limit.
  34125. */
  34126. private _isRadiusAtLimit;
  34127. /**
  34128. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34129. * @param radiusDelta The delta by which to animate to. Can be negative.
  34130. */
  34131. private _applyBoundRadiusAnimation;
  34132. /**
  34133. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34134. */
  34135. protected _clearAnimationLocks(): void;
  34136. /**
  34137. * Stops and removes all animations that have been applied to the camera
  34138. */
  34139. stopAllAnimations(): void;
  34140. }
  34141. }
  34142. declare module BABYLON {
  34143. /**
  34144. * 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.
  34145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34146. */
  34147. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34148. /**
  34149. * Gets the name of the behavior.
  34150. */
  34151. readonly name: string;
  34152. private _mode;
  34153. private _radiusScale;
  34154. private _positionScale;
  34155. private _defaultElevation;
  34156. private _elevationReturnTime;
  34157. private _elevationReturnWaitTime;
  34158. private _zoomStopsAnimation;
  34159. private _framingTime;
  34160. /**
  34161. * The easing function used by animations
  34162. */
  34163. static EasingFunction: ExponentialEase;
  34164. /**
  34165. * The easing mode used by animations
  34166. */
  34167. static EasingMode: number;
  34168. /**
  34169. * Sets the current mode used by the behavior
  34170. */
  34171. /**
  34172. * Gets current mode used by the behavior.
  34173. */
  34174. mode: number;
  34175. /**
  34176. * Sets the scale applied to the radius (1 by default)
  34177. */
  34178. /**
  34179. * Gets the scale applied to the radius
  34180. */
  34181. radiusScale: number;
  34182. /**
  34183. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34184. */
  34185. /**
  34186. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34187. */
  34188. positionScale: number;
  34189. /**
  34190. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34191. * behaviour is triggered, in radians.
  34192. */
  34193. /**
  34194. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34195. * behaviour is triggered, in radians.
  34196. */
  34197. defaultElevation: number;
  34198. /**
  34199. * Sets the time (in milliseconds) taken to return to the default beta position.
  34200. * Negative value indicates camera should not return to default.
  34201. */
  34202. /**
  34203. * Gets the time (in milliseconds) taken to return to the default beta position.
  34204. * Negative value indicates camera should not return to default.
  34205. */
  34206. elevationReturnTime: number;
  34207. /**
  34208. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34209. */
  34210. /**
  34211. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34212. */
  34213. elevationReturnWaitTime: number;
  34214. /**
  34215. * Sets the flag that indicates if user zooming should stop animation.
  34216. */
  34217. /**
  34218. * Gets the flag that indicates if user zooming should stop animation.
  34219. */
  34220. zoomStopsAnimation: boolean;
  34221. /**
  34222. * Sets the transition time when framing the mesh, in milliseconds
  34223. */
  34224. /**
  34225. * Gets the transition time when framing the mesh, in milliseconds
  34226. */
  34227. framingTime: number;
  34228. /**
  34229. * Define if the behavior should automatically change the configured
  34230. * camera limits and sensibilities.
  34231. */
  34232. autoCorrectCameraLimitsAndSensibility: boolean;
  34233. private _onPrePointerObservableObserver;
  34234. private _onAfterCheckInputsObserver;
  34235. private _onMeshTargetChangedObserver;
  34236. private _attachedCamera;
  34237. private _isPointerDown;
  34238. private _lastInteractionTime;
  34239. /**
  34240. * Initializes the behavior.
  34241. */
  34242. init(): void;
  34243. /**
  34244. * Attaches the behavior to its arc rotate camera.
  34245. * @param camera Defines the camera to attach the behavior to
  34246. */
  34247. attach(camera: ArcRotateCamera): void;
  34248. /**
  34249. * Detaches the behavior from its current arc rotate camera.
  34250. */
  34251. detach(): void;
  34252. private _animatables;
  34253. private _betaIsAnimating;
  34254. private _betaTransition;
  34255. private _radiusTransition;
  34256. private _vectorTransition;
  34257. /**
  34258. * Targets the given mesh and updates zoom level accordingly.
  34259. * @param mesh The mesh to target.
  34260. * @param radius Optional. If a cached radius position already exists, overrides default.
  34261. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34262. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34263. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34264. */
  34265. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34266. /**
  34267. * Targets the given mesh with its children and updates zoom level accordingly.
  34268. * @param mesh The mesh to target.
  34269. * @param radius Optional. If a cached radius position already exists, overrides default.
  34270. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34271. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34272. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34273. */
  34274. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34275. /**
  34276. * Targets the given meshes with their children and updates zoom level accordingly.
  34277. * @param meshes The mesh to target.
  34278. * @param radius Optional. If a cached radius position already exists, overrides default.
  34279. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34280. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34281. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34282. */
  34283. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34284. /**
  34285. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34286. * @param minimumWorld Determines the smaller position of the bounding box extend
  34287. * @param maximumWorld Determines the bigger position of the bounding box extend
  34288. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34289. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34290. */
  34291. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34292. /**
  34293. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34294. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34295. * frustum width.
  34296. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34297. * to fully enclose the mesh in the viewing frustum.
  34298. */
  34299. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34300. /**
  34301. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34302. * is automatically returned to its default position (expected to be above ground plane).
  34303. */
  34304. private _maintainCameraAboveGround;
  34305. /**
  34306. * Returns the frustum slope based on the canvas ratio and camera FOV
  34307. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34308. */
  34309. private _getFrustumSlope;
  34310. /**
  34311. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34312. */
  34313. private _clearAnimationLocks;
  34314. /**
  34315. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34316. */
  34317. private _applyUserInteraction;
  34318. /**
  34319. * Stops and removes all animations that have been applied to the camera
  34320. */
  34321. stopAllAnimations(): void;
  34322. /**
  34323. * Gets a value indicating if the user is moving the camera
  34324. */
  34325. readonly isUserIsMoving: boolean;
  34326. /**
  34327. * The camera can move all the way towards the mesh.
  34328. */
  34329. static IgnoreBoundsSizeMode: number;
  34330. /**
  34331. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34332. */
  34333. static FitFrustumSidesMode: number;
  34334. }
  34335. }
  34336. declare module BABYLON {
  34337. /**
  34338. * Base class for Camera Pointer Inputs.
  34339. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34340. * for example usage.
  34341. */
  34342. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34343. /**
  34344. * Defines the camera the input is attached to.
  34345. */
  34346. abstract camera: Camera;
  34347. /**
  34348. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34349. */
  34350. protected _altKey: boolean;
  34351. protected _ctrlKey: boolean;
  34352. protected _metaKey: boolean;
  34353. protected _shiftKey: boolean;
  34354. /**
  34355. * Which mouse buttons were pressed at time of last mouse event.
  34356. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34357. */
  34358. protected _buttonsPressed: number;
  34359. /**
  34360. * Defines the buttons associated with the input to handle camera move.
  34361. */
  34362. buttons: number[];
  34363. /**
  34364. * Attach the input controls to a specific dom element to get the input from.
  34365. * @param element Defines the element the controls should be listened from
  34366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34367. */
  34368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34369. /**
  34370. * Detach the current controls from the specified dom element.
  34371. * @param element Defines the element to stop listening the inputs from
  34372. */
  34373. detachControl(element: Nullable<HTMLElement>): void;
  34374. /**
  34375. * Gets the class name of the current input.
  34376. * @returns the class name
  34377. */
  34378. getClassName(): string;
  34379. /**
  34380. * Get the friendly name associated with the input class.
  34381. * @returns the input friendly name
  34382. */
  34383. getSimpleName(): string;
  34384. /**
  34385. * Called on pointer POINTERDOUBLETAP event.
  34386. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34387. */
  34388. protected onDoubleTap(type: string): void;
  34389. /**
  34390. * Called on pointer POINTERMOVE event if only a single touch is active.
  34391. * Override this method to provide functionality.
  34392. */
  34393. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34394. /**
  34395. * Called on pointer POINTERMOVE event if multiple touches are active.
  34396. * Override this method to provide functionality.
  34397. */
  34398. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34399. /**
  34400. * Called on JS contextmenu event.
  34401. * Override this method to provide functionality.
  34402. */
  34403. protected onContextMenu(evt: PointerEvent): void;
  34404. /**
  34405. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34406. * press.
  34407. * Override this method to provide functionality.
  34408. */
  34409. protected onButtonDown(evt: PointerEvent): void;
  34410. /**
  34411. * Called each time a new POINTERUP event occurs. Ie, for each button
  34412. * release.
  34413. * Override this method to provide functionality.
  34414. */
  34415. protected onButtonUp(evt: PointerEvent): void;
  34416. /**
  34417. * Called when window becomes inactive.
  34418. * Override this method to provide functionality.
  34419. */
  34420. protected onLostFocus(): void;
  34421. private _pointerInput;
  34422. private _observer;
  34423. private _onLostFocus;
  34424. private pointA;
  34425. private pointB;
  34426. }
  34427. }
  34428. declare module BABYLON {
  34429. /**
  34430. * Manage the pointers inputs to control an arc rotate camera.
  34431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34432. */
  34433. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34434. /**
  34435. * Defines the camera the input is attached to.
  34436. */
  34437. camera: ArcRotateCamera;
  34438. /**
  34439. * Gets the class name of the current input.
  34440. * @returns the class name
  34441. */
  34442. getClassName(): string;
  34443. /**
  34444. * Defines the buttons associated with the input to handle camera move.
  34445. */
  34446. buttons: number[];
  34447. /**
  34448. * Defines the pointer angular sensibility along the X axis or how fast is
  34449. * the camera rotating.
  34450. */
  34451. angularSensibilityX: number;
  34452. /**
  34453. * Defines the pointer angular sensibility along the Y axis or how fast is
  34454. * the camera rotating.
  34455. */
  34456. angularSensibilityY: number;
  34457. /**
  34458. * Defines the pointer pinch precision or how fast is the camera zooming.
  34459. */
  34460. pinchPrecision: number;
  34461. /**
  34462. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34463. * from 0.
  34464. * It defines the percentage of current camera.radius to use as delta when
  34465. * pinch zoom is used.
  34466. */
  34467. pinchDeltaPercentage: number;
  34468. /**
  34469. * Defines the pointer panning sensibility or how fast is the camera moving.
  34470. */
  34471. panningSensibility: number;
  34472. /**
  34473. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34474. */
  34475. multiTouchPanning: boolean;
  34476. /**
  34477. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34478. * zoom (pinch) through multitouch.
  34479. */
  34480. multiTouchPanAndZoom: boolean;
  34481. /**
  34482. * Revers pinch action direction.
  34483. */
  34484. pinchInwards: boolean;
  34485. private _isPanClick;
  34486. private _twoFingerActivityCount;
  34487. private _isPinching;
  34488. /**
  34489. * Called on pointer POINTERMOVE event if only a single touch is active.
  34490. */
  34491. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34492. /**
  34493. * Called on pointer POINTERDOUBLETAP event.
  34494. */
  34495. protected onDoubleTap(type: string): void;
  34496. /**
  34497. * Called on pointer POINTERMOVE event if multiple touches are active.
  34498. */
  34499. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34500. /**
  34501. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34502. * press.
  34503. */
  34504. protected onButtonDown(evt: PointerEvent): void;
  34505. /**
  34506. * Called each time a new POINTERUP event occurs. Ie, for each button
  34507. * release.
  34508. */
  34509. protected onButtonUp(evt: PointerEvent): void;
  34510. /**
  34511. * Called when window becomes inactive.
  34512. */
  34513. protected onLostFocus(): void;
  34514. }
  34515. }
  34516. declare module BABYLON {
  34517. /**
  34518. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34520. */
  34521. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34522. /**
  34523. * Defines the camera the input is attached to.
  34524. */
  34525. camera: ArcRotateCamera;
  34526. /**
  34527. * Defines the list of key codes associated with the up action (increase alpha)
  34528. */
  34529. keysUp: number[];
  34530. /**
  34531. * Defines the list of key codes associated with the down action (decrease alpha)
  34532. */
  34533. keysDown: number[];
  34534. /**
  34535. * Defines the list of key codes associated with the left action (increase beta)
  34536. */
  34537. keysLeft: number[];
  34538. /**
  34539. * Defines the list of key codes associated with the right action (decrease beta)
  34540. */
  34541. keysRight: number[];
  34542. /**
  34543. * Defines the list of key codes associated with the reset action.
  34544. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34545. */
  34546. keysReset: number[];
  34547. /**
  34548. * Defines the panning sensibility of the inputs.
  34549. * (How fast is the camera paning)
  34550. */
  34551. panningSensibility: number;
  34552. /**
  34553. * Defines the zooming sensibility of the inputs.
  34554. * (How fast is the camera zooming)
  34555. */
  34556. zoomingSensibility: number;
  34557. /**
  34558. * Defines wether maintaining the alt key down switch the movement mode from
  34559. * orientation to zoom.
  34560. */
  34561. useAltToZoom: boolean;
  34562. /**
  34563. * Rotation speed of the camera
  34564. */
  34565. angularSpeed: number;
  34566. private _keys;
  34567. private _ctrlPressed;
  34568. private _altPressed;
  34569. private _onCanvasBlurObserver;
  34570. private _onKeyboardObserver;
  34571. private _engine;
  34572. private _scene;
  34573. /**
  34574. * Attach the input controls to a specific dom element to get the input from.
  34575. * @param element Defines the element the controls should be listened from
  34576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34577. */
  34578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34579. /**
  34580. * Detach the current controls from the specified dom element.
  34581. * @param element Defines the element to stop listening the inputs from
  34582. */
  34583. detachControl(element: Nullable<HTMLElement>): void;
  34584. /**
  34585. * Update the current camera state depending on the inputs that have been used this frame.
  34586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34587. */
  34588. checkInputs(): void;
  34589. /**
  34590. * Gets the class name of the current intput.
  34591. * @returns the class name
  34592. */
  34593. getClassName(): string;
  34594. /**
  34595. * Get the friendly name associated with the input class.
  34596. * @returns the input friendly name
  34597. */
  34598. getSimpleName(): string;
  34599. }
  34600. }
  34601. declare module BABYLON {
  34602. /**
  34603. * Manage the mouse wheel inputs to control an arc rotate camera.
  34604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34605. */
  34606. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34607. /**
  34608. * Defines the camera the input is attached to.
  34609. */
  34610. camera: ArcRotateCamera;
  34611. /**
  34612. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34613. */
  34614. wheelPrecision: number;
  34615. /**
  34616. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34617. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34618. */
  34619. wheelDeltaPercentage: number;
  34620. private _wheel;
  34621. private _observer;
  34622. /**
  34623. * Attach the input controls to a specific dom element to get the input from.
  34624. * @param element Defines the element the controls should be listened from
  34625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34626. */
  34627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34628. /**
  34629. * Detach the current controls from the specified dom element.
  34630. * @param element Defines the element to stop listening the inputs from
  34631. */
  34632. detachControl(element: Nullable<HTMLElement>): void;
  34633. /**
  34634. * Gets the class name of the current intput.
  34635. * @returns the class name
  34636. */
  34637. getClassName(): string;
  34638. /**
  34639. * Get the friendly name associated with the input class.
  34640. * @returns the input friendly name
  34641. */
  34642. getSimpleName(): string;
  34643. }
  34644. }
  34645. declare module BABYLON {
  34646. /**
  34647. * Default Inputs manager for the ArcRotateCamera.
  34648. * It groups all the default supported inputs for ease of use.
  34649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34650. */
  34651. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34652. /**
  34653. * Instantiates a new ArcRotateCameraInputsManager.
  34654. * @param camera Defines the camera the inputs belong to
  34655. */
  34656. constructor(camera: ArcRotateCamera);
  34657. /**
  34658. * Add mouse wheel input support to the input manager.
  34659. * @returns the current input manager
  34660. */
  34661. addMouseWheel(): ArcRotateCameraInputsManager;
  34662. /**
  34663. * Add pointers input support to the input manager.
  34664. * @returns the current input manager
  34665. */
  34666. addPointers(): ArcRotateCameraInputsManager;
  34667. /**
  34668. * Add keyboard input support to the input manager.
  34669. * @returns the current input manager
  34670. */
  34671. addKeyboard(): ArcRotateCameraInputsManager;
  34672. }
  34673. }
  34674. declare module BABYLON {
  34675. /**
  34676. * This represents an orbital type of camera.
  34677. *
  34678. * 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.
  34679. * 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.
  34680. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34681. */
  34682. export class ArcRotateCamera extends TargetCamera {
  34683. /**
  34684. * Defines the rotation angle of the camera along the longitudinal axis.
  34685. */
  34686. alpha: number;
  34687. /**
  34688. * Defines the rotation angle of the camera along the latitudinal axis.
  34689. */
  34690. beta: number;
  34691. /**
  34692. * Defines the radius of the camera from it s target point.
  34693. */
  34694. radius: number;
  34695. protected _target: Vector3;
  34696. protected _targetHost: Nullable<AbstractMesh>;
  34697. /**
  34698. * Defines the target point of the camera.
  34699. * The camera looks towards it form the radius distance.
  34700. */
  34701. target: Vector3;
  34702. /**
  34703. * Define the current local position of the camera in the scene
  34704. */
  34705. position: Vector3;
  34706. /**
  34707. * Current inertia value on the longitudinal axis.
  34708. * The bigger this number the longer it will take for the camera to stop.
  34709. */
  34710. inertialAlphaOffset: number;
  34711. /**
  34712. * Current inertia value on the latitudinal axis.
  34713. * The bigger this number the longer it will take for the camera to stop.
  34714. */
  34715. inertialBetaOffset: number;
  34716. /**
  34717. * Current inertia value on the radius axis.
  34718. * The bigger this number the longer it will take for the camera to stop.
  34719. */
  34720. inertialRadiusOffset: number;
  34721. /**
  34722. * Minimum allowed angle on the longitudinal axis.
  34723. * This can help limiting how the Camera is able to move in the scene.
  34724. */
  34725. lowerAlphaLimit: Nullable<number>;
  34726. /**
  34727. * Maximum allowed angle on the longitudinal axis.
  34728. * This can help limiting how the Camera is able to move in the scene.
  34729. */
  34730. upperAlphaLimit: Nullable<number>;
  34731. /**
  34732. * Minimum allowed angle on the latitudinal axis.
  34733. * This can help limiting how the Camera is able to move in the scene.
  34734. */
  34735. lowerBetaLimit: number;
  34736. /**
  34737. * Maximum allowed angle on the latitudinal axis.
  34738. * This can help limiting how the Camera is able to move in the scene.
  34739. */
  34740. upperBetaLimit: number;
  34741. /**
  34742. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34743. * This can help limiting how the Camera is able to move in the scene.
  34744. */
  34745. lowerRadiusLimit: Nullable<number>;
  34746. /**
  34747. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34748. * This can help limiting how the Camera is able to move in the scene.
  34749. */
  34750. upperRadiusLimit: Nullable<number>;
  34751. /**
  34752. * Defines the current inertia value used during panning of the camera along the X axis.
  34753. */
  34754. inertialPanningX: number;
  34755. /**
  34756. * Defines the current inertia value used during panning of the camera along the Y axis.
  34757. */
  34758. inertialPanningY: number;
  34759. /**
  34760. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34761. * Basically if your fingers moves away from more than this distance you will be considered
  34762. * in pinch mode.
  34763. */
  34764. pinchToPanMaxDistance: number;
  34765. /**
  34766. * Defines the maximum distance the camera can pan.
  34767. * This could help keeping the cammera always in your scene.
  34768. */
  34769. panningDistanceLimit: Nullable<number>;
  34770. /**
  34771. * Defines the target of the camera before paning.
  34772. */
  34773. panningOriginTarget: Vector3;
  34774. /**
  34775. * Defines the value of the inertia used during panning.
  34776. * 0 would mean stop inertia and one would mean no decelleration at all.
  34777. */
  34778. panningInertia: number;
  34779. /**
  34780. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34781. */
  34782. angularSensibilityX: number;
  34783. /**
  34784. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34785. */
  34786. angularSensibilityY: number;
  34787. /**
  34788. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34789. */
  34790. pinchPrecision: number;
  34791. /**
  34792. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34793. * It will be used instead of pinchDeltaPrecision if different from 0.
  34794. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34795. */
  34796. pinchDeltaPercentage: number;
  34797. /**
  34798. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34799. */
  34800. panningSensibility: number;
  34801. /**
  34802. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34803. */
  34804. keysUp: number[];
  34805. /**
  34806. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34807. */
  34808. keysDown: number[];
  34809. /**
  34810. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34811. */
  34812. keysLeft: number[];
  34813. /**
  34814. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34815. */
  34816. keysRight: number[];
  34817. /**
  34818. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34819. */
  34820. wheelPrecision: number;
  34821. /**
  34822. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34823. * It will be used instead of pinchDeltaPrecision if different from 0.
  34824. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34825. */
  34826. wheelDeltaPercentage: number;
  34827. /**
  34828. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34829. */
  34830. zoomOnFactor: number;
  34831. /**
  34832. * Defines a screen offset for the camera position.
  34833. */
  34834. targetScreenOffset: Vector2;
  34835. /**
  34836. * Allows the camera to be completely reversed.
  34837. * If false the camera can not arrive upside down.
  34838. */
  34839. allowUpsideDown: boolean;
  34840. /**
  34841. * Define if double tap/click is used to restore the previously saved state of the camera.
  34842. */
  34843. useInputToRestoreState: boolean;
  34844. /** @hidden */
  34845. _viewMatrix: Matrix;
  34846. /** @hidden */
  34847. _useCtrlForPanning: boolean;
  34848. /** @hidden */
  34849. _panningMouseButton: number;
  34850. /**
  34851. * Defines the input associated to the camera.
  34852. */
  34853. inputs: ArcRotateCameraInputsManager;
  34854. /** @hidden */
  34855. _reset: () => void;
  34856. /**
  34857. * Defines the allowed panning axis.
  34858. */
  34859. panningAxis: Vector3;
  34860. protected _localDirection: Vector3;
  34861. protected _transformedDirection: Vector3;
  34862. private _bouncingBehavior;
  34863. /**
  34864. * Gets the bouncing behavior of the camera if it has been enabled.
  34865. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34866. */
  34867. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34868. /**
  34869. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34870. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34871. */
  34872. useBouncingBehavior: boolean;
  34873. private _framingBehavior;
  34874. /**
  34875. * Gets the framing behavior of the camera if it has been enabled.
  34876. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34877. */
  34878. readonly framingBehavior: Nullable<FramingBehavior>;
  34879. /**
  34880. * Defines if the framing behavior of the camera is enabled on the camera.
  34881. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34882. */
  34883. useFramingBehavior: boolean;
  34884. private _autoRotationBehavior;
  34885. /**
  34886. * Gets the auto rotation behavior of the camera if it has been enabled.
  34887. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34888. */
  34889. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34890. /**
  34891. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34893. */
  34894. useAutoRotationBehavior: boolean;
  34895. /**
  34896. * Observable triggered when the mesh target has been changed on the camera.
  34897. */
  34898. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34899. /**
  34900. * Event raised when the camera is colliding with a mesh.
  34901. */
  34902. onCollide: (collidedMesh: AbstractMesh) => void;
  34903. /**
  34904. * Defines whether the camera should check collision with the objects oh the scene.
  34905. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34906. */
  34907. checkCollisions: boolean;
  34908. /**
  34909. * Defines the collision radius of the camera.
  34910. * This simulates a sphere around the camera.
  34911. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34912. */
  34913. collisionRadius: Vector3;
  34914. protected _collider: Collider;
  34915. protected _previousPosition: Vector3;
  34916. protected _collisionVelocity: Vector3;
  34917. protected _newPosition: Vector3;
  34918. protected _previousAlpha: number;
  34919. protected _previousBeta: number;
  34920. protected _previousRadius: number;
  34921. protected _collisionTriggered: boolean;
  34922. protected _targetBoundingCenter: Nullable<Vector3>;
  34923. private _computationVector;
  34924. private _tempAxisVector;
  34925. private _tempAxisRotationMatrix;
  34926. /**
  34927. * Instantiates a new ArcRotateCamera in a given scene
  34928. * @param name Defines the name of the camera
  34929. * @param alpha Defines the camera rotation along the logitudinal axis
  34930. * @param beta Defines the camera rotation along the latitudinal axis
  34931. * @param radius Defines the camera distance from its target
  34932. * @param target Defines the camera target
  34933. * @param scene Defines the scene the camera belongs to
  34934. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34935. */
  34936. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34937. /** @hidden */
  34938. _initCache(): void;
  34939. /** @hidden */
  34940. _updateCache(ignoreParentClass?: boolean): void;
  34941. protected _getTargetPosition(): Vector3;
  34942. private _storedAlpha;
  34943. private _storedBeta;
  34944. private _storedRadius;
  34945. private _storedTarget;
  34946. /**
  34947. * Stores the current state of the camera (alpha, beta, radius and target)
  34948. * @returns the camera itself
  34949. */
  34950. storeState(): Camera;
  34951. /**
  34952. * @hidden
  34953. * Restored camera state. You must call storeState() first
  34954. */
  34955. _restoreStateValues(): boolean;
  34956. /** @hidden */
  34957. _isSynchronizedViewMatrix(): boolean;
  34958. /**
  34959. * Attached controls to the current camera.
  34960. * @param element Defines the element the controls should be listened from
  34961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34962. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34963. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34964. */
  34965. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34966. /**
  34967. * Detach the current controls from the camera.
  34968. * The camera will stop reacting to inputs.
  34969. * @param element Defines the element to stop listening the inputs from
  34970. */
  34971. detachControl(element: HTMLElement): void;
  34972. /** @hidden */
  34973. _checkInputs(): void;
  34974. protected _checkLimits(): void;
  34975. /**
  34976. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34977. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  34978. */
  34979. rebuildAnglesAndRadius(updateView?: boolean): void;
  34980. /**
  34981. * Use a position to define the current camera related information like aplha, beta and radius
  34982. * @param position Defines the position to set the camera at
  34983. */
  34984. setPosition(position: Vector3): void;
  34985. /**
  34986. * Defines the target the camera should look at.
  34987. * This will automatically adapt alpha beta and radius to fit within the new target.
  34988. * @param target Defines the new target as a Vector or a mesh
  34989. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34990. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34991. */
  34992. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34993. /** @hidden */
  34994. _getViewMatrix(): Matrix;
  34995. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34996. /**
  34997. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34998. * @param meshes Defines the mesh to zoom on
  34999. * @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)
  35000. */
  35001. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35002. /**
  35003. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35004. * The target will be changed but the radius
  35005. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35006. * @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)
  35007. */
  35008. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35009. min: Vector3;
  35010. max: Vector3;
  35011. distance: number;
  35012. }, doNotUpdateMaxZ?: boolean): void;
  35013. /**
  35014. * @override
  35015. * Override Camera.createRigCamera
  35016. */
  35017. createRigCamera(name: string, cameraIndex: number): Camera;
  35018. /**
  35019. * @hidden
  35020. * @override
  35021. * Override Camera._updateRigCameras
  35022. */
  35023. _updateRigCameras(): void;
  35024. /**
  35025. * Destroy the camera and release the current resources hold by it.
  35026. */
  35027. dispose(): void;
  35028. /**
  35029. * Gets the current object class name.
  35030. * @return the class name
  35031. */
  35032. getClassName(): string;
  35033. }
  35034. }
  35035. declare module BABYLON {
  35036. /**
  35037. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35039. */
  35040. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35041. /**
  35042. * Gets the name of the behavior.
  35043. */
  35044. readonly name: string;
  35045. private _zoomStopsAnimation;
  35046. private _idleRotationSpeed;
  35047. private _idleRotationWaitTime;
  35048. private _idleRotationSpinupTime;
  35049. /**
  35050. * Sets the flag that indicates if user zooming should stop animation.
  35051. */
  35052. /**
  35053. * Gets the flag that indicates if user zooming should stop animation.
  35054. */
  35055. zoomStopsAnimation: boolean;
  35056. /**
  35057. * Sets the default speed at which the camera rotates around the model.
  35058. */
  35059. /**
  35060. * Gets the default speed at which the camera rotates around the model.
  35061. */
  35062. idleRotationSpeed: number;
  35063. /**
  35064. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35065. */
  35066. /**
  35067. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35068. */
  35069. idleRotationWaitTime: number;
  35070. /**
  35071. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35072. */
  35073. /**
  35074. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35075. */
  35076. idleRotationSpinupTime: number;
  35077. /**
  35078. * Gets a value indicating if the camera is currently rotating because of this behavior
  35079. */
  35080. readonly rotationInProgress: boolean;
  35081. private _onPrePointerObservableObserver;
  35082. private _onAfterCheckInputsObserver;
  35083. private _attachedCamera;
  35084. private _isPointerDown;
  35085. private _lastFrameTime;
  35086. private _lastInteractionTime;
  35087. private _cameraRotationSpeed;
  35088. /**
  35089. * Initializes the behavior.
  35090. */
  35091. init(): void;
  35092. /**
  35093. * Attaches the behavior to its arc rotate camera.
  35094. * @param camera Defines the camera to attach the behavior to
  35095. */
  35096. attach(camera: ArcRotateCamera): void;
  35097. /**
  35098. * Detaches the behavior from its current arc rotate camera.
  35099. */
  35100. detach(): void;
  35101. /**
  35102. * Returns true if user is scrolling.
  35103. * @return true if user is scrolling.
  35104. */
  35105. private _userIsZooming;
  35106. private _lastFrameRadius;
  35107. private _shouldAnimationStopForInteraction;
  35108. /**
  35109. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35110. */
  35111. private _applyUserInteraction;
  35112. private _userIsMoving;
  35113. }
  35114. }
  35115. declare module BABYLON {
  35116. /**
  35117. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35118. */
  35119. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35120. private ui;
  35121. /**
  35122. * The name of the behavior
  35123. */
  35124. name: string;
  35125. /**
  35126. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35127. */
  35128. distanceAwayFromFace: number;
  35129. /**
  35130. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35131. */
  35132. distanceAwayFromBottomOfFace: number;
  35133. private _faceVectors;
  35134. private _target;
  35135. private _scene;
  35136. private _onRenderObserver;
  35137. private _tmpMatrix;
  35138. private _tmpVector;
  35139. /**
  35140. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35141. * @param ui The transform node that should be attched to the mesh
  35142. */
  35143. constructor(ui: TransformNode);
  35144. /**
  35145. * Initializes the behavior
  35146. */
  35147. init(): void;
  35148. private _closestFace;
  35149. private _zeroVector;
  35150. private _lookAtTmpMatrix;
  35151. private _lookAtToRef;
  35152. /**
  35153. * Attaches the AttachToBoxBehavior to the passed in mesh
  35154. * @param target The mesh that the specified node will be attached to
  35155. */
  35156. attach(target: Mesh): void;
  35157. /**
  35158. * Detaches the behavior from the mesh
  35159. */
  35160. detach(): void;
  35161. }
  35162. }
  35163. declare module BABYLON {
  35164. /**
  35165. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35166. */
  35167. export class FadeInOutBehavior implements Behavior<Mesh> {
  35168. /**
  35169. * Time in milliseconds to delay before fading in (Default: 0)
  35170. */
  35171. delay: number;
  35172. /**
  35173. * Time in milliseconds for the mesh to fade in (Default: 300)
  35174. */
  35175. fadeInTime: number;
  35176. private _millisecondsPerFrame;
  35177. private _hovered;
  35178. private _hoverValue;
  35179. private _ownerNode;
  35180. /**
  35181. * Instatiates the FadeInOutBehavior
  35182. */
  35183. constructor();
  35184. /**
  35185. * The name of the behavior
  35186. */
  35187. readonly name: string;
  35188. /**
  35189. * Initializes the behavior
  35190. */
  35191. init(): void;
  35192. /**
  35193. * Attaches the fade behavior on the passed in mesh
  35194. * @param ownerNode The mesh that will be faded in/out once attached
  35195. */
  35196. attach(ownerNode: Mesh): void;
  35197. /**
  35198. * Detaches the behavior from the mesh
  35199. */
  35200. detach(): void;
  35201. /**
  35202. * Triggers the mesh to begin fading in or out
  35203. * @param value if the object should fade in or out (true to fade in)
  35204. */
  35205. fadeIn(value: boolean): void;
  35206. private _update;
  35207. private _setAllVisibility;
  35208. }
  35209. }
  35210. declare module BABYLON {
  35211. /**
  35212. * Class containing a set of static utilities functions for managing Pivots
  35213. * @hidden
  35214. */
  35215. export class PivotTools {
  35216. private static _PivotCached;
  35217. private static _OldPivotPoint;
  35218. private static _PivotTranslation;
  35219. private static _PivotTmpVector;
  35220. /** @hidden */
  35221. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35222. /** @hidden */
  35223. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35224. }
  35225. }
  35226. declare module BABYLON {
  35227. /**
  35228. * Class containing static functions to help procedurally build meshes
  35229. */
  35230. export class PlaneBuilder {
  35231. /**
  35232. * Creates a plane mesh
  35233. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35234. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35235. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35237. * * 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
  35238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35239. * @param name defines the name of the mesh
  35240. * @param options defines the options used to create the mesh
  35241. * @param scene defines the hosting scene
  35242. * @returns the plane mesh
  35243. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35244. */
  35245. static CreatePlane(name: string, options: {
  35246. size?: number;
  35247. width?: number;
  35248. height?: number;
  35249. sideOrientation?: number;
  35250. frontUVs?: Vector4;
  35251. backUVs?: Vector4;
  35252. updatable?: boolean;
  35253. sourcePlane?: Plane;
  35254. }, scene: Scene): Mesh;
  35255. }
  35256. }
  35257. declare module BABYLON {
  35258. /**
  35259. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35260. */
  35261. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35262. private static _AnyMouseID;
  35263. private _attachedNode;
  35264. private _dragPlane;
  35265. private _scene;
  35266. private _pointerObserver;
  35267. private _beforeRenderObserver;
  35268. private static _planeScene;
  35269. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35270. /**
  35271. * 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)
  35272. */
  35273. maxDragAngle: number;
  35274. /**
  35275. * @hidden
  35276. */
  35277. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35278. /**
  35279. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35280. */
  35281. currentDraggingPointerID: number;
  35282. /**
  35283. * The last position where the pointer hit the drag plane in world space
  35284. */
  35285. lastDragPosition: Vector3;
  35286. /**
  35287. * If the behavior is currently in a dragging state
  35288. */
  35289. dragging: boolean;
  35290. /**
  35291. * 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)
  35292. */
  35293. dragDeltaRatio: number;
  35294. /**
  35295. * If the drag plane orientation should be updated during the dragging (Default: true)
  35296. */
  35297. updateDragPlane: boolean;
  35298. private _debugMode;
  35299. private _moving;
  35300. /**
  35301. * Fires each time the attached mesh is dragged with the pointer
  35302. * * delta between last drag position and current drag position in world space
  35303. * * dragDistance along the drag axis
  35304. * * dragPlaneNormal normal of the current drag plane used during the drag
  35305. * * dragPlanePoint in world space where the drag intersects the drag plane
  35306. */
  35307. onDragObservable: Observable<{
  35308. delta: Vector3;
  35309. dragPlanePoint: Vector3;
  35310. dragPlaneNormal: Vector3;
  35311. dragDistance: number;
  35312. pointerId: number;
  35313. }>;
  35314. /**
  35315. * Fires each time a drag begins (eg. mouse down on mesh)
  35316. */
  35317. onDragStartObservable: Observable<{
  35318. dragPlanePoint: Vector3;
  35319. pointerId: number;
  35320. }>;
  35321. /**
  35322. * Fires each time a drag ends (eg. mouse release after drag)
  35323. */
  35324. onDragEndObservable: Observable<{
  35325. dragPlanePoint: Vector3;
  35326. pointerId: number;
  35327. }>;
  35328. /**
  35329. * If the attached mesh should be moved when dragged
  35330. */
  35331. moveAttached: boolean;
  35332. /**
  35333. * If the drag behavior will react to drag events (Default: true)
  35334. */
  35335. enabled: boolean;
  35336. /**
  35337. * If camera controls should be detached during the drag
  35338. */
  35339. detachCameraControls: boolean;
  35340. /**
  35341. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35342. */
  35343. useObjectOrienationForDragging: boolean;
  35344. private _options;
  35345. /**
  35346. * Creates a pointer drag behavior that can be attached to a mesh
  35347. * @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)
  35348. */
  35349. constructor(options?: {
  35350. dragAxis?: Vector3;
  35351. dragPlaneNormal?: Vector3;
  35352. });
  35353. /**
  35354. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35355. */
  35356. validateDrag: (targetPosition: Vector3) => boolean;
  35357. /**
  35358. * The name of the behavior
  35359. */
  35360. readonly name: string;
  35361. /**
  35362. * Initializes the behavior
  35363. */
  35364. init(): void;
  35365. private _tmpVector;
  35366. private _alternatePickedPoint;
  35367. private _worldDragAxis;
  35368. private _targetPosition;
  35369. private _attachedElement;
  35370. /**
  35371. * Attaches the drag behavior the passed in mesh
  35372. * @param ownerNode The mesh that will be dragged around once attached
  35373. */
  35374. attach(ownerNode: AbstractMesh): void;
  35375. /**
  35376. * Force relase the drag action by code.
  35377. */
  35378. releaseDrag(): void;
  35379. private _startDragRay;
  35380. private _lastPointerRay;
  35381. /**
  35382. * Simulates the start of a pointer drag event on the behavior
  35383. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35384. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35385. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35386. */
  35387. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35388. private _startDrag;
  35389. private _dragDelta;
  35390. private _moveDrag;
  35391. private _pickWithRayOnDragPlane;
  35392. private _pointA;
  35393. private _pointB;
  35394. private _pointC;
  35395. private _lineA;
  35396. private _lineB;
  35397. private _localAxis;
  35398. private _lookAt;
  35399. private _updateDragPlanePosition;
  35400. /**
  35401. * Detaches the behavior from the mesh
  35402. */
  35403. detach(): void;
  35404. }
  35405. }
  35406. declare module BABYLON {
  35407. /**
  35408. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35409. */
  35410. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35411. private _dragBehaviorA;
  35412. private _dragBehaviorB;
  35413. private _startDistance;
  35414. private _initialScale;
  35415. private _targetScale;
  35416. private _ownerNode;
  35417. private _sceneRenderObserver;
  35418. /**
  35419. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35420. */
  35421. constructor();
  35422. /**
  35423. * The name of the behavior
  35424. */
  35425. readonly name: string;
  35426. /**
  35427. * Initializes the behavior
  35428. */
  35429. init(): void;
  35430. private _getCurrentDistance;
  35431. /**
  35432. * Attaches the scale behavior the passed in mesh
  35433. * @param ownerNode The mesh that will be scaled around once attached
  35434. */
  35435. attach(ownerNode: Mesh): void;
  35436. /**
  35437. * Detaches the behavior from the mesh
  35438. */
  35439. detach(): void;
  35440. }
  35441. }
  35442. declare module BABYLON {
  35443. /**
  35444. * 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
  35445. */
  35446. export class SixDofDragBehavior implements Behavior<Mesh> {
  35447. private static _virtualScene;
  35448. private _ownerNode;
  35449. private _sceneRenderObserver;
  35450. private _scene;
  35451. private _targetPosition;
  35452. private _virtualOriginMesh;
  35453. private _virtualDragMesh;
  35454. private _pointerObserver;
  35455. private _moving;
  35456. private _startingOrientation;
  35457. /**
  35458. * 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)
  35459. */
  35460. private zDragFactor;
  35461. /**
  35462. * If the object should rotate to face the drag origin
  35463. */
  35464. rotateDraggedObject: boolean;
  35465. /**
  35466. * If the behavior is currently in a dragging state
  35467. */
  35468. dragging: boolean;
  35469. /**
  35470. * 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)
  35471. */
  35472. dragDeltaRatio: number;
  35473. /**
  35474. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35475. */
  35476. currentDraggingPointerID: number;
  35477. /**
  35478. * If camera controls should be detached during the drag
  35479. */
  35480. detachCameraControls: boolean;
  35481. /**
  35482. * Fires each time a drag starts
  35483. */
  35484. onDragStartObservable: Observable<{}>;
  35485. /**
  35486. * Fires each time a drag ends (eg. mouse release after drag)
  35487. */
  35488. onDragEndObservable: Observable<{}>;
  35489. /**
  35490. * 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
  35491. */
  35492. constructor();
  35493. /**
  35494. * The name of the behavior
  35495. */
  35496. readonly name: string;
  35497. /**
  35498. * Initializes the behavior
  35499. */
  35500. init(): void;
  35501. /**
  35502. * Attaches the scale behavior the passed in mesh
  35503. * @param ownerNode The mesh that will be scaled around once attached
  35504. */
  35505. attach(ownerNode: Mesh): void;
  35506. /**
  35507. * Detaches the behavior from the mesh
  35508. */
  35509. detach(): void;
  35510. }
  35511. }
  35512. declare module BABYLON {
  35513. /**
  35514. * Class used to apply inverse kinematics to bones
  35515. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35516. */
  35517. export class BoneIKController {
  35518. private static _tmpVecs;
  35519. private static _tmpQuat;
  35520. private static _tmpMats;
  35521. /**
  35522. * Gets or sets the target mesh
  35523. */
  35524. targetMesh: AbstractMesh;
  35525. /** Gets or sets the mesh used as pole */
  35526. poleTargetMesh: AbstractMesh;
  35527. /**
  35528. * Gets or sets the bone used as pole
  35529. */
  35530. poleTargetBone: Nullable<Bone>;
  35531. /**
  35532. * Gets or sets the target position
  35533. */
  35534. targetPosition: Vector3;
  35535. /**
  35536. * Gets or sets the pole target position
  35537. */
  35538. poleTargetPosition: Vector3;
  35539. /**
  35540. * Gets or sets the pole target local offset
  35541. */
  35542. poleTargetLocalOffset: Vector3;
  35543. /**
  35544. * Gets or sets the pole angle
  35545. */
  35546. poleAngle: number;
  35547. /**
  35548. * Gets or sets the mesh associated with the controller
  35549. */
  35550. mesh: AbstractMesh;
  35551. /**
  35552. * 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)
  35553. */
  35554. slerpAmount: number;
  35555. private _bone1Quat;
  35556. private _bone1Mat;
  35557. private _bone2Ang;
  35558. private _bone1;
  35559. private _bone2;
  35560. private _bone1Length;
  35561. private _bone2Length;
  35562. private _maxAngle;
  35563. private _maxReach;
  35564. private _rightHandedSystem;
  35565. private _bendAxis;
  35566. private _slerping;
  35567. private _adjustRoll;
  35568. /**
  35569. * Gets or sets maximum allowed angle
  35570. */
  35571. maxAngle: number;
  35572. /**
  35573. * Creates a new BoneIKController
  35574. * @param mesh defines the mesh to control
  35575. * @param bone defines the bone to control
  35576. * @param options defines options to set up the controller
  35577. */
  35578. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35579. targetMesh?: AbstractMesh;
  35580. poleTargetMesh?: AbstractMesh;
  35581. poleTargetBone?: Bone;
  35582. poleTargetLocalOffset?: Vector3;
  35583. poleAngle?: number;
  35584. bendAxis?: Vector3;
  35585. maxAngle?: number;
  35586. slerpAmount?: number;
  35587. });
  35588. private _setMaxAngle;
  35589. /**
  35590. * Force the controller to update the bones
  35591. */
  35592. update(): void;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. /**
  35597. * Class used to make a bone look toward a point in space
  35598. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35599. */
  35600. export class BoneLookController {
  35601. private static _tmpVecs;
  35602. private static _tmpQuat;
  35603. private static _tmpMats;
  35604. /**
  35605. * The target Vector3 that the bone will look at
  35606. */
  35607. target: Vector3;
  35608. /**
  35609. * The mesh that the bone is attached to
  35610. */
  35611. mesh: AbstractMesh;
  35612. /**
  35613. * The bone that will be looking to the target
  35614. */
  35615. bone: Bone;
  35616. /**
  35617. * The up axis of the coordinate system that is used when the bone is rotated
  35618. */
  35619. upAxis: Vector3;
  35620. /**
  35621. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35622. */
  35623. upAxisSpace: Space;
  35624. /**
  35625. * Used to make an adjustment to the yaw of the bone
  35626. */
  35627. adjustYaw: number;
  35628. /**
  35629. * Used to make an adjustment to the pitch of the bone
  35630. */
  35631. adjustPitch: number;
  35632. /**
  35633. * Used to make an adjustment to the roll of the bone
  35634. */
  35635. adjustRoll: number;
  35636. /**
  35637. * 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)
  35638. */
  35639. slerpAmount: number;
  35640. private _minYaw;
  35641. private _maxYaw;
  35642. private _minPitch;
  35643. private _maxPitch;
  35644. private _minYawSin;
  35645. private _minYawCos;
  35646. private _maxYawSin;
  35647. private _maxYawCos;
  35648. private _midYawConstraint;
  35649. private _minPitchTan;
  35650. private _maxPitchTan;
  35651. private _boneQuat;
  35652. private _slerping;
  35653. private _transformYawPitch;
  35654. private _transformYawPitchInv;
  35655. private _firstFrameSkipped;
  35656. private _yawRange;
  35657. private _fowardAxis;
  35658. /**
  35659. * Gets or sets the minimum yaw angle that the bone can look to
  35660. */
  35661. minYaw: number;
  35662. /**
  35663. * Gets or sets the maximum yaw angle that the bone can look to
  35664. */
  35665. maxYaw: number;
  35666. /**
  35667. * Gets or sets the minimum pitch angle that the bone can look to
  35668. */
  35669. minPitch: number;
  35670. /**
  35671. * Gets or sets the maximum pitch angle that the bone can look to
  35672. */
  35673. maxPitch: number;
  35674. /**
  35675. * Create a BoneLookController
  35676. * @param mesh the mesh that the bone belongs to
  35677. * @param bone the bone that will be looking to the target
  35678. * @param target the target Vector3 to look at
  35679. * @param options optional settings:
  35680. * * maxYaw: the maximum angle the bone will yaw to
  35681. * * minYaw: the minimum angle the bone will yaw to
  35682. * * maxPitch: the maximum angle the bone will pitch to
  35683. * * minPitch: the minimum angle the bone will yaw to
  35684. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35685. * * upAxis: the up axis of the coordinate system
  35686. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35687. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35688. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35689. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35690. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35691. * * adjustRoll: used to make an adjustment to the roll of the bone
  35692. **/
  35693. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35694. maxYaw?: number;
  35695. minYaw?: number;
  35696. maxPitch?: number;
  35697. minPitch?: number;
  35698. slerpAmount?: number;
  35699. upAxis?: Vector3;
  35700. upAxisSpace?: Space;
  35701. yawAxis?: Vector3;
  35702. pitchAxis?: Vector3;
  35703. adjustYaw?: number;
  35704. adjustPitch?: number;
  35705. adjustRoll?: number;
  35706. });
  35707. /**
  35708. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35709. */
  35710. update(): void;
  35711. private _getAngleDiff;
  35712. private _getAngleBetween;
  35713. private _isAngleBetween;
  35714. }
  35715. }
  35716. declare module BABYLON {
  35717. /**
  35718. * Manage the gamepad inputs to control an arc rotate camera.
  35719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35720. */
  35721. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35722. /**
  35723. * Defines the camera the input is attached to.
  35724. */
  35725. camera: ArcRotateCamera;
  35726. /**
  35727. * Defines the gamepad the input is gathering event from.
  35728. */
  35729. gamepad: Nullable<Gamepad>;
  35730. /**
  35731. * Defines the gamepad rotation sensiblity.
  35732. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35733. */
  35734. gamepadRotationSensibility: number;
  35735. /**
  35736. * Defines the gamepad move sensiblity.
  35737. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35738. */
  35739. gamepadMoveSensibility: number;
  35740. private _onGamepadConnectedObserver;
  35741. private _onGamepadDisconnectedObserver;
  35742. /**
  35743. * Attach the input controls to a specific dom element to get the input from.
  35744. * @param element Defines the element the controls should be listened from
  35745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35746. */
  35747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35748. /**
  35749. * Detach the current controls from the specified dom element.
  35750. * @param element Defines the element to stop listening the inputs from
  35751. */
  35752. detachControl(element: Nullable<HTMLElement>): void;
  35753. /**
  35754. * Update the current camera state depending on the inputs that have been used this frame.
  35755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35756. */
  35757. checkInputs(): void;
  35758. /**
  35759. * Gets the class name of the current intput.
  35760. * @returns the class name
  35761. */
  35762. getClassName(): string;
  35763. /**
  35764. * Get the friendly name associated with the input class.
  35765. * @returns the input friendly name
  35766. */
  35767. getSimpleName(): string;
  35768. }
  35769. }
  35770. declare module BABYLON {
  35771. interface ArcRotateCameraInputsManager {
  35772. /**
  35773. * Add orientation input support to the input manager.
  35774. * @returns the current input manager
  35775. */
  35776. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35777. }
  35778. /**
  35779. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35781. */
  35782. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35783. /**
  35784. * Defines the camera the input is attached to.
  35785. */
  35786. camera: ArcRotateCamera;
  35787. /**
  35788. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35789. */
  35790. alphaCorrection: number;
  35791. /**
  35792. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35793. */
  35794. gammaCorrection: number;
  35795. private _alpha;
  35796. private _gamma;
  35797. private _dirty;
  35798. private _deviceOrientationHandler;
  35799. /**
  35800. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35801. */
  35802. constructor();
  35803. /**
  35804. * Attach the input controls to a specific dom element to get the input from.
  35805. * @param element Defines the element the controls should be listened from
  35806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35807. */
  35808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35809. /** @hidden */
  35810. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35811. /**
  35812. * Update the current camera state depending on the inputs that have been used this frame.
  35813. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35814. */
  35815. checkInputs(): void;
  35816. /**
  35817. * Detach the current controls from the specified dom element.
  35818. * @param element Defines the element to stop listening the inputs from
  35819. */
  35820. detachControl(element: Nullable<HTMLElement>): void;
  35821. /**
  35822. * Gets the class name of the current intput.
  35823. * @returns the class name
  35824. */
  35825. getClassName(): string;
  35826. /**
  35827. * Get the friendly name associated with the input class.
  35828. * @returns the input friendly name
  35829. */
  35830. getSimpleName(): string;
  35831. }
  35832. }
  35833. declare module BABYLON {
  35834. /**
  35835. * Listen to mouse events to control the camera.
  35836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35837. */
  35838. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35839. /**
  35840. * Defines the camera the input is attached to.
  35841. */
  35842. camera: FlyCamera;
  35843. /**
  35844. * Defines if touch is enabled. (Default is true.)
  35845. */
  35846. touchEnabled: boolean;
  35847. /**
  35848. * Defines the buttons associated with the input to handle camera rotation.
  35849. */
  35850. buttons: number[];
  35851. /**
  35852. * Assign buttons for Yaw control.
  35853. */
  35854. buttonsYaw: number[];
  35855. /**
  35856. * Assign buttons for Pitch control.
  35857. */
  35858. buttonsPitch: number[];
  35859. /**
  35860. * Assign buttons for Roll control.
  35861. */
  35862. buttonsRoll: number[];
  35863. /**
  35864. * Detect if any button is being pressed while mouse is moved.
  35865. * -1 = Mouse locked.
  35866. * 0 = Left button.
  35867. * 1 = Middle Button.
  35868. * 2 = Right Button.
  35869. */
  35870. activeButton: number;
  35871. /**
  35872. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35873. * Higher values reduce its sensitivity.
  35874. */
  35875. angularSensibility: number;
  35876. private _mousemoveCallback;
  35877. private _observer;
  35878. private _rollObserver;
  35879. private previousPosition;
  35880. private noPreventDefault;
  35881. private element;
  35882. /**
  35883. * Listen to mouse events to control the camera.
  35884. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35886. */
  35887. constructor(touchEnabled?: boolean);
  35888. /**
  35889. * Attach the mouse control to the HTML DOM element.
  35890. * @param element Defines the element that listens to the input events.
  35891. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35892. */
  35893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35894. /**
  35895. * Detach the current controls from the specified dom element.
  35896. * @param element Defines the element to stop listening the inputs from
  35897. */
  35898. detachControl(element: Nullable<HTMLElement>): void;
  35899. /**
  35900. * Gets the class name of the current input.
  35901. * @returns the class name.
  35902. */
  35903. getClassName(): string;
  35904. /**
  35905. * Get the friendly name associated with the input class.
  35906. * @returns the input's friendly name.
  35907. */
  35908. getSimpleName(): string;
  35909. private _pointerInput;
  35910. private _onMouseMove;
  35911. /**
  35912. * Rotate camera by mouse offset.
  35913. */
  35914. private rotateCamera;
  35915. }
  35916. }
  35917. declare module BABYLON {
  35918. /**
  35919. * Default Inputs manager for the FlyCamera.
  35920. * It groups all the default supported inputs for ease of use.
  35921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35922. */
  35923. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35924. /**
  35925. * Instantiates a new FlyCameraInputsManager.
  35926. * @param camera Defines the camera the inputs belong to.
  35927. */
  35928. constructor(camera: FlyCamera);
  35929. /**
  35930. * Add keyboard input support to the input manager.
  35931. * @returns the new FlyCameraKeyboardMoveInput().
  35932. */
  35933. addKeyboard(): FlyCameraInputsManager;
  35934. /**
  35935. * Add mouse input support to the input manager.
  35936. * @param touchEnabled Enable touch screen support.
  35937. * @returns the new FlyCameraMouseInput().
  35938. */
  35939. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35940. }
  35941. }
  35942. declare module BABYLON {
  35943. /**
  35944. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35945. * such as in a 3D Space Shooter or a Flight Simulator.
  35946. */
  35947. export class FlyCamera extends TargetCamera {
  35948. /**
  35949. * Define the collision ellipsoid of the camera.
  35950. * This is helpful for simulating a camera body, like a player's body.
  35951. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35952. */
  35953. ellipsoid: Vector3;
  35954. /**
  35955. * Define an offset for the position of the ellipsoid around the camera.
  35956. * This can be helpful if the camera is attached away from the player's body center,
  35957. * such as at its head.
  35958. */
  35959. ellipsoidOffset: Vector3;
  35960. /**
  35961. * Enable or disable collisions of the camera with the rest of the scene objects.
  35962. */
  35963. checkCollisions: boolean;
  35964. /**
  35965. * Enable or disable gravity on the camera.
  35966. */
  35967. applyGravity: boolean;
  35968. /**
  35969. * Define the current direction the camera is moving to.
  35970. */
  35971. cameraDirection: Vector3;
  35972. /**
  35973. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35974. * This overrides and empties cameraRotation.
  35975. */
  35976. rotationQuaternion: Quaternion;
  35977. /**
  35978. * Track Roll to maintain the wanted Rolling when looking around.
  35979. */
  35980. _trackRoll: number;
  35981. /**
  35982. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35983. */
  35984. rollCorrect: number;
  35985. /**
  35986. * Mimic a banked turn, Rolling the camera when Yawing.
  35987. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35988. */
  35989. bankedTurn: boolean;
  35990. /**
  35991. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35992. */
  35993. bankedTurnLimit: number;
  35994. /**
  35995. * Value of 0 disables the banked Roll.
  35996. * Value of 1 is equal to the Yaw angle in radians.
  35997. */
  35998. bankedTurnMultiplier: number;
  35999. /**
  36000. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36001. */
  36002. inputs: FlyCameraInputsManager;
  36003. /**
  36004. * Gets the input sensibility for mouse input.
  36005. * Higher values reduce sensitivity.
  36006. */
  36007. /**
  36008. * Sets the input sensibility for a mouse input.
  36009. * Higher values reduce sensitivity.
  36010. */
  36011. angularSensibility: number;
  36012. /**
  36013. * Get the keys for camera movement forward.
  36014. */
  36015. /**
  36016. * Set the keys for camera movement forward.
  36017. */
  36018. keysForward: number[];
  36019. /**
  36020. * Get the keys for camera movement backward.
  36021. */
  36022. keysBackward: number[];
  36023. /**
  36024. * Get the keys for camera movement up.
  36025. */
  36026. /**
  36027. * Set the keys for camera movement up.
  36028. */
  36029. keysUp: number[];
  36030. /**
  36031. * Get the keys for camera movement down.
  36032. */
  36033. /**
  36034. * Set the keys for camera movement down.
  36035. */
  36036. keysDown: number[];
  36037. /**
  36038. * Get the keys for camera movement left.
  36039. */
  36040. /**
  36041. * Set the keys for camera movement left.
  36042. */
  36043. keysLeft: number[];
  36044. /**
  36045. * Set the keys for camera movement right.
  36046. */
  36047. /**
  36048. * Set the keys for camera movement right.
  36049. */
  36050. keysRight: number[];
  36051. /**
  36052. * Event raised when the camera collides with a mesh in the scene.
  36053. */
  36054. onCollide: (collidedMesh: AbstractMesh) => void;
  36055. private _collider;
  36056. private _needMoveForGravity;
  36057. private _oldPosition;
  36058. private _diffPosition;
  36059. private _newPosition;
  36060. /** @hidden */
  36061. _localDirection: Vector3;
  36062. /** @hidden */
  36063. _transformedDirection: Vector3;
  36064. /**
  36065. * Instantiates a FlyCamera.
  36066. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36067. * such as in a 3D Space Shooter or a Flight Simulator.
  36068. * @param name Define the name of the camera in the scene.
  36069. * @param position Define the starting position of the camera in the scene.
  36070. * @param scene Define the scene the camera belongs to.
  36071. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36072. */
  36073. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36074. /**
  36075. * Attach a control to the HTML DOM element.
  36076. * @param element Defines the element that listens to the input events.
  36077. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36078. */
  36079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36080. /**
  36081. * Detach a control from the HTML DOM element.
  36082. * The camera will stop reacting to that input.
  36083. * @param element Defines the element that listens to the input events.
  36084. */
  36085. detachControl(element: HTMLElement): void;
  36086. private _collisionMask;
  36087. /**
  36088. * Get the mask that the camera ignores in collision events.
  36089. */
  36090. /**
  36091. * Set the mask that the camera ignores in collision events.
  36092. */
  36093. collisionMask: number;
  36094. /** @hidden */
  36095. _collideWithWorld(displacement: Vector3): void;
  36096. /** @hidden */
  36097. private _onCollisionPositionChange;
  36098. /** @hidden */
  36099. _checkInputs(): void;
  36100. /** @hidden */
  36101. _decideIfNeedsToMove(): boolean;
  36102. /** @hidden */
  36103. _updatePosition(): void;
  36104. /**
  36105. * Restore the Roll to its target value at the rate specified.
  36106. * @param rate - Higher means slower restoring.
  36107. * @hidden
  36108. */
  36109. restoreRoll(rate: number): void;
  36110. /**
  36111. * Destroy the camera and release the current resources held by it.
  36112. */
  36113. dispose(): void;
  36114. /**
  36115. * Get the current object class name.
  36116. * @returns the class name.
  36117. */
  36118. getClassName(): string;
  36119. }
  36120. }
  36121. declare module BABYLON {
  36122. /**
  36123. * Listen to keyboard events to control the camera.
  36124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36125. */
  36126. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36127. /**
  36128. * Defines the camera the input is attached to.
  36129. */
  36130. camera: FlyCamera;
  36131. /**
  36132. * The list of keyboard keys used to control the forward move of the camera.
  36133. */
  36134. keysForward: number[];
  36135. /**
  36136. * The list of keyboard keys used to control the backward move of the camera.
  36137. */
  36138. keysBackward: number[];
  36139. /**
  36140. * The list of keyboard keys used to control the forward move of the camera.
  36141. */
  36142. keysUp: number[];
  36143. /**
  36144. * The list of keyboard keys used to control the backward move of the camera.
  36145. */
  36146. keysDown: number[];
  36147. /**
  36148. * The list of keyboard keys used to control the right strafe move of the camera.
  36149. */
  36150. keysRight: number[];
  36151. /**
  36152. * The list of keyboard keys used to control the left strafe move of the camera.
  36153. */
  36154. keysLeft: number[];
  36155. private _keys;
  36156. private _onCanvasBlurObserver;
  36157. private _onKeyboardObserver;
  36158. private _engine;
  36159. private _scene;
  36160. /**
  36161. * Attach the input controls to a specific dom element to get the input from.
  36162. * @param element Defines the element the controls should be listened from
  36163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36164. */
  36165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36166. /**
  36167. * Detach the current controls from the specified dom element.
  36168. * @param element Defines the element to stop listening the inputs from
  36169. */
  36170. detachControl(element: Nullable<HTMLElement>): void;
  36171. /**
  36172. * Gets the class name of the current intput.
  36173. * @returns the class name
  36174. */
  36175. getClassName(): string;
  36176. /** @hidden */
  36177. _onLostFocus(e: FocusEvent): void;
  36178. /**
  36179. * Get the friendly name associated with the input class.
  36180. * @returns the input friendly name
  36181. */
  36182. getSimpleName(): string;
  36183. /**
  36184. * Update the current camera state depending on the inputs that have been used this frame.
  36185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36186. */
  36187. checkInputs(): void;
  36188. }
  36189. }
  36190. declare module BABYLON {
  36191. /**
  36192. * Manage the mouse wheel inputs to control a follow camera.
  36193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36194. */
  36195. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36196. /**
  36197. * Defines the camera the input is attached to.
  36198. */
  36199. camera: FollowCamera;
  36200. /**
  36201. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36202. */
  36203. axisControlRadius: boolean;
  36204. /**
  36205. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36206. */
  36207. axisControlHeight: boolean;
  36208. /**
  36209. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36210. */
  36211. axisControlRotation: boolean;
  36212. /**
  36213. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36214. * relation to mouseWheel events.
  36215. */
  36216. wheelPrecision: number;
  36217. /**
  36218. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36219. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36220. */
  36221. wheelDeltaPercentage: number;
  36222. private _wheel;
  36223. private _observer;
  36224. /**
  36225. * Attach the input controls to a specific dom element to get the input from.
  36226. * @param element Defines the element the controls should be listened from
  36227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36228. */
  36229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36230. /**
  36231. * Detach the current controls from the specified dom element.
  36232. * @param element Defines the element to stop listening the inputs from
  36233. */
  36234. detachControl(element: Nullable<HTMLElement>): void;
  36235. /**
  36236. * Gets the class name of the current intput.
  36237. * @returns the class name
  36238. */
  36239. getClassName(): string;
  36240. /**
  36241. * Get the friendly name associated with the input class.
  36242. * @returns the input friendly name
  36243. */
  36244. getSimpleName(): string;
  36245. }
  36246. }
  36247. declare module BABYLON {
  36248. /**
  36249. * Manage the pointers inputs to control an follow camera.
  36250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36251. */
  36252. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36253. /**
  36254. * Defines the camera the input is attached to.
  36255. */
  36256. camera: FollowCamera;
  36257. /**
  36258. * Gets the class name of the current input.
  36259. * @returns the class name
  36260. */
  36261. getClassName(): string;
  36262. /**
  36263. * Defines the pointer angular sensibility along the X axis or how fast is
  36264. * the camera rotating.
  36265. * A negative number will reverse the axis direction.
  36266. */
  36267. angularSensibilityX: number;
  36268. /**
  36269. * Defines the pointer angular sensibility along the Y axis or how fast is
  36270. * the camera rotating.
  36271. * A negative number will reverse the axis direction.
  36272. */
  36273. angularSensibilityY: number;
  36274. /**
  36275. * Defines the pointer pinch precision or how fast is the camera zooming.
  36276. * A negative number will reverse the axis direction.
  36277. */
  36278. pinchPrecision: number;
  36279. /**
  36280. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36281. * from 0.
  36282. * It defines the percentage of current camera.radius to use as delta when
  36283. * pinch zoom is used.
  36284. */
  36285. pinchDeltaPercentage: number;
  36286. /**
  36287. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36288. */
  36289. axisXControlRadius: boolean;
  36290. /**
  36291. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36292. */
  36293. axisXControlHeight: boolean;
  36294. /**
  36295. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36296. */
  36297. axisXControlRotation: boolean;
  36298. /**
  36299. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36300. */
  36301. axisYControlRadius: boolean;
  36302. /**
  36303. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36304. */
  36305. axisYControlHeight: boolean;
  36306. /**
  36307. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36308. */
  36309. axisYControlRotation: boolean;
  36310. /**
  36311. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36312. */
  36313. axisPinchControlRadius: boolean;
  36314. /**
  36315. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36316. */
  36317. axisPinchControlHeight: boolean;
  36318. /**
  36319. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36320. */
  36321. axisPinchControlRotation: boolean;
  36322. /**
  36323. * Log error messages if basic misconfiguration has occurred.
  36324. */
  36325. warningEnable: boolean;
  36326. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36327. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36328. private _warningCounter;
  36329. private _warning;
  36330. }
  36331. }
  36332. declare module BABYLON {
  36333. /**
  36334. * Default Inputs manager for the FollowCamera.
  36335. * It groups all the default supported inputs for ease of use.
  36336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36337. */
  36338. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36339. /**
  36340. * Instantiates a new FollowCameraInputsManager.
  36341. * @param camera Defines the camera the inputs belong to
  36342. */
  36343. constructor(camera: FollowCamera);
  36344. /**
  36345. * Add keyboard input support to the input manager.
  36346. * @returns the current input manager
  36347. */
  36348. addKeyboard(): FollowCameraInputsManager;
  36349. /**
  36350. * Add mouse wheel input support to the input manager.
  36351. * @returns the current input manager
  36352. */
  36353. addMouseWheel(): FollowCameraInputsManager;
  36354. /**
  36355. * Add pointers input support to the input manager.
  36356. * @returns the current input manager
  36357. */
  36358. addPointers(): FollowCameraInputsManager;
  36359. /**
  36360. * Add orientation input support to the input manager.
  36361. * @returns the current input manager
  36362. */
  36363. addVRDeviceOrientation(): FollowCameraInputsManager;
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. /**
  36368. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36369. * an arc rotate version arcFollowCamera are available.
  36370. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36371. */
  36372. export class FollowCamera extends TargetCamera {
  36373. /**
  36374. * Distance the follow camera should follow an object at
  36375. */
  36376. radius: number;
  36377. /**
  36378. * Minimum allowed distance of the camera to the axis of rotation
  36379. * (The camera can not get closer).
  36380. * This can help limiting how the Camera is able to move in the scene.
  36381. */
  36382. lowerRadiusLimit: Nullable<number>;
  36383. /**
  36384. * Maximum allowed distance of the camera to the axis of rotation
  36385. * (The camera can not get further).
  36386. * This can help limiting how the Camera is able to move in the scene.
  36387. */
  36388. upperRadiusLimit: Nullable<number>;
  36389. /**
  36390. * Define a rotation offset between the camera and the object it follows
  36391. */
  36392. rotationOffset: number;
  36393. /**
  36394. * Minimum allowed angle to camera position relative to target object.
  36395. * This can help limiting how the Camera is able to move in the scene.
  36396. */
  36397. lowerRotationOffsetLimit: Nullable<number>;
  36398. /**
  36399. * Maximum allowed angle to camera position relative to target object.
  36400. * This can help limiting how the Camera is able to move in the scene.
  36401. */
  36402. upperRotationOffsetLimit: Nullable<number>;
  36403. /**
  36404. * Define a height offset between the camera and the object it follows.
  36405. * It can help following an object from the top (like a car chaing a plane)
  36406. */
  36407. heightOffset: number;
  36408. /**
  36409. * Minimum allowed height of camera position relative to target object.
  36410. * This can help limiting how the Camera is able to move in the scene.
  36411. */
  36412. lowerHeightOffsetLimit: Nullable<number>;
  36413. /**
  36414. * Maximum allowed height of camera position relative to target object.
  36415. * This can help limiting how the Camera is able to move in the scene.
  36416. */
  36417. upperHeightOffsetLimit: Nullable<number>;
  36418. /**
  36419. * Define how fast the camera can accelerate to follow it s target.
  36420. */
  36421. cameraAcceleration: number;
  36422. /**
  36423. * Define the speed limit of the camera following an object.
  36424. */
  36425. maxCameraSpeed: number;
  36426. /**
  36427. * Define the target of the camera.
  36428. */
  36429. lockedTarget: Nullable<AbstractMesh>;
  36430. /**
  36431. * Defines the input associated with the camera.
  36432. */
  36433. inputs: FollowCameraInputsManager;
  36434. /**
  36435. * Instantiates the follow camera.
  36436. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36437. * @param name Define the name of the camera in the scene
  36438. * @param position Define the position of the camera
  36439. * @param scene Define the scene the camera belong to
  36440. * @param lockedTarget Define the target of the camera
  36441. */
  36442. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36443. private _follow;
  36444. /**
  36445. * Attached controls to the current camera.
  36446. * @param element Defines the element the controls should be listened from
  36447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36448. */
  36449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36450. /**
  36451. * Detach the current controls from the camera.
  36452. * The camera will stop reacting to inputs.
  36453. * @param element Defines the element to stop listening the inputs from
  36454. */
  36455. detachControl(element: HTMLElement): void;
  36456. /** @hidden */
  36457. _checkInputs(): void;
  36458. private _checkLimits;
  36459. /**
  36460. * Gets the camera class name.
  36461. * @returns the class name
  36462. */
  36463. getClassName(): string;
  36464. }
  36465. /**
  36466. * Arc Rotate version of the follow camera.
  36467. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36468. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36469. */
  36470. export class ArcFollowCamera extends TargetCamera {
  36471. /** The longitudinal angle of the camera */
  36472. alpha: number;
  36473. /** The latitudinal angle of the camera */
  36474. beta: number;
  36475. /** The radius of the camera from its target */
  36476. radius: number;
  36477. /** Define the camera target (the messh it should follow) */
  36478. target: Nullable<AbstractMesh>;
  36479. private _cartesianCoordinates;
  36480. /**
  36481. * Instantiates a new ArcFollowCamera
  36482. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36483. * @param name Define the name of the camera
  36484. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36485. * @param beta Define the rotation angle of the camera around the elevation axis
  36486. * @param radius Define the radius of the camera from its target point
  36487. * @param target Define the target of the camera
  36488. * @param scene Define the scene the camera belongs to
  36489. */
  36490. constructor(name: string,
  36491. /** The longitudinal angle of the camera */
  36492. alpha: number,
  36493. /** The latitudinal angle of the camera */
  36494. beta: number,
  36495. /** The radius of the camera from its target */
  36496. radius: number,
  36497. /** Define the camera target (the messh it should follow) */
  36498. target: Nullable<AbstractMesh>, scene: Scene);
  36499. private _follow;
  36500. /** @hidden */
  36501. _checkInputs(): void;
  36502. /**
  36503. * Returns the class name of the object.
  36504. * It is mostly used internally for serialization purposes.
  36505. */
  36506. getClassName(): string;
  36507. }
  36508. }
  36509. declare module BABYLON {
  36510. /**
  36511. * Manage the keyboard inputs to control the movement of a follow camera.
  36512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36513. */
  36514. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36515. /**
  36516. * Defines the camera the input is attached to.
  36517. */
  36518. camera: FollowCamera;
  36519. /**
  36520. * Defines the list of key codes associated with the up action (increase heightOffset)
  36521. */
  36522. keysHeightOffsetIncr: number[];
  36523. /**
  36524. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36525. */
  36526. keysHeightOffsetDecr: number[];
  36527. /**
  36528. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36529. */
  36530. keysHeightOffsetModifierAlt: boolean;
  36531. /**
  36532. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36533. */
  36534. keysHeightOffsetModifierCtrl: boolean;
  36535. /**
  36536. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36537. */
  36538. keysHeightOffsetModifierShift: boolean;
  36539. /**
  36540. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36541. */
  36542. keysRotationOffsetIncr: number[];
  36543. /**
  36544. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36545. */
  36546. keysRotationOffsetDecr: number[];
  36547. /**
  36548. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36549. */
  36550. keysRotationOffsetModifierAlt: boolean;
  36551. /**
  36552. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36553. */
  36554. keysRotationOffsetModifierCtrl: boolean;
  36555. /**
  36556. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36557. */
  36558. keysRotationOffsetModifierShift: boolean;
  36559. /**
  36560. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36561. */
  36562. keysRadiusIncr: number[];
  36563. /**
  36564. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36565. */
  36566. keysRadiusDecr: number[];
  36567. /**
  36568. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36569. */
  36570. keysRadiusModifierAlt: boolean;
  36571. /**
  36572. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36573. */
  36574. keysRadiusModifierCtrl: boolean;
  36575. /**
  36576. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36577. */
  36578. keysRadiusModifierShift: boolean;
  36579. /**
  36580. * Defines the rate of change of heightOffset.
  36581. */
  36582. heightSensibility: number;
  36583. /**
  36584. * Defines the rate of change of rotationOffset.
  36585. */
  36586. rotationSensibility: number;
  36587. /**
  36588. * Defines the rate of change of radius.
  36589. */
  36590. radiusSensibility: number;
  36591. private _keys;
  36592. private _ctrlPressed;
  36593. private _altPressed;
  36594. private _shiftPressed;
  36595. private _onCanvasBlurObserver;
  36596. private _onKeyboardObserver;
  36597. private _engine;
  36598. private _scene;
  36599. /**
  36600. * Attach the input controls to a specific dom element to get the input from.
  36601. * @param element Defines the element the controls should be listened from
  36602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36603. */
  36604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36605. /**
  36606. * Detach the current controls from the specified dom element.
  36607. * @param element Defines the element to stop listening the inputs from
  36608. */
  36609. detachControl(element: Nullable<HTMLElement>): void;
  36610. /**
  36611. * Update the current camera state depending on the inputs that have been used this frame.
  36612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36613. */
  36614. checkInputs(): void;
  36615. /**
  36616. * Gets the class name of the current input.
  36617. * @returns the class name
  36618. */
  36619. getClassName(): string;
  36620. /**
  36621. * Get the friendly name associated with the input class.
  36622. * @returns the input friendly name
  36623. */
  36624. getSimpleName(): string;
  36625. /**
  36626. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36627. * allow modification of the heightOffset value.
  36628. */
  36629. private _modifierHeightOffset;
  36630. /**
  36631. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36632. * allow modification of the rotationOffset value.
  36633. */
  36634. private _modifierRotationOffset;
  36635. /**
  36636. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36637. * allow modification of the radius value.
  36638. */
  36639. private _modifierRadius;
  36640. }
  36641. }
  36642. declare module BABYLON {
  36643. interface FreeCameraInputsManager {
  36644. /**
  36645. * Add orientation input support to the input manager.
  36646. * @returns the current input manager
  36647. */
  36648. addDeviceOrientation(): FreeCameraInputsManager;
  36649. }
  36650. /**
  36651. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36652. * Screen rotation is taken into account.
  36653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36654. */
  36655. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36656. private _camera;
  36657. private _screenOrientationAngle;
  36658. private _constantTranform;
  36659. private _screenQuaternion;
  36660. private _alpha;
  36661. private _beta;
  36662. private _gamma;
  36663. /**
  36664. * Instantiates a new input
  36665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36666. */
  36667. constructor();
  36668. /**
  36669. * Define the camera controlled by the input.
  36670. */
  36671. camera: FreeCamera;
  36672. /**
  36673. * Attach the input controls to a specific dom element to get the input from.
  36674. * @param element Defines the element the controls should be listened from
  36675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36676. */
  36677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36678. private _orientationChanged;
  36679. private _deviceOrientation;
  36680. /**
  36681. * Detach the current controls from the specified dom element.
  36682. * @param element Defines the element to stop listening the inputs from
  36683. */
  36684. detachControl(element: Nullable<HTMLElement>): void;
  36685. /**
  36686. * Update the current camera state depending on the inputs that have been used this frame.
  36687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36688. */
  36689. checkInputs(): void;
  36690. /**
  36691. * Gets the class name of the current intput.
  36692. * @returns the class name
  36693. */
  36694. getClassName(): string;
  36695. /**
  36696. * Get the friendly name associated with the input class.
  36697. * @returns the input friendly name
  36698. */
  36699. getSimpleName(): string;
  36700. }
  36701. }
  36702. declare module BABYLON {
  36703. /**
  36704. * Manage the gamepad inputs to control a free camera.
  36705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36706. */
  36707. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36708. /**
  36709. * Define the camera the input is attached to.
  36710. */
  36711. camera: FreeCamera;
  36712. /**
  36713. * Define the Gamepad controlling the input
  36714. */
  36715. gamepad: Nullable<Gamepad>;
  36716. /**
  36717. * Defines the gamepad rotation sensiblity.
  36718. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36719. */
  36720. gamepadAngularSensibility: number;
  36721. /**
  36722. * Defines the gamepad move sensiblity.
  36723. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36724. */
  36725. gamepadMoveSensibility: number;
  36726. private _onGamepadConnectedObserver;
  36727. private _onGamepadDisconnectedObserver;
  36728. private _cameraTransform;
  36729. private _deltaTransform;
  36730. private _vector3;
  36731. private _vector2;
  36732. /**
  36733. * Attach the input controls to a specific dom element to get the input from.
  36734. * @param element Defines the element the controls should be listened from
  36735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36736. */
  36737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36738. /**
  36739. * Detach the current controls from the specified dom element.
  36740. * @param element Defines the element to stop listening the inputs from
  36741. */
  36742. detachControl(element: Nullable<HTMLElement>): void;
  36743. /**
  36744. * Update the current camera state depending on the inputs that have been used this frame.
  36745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36746. */
  36747. checkInputs(): void;
  36748. /**
  36749. * Gets the class name of the current intput.
  36750. * @returns the class name
  36751. */
  36752. getClassName(): string;
  36753. /**
  36754. * Get the friendly name associated with the input class.
  36755. * @returns the input friendly name
  36756. */
  36757. getSimpleName(): string;
  36758. }
  36759. }
  36760. declare module BABYLON {
  36761. /**
  36762. * Defines the potential axis of a Joystick
  36763. */
  36764. export enum JoystickAxis {
  36765. /** X axis */
  36766. X = 0,
  36767. /** Y axis */
  36768. Y = 1,
  36769. /** Z axis */
  36770. Z = 2
  36771. }
  36772. /**
  36773. * Class used to define virtual joystick (used in touch mode)
  36774. */
  36775. export class VirtualJoystick {
  36776. /**
  36777. * Gets or sets a boolean indicating that left and right values must be inverted
  36778. */
  36779. reverseLeftRight: boolean;
  36780. /**
  36781. * Gets or sets a boolean indicating that up and down values must be inverted
  36782. */
  36783. reverseUpDown: boolean;
  36784. /**
  36785. * Gets the offset value for the position (ie. the change of the position value)
  36786. */
  36787. deltaPosition: Vector3;
  36788. /**
  36789. * Gets a boolean indicating if the virtual joystick was pressed
  36790. */
  36791. pressed: boolean;
  36792. /**
  36793. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36794. */
  36795. static Canvas: Nullable<HTMLCanvasElement>;
  36796. private static _globalJoystickIndex;
  36797. private static vjCanvasContext;
  36798. private static vjCanvasWidth;
  36799. private static vjCanvasHeight;
  36800. private static halfWidth;
  36801. private _action;
  36802. private _axisTargetedByLeftAndRight;
  36803. private _axisTargetedByUpAndDown;
  36804. private _joystickSensibility;
  36805. private _inversedSensibility;
  36806. private _joystickPointerID;
  36807. private _joystickColor;
  36808. private _joystickPointerPos;
  36809. private _joystickPreviousPointerPos;
  36810. private _joystickPointerStartPos;
  36811. private _deltaJoystickVector;
  36812. private _leftJoystick;
  36813. private _touches;
  36814. private _onPointerDownHandlerRef;
  36815. private _onPointerMoveHandlerRef;
  36816. private _onPointerUpHandlerRef;
  36817. private _onResize;
  36818. /**
  36819. * Creates a new virtual joystick
  36820. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36821. */
  36822. constructor(leftJoystick?: boolean);
  36823. /**
  36824. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36825. * @param newJoystickSensibility defines the new sensibility
  36826. */
  36827. setJoystickSensibility(newJoystickSensibility: number): void;
  36828. private _onPointerDown;
  36829. private _onPointerMove;
  36830. private _onPointerUp;
  36831. /**
  36832. * Change the color of the virtual joystick
  36833. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36834. */
  36835. setJoystickColor(newColor: string): void;
  36836. /**
  36837. * Defines a callback to call when the joystick is touched
  36838. * @param action defines the callback
  36839. */
  36840. setActionOnTouch(action: () => any): void;
  36841. /**
  36842. * Defines which axis you'd like to control for left & right
  36843. * @param axis defines the axis to use
  36844. */
  36845. setAxisForLeftRight(axis: JoystickAxis): void;
  36846. /**
  36847. * Defines which axis you'd like to control for up & down
  36848. * @param axis defines the axis to use
  36849. */
  36850. setAxisForUpDown(axis: JoystickAxis): void;
  36851. private _drawVirtualJoystick;
  36852. /**
  36853. * Release internal HTML canvas
  36854. */
  36855. releaseCanvas(): void;
  36856. }
  36857. }
  36858. declare module BABYLON {
  36859. interface FreeCameraInputsManager {
  36860. /**
  36861. * Add virtual joystick input support to the input manager.
  36862. * @returns the current input manager
  36863. */
  36864. addVirtualJoystick(): FreeCameraInputsManager;
  36865. }
  36866. /**
  36867. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36869. */
  36870. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36871. /**
  36872. * Defines the camera the input is attached to.
  36873. */
  36874. camera: FreeCamera;
  36875. private _leftjoystick;
  36876. private _rightjoystick;
  36877. /**
  36878. * Gets the left stick of the virtual joystick.
  36879. * @returns The virtual Joystick
  36880. */
  36881. getLeftJoystick(): VirtualJoystick;
  36882. /**
  36883. * Gets the right stick of the virtual joystick.
  36884. * @returns The virtual Joystick
  36885. */
  36886. getRightJoystick(): VirtualJoystick;
  36887. /**
  36888. * Update the current camera state depending on the inputs that have been used this frame.
  36889. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36890. */
  36891. checkInputs(): void;
  36892. /**
  36893. * Attach the input controls to a specific dom element to get the input from.
  36894. * @param element Defines the element the controls should be listened from
  36895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36896. */
  36897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36898. /**
  36899. * Detach the current controls from the specified dom element.
  36900. * @param element Defines the element to stop listening the inputs from
  36901. */
  36902. detachControl(element: Nullable<HTMLElement>): void;
  36903. /**
  36904. * Gets the class name of the current intput.
  36905. * @returns the class name
  36906. */
  36907. getClassName(): string;
  36908. /**
  36909. * Get the friendly name associated with the input class.
  36910. * @returns the input friendly name
  36911. */
  36912. getSimpleName(): string;
  36913. }
  36914. }
  36915. declare module BABYLON {
  36916. /**
  36917. * This represents a FPS type of camera controlled by touch.
  36918. * This is like a universal camera minus the Gamepad controls.
  36919. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36920. */
  36921. export class TouchCamera extends FreeCamera {
  36922. /**
  36923. * Defines the touch sensibility for rotation.
  36924. * The higher the faster.
  36925. */
  36926. touchAngularSensibility: number;
  36927. /**
  36928. * Defines the touch sensibility for move.
  36929. * The higher the faster.
  36930. */
  36931. touchMoveSensibility: number;
  36932. /**
  36933. * Instantiates a new touch camera.
  36934. * This represents a FPS type of camera controlled by touch.
  36935. * This is like a universal camera minus the Gamepad controls.
  36936. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36937. * @param name Define the name of the camera in the scene
  36938. * @param position Define the start position of the camera in the scene
  36939. * @param scene Define the scene the camera belongs to
  36940. */
  36941. constructor(name: string, position: Vector3, scene: Scene);
  36942. /**
  36943. * Gets the current object class name.
  36944. * @return the class name
  36945. */
  36946. getClassName(): string;
  36947. /** @hidden */
  36948. _setupInputs(): void;
  36949. }
  36950. }
  36951. declare module BABYLON {
  36952. /**
  36953. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36954. * being tilted forward or back and left or right.
  36955. */
  36956. export class DeviceOrientationCamera extends FreeCamera {
  36957. private _initialQuaternion;
  36958. private _quaternionCache;
  36959. /**
  36960. * Creates a new device orientation camera
  36961. * @param name The name of the camera
  36962. * @param position The start position camera
  36963. * @param scene The scene the camera belongs to
  36964. */
  36965. constructor(name: string, position: Vector3, scene: Scene);
  36966. /**
  36967. * Gets the current instance class name ("DeviceOrientationCamera").
  36968. * This helps avoiding instanceof at run time.
  36969. * @returns the class name
  36970. */
  36971. getClassName(): string;
  36972. /**
  36973. * @hidden
  36974. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36975. */
  36976. _checkInputs(): void;
  36977. /**
  36978. * Reset the camera to its default orientation on the specified axis only.
  36979. * @param axis The axis to reset
  36980. */
  36981. resetToCurrentRotation(axis?: Axis): void;
  36982. }
  36983. }
  36984. declare module BABYLON {
  36985. /**
  36986. * 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,
  36987. * which still works and will still be found in many Playgrounds.
  36988. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36989. */
  36990. export class UniversalCamera extends TouchCamera {
  36991. /**
  36992. * Defines the gamepad rotation sensiblity.
  36993. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36994. */
  36995. gamepadAngularSensibility: number;
  36996. /**
  36997. * Defines the gamepad move sensiblity.
  36998. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36999. */
  37000. gamepadMoveSensibility: number;
  37001. /**
  37002. * 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,
  37003. * which still works and will still be found in many Playgrounds.
  37004. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37005. * @param name Define the name of the camera in the scene
  37006. * @param position Define the start position of the camera in the scene
  37007. * @param scene Define the scene the camera belongs to
  37008. */
  37009. constructor(name: string, position: Vector3, scene: Scene);
  37010. /**
  37011. * Gets the current object class name.
  37012. * @return the class name
  37013. */
  37014. getClassName(): string;
  37015. }
  37016. }
  37017. declare module BABYLON {
  37018. /**
  37019. * This represents a FPS type of camera. This is only here for back compat purpose.
  37020. * Please use the UniversalCamera instead as both are identical.
  37021. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37022. */
  37023. export class GamepadCamera extends UniversalCamera {
  37024. /**
  37025. * Instantiates a new Gamepad Camera
  37026. * This represents a FPS type of camera. This is only here for back compat purpose.
  37027. * Please use the UniversalCamera instead as both are identical.
  37028. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37029. * @param name Define the name of the camera in the scene
  37030. * @param position Define the start position of the camera in the scene
  37031. * @param scene Define the scene the camera belongs to
  37032. */
  37033. constructor(name: string, position: Vector3, scene: Scene);
  37034. /**
  37035. * Gets the current object class name.
  37036. * @return the class name
  37037. */
  37038. getClassName(): string;
  37039. }
  37040. }
  37041. declare module BABYLON {
  37042. /** @hidden */
  37043. export var passPixelShader: {
  37044. name: string;
  37045. shader: string;
  37046. };
  37047. }
  37048. declare module BABYLON {
  37049. /** @hidden */
  37050. export var passCubePixelShader: {
  37051. name: string;
  37052. shader: string;
  37053. };
  37054. }
  37055. declare module BABYLON {
  37056. /**
  37057. * PassPostProcess which produces an output the same as it's input
  37058. */
  37059. export class PassPostProcess extends PostProcess {
  37060. /**
  37061. * Creates the PassPostProcess
  37062. * @param name The name of the effect.
  37063. * @param options The required width/height ratio to downsize to before computing the render pass.
  37064. * @param camera The camera to apply the render pass to.
  37065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37066. * @param engine The engine which the post process will be applied. (default: current engine)
  37067. * @param reusable If the post process can be reused on the same frame. (default: false)
  37068. * @param textureType The type of texture to be used when performing the post processing.
  37069. * @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)
  37070. */
  37071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37072. }
  37073. /**
  37074. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37075. */
  37076. export class PassCubePostProcess extends PostProcess {
  37077. private _face;
  37078. /**
  37079. * Gets or sets the cube face to display.
  37080. * * 0 is +X
  37081. * * 1 is -X
  37082. * * 2 is +Y
  37083. * * 3 is -Y
  37084. * * 4 is +Z
  37085. * * 5 is -Z
  37086. */
  37087. face: number;
  37088. /**
  37089. * Creates the PassCubePostProcess
  37090. * @param name The name of the effect.
  37091. * @param options The required width/height ratio to downsize to before computing the render pass.
  37092. * @param camera The camera to apply the render pass to.
  37093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37094. * @param engine The engine which the post process will be applied. (default: current engine)
  37095. * @param reusable If the post process can be reused on the same frame. (default: false)
  37096. * @param textureType The type of texture to be used when performing the post processing.
  37097. * @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)
  37098. */
  37099. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37100. }
  37101. }
  37102. declare module BABYLON {
  37103. /** @hidden */
  37104. export var anaglyphPixelShader: {
  37105. name: string;
  37106. shader: string;
  37107. };
  37108. }
  37109. declare module BABYLON {
  37110. /**
  37111. * Postprocess used to generate anaglyphic rendering
  37112. */
  37113. export class AnaglyphPostProcess extends PostProcess {
  37114. private _passedProcess;
  37115. /**
  37116. * Creates a new AnaglyphPostProcess
  37117. * @param name defines postprocess name
  37118. * @param options defines creation options or target ratio scale
  37119. * @param rigCameras defines cameras using this postprocess
  37120. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37121. * @param engine defines hosting engine
  37122. * @param reusable defines if the postprocess will be reused multiple times per frame
  37123. */
  37124. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37125. }
  37126. }
  37127. declare module BABYLON {
  37128. /**
  37129. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37130. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37131. */
  37132. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37133. /**
  37134. * Creates a new AnaglyphArcRotateCamera
  37135. * @param name defines camera name
  37136. * @param alpha defines alpha angle (in radians)
  37137. * @param beta defines beta angle (in radians)
  37138. * @param radius defines radius
  37139. * @param target defines camera target
  37140. * @param interaxialDistance defines distance between each color axis
  37141. * @param scene defines the hosting scene
  37142. */
  37143. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37144. /**
  37145. * Gets camera class name
  37146. * @returns AnaglyphArcRotateCamera
  37147. */
  37148. getClassName(): string;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. /**
  37153. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37154. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37155. */
  37156. export class AnaglyphFreeCamera extends FreeCamera {
  37157. /**
  37158. * Creates a new AnaglyphFreeCamera
  37159. * @param name defines camera name
  37160. * @param position defines initial position
  37161. * @param interaxialDistance defines distance between each color axis
  37162. * @param scene defines the hosting scene
  37163. */
  37164. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37165. /**
  37166. * Gets camera class name
  37167. * @returns AnaglyphFreeCamera
  37168. */
  37169. getClassName(): string;
  37170. }
  37171. }
  37172. declare module BABYLON {
  37173. /**
  37174. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37176. */
  37177. export class AnaglyphGamepadCamera extends GamepadCamera {
  37178. /**
  37179. * Creates a new AnaglyphGamepadCamera
  37180. * @param name defines camera name
  37181. * @param position defines initial position
  37182. * @param interaxialDistance defines distance between each color axis
  37183. * @param scene defines the hosting scene
  37184. */
  37185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37186. /**
  37187. * Gets camera class name
  37188. * @returns AnaglyphGamepadCamera
  37189. */
  37190. getClassName(): string;
  37191. }
  37192. }
  37193. declare module BABYLON {
  37194. /**
  37195. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37196. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37197. */
  37198. export class AnaglyphUniversalCamera extends UniversalCamera {
  37199. /**
  37200. * Creates a new AnaglyphUniversalCamera
  37201. * @param name defines camera name
  37202. * @param position defines initial position
  37203. * @param interaxialDistance defines distance between each color axis
  37204. * @param scene defines the hosting scene
  37205. */
  37206. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37207. /**
  37208. * Gets camera class name
  37209. * @returns AnaglyphUniversalCamera
  37210. */
  37211. getClassName(): string;
  37212. }
  37213. }
  37214. declare module BABYLON {
  37215. /** @hidden */
  37216. export var stereoscopicInterlacePixelShader: {
  37217. name: string;
  37218. shader: string;
  37219. };
  37220. }
  37221. declare module BABYLON {
  37222. /**
  37223. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37224. */
  37225. export class StereoscopicInterlacePostProcess extends PostProcess {
  37226. private _stepSize;
  37227. private _passedProcess;
  37228. /**
  37229. * Initializes a StereoscopicInterlacePostProcess
  37230. * @param name The name of the effect.
  37231. * @param rigCameras The rig cameras to be appled to the post process
  37232. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37234. * @param engine The engine which the post process will be applied. (default: current engine)
  37235. * @param reusable If the post process can be reused on the same frame. (default: false)
  37236. */
  37237. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37238. }
  37239. }
  37240. declare module BABYLON {
  37241. /**
  37242. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37243. * @see http://doc.babylonjs.com/features/cameras
  37244. */
  37245. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37246. /**
  37247. * Creates a new StereoscopicArcRotateCamera
  37248. * @param name defines camera name
  37249. * @param alpha defines alpha angle (in radians)
  37250. * @param beta defines beta angle (in radians)
  37251. * @param radius defines radius
  37252. * @param target defines camera target
  37253. * @param interaxialDistance defines distance between each color axis
  37254. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37255. * @param scene defines the hosting scene
  37256. */
  37257. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37258. /**
  37259. * Gets camera class name
  37260. * @returns StereoscopicArcRotateCamera
  37261. */
  37262. getClassName(): string;
  37263. }
  37264. }
  37265. declare module BABYLON {
  37266. /**
  37267. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37268. * @see http://doc.babylonjs.com/features/cameras
  37269. */
  37270. export class StereoscopicFreeCamera extends FreeCamera {
  37271. /**
  37272. * Creates a new StereoscopicFreeCamera
  37273. * @param name defines camera name
  37274. * @param position defines initial position
  37275. * @param interaxialDistance defines distance between each color axis
  37276. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37277. * @param scene defines the hosting scene
  37278. */
  37279. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37280. /**
  37281. * Gets camera class name
  37282. * @returns StereoscopicFreeCamera
  37283. */
  37284. getClassName(): string;
  37285. }
  37286. }
  37287. declare module BABYLON {
  37288. /**
  37289. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37290. * @see http://doc.babylonjs.com/features/cameras
  37291. */
  37292. export class StereoscopicGamepadCamera extends GamepadCamera {
  37293. /**
  37294. * Creates a new StereoscopicGamepadCamera
  37295. * @param name defines camera name
  37296. * @param position defines initial position
  37297. * @param interaxialDistance defines distance between each color axis
  37298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37299. * @param scene defines the hosting scene
  37300. */
  37301. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37302. /**
  37303. * Gets camera class name
  37304. * @returns StereoscopicGamepadCamera
  37305. */
  37306. getClassName(): string;
  37307. }
  37308. }
  37309. declare module BABYLON {
  37310. /**
  37311. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37312. * @see http://doc.babylonjs.com/features/cameras
  37313. */
  37314. export class StereoscopicUniversalCamera extends UniversalCamera {
  37315. /**
  37316. * Creates a new StereoscopicUniversalCamera
  37317. * @param name defines camera name
  37318. * @param position defines initial position
  37319. * @param interaxialDistance defines distance between each color axis
  37320. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37321. * @param scene defines the hosting scene
  37322. */
  37323. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37324. /**
  37325. * Gets camera class name
  37326. * @returns StereoscopicUniversalCamera
  37327. */
  37328. getClassName(): string;
  37329. }
  37330. }
  37331. declare module BABYLON {
  37332. /**
  37333. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37334. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37335. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37336. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37337. */
  37338. export class VirtualJoysticksCamera extends FreeCamera {
  37339. /**
  37340. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37341. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37342. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37343. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37344. * @param name Define the name of the camera in the scene
  37345. * @param position Define the start position of the camera in the scene
  37346. * @param scene Define the scene the camera belongs to
  37347. */
  37348. constructor(name: string, position: Vector3, scene: Scene);
  37349. /**
  37350. * Gets the current object class name.
  37351. * @return the class name
  37352. */
  37353. getClassName(): string;
  37354. }
  37355. }
  37356. declare module BABYLON {
  37357. /**
  37358. * This represents all the required metrics to create a VR camera.
  37359. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37360. */
  37361. export class VRCameraMetrics {
  37362. /**
  37363. * Define the horizontal resolution off the screen.
  37364. */
  37365. hResolution: number;
  37366. /**
  37367. * Define the vertical resolution off the screen.
  37368. */
  37369. vResolution: number;
  37370. /**
  37371. * Define the horizontal screen size.
  37372. */
  37373. hScreenSize: number;
  37374. /**
  37375. * Define the vertical screen size.
  37376. */
  37377. vScreenSize: number;
  37378. /**
  37379. * Define the vertical screen center position.
  37380. */
  37381. vScreenCenter: number;
  37382. /**
  37383. * Define the distance of the eyes to the screen.
  37384. */
  37385. eyeToScreenDistance: number;
  37386. /**
  37387. * Define the distance between both lenses
  37388. */
  37389. lensSeparationDistance: number;
  37390. /**
  37391. * Define the distance between both viewer's eyes.
  37392. */
  37393. interpupillaryDistance: number;
  37394. /**
  37395. * Define the distortion factor of the VR postprocess.
  37396. * Please, touch with care.
  37397. */
  37398. distortionK: number[];
  37399. /**
  37400. * Define the chromatic aberration correction factors for the VR post process.
  37401. */
  37402. chromaAbCorrection: number[];
  37403. /**
  37404. * Define the scale factor of the post process.
  37405. * The smaller the better but the slower.
  37406. */
  37407. postProcessScaleFactor: number;
  37408. /**
  37409. * Define an offset for the lens center.
  37410. */
  37411. lensCenterOffset: number;
  37412. /**
  37413. * Define if the current vr camera should compensate the distortion of the lense or not.
  37414. */
  37415. compensateDistortion: boolean;
  37416. /**
  37417. * Gets the rendering aspect ratio based on the provided resolutions.
  37418. */
  37419. readonly aspectRatio: number;
  37420. /**
  37421. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37422. */
  37423. readonly aspectRatioFov: number;
  37424. /**
  37425. * @hidden
  37426. */
  37427. readonly leftHMatrix: Matrix;
  37428. /**
  37429. * @hidden
  37430. */
  37431. readonly rightHMatrix: Matrix;
  37432. /**
  37433. * @hidden
  37434. */
  37435. readonly leftPreViewMatrix: Matrix;
  37436. /**
  37437. * @hidden
  37438. */
  37439. readonly rightPreViewMatrix: Matrix;
  37440. /**
  37441. * Get the default VRMetrics based on the most generic setup.
  37442. * @returns the default vr metrics
  37443. */
  37444. static GetDefault(): VRCameraMetrics;
  37445. }
  37446. }
  37447. declare module BABYLON {
  37448. /** @hidden */
  37449. export var vrDistortionCorrectionPixelShader: {
  37450. name: string;
  37451. shader: string;
  37452. };
  37453. }
  37454. declare module BABYLON {
  37455. /**
  37456. * VRDistortionCorrectionPostProcess used for mobile VR
  37457. */
  37458. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37459. private _isRightEye;
  37460. private _distortionFactors;
  37461. private _postProcessScaleFactor;
  37462. private _lensCenterOffset;
  37463. private _scaleIn;
  37464. private _scaleFactor;
  37465. private _lensCenter;
  37466. /**
  37467. * Initializes the VRDistortionCorrectionPostProcess
  37468. * @param name The name of the effect.
  37469. * @param camera The camera to apply the render pass to.
  37470. * @param isRightEye If this is for the right eye distortion
  37471. * @param vrMetrics All the required metrics for the VR camera
  37472. */
  37473. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37474. }
  37475. }
  37476. declare module BABYLON {
  37477. /**
  37478. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37479. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37480. */
  37481. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37482. /**
  37483. * Creates a new VRDeviceOrientationArcRotateCamera
  37484. * @param name defines camera name
  37485. * @param alpha defines the camera rotation along the logitudinal axis
  37486. * @param beta defines the camera rotation along the latitudinal axis
  37487. * @param radius defines the camera distance from its target
  37488. * @param target defines the camera target
  37489. * @param scene defines the scene the camera belongs to
  37490. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37491. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37492. */
  37493. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37494. /**
  37495. * Gets camera class name
  37496. * @returns VRDeviceOrientationArcRotateCamera
  37497. */
  37498. getClassName(): string;
  37499. }
  37500. }
  37501. declare module BABYLON {
  37502. /**
  37503. * Camera used to simulate VR rendering (based on FreeCamera)
  37504. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37505. */
  37506. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37507. /**
  37508. * Creates a new VRDeviceOrientationFreeCamera
  37509. * @param name defines camera name
  37510. * @param position defines the start position of the camera
  37511. * @param scene defines the scene the camera belongs to
  37512. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37513. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37514. */
  37515. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37516. /**
  37517. * Gets camera class name
  37518. * @returns VRDeviceOrientationFreeCamera
  37519. */
  37520. getClassName(): string;
  37521. }
  37522. }
  37523. declare module BABYLON {
  37524. /**
  37525. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37526. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37527. */
  37528. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37529. /**
  37530. * Creates a new VRDeviceOrientationGamepadCamera
  37531. * @param name defines camera name
  37532. * @param position defines the start position of the camera
  37533. * @param scene defines the scene the camera belongs to
  37534. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37535. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37536. */
  37537. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37538. /**
  37539. * Gets camera class name
  37540. * @returns VRDeviceOrientationGamepadCamera
  37541. */
  37542. getClassName(): string;
  37543. }
  37544. }
  37545. declare module BABYLON {
  37546. /**
  37547. * Defines supported buttons for XBox360 compatible gamepads
  37548. */
  37549. export enum Xbox360Button {
  37550. /** A */
  37551. A = 0,
  37552. /** B */
  37553. B = 1,
  37554. /** X */
  37555. X = 2,
  37556. /** Y */
  37557. Y = 3,
  37558. /** Start */
  37559. Start = 4,
  37560. /** Back */
  37561. Back = 5,
  37562. /** Left button */
  37563. LB = 6,
  37564. /** Right button */
  37565. RB = 7,
  37566. /** Left stick */
  37567. LeftStick = 8,
  37568. /** Right stick */
  37569. RightStick = 9
  37570. }
  37571. /** Defines values for XBox360 DPad */
  37572. export enum Xbox360Dpad {
  37573. /** Up */
  37574. Up = 0,
  37575. /** Down */
  37576. Down = 1,
  37577. /** Left */
  37578. Left = 2,
  37579. /** Right */
  37580. Right = 3
  37581. }
  37582. /**
  37583. * Defines a XBox360 gamepad
  37584. */
  37585. export class Xbox360Pad extends Gamepad {
  37586. private _leftTrigger;
  37587. private _rightTrigger;
  37588. private _onlefttriggerchanged;
  37589. private _onrighttriggerchanged;
  37590. private _onbuttondown;
  37591. private _onbuttonup;
  37592. private _ondpaddown;
  37593. private _ondpadup;
  37594. /** Observable raised when a button is pressed */
  37595. onButtonDownObservable: Observable<Xbox360Button>;
  37596. /** Observable raised when a button is released */
  37597. onButtonUpObservable: Observable<Xbox360Button>;
  37598. /** Observable raised when a pad is pressed */
  37599. onPadDownObservable: Observable<Xbox360Dpad>;
  37600. /** Observable raised when a pad is released */
  37601. onPadUpObservable: Observable<Xbox360Dpad>;
  37602. private _buttonA;
  37603. private _buttonB;
  37604. private _buttonX;
  37605. private _buttonY;
  37606. private _buttonBack;
  37607. private _buttonStart;
  37608. private _buttonLB;
  37609. private _buttonRB;
  37610. private _buttonLeftStick;
  37611. private _buttonRightStick;
  37612. private _dPadUp;
  37613. private _dPadDown;
  37614. private _dPadLeft;
  37615. private _dPadRight;
  37616. private _isXboxOnePad;
  37617. /**
  37618. * Creates a new XBox360 gamepad object
  37619. * @param id defines the id of this gamepad
  37620. * @param index defines its index
  37621. * @param gamepad defines the internal HTML gamepad object
  37622. * @param xboxOne defines if it is a XBox One gamepad
  37623. */
  37624. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37625. /**
  37626. * Defines the callback to call when left trigger is pressed
  37627. * @param callback defines the callback to use
  37628. */
  37629. onlefttriggerchanged(callback: (value: number) => void): void;
  37630. /**
  37631. * Defines the callback to call when right trigger is pressed
  37632. * @param callback defines the callback to use
  37633. */
  37634. onrighttriggerchanged(callback: (value: number) => void): void;
  37635. /**
  37636. * Gets the left trigger value
  37637. */
  37638. /**
  37639. * Sets the left trigger value
  37640. */
  37641. leftTrigger: number;
  37642. /**
  37643. * Gets the right trigger value
  37644. */
  37645. /**
  37646. * Sets the right trigger value
  37647. */
  37648. rightTrigger: number;
  37649. /**
  37650. * Defines the callback to call when a button is pressed
  37651. * @param callback defines the callback to use
  37652. */
  37653. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37654. /**
  37655. * Defines the callback to call when a button is released
  37656. * @param callback defines the callback to use
  37657. */
  37658. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37659. /**
  37660. * Defines the callback to call when a pad is pressed
  37661. * @param callback defines the callback to use
  37662. */
  37663. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37664. /**
  37665. * Defines the callback to call when a pad is released
  37666. * @param callback defines the callback to use
  37667. */
  37668. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37669. private _setButtonValue;
  37670. private _setDPadValue;
  37671. /**
  37672. * Gets the value of the `A` button
  37673. */
  37674. /**
  37675. * Sets the value of the `A` button
  37676. */
  37677. buttonA: number;
  37678. /**
  37679. * Gets the value of the `B` button
  37680. */
  37681. /**
  37682. * Sets the value of the `B` button
  37683. */
  37684. buttonB: number;
  37685. /**
  37686. * Gets the value of the `X` button
  37687. */
  37688. /**
  37689. * Sets the value of the `X` button
  37690. */
  37691. buttonX: number;
  37692. /**
  37693. * Gets the value of the `Y` button
  37694. */
  37695. /**
  37696. * Sets the value of the `Y` button
  37697. */
  37698. buttonY: number;
  37699. /**
  37700. * Gets the value of the `Start` button
  37701. */
  37702. /**
  37703. * Sets the value of the `Start` button
  37704. */
  37705. buttonStart: number;
  37706. /**
  37707. * Gets the value of the `Back` button
  37708. */
  37709. /**
  37710. * Sets the value of the `Back` button
  37711. */
  37712. buttonBack: number;
  37713. /**
  37714. * Gets the value of the `Left` button
  37715. */
  37716. /**
  37717. * Sets the value of the `Left` button
  37718. */
  37719. buttonLB: number;
  37720. /**
  37721. * Gets the value of the `Right` button
  37722. */
  37723. /**
  37724. * Sets the value of the `Right` button
  37725. */
  37726. buttonRB: number;
  37727. /**
  37728. * Gets the value of the Left joystick
  37729. */
  37730. /**
  37731. * Sets the value of the Left joystick
  37732. */
  37733. buttonLeftStick: number;
  37734. /**
  37735. * Gets the value of the Right joystick
  37736. */
  37737. /**
  37738. * Sets the value of the Right joystick
  37739. */
  37740. buttonRightStick: number;
  37741. /**
  37742. * Gets the value of D-pad up
  37743. */
  37744. /**
  37745. * Sets the value of D-pad up
  37746. */
  37747. dPadUp: number;
  37748. /**
  37749. * Gets the value of D-pad down
  37750. */
  37751. /**
  37752. * Sets the value of D-pad down
  37753. */
  37754. dPadDown: number;
  37755. /**
  37756. * Gets the value of D-pad left
  37757. */
  37758. /**
  37759. * Sets the value of D-pad left
  37760. */
  37761. dPadLeft: number;
  37762. /**
  37763. * Gets the value of D-pad right
  37764. */
  37765. /**
  37766. * Sets the value of D-pad right
  37767. */
  37768. dPadRight: number;
  37769. /**
  37770. * Force the gamepad to synchronize with device values
  37771. */
  37772. update(): void;
  37773. /**
  37774. * Disposes the gamepad
  37775. */
  37776. dispose(): void;
  37777. }
  37778. }
  37779. declare module BABYLON {
  37780. /**
  37781. * Base class of materials working in push mode in babylon JS
  37782. * @hidden
  37783. */
  37784. export class PushMaterial extends Material {
  37785. protected _activeEffect: Effect;
  37786. protected _normalMatrix: Matrix;
  37787. /**
  37788. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37789. * This means that the material can keep using a previous shader while a new one is being compiled.
  37790. * This is mostly used when shader parallel compilation is supported (true by default)
  37791. */
  37792. allowShaderHotSwapping: boolean;
  37793. constructor(name: string, scene: Scene);
  37794. getEffect(): Effect;
  37795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37796. /**
  37797. * Binds the given world matrix to the active effect
  37798. *
  37799. * @param world the matrix to bind
  37800. */
  37801. bindOnlyWorldMatrix(world: Matrix): void;
  37802. /**
  37803. * Binds the given normal matrix to the active effect
  37804. *
  37805. * @param normalMatrix the matrix to bind
  37806. */
  37807. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37808. bind(world: Matrix, mesh?: Mesh): void;
  37809. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37810. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37811. }
  37812. }
  37813. declare module BABYLON {
  37814. /**
  37815. * This groups all the flags used to control the materials channel.
  37816. */
  37817. export class MaterialFlags {
  37818. private static _DiffuseTextureEnabled;
  37819. /**
  37820. * Are diffuse textures enabled in the application.
  37821. */
  37822. static DiffuseTextureEnabled: boolean;
  37823. private static _AmbientTextureEnabled;
  37824. /**
  37825. * Are ambient textures enabled in the application.
  37826. */
  37827. static AmbientTextureEnabled: boolean;
  37828. private static _OpacityTextureEnabled;
  37829. /**
  37830. * Are opacity textures enabled in the application.
  37831. */
  37832. static OpacityTextureEnabled: boolean;
  37833. private static _ReflectionTextureEnabled;
  37834. /**
  37835. * Are reflection textures enabled in the application.
  37836. */
  37837. static ReflectionTextureEnabled: boolean;
  37838. private static _EmissiveTextureEnabled;
  37839. /**
  37840. * Are emissive textures enabled in the application.
  37841. */
  37842. static EmissiveTextureEnabled: boolean;
  37843. private static _SpecularTextureEnabled;
  37844. /**
  37845. * Are specular textures enabled in the application.
  37846. */
  37847. static SpecularTextureEnabled: boolean;
  37848. private static _BumpTextureEnabled;
  37849. /**
  37850. * Are bump textures enabled in the application.
  37851. */
  37852. static BumpTextureEnabled: boolean;
  37853. private static _LightmapTextureEnabled;
  37854. /**
  37855. * Are lightmap textures enabled in the application.
  37856. */
  37857. static LightmapTextureEnabled: boolean;
  37858. private static _RefractionTextureEnabled;
  37859. /**
  37860. * Are refraction textures enabled in the application.
  37861. */
  37862. static RefractionTextureEnabled: boolean;
  37863. private static _ColorGradingTextureEnabled;
  37864. /**
  37865. * Are color grading textures enabled in the application.
  37866. */
  37867. static ColorGradingTextureEnabled: boolean;
  37868. private static _FresnelEnabled;
  37869. /**
  37870. * Are fresnels enabled in the application.
  37871. */
  37872. static FresnelEnabled: boolean;
  37873. private static _ClearCoatTextureEnabled;
  37874. /**
  37875. * Are clear coat textures enabled in the application.
  37876. */
  37877. static ClearCoatTextureEnabled: boolean;
  37878. private static _ClearCoatBumpTextureEnabled;
  37879. /**
  37880. * Are clear coat bump textures enabled in the application.
  37881. */
  37882. static ClearCoatBumpTextureEnabled: boolean;
  37883. private static _ClearCoatTintTextureEnabled;
  37884. /**
  37885. * Are clear coat tint textures enabled in the application.
  37886. */
  37887. static ClearCoatTintTextureEnabled: boolean;
  37888. private static _SheenTextureEnabled;
  37889. /**
  37890. * Are sheen textures enabled in the application.
  37891. */
  37892. static SheenTextureEnabled: boolean;
  37893. private static _AnisotropicTextureEnabled;
  37894. /**
  37895. * Are anisotropic textures enabled in the application.
  37896. */
  37897. static AnisotropicTextureEnabled: boolean;
  37898. }
  37899. }
  37900. declare module BABYLON {
  37901. /** @hidden */
  37902. export var defaultFragmentDeclaration: {
  37903. name: string;
  37904. shader: string;
  37905. };
  37906. }
  37907. declare module BABYLON {
  37908. /** @hidden */
  37909. export var defaultUboDeclaration: {
  37910. name: string;
  37911. shader: string;
  37912. };
  37913. }
  37914. declare module BABYLON {
  37915. /** @hidden */
  37916. export var lightFragmentDeclaration: {
  37917. name: string;
  37918. shader: string;
  37919. };
  37920. }
  37921. declare module BABYLON {
  37922. /** @hidden */
  37923. export var lightUboDeclaration: {
  37924. name: string;
  37925. shader: string;
  37926. };
  37927. }
  37928. declare module BABYLON {
  37929. /** @hidden */
  37930. export var lightsFragmentFunctions: {
  37931. name: string;
  37932. shader: string;
  37933. };
  37934. }
  37935. declare module BABYLON {
  37936. /** @hidden */
  37937. export var shadowsFragmentFunctions: {
  37938. name: string;
  37939. shader: string;
  37940. };
  37941. }
  37942. declare module BABYLON {
  37943. /** @hidden */
  37944. export var fresnelFunction: {
  37945. name: string;
  37946. shader: string;
  37947. };
  37948. }
  37949. declare module BABYLON {
  37950. /** @hidden */
  37951. export var reflectionFunction: {
  37952. name: string;
  37953. shader: string;
  37954. };
  37955. }
  37956. declare module BABYLON {
  37957. /** @hidden */
  37958. export var bumpFragmentFunctions: {
  37959. name: string;
  37960. shader: string;
  37961. };
  37962. }
  37963. declare module BABYLON {
  37964. /** @hidden */
  37965. export var logDepthDeclaration: {
  37966. name: string;
  37967. shader: string;
  37968. };
  37969. }
  37970. declare module BABYLON {
  37971. /** @hidden */
  37972. export var bumpFragment: {
  37973. name: string;
  37974. shader: string;
  37975. };
  37976. }
  37977. declare module BABYLON {
  37978. /** @hidden */
  37979. export var depthPrePass: {
  37980. name: string;
  37981. shader: string;
  37982. };
  37983. }
  37984. declare module BABYLON {
  37985. /** @hidden */
  37986. export var lightFragment: {
  37987. name: string;
  37988. shader: string;
  37989. };
  37990. }
  37991. declare module BABYLON {
  37992. /** @hidden */
  37993. export var logDepthFragment: {
  37994. name: string;
  37995. shader: string;
  37996. };
  37997. }
  37998. declare module BABYLON {
  37999. /** @hidden */
  38000. export var defaultPixelShader: {
  38001. name: string;
  38002. shader: string;
  38003. };
  38004. }
  38005. declare module BABYLON {
  38006. /** @hidden */
  38007. export var defaultVertexDeclaration: {
  38008. name: string;
  38009. shader: string;
  38010. };
  38011. }
  38012. declare module BABYLON {
  38013. /** @hidden */
  38014. export var bumpVertexDeclaration: {
  38015. name: string;
  38016. shader: string;
  38017. };
  38018. }
  38019. declare module BABYLON {
  38020. /** @hidden */
  38021. export var bumpVertex: {
  38022. name: string;
  38023. shader: string;
  38024. };
  38025. }
  38026. declare module BABYLON {
  38027. /** @hidden */
  38028. export var fogVertex: {
  38029. name: string;
  38030. shader: string;
  38031. };
  38032. }
  38033. declare module BABYLON {
  38034. /** @hidden */
  38035. export var shadowsVertex: {
  38036. name: string;
  38037. shader: string;
  38038. };
  38039. }
  38040. declare module BABYLON {
  38041. /** @hidden */
  38042. export var pointCloudVertex: {
  38043. name: string;
  38044. shader: string;
  38045. };
  38046. }
  38047. declare module BABYLON {
  38048. /** @hidden */
  38049. export var logDepthVertex: {
  38050. name: string;
  38051. shader: string;
  38052. };
  38053. }
  38054. declare module BABYLON {
  38055. /** @hidden */
  38056. export var defaultVertexShader: {
  38057. name: string;
  38058. shader: string;
  38059. };
  38060. }
  38061. declare module BABYLON {
  38062. /** @hidden */
  38063. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38064. MAINUV1: boolean;
  38065. MAINUV2: boolean;
  38066. DIFFUSE: boolean;
  38067. DIFFUSEDIRECTUV: number;
  38068. AMBIENT: boolean;
  38069. AMBIENTDIRECTUV: number;
  38070. OPACITY: boolean;
  38071. OPACITYDIRECTUV: number;
  38072. OPACITYRGB: boolean;
  38073. REFLECTION: boolean;
  38074. EMISSIVE: boolean;
  38075. EMISSIVEDIRECTUV: number;
  38076. SPECULAR: boolean;
  38077. SPECULARDIRECTUV: number;
  38078. BUMP: boolean;
  38079. BUMPDIRECTUV: number;
  38080. PARALLAX: boolean;
  38081. PARALLAXOCCLUSION: boolean;
  38082. SPECULAROVERALPHA: boolean;
  38083. CLIPPLANE: boolean;
  38084. CLIPPLANE2: boolean;
  38085. CLIPPLANE3: boolean;
  38086. CLIPPLANE4: boolean;
  38087. ALPHATEST: boolean;
  38088. DEPTHPREPASS: boolean;
  38089. ALPHAFROMDIFFUSE: boolean;
  38090. POINTSIZE: boolean;
  38091. FOG: boolean;
  38092. SPECULARTERM: boolean;
  38093. DIFFUSEFRESNEL: boolean;
  38094. OPACITYFRESNEL: boolean;
  38095. REFLECTIONFRESNEL: boolean;
  38096. REFRACTIONFRESNEL: boolean;
  38097. EMISSIVEFRESNEL: boolean;
  38098. FRESNEL: boolean;
  38099. NORMAL: boolean;
  38100. UV1: boolean;
  38101. UV2: boolean;
  38102. VERTEXCOLOR: boolean;
  38103. VERTEXALPHA: boolean;
  38104. NUM_BONE_INFLUENCERS: number;
  38105. BonesPerMesh: number;
  38106. BONETEXTURE: boolean;
  38107. INSTANCES: boolean;
  38108. GLOSSINESS: boolean;
  38109. ROUGHNESS: boolean;
  38110. EMISSIVEASILLUMINATION: boolean;
  38111. LINKEMISSIVEWITHDIFFUSE: boolean;
  38112. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38113. LIGHTMAP: boolean;
  38114. LIGHTMAPDIRECTUV: number;
  38115. OBJECTSPACE_NORMALMAP: boolean;
  38116. USELIGHTMAPASSHADOWMAP: boolean;
  38117. REFLECTIONMAP_3D: boolean;
  38118. REFLECTIONMAP_SPHERICAL: boolean;
  38119. REFLECTIONMAP_PLANAR: boolean;
  38120. REFLECTIONMAP_CUBIC: boolean;
  38121. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38122. REFLECTIONMAP_PROJECTION: boolean;
  38123. REFLECTIONMAP_SKYBOX: boolean;
  38124. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38125. REFLECTIONMAP_EXPLICIT: boolean;
  38126. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38127. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38128. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38129. INVERTCUBICMAP: boolean;
  38130. LOGARITHMICDEPTH: boolean;
  38131. REFRACTION: boolean;
  38132. REFRACTIONMAP_3D: boolean;
  38133. REFLECTIONOVERALPHA: boolean;
  38134. TWOSIDEDLIGHTING: boolean;
  38135. SHADOWFLOAT: boolean;
  38136. MORPHTARGETS: boolean;
  38137. MORPHTARGETS_NORMAL: boolean;
  38138. MORPHTARGETS_TANGENT: boolean;
  38139. NUM_MORPH_INFLUENCERS: number;
  38140. NONUNIFORMSCALING: boolean;
  38141. PREMULTIPLYALPHA: boolean;
  38142. IMAGEPROCESSING: boolean;
  38143. VIGNETTE: boolean;
  38144. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38145. VIGNETTEBLENDMODEOPAQUE: boolean;
  38146. TONEMAPPING: boolean;
  38147. TONEMAPPING_ACES: boolean;
  38148. CONTRAST: boolean;
  38149. COLORCURVES: boolean;
  38150. COLORGRADING: boolean;
  38151. COLORGRADING3D: boolean;
  38152. SAMPLER3DGREENDEPTH: boolean;
  38153. SAMPLER3DBGRMAP: boolean;
  38154. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38155. /**
  38156. * If the reflection texture on this material is in linear color space
  38157. * @hidden
  38158. */
  38159. IS_REFLECTION_LINEAR: boolean;
  38160. /**
  38161. * If the refraction texture on this material is in linear color space
  38162. * @hidden
  38163. */
  38164. IS_REFRACTION_LINEAR: boolean;
  38165. EXPOSURE: boolean;
  38166. constructor();
  38167. setReflectionMode(modeToEnable: string): void;
  38168. }
  38169. /**
  38170. * This is the default material used in Babylon. It is the best trade off between quality
  38171. * and performances.
  38172. * @see http://doc.babylonjs.com/babylon101/materials
  38173. */
  38174. export class StandardMaterial extends PushMaterial {
  38175. private _diffuseTexture;
  38176. /**
  38177. * The basic texture of the material as viewed under a light.
  38178. */
  38179. diffuseTexture: Nullable<BaseTexture>;
  38180. private _ambientTexture;
  38181. /**
  38182. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38183. */
  38184. ambientTexture: Nullable<BaseTexture>;
  38185. private _opacityTexture;
  38186. /**
  38187. * Define the transparency of the material from a texture.
  38188. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38189. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38190. */
  38191. opacityTexture: Nullable<BaseTexture>;
  38192. private _reflectionTexture;
  38193. /**
  38194. * Define the texture used to display the reflection.
  38195. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38196. */
  38197. reflectionTexture: Nullable<BaseTexture>;
  38198. private _emissiveTexture;
  38199. /**
  38200. * Define texture of the material as if self lit.
  38201. * This will be mixed in the final result even in the absence of light.
  38202. */
  38203. emissiveTexture: Nullable<BaseTexture>;
  38204. private _specularTexture;
  38205. /**
  38206. * Define how the color and intensity of the highlight given by the light in the material.
  38207. */
  38208. specularTexture: Nullable<BaseTexture>;
  38209. private _bumpTexture;
  38210. /**
  38211. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38212. * 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.
  38213. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38214. */
  38215. bumpTexture: Nullable<BaseTexture>;
  38216. private _lightmapTexture;
  38217. /**
  38218. * Complex lighting can be computationally expensive to compute at runtime.
  38219. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38220. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38221. */
  38222. lightmapTexture: Nullable<BaseTexture>;
  38223. private _refractionTexture;
  38224. /**
  38225. * Define the texture used to display the refraction.
  38226. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38227. */
  38228. refractionTexture: Nullable<BaseTexture>;
  38229. /**
  38230. * The color of the material lit by the environmental background lighting.
  38231. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38232. */
  38233. ambientColor: Color3;
  38234. /**
  38235. * The basic color of the material as viewed under a light.
  38236. */
  38237. diffuseColor: Color3;
  38238. /**
  38239. * Define how the color and intensity of the highlight given by the light in the material.
  38240. */
  38241. specularColor: Color3;
  38242. /**
  38243. * Define the color of the material as if self lit.
  38244. * This will be mixed in the final result even in the absence of light.
  38245. */
  38246. emissiveColor: Color3;
  38247. /**
  38248. * Defines how sharp are the highlights in the material.
  38249. * The bigger the value the sharper giving a more glossy feeling to the result.
  38250. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38251. */
  38252. specularPower: number;
  38253. private _useAlphaFromDiffuseTexture;
  38254. /**
  38255. * Does the transparency come from the diffuse texture alpha channel.
  38256. */
  38257. useAlphaFromDiffuseTexture: boolean;
  38258. private _useEmissiveAsIllumination;
  38259. /**
  38260. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38261. */
  38262. useEmissiveAsIllumination: boolean;
  38263. private _linkEmissiveWithDiffuse;
  38264. /**
  38265. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38266. * the emissive level when the final color is close to one.
  38267. */
  38268. linkEmissiveWithDiffuse: boolean;
  38269. private _useSpecularOverAlpha;
  38270. /**
  38271. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38272. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38273. */
  38274. useSpecularOverAlpha: boolean;
  38275. private _useReflectionOverAlpha;
  38276. /**
  38277. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38278. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38279. */
  38280. useReflectionOverAlpha: boolean;
  38281. private _disableLighting;
  38282. /**
  38283. * Does lights from the scene impacts this material.
  38284. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38285. */
  38286. disableLighting: boolean;
  38287. private _useObjectSpaceNormalMap;
  38288. /**
  38289. * Allows using an object space normal map (instead of tangent space).
  38290. */
  38291. useObjectSpaceNormalMap: boolean;
  38292. private _useParallax;
  38293. /**
  38294. * Is parallax enabled or not.
  38295. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38296. */
  38297. useParallax: boolean;
  38298. private _useParallaxOcclusion;
  38299. /**
  38300. * Is parallax occlusion enabled or not.
  38301. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38302. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38303. */
  38304. useParallaxOcclusion: boolean;
  38305. /**
  38306. * 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.
  38307. */
  38308. parallaxScaleBias: number;
  38309. private _roughness;
  38310. /**
  38311. * Helps to define how blurry the reflections should appears in the material.
  38312. */
  38313. roughness: number;
  38314. /**
  38315. * In case of refraction, define the value of the indice of refraction.
  38316. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38317. */
  38318. indexOfRefraction: number;
  38319. /**
  38320. * Invert the refraction texture alongside the y axis.
  38321. * It can be useful with procedural textures or probe for instance.
  38322. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38323. */
  38324. invertRefractionY: boolean;
  38325. /**
  38326. * Defines the alpha limits in alpha test mode.
  38327. */
  38328. alphaCutOff: number;
  38329. private _useLightmapAsShadowmap;
  38330. /**
  38331. * In case of light mapping, define whether the map contains light or shadow informations.
  38332. */
  38333. useLightmapAsShadowmap: boolean;
  38334. private _diffuseFresnelParameters;
  38335. /**
  38336. * Define the diffuse fresnel parameters of the material.
  38337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38338. */
  38339. diffuseFresnelParameters: FresnelParameters;
  38340. private _opacityFresnelParameters;
  38341. /**
  38342. * Define the opacity fresnel parameters of the material.
  38343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38344. */
  38345. opacityFresnelParameters: FresnelParameters;
  38346. private _reflectionFresnelParameters;
  38347. /**
  38348. * Define the reflection fresnel parameters of the material.
  38349. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38350. */
  38351. reflectionFresnelParameters: FresnelParameters;
  38352. private _refractionFresnelParameters;
  38353. /**
  38354. * Define the refraction fresnel parameters of the material.
  38355. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38356. */
  38357. refractionFresnelParameters: FresnelParameters;
  38358. private _emissiveFresnelParameters;
  38359. /**
  38360. * Define the emissive fresnel parameters of the material.
  38361. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38362. */
  38363. emissiveFresnelParameters: FresnelParameters;
  38364. private _useReflectionFresnelFromSpecular;
  38365. /**
  38366. * If true automatically deducts the fresnels values from the material specularity.
  38367. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38368. */
  38369. useReflectionFresnelFromSpecular: boolean;
  38370. private _useGlossinessFromSpecularMapAlpha;
  38371. /**
  38372. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38373. */
  38374. useGlossinessFromSpecularMapAlpha: boolean;
  38375. private _maxSimultaneousLights;
  38376. /**
  38377. * Defines the maximum number of lights that can be used in the material
  38378. */
  38379. maxSimultaneousLights: number;
  38380. private _invertNormalMapX;
  38381. /**
  38382. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38383. */
  38384. invertNormalMapX: boolean;
  38385. private _invertNormalMapY;
  38386. /**
  38387. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38388. */
  38389. invertNormalMapY: boolean;
  38390. private _twoSidedLighting;
  38391. /**
  38392. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38393. */
  38394. twoSidedLighting: boolean;
  38395. /**
  38396. * Default configuration related to image processing available in the standard Material.
  38397. */
  38398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38399. /**
  38400. * Gets the image processing configuration used either in this material.
  38401. */
  38402. /**
  38403. * Sets the Default image processing configuration used either in the this material.
  38404. *
  38405. * If sets to null, the scene one is in use.
  38406. */
  38407. imageProcessingConfiguration: ImageProcessingConfiguration;
  38408. /**
  38409. * Keep track of the image processing observer to allow dispose and replace.
  38410. */
  38411. private _imageProcessingObserver;
  38412. /**
  38413. * Attaches a new image processing configuration to the Standard Material.
  38414. * @param configuration
  38415. */
  38416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38417. /**
  38418. * Gets wether the color curves effect is enabled.
  38419. */
  38420. /**
  38421. * Sets wether the color curves effect is enabled.
  38422. */
  38423. cameraColorCurvesEnabled: boolean;
  38424. /**
  38425. * Gets wether the color grading effect is enabled.
  38426. */
  38427. /**
  38428. * Gets wether the color grading effect is enabled.
  38429. */
  38430. cameraColorGradingEnabled: boolean;
  38431. /**
  38432. * Gets wether tonemapping is enabled or not.
  38433. */
  38434. /**
  38435. * Sets wether tonemapping is enabled or not
  38436. */
  38437. cameraToneMappingEnabled: boolean;
  38438. /**
  38439. * The camera exposure used on this material.
  38440. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38441. * This corresponds to a photographic exposure.
  38442. */
  38443. /**
  38444. * The camera exposure used on this material.
  38445. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38446. * This corresponds to a photographic exposure.
  38447. */
  38448. cameraExposure: number;
  38449. /**
  38450. * Gets The camera contrast used on this material.
  38451. */
  38452. /**
  38453. * Sets The camera contrast used on this material.
  38454. */
  38455. cameraContrast: number;
  38456. /**
  38457. * Gets the Color Grading 2D Lookup Texture.
  38458. */
  38459. /**
  38460. * Sets the Color Grading 2D Lookup Texture.
  38461. */
  38462. cameraColorGradingTexture: Nullable<BaseTexture>;
  38463. /**
  38464. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38465. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38466. * 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;
  38467. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38468. */
  38469. /**
  38470. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38471. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38472. * 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;
  38473. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38474. */
  38475. cameraColorCurves: Nullable<ColorCurves>;
  38476. /**
  38477. * Custom callback helping to override the default shader used in the material.
  38478. */
  38479. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38480. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38481. protected _worldViewProjectionMatrix: Matrix;
  38482. protected _globalAmbientColor: Color3;
  38483. protected _useLogarithmicDepth: boolean;
  38484. /**
  38485. * Instantiates a new standard material.
  38486. * This is the default material used in Babylon. It is the best trade off between quality
  38487. * and performances.
  38488. * @see http://doc.babylonjs.com/babylon101/materials
  38489. * @param name Define the name of the material in the scene
  38490. * @param scene Define the scene the material belong to
  38491. */
  38492. constructor(name: string, scene: Scene);
  38493. /**
  38494. * Gets a boolean indicating that current material needs to register RTT
  38495. */
  38496. readonly hasRenderTargetTextures: boolean;
  38497. /**
  38498. * Gets the current class name of the material e.g. "StandardMaterial"
  38499. * Mainly use in serialization.
  38500. * @returns the class name
  38501. */
  38502. getClassName(): string;
  38503. /**
  38504. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38505. * You can try switching to logarithmic depth.
  38506. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38507. */
  38508. useLogarithmicDepth: boolean;
  38509. /**
  38510. * Specifies if the material will require alpha blending
  38511. * @returns a boolean specifying if alpha blending is needed
  38512. */
  38513. needAlphaBlending(): boolean;
  38514. /**
  38515. * Specifies if this material should be rendered in alpha test mode
  38516. * @returns a boolean specifying if an alpha test is needed.
  38517. */
  38518. needAlphaTesting(): boolean;
  38519. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38520. /**
  38521. * Get the texture used for alpha test purpose.
  38522. * @returns the diffuse texture in case of the standard material.
  38523. */
  38524. getAlphaTestTexture(): Nullable<BaseTexture>;
  38525. /**
  38526. * Get if the submesh is ready to be used and all its information available.
  38527. * Child classes can use it to update shaders
  38528. * @param mesh defines the mesh to check
  38529. * @param subMesh defines which submesh to check
  38530. * @param useInstances specifies that instances should be used
  38531. * @returns a boolean indicating that the submesh is ready or not
  38532. */
  38533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38534. /**
  38535. * Builds the material UBO layouts.
  38536. * Used internally during the effect preparation.
  38537. */
  38538. buildUniformLayout(): void;
  38539. /**
  38540. * Unbinds the material from the mesh
  38541. */
  38542. unbind(): void;
  38543. /**
  38544. * Binds the submesh to this material by preparing the effect and shader to draw
  38545. * @param world defines the world transformation matrix
  38546. * @param mesh defines the mesh containing the submesh
  38547. * @param subMesh defines the submesh to bind the material to
  38548. */
  38549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38550. /**
  38551. * Get the list of animatables in the material.
  38552. * @returns the list of animatables object used in the material
  38553. */
  38554. getAnimatables(): IAnimatable[];
  38555. /**
  38556. * Gets the active textures from the material
  38557. * @returns an array of textures
  38558. */
  38559. getActiveTextures(): BaseTexture[];
  38560. /**
  38561. * Specifies if the material uses a texture
  38562. * @param texture defines the texture to check against the material
  38563. * @returns a boolean specifying if the material uses the texture
  38564. */
  38565. hasTexture(texture: BaseTexture): boolean;
  38566. /**
  38567. * Disposes the material
  38568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38570. */
  38571. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38572. /**
  38573. * Makes a duplicate of the material, and gives it a new name
  38574. * @param name defines the new name for the duplicated material
  38575. * @returns the cloned material
  38576. */
  38577. clone(name: string): StandardMaterial;
  38578. /**
  38579. * Serializes this material in a JSON representation
  38580. * @returns the serialized material object
  38581. */
  38582. serialize(): any;
  38583. /**
  38584. * Creates a standard material from parsed material data
  38585. * @param source defines the JSON representation of the material
  38586. * @param scene defines the hosting scene
  38587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38588. * @returns a new standard material
  38589. */
  38590. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38591. /**
  38592. * Are diffuse textures enabled in the application.
  38593. */
  38594. static DiffuseTextureEnabled: boolean;
  38595. /**
  38596. * Are ambient textures enabled in the application.
  38597. */
  38598. static AmbientTextureEnabled: boolean;
  38599. /**
  38600. * Are opacity textures enabled in the application.
  38601. */
  38602. static OpacityTextureEnabled: boolean;
  38603. /**
  38604. * Are reflection textures enabled in the application.
  38605. */
  38606. static ReflectionTextureEnabled: boolean;
  38607. /**
  38608. * Are emissive textures enabled in the application.
  38609. */
  38610. static EmissiveTextureEnabled: boolean;
  38611. /**
  38612. * Are specular textures enabled in the application.
  38613. */
  38614. static SpecularTextureEnabled: boolean;
  38615. /**
  38616. * Are bump textures enabled in the application.
  38617. */
  38618. static BumpTextureEnabled: boolean;
  38619. /**
  38620. * Are lightmap textures enabled in the application.
  38621. */
  38622. static LightmapTextureEnabled: boolean;
  38623. /**
  38624. * Are refraction textures enabled in the application.
  38625. */
  38626. static RefractionTextureEnabled: boolean;
  38627. /**
  38628. * Are color grading textures enabled in the application.
  38629. */
  38630. static ColorGradingTextureEnabled: boolean;
  38631. /**
  38632. * Are fresnels enabled in the application.
  38633. */
  38634. static FresnelEnabled: boolean;
  38635. }
  38636. }
  38637. declare module BABYLON {
  38638. /**
  38639. * A class extending Texture allowing drawing on a texture
  38640. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38641. */
  38642. export class DynamicTexture extends Texture {
  38643. private _generateMipMaps;
  38644. private _canvas;
  38645. private _context;
  38646. private _engine;
  38647. /**
  38648. * Creates a DynamicTexture
  38649. * @param name defines the name of the texture
  38650. * @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
  38651. * @param scene defines the scene where you want the texture
  38652. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38653. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38654. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38655. */
  38656. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38657. /**
  38658. * Get the current class name of the texture useful for serialization or dynamic coding.
  38659. * @returns "DynamicTexture"
  38660. */
  38661. getClassName(): string;
  38662. /**
  38663. * Gets the current state of canRescale
  38664. */
  38665. readonly canRescale: boolean;
  38666. private _recreate;
  38667. /**
  38668. * Scales the texture
  38669. * @param ratio the scale factor to apply to both width and height
  38670. */
  38671. scale(ratio: number): void;
  38672. /**
  38673. * Resizes the texture
  38674. * @param width the new width
  38675. * @param height the new height
  38676. */
  38677. scaleTo(width: number, height: number): void;
  38678. /**
  38679. * Gets the context of the canvas used by the texture
  38680. * @returns the canvas context of the dynamic texture
  38681. */
  38682. getContext(): CanvasRenderingContext2D;
  38683. /**
  38684. * Clears the texture
  38685. */
  38686. clear(): void;
  38687. /**
  38688. * Updates the texture
  38689. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38690. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38691. */
  38692. update(invertY?: boolean, premulAlpha?: boolean): void;
  38693. /**
  38694. * Draws text onto the texture
  38695. * @param text defines the text to be drawn
  38696. * @param x defines the placement of the text from the left
  38697. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38698. * @param font defines the font to be used with font-style, font-size, font-name
  38699. * @param color defines the color used for the text
  38700. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38701. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38702. * @param update defines whether texture is immediately update (default is true)
  38703. */
  38704. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38705. /**
  38706. * Clones the texture
  38707. * @returns the clone of the texture.
  38708. */
  38709. clone(): DynamicTexture;
  38710. /**
  38711. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38712. * @returns a serialized dynamic texture object
  38713. */
  38714. serialize(): any;
  38715. /** @hidden */
  38716. _rebuild(): void;
  38717. }
  38718. }
  38719. declare module BABYLON {
  38720. /** @hidden */
  38721. export var imageProcessingPixelShader: {
  38722. name: string;
  38723. shader: string;
  38724. };
  38725. }
  38726. declare module BABYLON {
  38727. /**
  38728. * ImageProcessingPostProcess
  38729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38730. */
  38731. export class ImageProcessingPostProcess extends PostProcess {
  38732. /**
  38733. * Default configuration related to image processing available in the PBR Material.
  38734. */
  38735. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38736. /**
  38737. * Gets the image processing configuration used either in this material.
  38738. */
  38739. /**
  38740. * Sets the Default image processing configuration used either in the this material.
  38741. *
  38742. * If sets to null, the scene one is in use.
  38743. */
  38744. imageProcessingConfiguration: ImageProcessingConfiguration;
  38745. /**
  38746. * Keep track of the image processing observer to allow dispose and replace.
  38747. */
  38748. private _imageProcessingObserver;
  38749. /**
  38750. * Attaches a new image processing configuration to the PBR Material.
  38751. * @param configuration
  38752. */
  38753. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38754. /**
  38755. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38756. */
  38757. /**
  38758. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38759. */
  38760. colorCurves: Nullable<ColorCurves>;
  38761. /**
  38762. * Gets wether the color curves effect is enabled.
  38763. */
  38764. /**
  38765. * Sets wether the color curves effect is enabled.
  38766. */
  38767. colorCurvesEnabled: boolean;
  38768. /**
  38769. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38770. */
  38771. /**
  38772. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38773. */
  38774. colorGradingTexture: Nullable<BaseTexture>;
  38775. /**
  38776. * Gets wether the color grading effect is enabled.
  38777. */
  38778. /**
  38779. * Gets wether the color grading effect is enabled.
  38780. */
  38781. colorGradingEnabled: boolean;
  38782. /**
  38783. * Gets exposure used in the effect.
  38784. */
  38785. /**
  38786. * Sets exposure used in the effect.
  38787. */
  38788. exposure: number;
  38789. /**
  38790. * Gets wether tonemapping is enabled or not.
  38791. */
  38792. /**
  38793. * Sets wether tonemapping is enabled or not
  38794. */
  38795. toneMappingEnabled: boolean;
  38796. /**
  38797. * Gets the type of tone mapping effect.
  38798. */
  38799. /**
  38800. * Sets the type of tone mapping effect.
  38801. */
  38802. toneMappingType: number;
  38803. /**
  38804. * Gets contrast used in the effect.
  38805. */
  38806. /**
  38807. * Sets contrast used in the effect.
  38808. */
  38809. contrast: number;
  38810. /**
  38811. * Gets Vignette stretch size.
  38812. */
  38813. /**
  38814. * Sets Vignette stretch size.
  38815. */
  38816. vignetteStretch: number;
  38817. /**
  38818. * Gets Vignette centre X Offset.
  38819. */
  38820. /**
  38821. * Sets Vignette centre X Offset.
  38822. */
  38823. vignetteCentreX: number;
  38824. /**
  38825. * Gets Vignette centre Y Offset.
  38826. */
  38827. /**
  38828. * Sets Vignette centre Y Offset.
  38829. */
  38830. vignetteCentreY: number;
  38831. /**
  38832. * Gets Vignette weight or intensity of the vignette effect.
  38833. */
  38834. /**
  38835. * Sets Vignette weight or intensity of the vignette effect.
  38836. */
  38837. vignetteWeight: number;
  38838. /**
  38839. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38840. * if vignetteEnabled is set to true.
  38841. */
  38842. /**
  38843. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38844. * if vignetteEnabled is set to true.
  38845. */
  38846. vignetteColor: Color4;
  38847. /**
  38848. * Gets Camera field of view used by the Vignette effect.
  38849. */
  38850. /**
  38851. * Sets Camera field of view used by the Vignette effect.
  38852. */
  38853. vignetteCameraFov: number;
  38854. /**
  38855. * Gets the vignette blend mode allowing different kind of effect.
  38856. */
  38857. /**
  38858. * Sets the vignette blend mode allowing different kind of effect.
  38859. */
  38860. vignetteBlendMode: number;
  38861. /**
  38862. * Gets wether the vignette effect is enabled.
  38863. */
  38864. /**
  38865. * Sets wether the vignette effect is enabled.
  38866. */
  38867. vignetteEnabled: boolean;
  38868. private _fromLinearSpace;
  38869. /**
  38870. * Gets wether the input of the processing is in Gamma or Linear Space.
  38871. */
  38872. /**
  38873. * Sets wether the input of the processing is in Gamma or Linear Space.
  38874. */
  38875. fromLinearSpace: boolean;
  38876. /**
  38877. * Defines cache preventing GC.
  38878. */
  38879. private _defines;
  38880. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38881. /**
  38882. * "ImageProcessingPostProcess"
  38883. * @returns "ImageProcessingPostProcess"
  38884. */
  38885. getClassName(): string;
  38886. protected _updateParameters(): void;
  38887. dispose(camera?: Camera): void;
  38888. }
  38889. }
  38890. declare module BABYLON {
  38891. /**
  38892. * Class containing static functions to help procedurally build meshes
  38893. */
  38894. export class GroundBuilder {
  38895. /**
  38896. * Creates a ground mesh
  38897. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38898. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38900. * @param name defines the name of the mesh
  38901. * @param options defines the options used to create the mesh
  38902. * @param scene defines the hosting scene
  38903. * @returns the ground mesh
  38904. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38905. */
  38906. static CreateGround(name: string, options: {
  38907. width?: number;
  38908. height?: number;
  38909. subdivisions?: number;
  38910. subdivisionsX?: number;
  38911. subdivisionsY?: number;
  38912. updatable?: boolean;
  38913. }, scene: any): Mesh;
  38914. /**
  38915. * Creates a tiled ground mesh
  38916. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38917. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38918. * * 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
  38919. * * 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
  38920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38921. * @param name defines the name of the mesh
  38922. * @param options defines the options used to create the mesh
  38923. * @param scene defines the hosting scene
  38924. * @returns the tiled ground mesh
  38925. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38926. */
  38927. static CreateTiledGround(name: string, options: {
  38928. xmin: number;
  38929. zmin: number;
  38930. xmax: number;
  38931. zmax: number;
  38932. subdivisions?: {
  38933. w: number;
  38934. h: number;
  38935. };
  38936. precision?: {
  38937. w: number;
  38938. h: number;
  38939. };
  38940. updatable?: boolean;
  38941. }, scene: Scene): Mesh;
  38942. /**
  38943. * Creates a ground mesh from a height map
  38944. * * The parameter `url` sets the URL of the height map image resource.
  38945. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38946. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38947. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38948. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38949. * * 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.
  38950. * * 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).
  38951. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38953. * @param name defines the name of the mesh
  38954. * @param url defines the url to the height map
  38955. * @param options defines the options used to create the mesh
  38956. * @param scene defines the hosting scene
  38957. * @returns the ground mesh
  38958. * @see https://doc.babylonjs.com/babylon101/height_map
  38959. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38960. */
  38961. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38962. width?: number;
  38963. height?: number;
  38964. subdivisions?: number;
  38965. minHeight?: number;
  38966. maxHeight?: number;
  38967. colorFilter?: Color3;
  38968. alphaFilter?: number;
  38969. updatable?: boolean;
  38970. onReady?: (mesh: GroundMesh) => void;
  38971. }, scene: Scene): GroundMesh;
  38972. }
  38973. }
  38974. declare module BABYLON {
  38975. /**
  38976. * Class containing static functions to help procedurally build meshes
  38977. */
  38978. export class TorusBuilder {
  38979. /**
  38980. * Creates a torus mesh
  38981. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38982. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38983. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38985. * * 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
  38986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38987. * @param name defines the name of the mesh
  38988. * @param options defines the options used to create the mesh
  38989. * @param scene defines the hosting scene
  38990. * @returns the torus mesh
  38991. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38992. */
  38993. static CreateTorus(name: string, options: {
  38994. diameter?: number;
  38995. thickness?: number;
  38996. tessellation?: number;
  38997. updatable?: boolean;
  38998. sideOrientation?: number;
  38999. frontUVs?: Vector4;
  39000. backUVs?: Vector4;
  39001. }, scene: any): Mesh;
  39002. }
  39003. }
  39004. declare module BABYLON {
  39005. /**
  39006. * Class containing static functions to help procedurally build meshes
  39007. */
  39008. export class CylinderBuilder {
  39009. /**
  39010. * Creates a cylinder or a cone mesh
  39011. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39012. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39013. * * 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.
  39014. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39015. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39016. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39017. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39018. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39019. * * 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).
  39020. * * 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
  39021. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39022. * * 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
  39023. * * 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.
  39024. * * If `enclose` is false, a ring surface is one element.
  39025. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39026. * * 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
  39027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39028. * * 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
  39029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39030. * @param name defines the name of the mesh
  39031. * @param options defines the options used to create the mesh
  39032. * @param scene defines the hosting scene
  39033. * @returns the cylinder mesh
  39034. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39035. */
  39036. static CreateCylinder(name: string, options: {
  39037. height?: number;
  39038. diameterTop?: number;
  39039. diameterBottom?: number;
  39040. diameter?: number;
  39041. tessellation?: number;
  39042. subdivisions?: number;
  39043. arc?: number;
  39044. faceColors?: Color4[];
  39045. faceUV?: Vector4[];
  39046. updatable?: boolean;
  39047. hasRings?: boolean;
  39048. enclose?: boolean;
  39049. sideOrientation?: number;
  39050. frontUVs?: Vector4;
  39051. backUVs?: Vector4;
  39052. }, scene: any): Mesh;
  39053. }
  39054. }
  39055. declare module BABYLON {
  39056. /**
  39057. * Manager for handling gamepads
  39058. */
  39059. export class GamepadManager {
  39060. private _scene?;
  39061. private _babylonGamepads;
  39062. private _oneGamepadConnected;
  39063. /** @hidden */
  39064. _isMonitoring: boolean;
  39065. private _gamepadEventSupported;
  39066. private _gamepadSupport;
  39067. /**
  39068. * observable to be triggered when the gamepad controller has been connected
  39069. */
  39070. onGamepadConnectedObservable: Observable<Gamepad>;
  39071. /**
  39072. * observable to be triggered when the gamepad controller has been disconnected
  39073. */
  39074. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39075. private _onGamepadConnectedEvent;
  39076. private _onGamepadDisconnectedEvent;
  39077. /**
  39078. * Initializes the gamepad manager
  39079. * @param _scene BabylonJS scene
  39080. */
  39081. constructor(_scene?: Scene | undefined);
  39082. /**
  39083. * The gamepads in the game pad manager
  39084. */
  39085. readonly gamepads: Gamepad[];
  39086. /**
  39087. * Get the gamepad controllers based on type
  39088. * @param type The type of gamepad controller
  39089. * @returns Nullable gamepad
  39090. */
  39091. getGamepadByType(type?: number): Nullable<Gamepad>;
  39092. /**
  39093. * Disposes the gamepad manager
  39094. */
  39095. dispose(): void;
  39096. private _addNewGamepad;
  39097. private _startMonitoringGamepads;
  39098. private _stopMonitoringGamepads;
  39099. /** @hidden */
  39100. _checkGamepadsStatus(): void;
  39101. private _updateGamepadObjects;
  39102. }
  39103. }
  39104. declare module BABYLON {
  39105. interface Scene {
  39106. /** @hidden */
  39107. _gamepadManager: Nullable<GamepadManager>;
  39108. /**
  39109. * Gets the gamepad manager associated with the scene
  39110. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39111. */
  39112. gamepadManager: GamepadManager;
  39113. }
  39114. /**
  39115. * Interface representing a free camera inputs manager
  39116. */
  39117. interface FreeCameraInputsManager {
  39118. /**
  39119. * Adds gamepad input support to the FreeCameraInputsManager.
  39120. * @returns the FreeCameraInputsManager
  39121. */
  39122. addGamepad(): FreeCameraInputsManager;
  39123. }
  39124. /**
  39125. * Interface representing an arc rotate camera inputs manager
  39126. */
  39127. interface ArcRotateCameraInputsManager {
  39128. /**
  39129. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39130. * @returns the camera inputs manager
  39131. */
  39132. addGamepad(): ArcRotateCameraInputsManager;
  39133. }
  39134. /**
  39135. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39136. */
  39137. export class GamepadSystemSceneComponent implements ISceneComponent {
  39138. /**
  39139. * The component name helpfull to identify the component in the list of scene components.
  39140. */
  39141. readonly name: string;
  39142. /**
  39143. * The scene the component belongs to.
  39144. */
  39145. scene: Scene;
  39146. /**
  39147. * Creates a new instance of the component for the given scene
  39148. * @param scene Defines the scene to register the component in
  39149. */
  39150. constructor(scene: Scene);
  39151. /**
  39152. * Registers the component in a given scene
  39153. */
  39154. register(): void;
  39155. /**
  39156. * Rebuilds the elements related to this component in case of
  39157. * context lost for instance.
  39158. */
  39159. rebuild(): void;
  39160. /**
  39161. * Disposes the component and the associated ressources
  39162. */
  39163. dispose(): void;
  39164. private _beforeCameraUpdate;
  39165. }
  39166. }
  39167. declare module BABYLON {
  39168. /**
  39169. * Options to modify the vr teleportation behavior.
  39170. */
  39171. export interface VRTeleportationOptions {
  39172. /**
  39173. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39174. */
  39175. floorMeshName?: string;
  39176. /**
  39177. * A list of meshes to be used as the teleportation floor. (default: empty)
  39178. */
  39179. floorMeshes?: Mesh[];
  39180. }
  39181. /**
  39182. * Options to modify the vr experience helper's behavior.
  39183. */
  39184. export interface VRExperienceHelperOptions extends WebVROptions {
  39185. /**
  39186. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39187. */
  39188. createDeviceOrientationCamera?: boolean;
  39189. /**
  39190. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39191. */
  39192. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39193. /**
  39194. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39195. */
  39196. laserToggle?: boolean;
  39197. /**
  39198. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39199. */
  39200. floorMeshes?: Mesh[];
  39201. /**
  39202. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39203. */
  39204. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39205. }
  39206. /**
  39207. * Event containing information after VR has been entered
  39208. */
  39209. export class OnAfterEnteringVRObservableEvent {
  39210. /**
  39211. * If entering vr was successful
  39212. */
  39213. success: boolean;
  39214. }
  39215. /**
  39216. * Helps to quickly add VR support to an existing scene.
  39217. * See http://doc.babylonjs.com/how_to/webvr_helper
  39218. */
  39219. export class VRExperienceHelper {
  39220. /** Options to modify the vr experience helper's behavior. */
  39221. webVROptions: VRExperienceHelperOptions;
  39222. private _scene;
  39223. private _position;
  39224. private _btnVR;
  39225. private _btnVRDisplayed;
  39226. private _webVRsupported;
  39227. private _webVRready;
  39228. private _webVRrequesting;
  39229. private _webVRpresenting;
  39230. private _hasEnteredVR;
  39231. private _fullscreenVRpresenting;
  39232. private _canvas;
  39233. private _webVRCamera;
  39234. private _vrDeviceOrientationCamera;
  39235. private _deviceOrientationCamera;
  39236. private _existingCamera;
  39237. private _onKeyDown;
  39238. private _onVrDisplayPresentChange;
  39239. private _onVRDisplayChanged;
  39240. private _onVRRequestPresentStart;
  39241. private _onVRRequestPresentComplete;
  39242. /**
  39243. * Observable raised right before entering VR.
  39244. */
  39245. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39246. /**
  39247. * Observable raised when entering VR has completed.
  39248. */
  39249. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39250. /**
  39251. * Observable raised when exiting VR.
  39252. */
  39253. onExitingVRObservable: Observable<VRExperienceHelper>;
  39254. /**
  39255. * Observable raised when controller mesh is loaded.
  39256. */
  39257. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39258. /** Return this.onEnteringVRObservable
  39259. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39260. */
  39261. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39262. /** Return this.onExitingVRObservable
  39263. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39264. */
  39265. readonly onExitingVR: Observable<VRExperienceHelper>;
  39266. /** Return this.onControllerMeshLoadedObservable
  39267. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39268. */
  39269. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39270. private _rayLength;
  39271. private _useCustomVRButton;
  39272. private _teleportationRequested;
  39273. private _teleportActive;
  39274. private _floorMeshName;
  39275. private _floorMeshesCollection;
  39276. private _rotationAllowed;
  39277. private _teleportBackwardsVector;
  39278. private _teleportationTarget;
  39279. private _isDefaultTeleportationTarget;
  39280. private _postProcessMove;
  39281. private _teleportationFillColor;
  39282. private _teleportationBorderColor;
  39283. private _rotationAngle;
  39284. private _haloCenter;
  39285. private _cameraGazer;
  39286. private _padSensibilityUp;
  39287. private _padSensibilityDown;
  39288. private _leftController;
  39289. private _rightController;
  39290. /**
  39291. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39292. */
  39293. onNewMeshSelected: Observable<AbstractMesh>;
  39294. /**
  39295. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39296. */
  39297. onNewMeshPicked: Observable<PickingInfo>;
  39298. private _circleEase;
  39299. /**
  39300. * Observable raised before camera teleportation
  39301. */
  39302. onBeforeCameraTeleport: Observable<Vector3>;
  39303. /**
  39304. * Observable raised after camera teleportation
  39305. */
  39306. onAfterCameraTeleport: Observable<Vector3>;
  39307. /**
  39308. * Observable raised when current selected mesh gets unselected
  39309. */
  39310. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39311. private _raySelectionPredicate;
  39312. /**
  39313. * To be optionaly changed by user to define custom ray selection
  39314. */
  39315. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39316. /**
  39317. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39318. */
  39319. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39320. /**
  39321. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39322. */
  39323. teleportationEnabled: boolean;
  39324. private _defaultHeight;
  39325. private _teleportationInitialized;
  39326. private _interactionsEnabled;
  39327. private _interactionsRequested;
  39328. private _displayGaze;
  39329. private _displayLaserPointer;
  39330. /**
  39331. * The mesh used to display where the user is going to teleport.
  39332. */
  39333. /**
  39334. * Sets the mesh to be used to display where the user is going to teleport.
  39335. */
  39336. teleportationTarget: Mesh;
  39337. /**
  39338. * 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
  39339. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39340. * See http://doc.babylonjs.com/resources/baking_transformations
  39341. */
  39342. gazeTrackerMesh: Mesh;
  39343. /**
  39344. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39345. */
  39346. updateGazeTrackerScale: boolean;
  39347. /**
  39348. * If the gaze trackers color should be updated when selecting meshes
  39349. */
  39350. updateGazeTrackerColor: boolean;
  39351. /**
  39352. * The gaze tracking mesh corresponding to the left controller
  39353. */
  39354. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39355. /**
  39356. * The gaze tracking mesh corresponding to the right controller
  39357. */
  39358. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39359. /**
  39360. * If the ray of the gaze should be displayed.
  39361. */
  39362. /**
  39363. * Sets if the ray of the gaze should be displayed.
  39364. */
  39365. displayGaze: boolean;
  39366. /**
  39367. * If the ray of the LaserPointer should be displayed.
  39368. */
  39369. /**
  39370. * Sets if the ray of the LaserPointer should be displayed.
  39371. */
  39372. displayLaserPointer: boolean;
  39373. /**
  39374. * The deviceOrientationCamera used as the camera when not in VR.
  39375. */
  39376. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39377. /**
  39378. * Based on the current WebVR support, returns the current VR camera used.
  39379. */
  39380. readonly currentVRCamera: Nullable<Camera>;
  39381. /**
  39382. * The webVRCamera which is used when in VR.
  39383. */
  39384. readonly webVRCamera: WebVRFreeCamera;
  39385. /**
  39386. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39387. */
  39388. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39389. private readonly _teleportationRequestInitiated;
  39390. /**
  39391. * Defines wether or not Pointer lock should be requested when switching to
  39392. * full screen.
  39393. */
  39394. requestPointerLockOnFullScreen: boolean;
  39395. /**
  39396. * Instantiates a VRExperienceHelper.
  39397. * Helps to quickly add VR support to an existing scene.
  39398. * @param scene The scene the VRExperienceHelper belongs to.
  39399. * @param webVROptions Options to modify the vr experience helper's behavior.
  39400. */
  39401. constructor(scene: Scene,
  39402. /** Options to modify the vr experience helper's behavior. */
  39403. webVROptions?: VRExperienceHelperOptions);
  39404. private _onDefaultMeshLoaded;
  39405. private _onResize;
  39406. private _onFullscreenChange;
  39407. /**
  39408. * Gets a value indicating if we are currently in VR mode.
  39409. */
  39410. readonly isInVRMode: boolean;
  39411. private onVrDisplayPresentChange;
  39412. private onVRDisplayChanged;
  39413. private moveButtonToBottomRight;
  39414. private displayVRButton;
  39415. private updateButtonVisibility;
  39416. private _cachedAngularSensibility;
  39417. /**
  39418. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39419. * Otherwise, will use the fullscreen API.
  39420. */
  39421. enterVR(): void;
  39422. /**
  39423. * Attempt to exit VR, or fullscreen.
  39424. */
  39425. exitVR(): void;
  39426. /**
  39427. * The position of the vr experience helper.
  39428. */
  39429. /**
  39430. * Sets the position of the vr experience helper.
  39431. */
  39432. position: Vector3;
  39433. /**
  39434. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39435. */
  39436. enableInteractions(): void;
  39437. private readonly _noControllerIsActive;
  39438. private beforeRender;
  39439. private _isTeleportationFloor;
  39440. /**
  39441. * Adds a floor mesh to be used for teleportation.
  39442. * @param floorMesh the mesh to be used for teleportation.
  39443. */
  39444. addFloorMesh(floorMesh: Mesh): void;
  39445. /**
  39446. * Removes a floor mesh from being used for teleportation.
  39447. * @param floorMesh the mesh to be removed.
  39448. */
  39449. removeFloorMesh(floorMesh: Mesh): void;
  39450. /**
  39451. * Enables interactions and teleportation using the VR controllers and gaze.
  39452. * @param vrTeleportationOptions options to modify teleportation behavior.
  39453. */
  39454. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39455. private _onNewGamepadConnected;
  39456. private _tryEnableInteractionOnController;
  39457. private _onNewGamepadDisconnected;
  39458. private _enableInteractionOnController;
  39459. private _checkTeleportWithRay;
  39460. private _checkRotate;
  39461. private _checkTeleportBackwards;
  39462. private _enableTeleportationOnController;
  39463. private _createTeleportationCircles;
  39464. private _displayTeleportationTarget;
  39465. private _hideTeleportationTarget;
  39466. private _rotateCamera;
  39467. private _moveTeleportationSelectorTo;
  39468. private _workingVector;
  39469. private _workingQuaternion;
  39470. private _workingMatrix;
  39471. /**
  39472. * Teleports the users feet to the desired location
  39473. * @param location The location where the user's feet should be placed
  39474. */
  39475. teleportCamera(location: Vector3): void;
  39476. private _convertNormalToDirectionOfRay;
  39477. private _castRayAndSelectObject;
  39478. private _notifySelectedMeshUnselected;
  39479. /**
  39480. * Sets the color of the laser ray from the vr controllers.
  39481. * @param color new color for the ray.
  39482. */
  39483. changeLaserColor(color: Color3): void;
  39484. /**
  39485. * Sets the color of the ray from the vr headsets gaze.
  39486. * @param color new color for the ray.
  39487. */
  39488. changeGazeColor(color: Color3): void;
  39489. /**
  39490. * Exits VR and disposes of the vr experience helper
  39491. */
  39492. dispose(): void;
  39493. /**
  39494. * Gets the name of the VRExperienceHelper class
  39495. * @returns "VRExperienceHelper"
  39496. */
  39497. getClassName(): string;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Manages an XRSession
  39503. * @see https://doc.babylonjs.com/how_to/webxr
  39504. */
  39505. export class WebXRSessionManager implements IDisposable {
  39506. private scene;
  39507. /**
  39508. * Fires every time a new xrFrame arrives which can be used to update the camera
  39509. */
  39510. onXRFrameObservable: Observable<any>;
  39511. /**
  39512. * Fires when the xr session is ended either by the device or manually done
  39513. */
  39514. onXRSessionEnded: Observable<any>;
  39515. /** @hidden */
  39516. _xrSession: XRSession;
  39517. /** @hidden */
  39518. _frameOfReference: XRFrameOfReference;
  39519. /** @hidden */
  39520. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39521. /** @hidden */
  39522. _currentXRFrame: Nullable<XRFrame>;
  39523. private _xrNavigator;
  39524. private _xrDevice;
  39525. private _tmpMatrix;
  39526. /**
  39527. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39528. * @param scene The scene which the session should be created for
  39529. */
  39530. constructor(scene: Scene);
  39531. /**
  39532. * Initializes the manager
  39533. * After initialization enterXR can be called to start an XR session
  39534. * @returns Promise which resolves after it is initialized
  39535. */
  39536. initializeAsync(): Promise<void>;
  39537. /**
  39538. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39539. * @param sessionCreationOptions xr options to create the session with
  39540. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39541. * @returns Promise which resolves after it enters XR
  39542. */
  39543. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39544. /**
  39545. * Stops the xrSession and restores the renderloop
  39546. * @returns Promise which resolves after it exits XR
  39547. */
  39548. exitXRAsync(): Promise<void>;
  39549. /**
  39550. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39551. * @param ray ray to cast into the environment
  39552. * @returns Promise which resolves with a collision point in the environment if it exists
  39553. */
  39554. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39555. /**
  39556. * Checks if a session would be supported for the creation options specified
  39557. * @param options creation options to check if they are supported
  39558. * @returns true if supported
  39559. */
  39560. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39561. /**
  39562. * @hidden
  39563. * Converts the render layer of xrSession to a render target
  39564. * @param session session to create render target for
  39565. * @param scene scene the new render target should be created for
  39566. */
  39567. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39568. /**
  39569. * Disposes of the session manager
  39570. */
  39571. dispose(): void;
  39572. }
  39573. }
  39574. declare module BABYLON {
  39575. /**
  39576. * WebXR Camera which holds the views for the xrSession
  39577. * @see https://doc.babylonjs.com/how_to/webxr
  39578. */
  39579. export class WebXRCamera extends FreeCamera {
  39580. private static _TmpMatrix;
  39581. /**
  39582. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39583. * @param name the name of the camera
  39584. * @param scene the scene to add the camera to
  39585. */
  39586. constructor(name: string, scene: Scene);
  39587. private _updateNumberOfRigCameras;
  39588. /** @hidden */
  39589. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39590. /**
  39591. * Updates the cameras position from the current pose information of the XR session
  39592. * @param xrSessionManager the session containing pose information
  39593. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39594. */
  39595. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39596. }
  39597. }
  39598. declare module BABYLON {
  39599. /**
  39600. * States of the webXR experience
  39601. */
  39602. export enum WebXRState {
  39603. /**
  39604. * Transitioning to being in XR mode
  39605. */
  39606. ENTERING_XR = 0,
  39607. /**
  39608. * Transitioning to non XR mode
  39609. */
  39610. EXITING_XR = 1,
  39611. /**
  39612. * In XR mode and presenting
  39613. */
  39614. IN_XR = 2,
  39615. /**
  39616. * Not entered XR mode
  39617. */
  39618. NOT_IN_XR = 3
  39619. }
  39620. /**
  39621. * Helper class used to enable XR
  39622. * @see https://doc.babylonjs.com/how_to/webxr
  39623. */
  39624. export class WebXRExperienceHelper implements IDisposable {
  39625. private scene;
  39626. /**
  39627. * 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
  39628. */
  39629. container: AbstractMesh;
  39630. /**
  39631. * Camera used to render xr content
  39632. */
  39633. camera: WebXRCamera;
  39634. /**
  39635. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39636. */
  39637. state: WebXRState;
  39638. private _setState;
  39639. private static _TmpVector;
  39640. /**
  39641. * Fires when the state of the experience helper has changed
  39642. */
  39643. onStateChangedObservable: Observable<WebXRState>;
  39644. /** @hidden */
  39645. _sessionManager: WebXRSessionManager;
  39646. private _nonVRCamera;
  39647. private _originalSceneAutoClear;
  39648. private _supported;
  39649. /**
  39650. * Creates the experience helper
  39651. * @param scene the scene to attach the experience helper to
  39652. * @returns a promise for the experience helper
  39653. */
  39654. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39655. /**
  39656. * Creates a WebXRExperienceHelper
  39657. * @param scene The scene the helper should be created in
  39658. */
  39659. private constructor();
  39660. /**
  39661. * Exits XR mode and returns the scene to its original state
  39662. * @returns promise that resolves after xr mode has exited
  39663. */
  39664. exitXRAsync(): Promise<void>;
  39665. /**
  39666. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39667. * @param sessionCreationOptions options for the XR session
  39668. * @param frameOfReference frame of reference of the XR session
  39669. * @returns promise that resolves after xr mode has entered
  39670. */
  39671. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39672. /**
  39673. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39674. * @param ray ray to cast into the environment
  39675. * @returns Promise which resolves with a collision point in the environment if it exists
  39676. */
  39677. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39678. /**
  39679. * Updates the global position of the camera by moving the camera's container
  39680. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39681. * @param position The desired global position of the camera
  39682. */
  39683. setPositionOfCameraUsingContainer(position: Vector3): void;
  39684. /**
  39685. * Rotates the xr camera by rotating the camera's container around the camera's position
  39686. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39687. * @param rotation the desired quaternion rotation to apply to the camera
  39688. */
  39689. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39690. /**
  39691. * Checks if the creation options are supported by the xr session
  39692. * @param options creation options
  39693. * @returns true if supported
  39694. */
  39695. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39696. /**
  39697. * Disposes of the experience helper
  39698. */
  39699. dispose(): void;
  39700. }
  39701. }
  39702. declare module BABYLON {
  39703. /**
  39704. * Button which can be used to enter a different mode of XR
  39705. */
  39706. export class WebXREnterExitUIButton {
  39707. /** button element */
  39708. element: HTMLElement;
  39709. /** XR initialization options for the button */
  39710. initializationOptions: XRSessionCreationOptions;
  39711. /**
  39712. * Creates a WebXREnterExitUIButton
  39713. * @param element button element
  39714. * @param initializationOptions XR initialization options for the button
  39715. */
  39716. constructor(
  39717. /** button element */
  39718. element: HTMLElement,
  39719. /** XR initialization options for the button */
  39720. initializationOptions: XRSessionCreationOptions);
  39721. /**
  39722. * Overwritable function which can be used to update the button's visuals when the state changes
  39723. * @param activeButton the current active button in the UI
  39724. */
  39725. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39726. }
  39727. /**
  39728. * Options to create the webXR UI
  39729. */
  39730. export class WebXREnterExitUIOptions {
  39731. /**
  39732. * Context to enter xr with
  39733. */
  39734. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39735. /**
  39736. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39737. */
  39738. customButtons?: Array<WebXREnterExitUIButton>;
  39739. }
  39740. /**
  39741. * UI to allow the user to enter/exit XR mode
  39742. */
  39743. export class WebXREnterExitUI implements IDisposable {
  39744. private scene;
  39745. private _overlay;
  39746. private _buttons;
  39747. private _activeButton;
  39748. /**
  39749. * Fired every time the active button is changed.
  39750. *
  39751. * When xr is entered via a button that launches xr that button will be the callback parameter
  39752. *
  39753. * When exiting xr the callback parameter will be null)
  39754. */
  39755. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39756. /**
  39757. * Creates UI to allow the user to enter/exit XR mode
  39758. * @param scene the scene to add the ui to
  39759. * @param helper the xr experience helper to enter/exit xr with
  39760. * @param options options to configure the UI
  39761. * @returns the created ui
  39762. */
  39763. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39764. private constructor();
  39765. private _updateButtons;
  39766. /**
  39767. * Disposes of the object
  39768. */
  39769. dispose(): void;
  39770. }
  39771. }
  39772. declare module BABYLON {
  39773. /**
  39774. * Represents an XR input
  39775. */
  39776. export class WebXRController {
  39777. /**
  39778. * 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
  39779. */
  39780. grip?: AbstractMesh;
  39781. /**
  39782. * Pointer which can be used to select objects or attach a visible laser to
  39783. */
  39784. pointer: AbstractMesh;
  39785. /**
  39786. * Creates the controller
  39787. * @see https://doc.babylonjs.com/how_to/webxr
  39788. * @param scene the scene which the controller should be associated to
  39789. */
  39790. constructor(scene: Scene);
  39791. /**
  39792. * Disposes of the object
  39793. */
  39794. dispose(): void;
  39795. }
  39796. /**
  39797. * XR input used to track XR inputs such as controllers/rays
  39798. */
  39799. export class WebXRInput implements IDisposable {
  39800. private helper;
  39801. /**
  39802. * XR controllers being tracked
  39803. */
  39804. controllers: Array<WebXRController>;
  39805. private _tmpMatrix;
  39806. private _frameObserver;
  39807. /**
  39808. * Initializes the WebXRInput
  39809. * @param helper experience helper which the input should be created for
  39810. */
  39811. constructor(helper: WebXRExperienceHelper);
  39812. /**
  39813. * Disposes of the object
  39814. */
  39815. dispose(): void;
  39816. }
  39817. }
  39818. declare module BABYLON {
  39819. /**
  39820. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39821. */
  39822. export class WebXRManagedOutputCanvas implements IDisposable {
  39823. private _canvas;
  39824. /**
  39825. * xrpresent context of the canvas which can be used to display/mirror xr content
  39826. */
  39827. canvasContext: Nullable<WebGLRenderingContext>;
  39828. /**
  39829. * Initializes the canvas to be added/removed upon entering/exiting xr
  39830. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39831. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39832. */
  39833. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39834. /**
  39835. * Disposes of the object
  39836. */
  39837. dispose(): void;
  39838. private _setManagedOutputCanvas;
  39839. private _addCanvas;
  39840. private _removeCanvas;
  39841. }
  39842. }
  39843. declare module BABYLON {
  39844. /**
  39845. * Contains an array of blocks representing the octree
  39846. */
  39847. export interface IOctreeContainer<T> {
  39848. /**
  39849. * Blocks within the octree
  39850. */
  39851. blocks: Array<OctreeBlock<T>>;
  39852. }
  39853. /**
  39854. * Class used to store a cell in an octree
  39855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39856. */
  39857. export class OctreeBlock<T> {
  39858. /**
  39859. * Gets the content of the current block
  39860. */
  39861. entries: T[];
  39862. /**
  39863. * Gets the list of block children
  39864. */
  39865. blocks: Array<OctreeBlock<T>>;
  39866. private _depth;
  39867. private _maxDepth;
  39868. private _capacity;
  39869. private _minPoint;
  39870. private _maxPoint;
  39871. private _boundingVectors;
  39872. private _creationFunc;
  39873. /**
  39874. * Creates a new block
  39875. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39876. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39877. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39878. * @param depth defines the current depth of this block in the octree
  39879. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39880. * @param creationFunc defines a callback to call when an element is added to the block
  39881. */
  39882. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39883. /**
  39884. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39885. */
  39886. readonly capacity: number;
  39887. /**
  39888. * Gets the minimum vector (in world space) of the block's bounding box
  39889. */
  39890. readonly minPoint: Vector3;
  39891. /**
  39892. * Gets the maximum vector (in world space) of the block's bounding box
  39893. */
  39894. readonly maxPoint: Vector3;
  39895. /**
  39896. * Add a new element to this block
  39897. * @param entry defines the element to add
  39898. */
  39899. addEntry(entry: T): void;
  39900. /**
  39901. * Remove an element from this block
  39902. * @param entry defines the element to remove
  39903. */
  39904. removeEntry(entry: T): void;
  39905. /**
  39906. * Add an array of elements to this block
  39907. * @param entries defines the array of elements to add
  39908. */
  39909. addEntries(entries: T[]): void;
  39910. /**
  39911. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39912. * @param frustumPlanes defines the frustum planes to test
  39913. * @param selection defines the array to store current content if selection is positive
  39914. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39915. */
  39916. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39917. /**
  39918. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39919. * @param sphereCenter defines the bounding sphere center
  39920. * @param sphereRadius defines the bounding sphere radius
  39921. * @param selection defines the array to store current content if selection is positive
  39922. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39923. */
  39924. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39925. /**
  39926. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39927. * @param ray defines the ray to test with
  39928. * @param selection defines the array to store current content if selection is positive
  39929. */
  39930. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39931. /**
  39932. * Subdivide the content into child blocks (this block will then be empty)
  39933. */
  39934. createInnerBlocks(): void;
  39935. /**
  39936. * @hidden
  39937. */
  39938. 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;
  39939. }
  39940. }
  39941. declare module BABYLON {
  39942. /**
  39943. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39945. */
  39946. export class Octree<T> {
  39947. /** 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.) */
  39948. maxDepth: number;
  39949. /**
  39950. * Blocks within the octree containing objects
  39951. */
  39952. blocks: Array<OctreeBlock<T>>;
  39953. /**
  39954. * Content stored in the octree
  39955. */
  39956. dynamicContent: T[];
  39957. private _maxBlockCapacity;
  39958. private _selectionContent;
  39959. private _creationFunc;
  39960. /**
  39961. * Creates a octree
  39962. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39963. * @param creationFunc function to be used to instatiate the octree
  39964. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39965. * @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.)
  39966. */
  39967. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39968. /** 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.) */
  39969. maxDepth?: number);
  39970. /**
  39971. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39972. * @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);
  39973. * @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);
  39974. * @param entries meshes to be added to the octree blocks
  39975. */
  39976. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39977. /**
  39978. * Adds a mesh to the octree
  39979. * @param entry Mesh to add to the octree
  39980. */
  39981. addMesh(entry: T): void;
  39982. /**
  39983. * Remove an element from the octree
  39984. * @param entry defines the element to remove
  39985. */
  39986. removeMesh(entry: T): void;
  39987. /**
  39988. * Selects an array of meshes within the frustum
  39989. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39990. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39991. * @returns array of meshes within the frustum
  39992. */
  39993. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39994. /**
  39995. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39996. * @param sphereCenter defines the bounding sphere center
  39997. * @param sphereRadius defines the bounding sphere radius
  39998. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39999. * @returns an array of objects that intersect the sphere
  40000. */
  40001. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40002. /**
  40003. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40004. * @param ray defines the ray to test with
  40005. * @returns array of intersected objects
  40006. */
  40007. intersectsRay(ray: Ray): SmartArray<T>;
  40008. /**
  40009. * Adds a mesh into the octree block if it intersects the block
  40010. */
  40011. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40012. /**
  40013. * Adds a submesh into the octree block if it intersects the block
  40014. */
  40015. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40016. }
  40017. }
  40018. declare module BABYLON {
  40019. interface Scene {
  40020. /**
  40021. * @hidden
  40022. * Backing Filed
  40023. */
  40024. _selectionOctree: Octree<AbstractMesh>;
  40025. /**
  40026. * Gets the octree used to boost mesh selection (picking)
  40027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40028. */
  40029. selectionOctree: Octree<AbstractMesh>;
  40030. /**
  40031. * Creates or updates the octree used to boost selection (picking)
  40032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40033. * @param maxCapacity defines the maximum capacity per leaf
  40034. * @param maxDepth defines the maximum depth of the octree
  40035. * @returns an octree of AbstractMesh
  40036. */
  40037. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40038. }
  40039. interface AbstractMesh {
  40040. /**
  40041. * @hidden
  40042. * Backing Field
  40043. */
  40044. _submeshesOctree: Octree<SubMesh>;
  40045. /**
  40046. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40047. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40048. * @param maxCapacity defines the maximum size of each block (64 by default)
  40049. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40050. * @returns the new octree
  40051. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40053. */
  40054. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40055. }
  40056. /**
  40057. * Defines the octree scene component responsible to manage any octrees
  40058. * in a given scene.
  40059. */
  40060. export class OctreeSceneComponent {
  40061. /**
  40062. * The component name helpfull to identify the component in the list of scene components.
  40063. */
  40064. readonly name: string;
  40065. /**
  40066. * The scene the component belongs to.
  40067. */
  40068. scene: Scene;
  40069. /**
  40070. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40071. */
  40072. readonly checksIsEnabled: boolean;
  40073. /**
  40074. * Creates a new instance of the component for the given scene
  40075. * @param scene Defines the scene to register the component in
  40076. */
  40077. constructor(scene: Scene);
  40078. /**
  40079. * Registers the component in a given scene
  40080. */
  40081. register(): void;
  40082. /**
  40083. * Return the list of active meshes
  40084. * @returns the list of active meshes
  40085. */
  40086. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40087. /**
  40088. * Return the list of active sub meshes
  40089. * @param mesh The mesh to get the candidates sub meshes from
  40090. * @returns the list of active sub meshes
  40091. */
  40092. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40093. private _tempRay;
  40094. /**
  40095. * Return the list of sub meshes intersecting with a given local ray
  40096. * @param mesh defines the mesh to find the submesh for
  40097. * @param localRay defines the ray in local space
  40098. * @returns the list of intersecting sub meshes
  40099. */
  40100. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40101. /**
  40102. * Return the list of sub meshes colliding with a collider
  40103. * @param mesh defines the mesh to find the submesh for
  40104. * @param collider defines the collider to evaluate the collision against
  40105. * @returns the list of colliding sub meshes
  40106. */
  40107. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40108. /**
  40109. * Rebuilds the elements related to this component in case of
  40110. * context lost for instance.
  40111. */
  40112. rebuild(): void;
  40113. /**
  40114. * Disposes the component and the associated ressources.
  40115. */
  40116. dispose(): void;
  40117. }
  40118. }
  40119. declare module BABYLON {
  40120. /**
  40121. * Class containing static functions to help procedurally build meshes
  40122. */
  40123. export class LinesBuilder {
  40124. /**
  40125. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40126. * * 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
  40127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40128. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40129. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40130. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40132. * * 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
  40133. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40136. * @param name defines the name of the new line system
  40137. * @param options defines the options used to create the line system
  40138. * @param scene defines the hosting scene
  40139. * @returns a new line system mesh
  40140. */
  40141. static CreateLineSystem(name: string, options: {
  40142. lines: Vector3[][];
  40143. updatable?: boolean;
  40144. instance?: Nullable<LinesMesh>;
  40145. colors?: Nullable<Color4[][]>;
  40146. useVertexAlpha?: boolean;
  40147. }, scene: Nullable<Scene>): LinesMesh;
  40148. /**
  40149. * Creates a line mesh
  40150. * 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
  40151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40152. * * The parameter `points` is an array successive Vector3
  40153. * * 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
  40154. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40155. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40156. * * When updating an instance, remember that only point positions can change, not the number of points
  40157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40159. * @param name defines the name of the new line system
  40160. * @param options defines the options used to create the line system
  40161. * @param scene defines the hosting scene
  40162. * @returns a new line mesh
  40163. */
  40164. static CreateLines(name: string, options: {
  40165. points: Vector3[];
  40166. updatable?: boolean;
  40167. instance?: Nullable<LinesMesh>;
  40168. colors?: Color4[];
  40169. useVertexAlpha?: boolean;
  40170. }, scene?: Nullable<Scene>): LinesMesh;
  40171. /**
  40172. * Creates a dashed line mesh
  40173. * * 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
  40174. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40175. * * The parameter `points` is an array successive Vector3
  40176. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40177. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40178. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40179. * * 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
  40180. * * When updating an instance, remember that only point positions can change, not the number of points
  40181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40182. * @param name defines the name of the mesh
  40183. * @param options defines the options used to create the mesh
  40184. * @param scene defines the hosting scene
  40185. * @returns the dashed line mesh
  40186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40187. */
  40188. static CreateDashedLines(name: string, options: {
  40189. points: Vector3[];
  40190. dashSize?: number;
  40191. gapSize?: number;
  40192. dashNb?: number;
  40193. updatable?: boolean;
  40194. instance?: LinesMesh;
  40195. }, scene?: Nullable<Scene>): LinesMesh;
  40196. }
  40197. }
  40198. declare module BABYLON {
  40199. /**
  40200. * Renders a layer on top of an existing scene
  40201. */
  40202. export class UtilityLayerRenderer implements IDisposable {
  40203. /** the original scene that will be rendered on top of */
  40204. originalScene: Scene;
  40205. private _pointerCaptures;
  40206. private _lastPointerEvents;
  40207. private static _DefaultUtilityLayer;
  40208. private static _DefaultKeepDepthUtilityLayer;
  40209. /**
  40210. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40211. */
  40212. pickUtilitySceneFirst: boolean;
  40213. /**
  40214. * 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)
  40215. */
  40216. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40217. /**
  40218. * 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)
  40219. */
  40220. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40221. /**
  40222. * The scene that is rendered on top of the original scene
  40223. */
  40224. utilityLayerScene: Scene;
  40225. /**
  40226. * If the utility layer should automatically be rendered on top of existing scene
  40227. */
  40228. shouldRender: boolean;
  40229. /**
  40230. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40231. */
  40232. onlyCheckPointerDownEvents: boolean;
  40233. /**
  40234. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40235. */
  40236. processAllEvents: boolean;
  40237. /**
  40238. * Observable raised when the pointer move from the utility layer scene to the main scene
  40239. */
  40240. onPointerOutObservable: Observable<number>;
  40241. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40242. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40243. private _afterRenderObserver;
  40244. private _sceneDisposeObserver;
  40245. private _originalPointerObserver;
  40246. /**
  40247. * Instantiates a UtilityLayerRenderer
  40248. * @param originalScene the original scene that will be rendered on top of
  40249. * @param handleEvents boolean indicating if the utility layer should handle events
  40250. */
  40251. constructor(
  40252. /** the original scene that will be rendered on top of */
  40253. originalScene: Scene, handleEvents?: boolean);
  40254. private _notifyObservers;
  40255. /**
  40256. * Renders the utility layers scene on top of the original scene
  40257. */
  40258. render(): void;
  40259. /**
  40260. * Disposes of the renderer
  40261. */
  40262. dispose(): void;
  40263. private _updateCamera;
  40264. }
  40265. }
  40266. declare module BABYLON {
  40267. /**
  40268. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40269. */
  40270. export class Gizmo implements IDisposable {
  40271. /** The utility layer the gizmo will be added to */
  40272. gizmoLayer: UtilityLayerRenderer;
  40273. /**
  40274. * The root mesh of the gizmo
  40275. */
  40276. _rootMesh: Mesh;
  40277. private _attachedMesh;
  40278. /**
  40279. * Ratio for the scale of the gizmo (Default: 1)
  40280. */
  40281. scaleRatio: number;
  40282. private _tmpMatrix;
  40283. /**
  40284. * If a custom mesh has been set (Default: false)
  40285. */
  40286. protected _customMeshSet: boolean;
  40287. /**
  40288. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40289. * * When set, interactions will be enabled
  40290. */
  40291. attachedMesh: Nullable<AbstractMesh>;
  40292. /**
  40293. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40294. * @param mesh The mesh to replace the default mesh of the gizmo
  40295. */
  40296. setCustomMesh(mesh: Mesh): void;
  40297. /**
  40298. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40299. */
  40300. updateGizmoRotationToMatchAttachedMesh: boolean;
  40301. /**
  40302. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40303. */
  40304. updateGizmoPositionToMatchAttachedMesh: boolean;
  40305. /**
  40306. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40307. */
  40308. protected _updateScale: boolean;
  40309. protected _interactionsEnabled: boolean;
  40310. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40311. private _beforeRenderObserver;
  40312. /**
  40313. * Creates a gizmo
  40314. * @param gizmoLayer The utility layer the gizmo will be added to
  40315. */
  40316. constructor(
  40317. /** The utility layer the gizmo will be added to */
  40318. gizmoLayer?: UtilityLayerRenderer);
  40319. private _tempVector;
  40320. /**
  40321. * @hidden
  40322. * Updates the gizmo to match the attached mesh's position/rotation
  40323. */
  40324. protected _update(): void;
  40325. /**
  40326. * Disposes of the gizmo
  40327. */
  40328. dispose(): void;
  40329. }
  40330. }
  40331. declare module BABYLON {
  40332. /**
  40333. * Single axis drag gizmo
  40334. */
  40335. export class AxisDragGizmo extends Gizmo {
  40336. /**
  40337. * Drag behavior responsible for the gizmos dragging interactions
  40338. */
  40339. dragBehavior: PointerDragBehavior;
  40340. private _pointerObserver;
  40341. /**
  40342. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40343. */
  40344. snapDistance: number;
  40345. /**
  40346. * Event that fires each time the gizmo snaps to a new location.
  40347. * * snapDistance is the the change in distance
  40348. */
  40349. onSnapObservable: Observable<{
  40350. snapDistance: number;
  40351. }>;
  40352. /** @hidden */
  40353. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40354. /** @hidden */
  40355. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40356. /**
  40357. * Creates an AxisDragGizmo
  40358. * @param gizmoLayer The utility layer the gizmo will be added to
  40359. * @param dragAxis The axis which the gizmo will be able to drag on
  40360. * @param color The color of the gizmo
  40361. */
  40362. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40364. /**
  40365. * Disposes of the gizmo
  40366. */
  40367. dispose(): void;
  40368. }
  40369. }
  40370. declare module BABYLON.Debug {
  40371. /**
  40372. * The Axes viewer will show 3 axes in a specific point in space
  40373. */
  40374. export class AxesViewer {
  40375. private _xAxis;
  40376. private _yAxis;
  40377. private _zAxis;
  40378. private _scaleLinesFactor;
  40379. private _instanced;
  40380. /**
  40381. * Gets the hosting scene
  40382. */
  40383. scene: Scene;
  40384. /**
  40385. * Gets or sets a number used to scale line length
  40386. */
  40387. scaleLines: number;
  40388. /** Gets the node hierarchy used to render x-axis */
  40389. readonly xAxis: TransformNode;
  40390. /** Gets the node hierarchy used to render y-axis */
  40391. readonly yAxis: TransformNode;
  40392. /** Gets the node hierarchy used to render z-axis */
  40393. readonly zAxis: TransformNode;
  40394. /**
  40395. * Creates a new AxesViewer
  40396. * @param scene defines the hosting scene
  40397. * @param scaleLines defines a number used to scale line length (1 by default)
  40398. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40399. * @param xAxis defines the node hierarchy used to render the x-axis
  40400. * @param yAxis defines the node hierarchy used to render the y-axis
  40401. * @param zAxis defines the node hierarchy used to render the z-axis
  40402. */
  40403. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40404. /**
  40405. * Force the viewer to update
  40406. * @param position defines the position of the viewer
  40407. * @param xaxis defines the x axis of the viewer
  40408. * @param yaxis defines the y axis of the viewer
  40409. * @param zaxis defines the z axis of the viewer
  40410. */
  40411. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40412. /**
  40413. * Creates an instance of this axes viewer.
  40414. * @returns a new axes viewer with instanced meshes
  40415. */
  40416. createInstance(): AxesViewer;
  40417. /** Releases resources */
  40418. dispose(): void;
  40419. private static _SetRenderingGroupId;
  40420. }
  40421. }
  40422. declare module BABYLON.Debug {
  40423. /**
  40424. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40425. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40426. */
  40427. export class BoneAxesViewer extends AxesViewer {
  40428. /**
  40429. * Gets or sets the target mesh where to display the axes viewer
  40430. */
  40431. mesh: Nullable<Mesh>;
  40432. /**
  40433. * Gets or sets the target bone where to display the axes viewer
  40434. */
  40435. bone: Nullable<Bone>;
  40436. /** Gets current position */
  40437. pos: Vector3;
  40438. /** Gets direction of X axis */
  40439. xaxis: Vector3;
  40440. /** Gets direction of Y axis */
  40441. yaxis: Vector3;
  40442. /** Gets direction of Z axis */
  40443. zaxis: Vector3;
  40444. /**
  40445. * Creates a new BoneAxesViewer
  40446. * @param scene defines the hosting scene
  40447. * @param bone defines the target bone
  40448. * @param mesh defines the target mesh
  40449. * @param scaleLines defines a scaling factor for line length (1 by default)
  40450. */
  40451. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40452. /**
  40453. * Force the viewer to update
  40454. */
  40455. update(): void;
  40456. /** Releases resources */
  40457. dispose(): void;
  40458. }
  40459. }
  40460. declare module BABYLON {
  40461. /**
  40462. * Interface used to define scene explorer extensibility option
  40463. */
  40464. export interface IExplorerExtensibilityOption {
  40465. /**
  40466. * Define the option label
  40467. */
  40468. label: string;
  40469. /**
  40470. * Defines the action to execute on click
  40471. */
  40472. action: (entity: any) => void;
  40473. }
  40474. /**
  40475. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40476. */
  40477. export interface IExplorerExtensibilityGroup {
  40478. /**
  40479. * Defines a predicate to test if a given type mut be extended
  40480. */
  40481. predicate: (entity: any) => boolean;
  40482. /**
  40483. * Gets the list of options added to a type
  40484. */
  40485. entries: IExplorerExtensibilityOption[];
  40486. }
  40487. /**
  40488. * Interface used to define the options to use to create the Inspector
  40489. */
  40490. export interface IInspectorOptions {
  40491. /**
  40492. * Display in overlay mode (default: false)
  40493. */
  40494. overlay?: boolean;
  40495. /**
  40496. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40497. */
  40498. globalRoot?: HTMLElement;
  40499. /**
  40500. * Display the Scene explorer
  40501. */
  40502. showExplorer?: boolean;
  40503. /**
  40504. * Display the property inspector
  40505. */
  40506. showInspector?: boolean;
  40507. /**
  40508. * Display in embed mode (both panes on the right)
  40509. */
  40510. embedMode?: boolean;
  40511. /**
  40512. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40513. */
  40514. handleResize?: boolean;
  40515. /**
  40516. * Allow the panes to popup (default: true)
  40517. */
  40518. enablePopup?: boolean;
  40519. /**
  40520. * Allow the panes to be closed by users (default: true)
  40521. */
  40522. enableClose?: boolean;
  40523. /**
  40524. * Optional list of extensibility entries
  40525. */
  40526. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40527. /**
  40528. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40529. */
  40530. inspectorURL?: string;
  40531. }
  40532. interface Scene {
  40533. /**
  40534. * @hidden
  40535. * Backing field
  40536. */
  40537. _debugLayer: DebugLayer;
  40538. /**
  40539. * Gets the debug layer (aka Inspector) associated with the scene
  40540. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40541. */
  40542. debugLayer: DebugLayer;
  40543. }
  40544. /**
  40545. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40546. * what is happening in your scene
  40547. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40548. */
  40549. export class DebugLayer {
  40550. /**
  40551. * Define the url to get the inspector script from.
  40552. * By default it uses the babylonjs CDN.
  40553. * @ignoreNaming
  40554. */
  40555. static InspectorURL: string;
  40556. private _scene;
  40557. private BJSINSPECTOR;
  40558. /**
  40559. * Observable triggered when a property is changed through the inspector.
  40560. */
  40561. onPropertyChangedObservable: Observable<{
  40562. object: any;
  40563. property: string;
  40564. value: any;
  40565. initialValue: any;
  40566. }>;
  40567. /**
  40568. * Instantiates a new debug layer.
  40569. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40570. * what is happening in your scene
  40571. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40572. * @param scene Defines the scene to inspect
  40573. */
  40574. constructor(scene: Scene);
  40575. /** Creates the inspector window. */
  40576. private _createInspector;
  40577. /**
  40578. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40579. * @param entity defines the entity to select
  40580. * @param lineContainerTitle defines the specific block to highlight
  40581. */
  40582. select(entity: any, lineContainerTitle?: string): void;
  40583. /** Get the inspector from bundle or global */
  40584. private _getGlobalInspector;
  40585. /**
  40586. * Get if the inspector is visible or not.
  40587. * @returns true if visible otherwise, false
  40588. */
  40589. isVisible(): boolean;
  40590. /**
  40591. * Hide the inspector and close its window.
  40592. */
  40593. hide(): void;
  40594. /**
  40595. * Launch the debugLayer.
  40596. * @param config Define the configuration of the inspector
  40597. * @return a promise fulfilled when the debug layer is visible
  40598. */
  40599. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40600. }
  40601. }
  40602. declare module BABYLON {
  40603. /**
  40604. * Class containing static functions to help procedurally build meshes
  40605. */
  40606. export class BoxBuilder {
  40607. /**
  40608. * Creates a box mesh
  40609. * * The parameter `size` sets the size (float) of each box side (default 1)
  40610. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40611. * * 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)
  40612. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40614. * * 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
  40615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40616. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40617. * @param name defines the name of the mesh
  40618. * @param options defines the options used to create the mesh
  40619. * @param scene defines the hosting scene
  40620. * @returns the box mesh
  40621. */
  40622. static CreateBox(name: string, options: {
  40623. size?: number;
  40624. width?: number;
  40625. height?: number;
  40626. depth?: number;
  40627. faceUV?: Vector4[];
  40628. faceColors?: Color4[];
  40629. sideOrientation?: number;
  40630. frontUVs?: Vector4;
  40631. backUVs?: Vector4;
  40632. updatable?: boolean;
  40633. }, scene?: Nullable<Scene>): Mesh;
  40634. }
  40635. }
  40636. declare module BABYLON {
  40637. /**
  40638. * Class containing static functions to help procedurally build meshes
  40639. */
  40640. export class SphereBuilder {
  40641. /**
  40642. * Creates a sphere mesh
  40643. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40644. * * 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`)
  40645. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40646. * * 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
  40647. * * 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)
  40648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40649. * * 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
  40650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40651. * @param name defines the name of the mesh
  40652. * @param options defines the options used to create the mesh
  40653. * @param scene defines the hosting scene
  40654. * @returns the sphere mesh
  40655. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40656. */
  40657. static CreateSphere(name: string, options: {
  40658. segments?: number;
  40659. diameter?: number;
  40660. diameterX?: number;
  40661. diameterY?: number;
  40662. diameterZ?: number;
  40663. arc?: number;
  40664. slice?: number;
  40665. sideOrientation?: number;
  40666. frontUVs?: Vector4;
  40667. backUVs?: Vector4;
  40668. updatable?: boolean;
  40669. }, scene: any): Mesh;
  40670. }
  40671. }
  40672. declare module BABYLON.Debug {
  40673. /**
  40674. * Used to show the physics impostor around the specific mesh
  40675. */
  40676. export class PhysicsViewer {
  40677. /** @hidden */
  40678. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40679. /** @hidden */
  40680. protected _meshes: Array<Nullable<AbstractMesh>>;
  40681. /** @hidden */
  40682. protected _scene: Nullable<Scene>;
  40683. /** @hidden */
  40684. protected _numMeshes: number;
  40685. /** @hidden */
  40686. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40687. private _renderFunction;
  40688. private _utilityLayer;
  40689. private _debugBoxMesh;
  40690. private _debugSphereMesh;
  40691. private _debugMaterial;
  40692. /**
  40693. * Creates a new PhysicsViewer
  40694. * @param scene defines the hosting scene
  40695. */
  40696. constructor(scene: Scene);
  40697. /** @hidden */
  40698. protected _updateDebugMeshes(): void;
  40699. /**
  40700. * Renders a specified physic impostor
  40701. * @param impostor defines the impostor to render
  40702. * @returns the new debug mesh used to render the impostor
  40703. */
  40704. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  40705. /**
  40706. * Hides a specified physic impostor
  40707. * @param impostor defines the impostor to hide
  40708. */
  40709. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40710. private _getDebugMaterial;
  40711. private _getDebugBoxMesh;
  40712. private _getDebugSphereMesh;
  40713. private _getDebugMesh;
  40714. /** Releases all resources */
  40715. dispose(): void;
  40716. }
  40717. }
  40718. declare module BABYLON {
  40719. /**
  40720. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40721. * in order to better appreciate the issue one might have.
  40722. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40723. */
  40724. export class RayHelper {
  40725. /**
  40726. * Defines the ray we are currently tryin to visualize.
  40727. */
  40728. ray: Nullable<Ray>;
  40729. private _renderPoints;
  40730. private _renderLine;
  40731. private _renderFunction;
  40732. private _scene;
  40733. private _updateToMeshFunction;
  40734. private _attachedToMesh;
  40735. private _meshSpaceDirection;
  40736. private _meshSpaceOrigin;
  40737. /**
  40738. * Helper function to create a colored helper in a scene in one line.
  40739. * @param ray Defines the ray we are currently tryin to visualize
  40740. * @param scene Defines the scene the ray is used in
  40741. * @param color Defines the color we want to see the ray in
  40742. * @returns The newly created ray helper.
  40743. */
  40744. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40745. /**
  40746. * Instantiate a new ray helper.
  40747. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40748. * in order to better appreciate the issue one might have.
  40749. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40750. * @param ray Defines the ray we are currently tryin to visualize
  40751. */
  40752. constructor(ray: Ray);
  40753. /**
  40754. * Shows the ray we are willing to debug.
  40755. * @param scene Defines the scene the ray needs to be rendered in
  40756. * @param color Defines the color the ray needs to be rendered in
  40757. */
  40758. show(scene: Scene, color?: Color3): void;
  40759. /**
  40760. * Hides the ray we are debugging.
  40761. */
  40762. hide(): void;
  40763. private _render;
  40764. /**
  40765. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40766. * @param mesh Defines the mesh we want the helper attached to
  40767. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40768. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40769. * @param length Defines the length of the ray
  40770. */
  40771. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40772. /**
  40773. * Detach the ray helper from the mesh it has previously been attached to.
  40774. */
  40775. detachFromMesh(): void;
  40776. private _updateToMesh;
  40777. /**
  40778. * Dispose the helper and release its associated resources.
  40779. */
  40780. dispose(): void;
  40781. }
  40782. }
  40783. declare module BABYLON.Debug {
  40784. /**
  40785. * Class used to render a debug view of a given skeleton
  40786. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40787. */
  40788. export class SkeletonViewer {
  40789. /** defines the skeleton to render */
  40790. skeleton: Skeleton;
  40791. /** defines the mesh attached to the skeleton */
  40792. mesh: AbstractMesh;
  40793. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40794. autoUpdateBonesMatrices: boolean;
  40795. /** defines the rendering group id to use with the viewer */
  40796. renderingGroupId: number;
  40797. /** Gets or sets the color used to render the skeleton */
  40798. color: Color3;
  40799. private _scene;
  40800. private _debugLines;
  40801. private _debugMesh;
  40802. private _isEnabled;
  40803. private _renderFunction;
  40804. private _utilityLayer;
  40805. /**
  40806. * Returns the mesh used to render the bones
  40807. */
  40808. readonly debugMesh: Nullable<LinesMesh>;
  40809. /**
  40810. * Creates a new SkeletonViewer
  40811. * @param skeleton defines the skeleton to render
  40812. * @param mesh defines the mesh attached to the skeleton
  40813. * @param scene defines the hosting scene
  40814. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40815. * @param renderingGroupId defines the rendering group id to use with the viewer
  40816. */
  40817. constructor(
  40818. /** defines the skeleton to render */
  40819. skeleton: Skeleton,
  40820. /** defines the mesh attached to the skeleton */
  40821. mesh: AbstractMesh, scene: Scene,
  40822. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40823. autoUpdateBonesMatrices?: boolean,
  40824. /** defines the rendering group id to use with the viewer */
  40825. renderingGroupId?: number);
  40826. /** Gets or sets a boolean indicating if the viewer is enabled */
  40827. isEnabled: boolean;
  40828. private _getBonePosition;
  40829. private _getLinesForBonesWithLength;
  40830. private _getLinesForBonesNoLength;
  40831. /** Update the viewer to sync with current skeleton state */
  40832. update(): void;
  40833. /** Release associated resources */
  40834. dispose(): void;
  40835. }
  40836. }
  40837. declare module BABYLON {
  40838. /**
  40839. * Options to create the null engine
  40840. */
  40841. export class NullEngineOptions {
  40842. /**
  40843. * Render width (Default: 512)
  40844. */
  40845. renderWidth: number;
  40846. /**
  40847. * Render height (Default: 256)
  40848. */
  40849. renderHeight: number;
  40850. /**
  40851. * Texture size (Default: 512)
  40852. */
  40853. textureSize: number;
  40854. /**
  40855. * If delta time between frames should be constant
  40856. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40857. */
  40858. deterministicLockstep: boolean;
  40859. /**
  40860. * Maximum about of steps between frames (Default: 4)
  40861. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40862. */
  40863. lockstepMaxSteps: number;
  40864. }
  40865. /**
  40866. * The null engine class provides support for headless version of babylon.js.
  40867. * This can be used in server side scenario or for testing purposes
  40868. */
  40869. export class NullEngine extends Engine {
  40870. private _options;
  40871. /**
  40872. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40873. */
  40874. isDeterministicLockStep(): boolean;
  40875. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40876. getLockstepMaxSteps(): number;
  40877. /**
  40878. * Sets hardware scaling, used to save performance if needed
  40879. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40880. */
  40881. getHardwareScalingLevel(): number;
  40882. constructor(options?: NullEngineOptions);
  40883. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40884. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40885. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40886. getRenderWidth(useScreen?: boolean): number;
  40887. getRenderHeight(useScreen?: boolean): number;
  40888. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40889. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40890. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40891. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40892. bindSamplers(effect: Effect): void;
  40893. enableEffect(effect: Effect): void;
  40894. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40895. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40896. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40897. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40898. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40899. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40900. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40901. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40902. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40903. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40904. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40905. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40906. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40907. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40908. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40909. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40910. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40911. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40912. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40913. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40914. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40915. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40916. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40917. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40918. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40919. bindBuffers(vertexBuffers: {
  40920. [key: string]: VertexBuffer;
  40921. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40922. wipeCaches(bruteForce?: boolean): void;
  40923. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40924. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40925. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40926. /** @hidden */
  40927. _createTexture(): WebGLTexture;
  40928. /** @hidden */
  40929. _releaseTexture(texture: InternalTexture): void;
  40930. 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;
  40931. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40932. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40933. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40934. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40935. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40936. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40937. areAllEffectsReady(): boolean;
  40938. /**
  40939. * @hidden
  40940. * Get the current error code of the webGL context
  40941. * @returns the error code
  40942. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40943. */
  40944. getError(): number;
  40945. /** @hidden */
  40946. _getUnpackAlignement(): number;
  40947. /** @hidden */
  40948. _unpackFlipY(value: boolean): void;
  40949. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40950. /**
  40951. * Updates a dynamic vertex buffer.
  40952. * @param vertexBuffer the vertex buffer to update
  40953. * @param data the data used to update the vertex buffer
  40954. * @param byteOffset the byte offset of the data (optional)
  40955. * @param byteLength the byte length of the data (optional)
  40956. */
  40957. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40958. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40959. /** @hidden */
  40960. _bindTexture(channel: number, texture: InternalTexture): void;
  40961. /** @hidden */
  40962. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40963. releaseEffects(): void;
  40964. displayLoadingUI(): void;
  40965. hideLoadingUI(): void;
  40966. /** @hidden */
  40967. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40968. /** @hidden */
  40969. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40970. /** @hidden */
  40971. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40972. /** @hidden */
  40973. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40974. }
  40975. }
  40976. declare module BABYLON {
  40977. /** @hidden */
  40978. export class _OcclusionDataStorage {
  40979. /** @hidden */
  40980. occlusionInternalRetryCounter: number;
  40981. /** @hidden */
  40982. isOcclusionQueryInProgress: boolean;
  40983. /** @hidden */
  40984. isOccluded: boolean;
  40985. /** @hidden */
  40986. occlusionRetryCount: number;
  40987. /** @hidden */
  40988. occlusionType: number;
  40989. /** @hidden */
  40990. occlusionQueryAlgorithmType: number;
  40991. }
  40992. interface Engine {
  40993. /**
  40994. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40995. * @return the new query
  40996. */
  40997. createQuery(): WebGLQuery;
  40998. /**
  40999. * Delete and release a webGL query
  41000. * @param query defines the query to delete
  41001. * @return the current engine
  41002. */
  41003. deleteQuery(query: WebGLQuery): Engine;
  41004. /**
  41005. * Check if a given query has resolved and got its value
  41006. * @param query defines the query to check
  41007. * @returns true if the query got its value
  41008. */
  41009. isQueryResultAvailable(query: WebGLQuery): boolean;
  41010. /**
  41011. * Gets the value of a given query
  41012. * @param query defines the query to check
  41013. * @returns the value of the query
  41014. */
  41015. getQueryResult(query: WebGLQuery): number;
  41016. /**
  41017. * Initiates an occlusion query
  41018. * @param algorithmType defines the algorithm to use
  41019. * @param query defines the query to use
  41020. * @returns the current engine
  41021. * @see http://doc.babylonjs.com/features/occlusionquery
  41022. */
  41023. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41024. /**
  41025. * Ends an occlusion query
  41026. * @see http://doc.babylonjs.com/features/occlusionquery
  41027. * @param algorithmType defines the algorithm to use
  41028. * @returns the current engine
  41029. */
  41030. endOcclusionQuery(algorithmType: number): Engine;
  41031. /**
  41032. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41033. * Please note that only one query can be issued at a time
  41034. * @returns a time token used to track the time span
  41035. */
  41036. startTimeQuery(): Nullable<_TimeToken>;
  41037. /**
  41038. * Ends a time query
  41039. * @param token defines the token used to measure the time span
  41040. * @returns the time spent (in ns)
  41041. */
  41042. endTimeQuery(token: _TimeToken): int;
  41043. /** @hidden */
  41044. _currentNonTimestampToken: Nullable<_TimeToken>;
  41045. /** @hidden */
  41046. _createTimeQuery(): WebGLQuery;
  41047. /** @hidden */
  41048. _deleteTimeQuery(query: WebGLQuery): void;
  41049. /** @hidden */
  41050. _getGlAlgorithmType(algorithmType: number): number;
  41051. /** @hidden */
  41052. _getTimeQueryResult(query: WebGLQuery): any;
  41053. /** @hidden */
  41054. _getTimeQueryAvailability(query: WebGLQuery): any;
  41055. }
  41056. interface AbstractMesh {
  41057. /**
  41058. * Backing filed
  41059. * @hidden
  41060. */
  41061. __occlusionDataStorage: _OcclusionDataStorage;
  41062. /**
  41063. * Access property
  41064. * @hidden
  41065. */
  41066. _occlusionDataStorage: _OcclusionDataStorage;
  41067. /**
  41068. * 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.
  41069. * The default value is -1 which means don't break the query and wait till the result
  41070. * @see http://doc.babylonjs.com/features/occlusionquery
  41071. */
  41072. occlusionRetryCount: number;
  41073. /**
  41074. * 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:
  41075. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41076. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41077. * * 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.
  41078. * @see http://doc.babylonjs.com/features/occlusionquery
  41079. */
  41080. occlusionType: number;
  41081. /**
  41082. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41083. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41084. * * 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.
  41085. * @see http://doc.babylonjs.com/features/occlusionquery
  41086. */
  41087. occlusionQueryAlgorithmType: number;
  41088. /**
  41089. * 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
  41090. * @see http://doc.babylonjs.com/features/occlusionquery
  41091. */
  41092. isOccluded: boolean;
  41093. /**
  41094. * Flag to check the progress status of the query
  41095. * @see http://doc.babylonjs.com/features/occlusionquery
  41096. */
  41097. isOcclusionQueryInProgress: boolean;
  41098. }
  41099. }
  41100. declare module BABYLON {
  41101. /** @hidden */
  41102. export var _forceTransformFeedbackToBundle: boolean;
  41103. interface Engine {
  41104. /**
  41105. * Creates a webGL transform feedback object
  41106. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41107. * @returns the webGL transform feedback object
  41108. */
  41109. createTransformFeedback(): WebGLTransformFeedback;
  41110. /**
  41111. * Delete a webGL transform feedback object
  41112. * @param value defines the webGL transform feedback object to delete
  41113. */
  41114. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41115. /**
  41116. * Bind a webGL transform feedback object to the webgl context
  41117. * @param value defines the webGL transform feedback object to bind
  41118. */
  41119. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41120. /**
  41121. * Begins a transform feedback operation
  41122. * @param usePoints defines if points or triangles must be used
  41123. */
  41124. beginTransformFeedback(usePoints: boolean): void;
  41125. /**
  41126. * Ends a transform feedback operation
  41127. */
  41128. endTransformFeedback(): void;
  41129. /**
  41130. * Specify the varyings to use with transform feedback
  41131. * @param program defines the associated webGL program
  41132. * @param value defines the list of strings representing the varying names
  41133. */
  41134. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41135. /**
  41136. * Bind a webGL buffer for a transform feedback operation
  41137. * @param value defines the webGL buffer to bind
  41138. */
  41139. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41140. }
  41141. }
  41142. declare module BABYLON {
  41143. /**
  41144. * Gather the list of clipboard event types as constants.
  41145. */
  41146. export class ClipboardEventTypes {
  41147. /**
  41148. * The clipboard event is fired when a copy command is active (pressed).
  41149. */
  41150. static readonly COPY: number;
  41151. /**
  41152. * The clipboard event is fired when a cut command is active (pressed).
  41153. */
  41154. static readonly CUT: number;
  41155. /**
  41156. * The clipboard event is fired when a paste command is active (pressed).
  41157. */
  41158. static readonly PASTE: number;
  41159. }
  41160. /**
  41161. * This class is used to store clipboard related info for the onClipboardObservable event.
  41162. */
  41163. export class ClipboardInfo {
  41164. /**
  41165. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41166. */
  41167. type: number;
  41168. /**
  41169. * Defines the related dom event
  41170. */
  41171. event: ClipboardEvent;
  41172. /**
  41173. *Creates an instance of ClipboardInfo.
  41174. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41175. * @param event Defines the related dom event
  41176. */
  41177. constructor(
  41178. /**
  41179. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41180. */
  41181. type: number,
  41182. /**
  41183. * Defines the related dom event
  41184. */
  41185. event: ClipboardEvent);
  41186. /**
  41187. * Get the clipboard event's type from the keycode.
  41188. * @param keyCode Defines the keyCode for the current keyboard event.
  41189. * @return {number}
  41190. */
  41191. static GetTypeFromCharacter(keyCode: number): number;
  41192. }
  41193. }
  41194. declare module BABYLON {
  41195. /**
  41196. * Class used to represent data loading progression
  41197. */
  41198. export class SceneLoaderProgressEvent {
  41199. /** defines if data length to load can be evaluated */
  41200. readonly lengthComputable: boolean;
  41201. /** defines the loaded data length */
  41202. readonly loaded: number;
  41203. /** defines the data length to load */
  41204. readonly total: number;
  41205. /**
  41206. * Create a new progress event
  41207. * @param lengthComputable defines if data length to load can be evaluated
  41208. * @param loaded defines the loaded data length
  41209. * @param total defines the data length to load
  41210. */
  41211. constructor(
  41212. /** defines if data length to load can be evaluated */
  41213. lengthComputable: boolean,
  41214. /** defines the loaded data length */
  41215. loaded: number,
  41216. /** defines the data length to load */
  41217. total: number);
  41218. /**
  41219. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41220. * @param event defines the source event
  41221. * @returns a new SceneLoaderProgressEvent
  41222. */
  41223. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41224. }
  41225. /**
  41226. * Interface used by SceneLoader plugins to define supported file extensions
  41227. */
  41228. export interface ISceneLoaderPluginExtensions {
  41229. /**
  41230. * Defines the list of supported extensions
  41231. */
  41232. [extension: string]: {
  41233. isBinary: boolean;
  41234. };
  41235. }
  41236. /**
  41237. * Interface used by SceneLoader plugin factory
  41238. */
  41239. export interface ISceneLoaderPluginFactory {
  41240. /**
  41241. * Defines the name of the factory
  41242. */
  41243. name: string;
  41244. /**
  41245. * Function called to create a new plugin
  41246. * @return the new plugin
  41247. */
  41248. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41249. /**
  41250. * Boolean indicating if the plugin can direct load specific data
  41251. */
  41252. canDirectLoad?: (data: string) => boolean;
  41253. }
  41254. /**
  41255. * Interface used to define a SceneLoader plugin
  41256. */
  41257. export interface ISceneLoaderPlugin {
  41258. /**
  41259. * The friendly name of this plugin.
  41260. */
  41261. name: string;
  41262. /**
  41263. * The file extensions supported by this plugin.
  41264. */
  41265. extensions: string | ISceneLoaderPluginExtensions;
  41266. /**
  41267. * Import meshes into a scene.
  41268. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41269. * @param scene The scene to import into
  41270. * @param data The data to import
  41271. * @param rootUrl The root url for scene and resources
  41272. * @param meshes The meshes array to import into
  41273. * @param particleSystems The particle systems array to import into
  41274. * @param skeletons The skeletons array to import into
  41275. * @param onError The callback when import fails
  41276. * @returns True if successful or false otherwise
  41277. */
  41278. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41279. /**
  41280. * Load into a scene.
  41281. * @param scene The scene to load into
  41282. * @param data The data to import
  41283. * @param rootUrl The root url for scene and resources
  41284. * @param onError The callback when import fails
  41285. * @returns true if successful or false otherwise
  41286. */
  41287. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41288. /**
  41289. * The callback that returns true if the data can be directly loaded.
  41290. */
  41291. canDirectLoad?: (data: string) => boolean;
  41292. /**
  41293. * The callback that allows custom handling of the root url based on the response url.
  41294. */
  41295. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41296. /**
  41297. * Load into an asset container.
  41298. * @param scene The scene to load into
  41299. * @param data The data to import
  41300. * @param rootUrl The root url for scene and resources
  41301. * @param onError The callback when import fails
  41302. * @returns The loaded asset container
  41303. */
  41304. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41305. }
  41306. /**
  41307. * Interface used to define an async SceneLoader plugin
  41308. */
  41309. export interface ISceneLoaderPluginAsync {
  41310. /**
  41311. * The friendly name of this plugin.
  41312. */
  41313. name: string;
  41314. /**
  41315. * The file extensions supported by this plugin.
  41316. */
  41317. extensions: string | ISceneLoaderPluginExtensions;
  41318. /**
  41319. * Import meshes into a scene.
  41320. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41321. * @param scene The scene to import into
  41322. * @param data The data to import
  41323. * @param rootUrl The root url for scene and resources
  41324. * @param onProgress The callback when the load progresses
  41325. * @param fileName Defines the name of the file to load
  41326. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41327. */
  41328. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41329. meshes: AbstractMesh[];
  41330. particleSystems: IParticleSystem[];
  41331. skeletons: Skeleton[];
  41332. animationGroups: AnimationGroup[];
  41333. }>;
  41334. /**
  41335. * Load into a scene.
  41336. * @param scene The scene to load into
  41337. * @param data The data to import
  41338. * @param rootUrl The root url for scene and resources
  41339. * @param onProgress The callback when the load progresses
  41340. * @param fileName Defines the name of the file to load
  41341. * @returns Nothing
  41342. */
  41343. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41344. /**
  41345. * The callback that returns true if the data can be directly loaded.
  41346. */
  41347. canDirectLoad?: (data: string) => boolean;
  41348. /**
  41349. * The callback that allows custom handling of the root url based on the response url.
  41350. */
  41351. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41352. /**
  41353. * Load into an asset container.
  41354. * @param scene The scene to load into
  41355. * @param data The data to import
  41356. * @param rootUrl The root url for scene and resources
  41357. * @param onProgress The callback when the load progresses
  41358. * @param fileName Defines the name of the file to load
  41359. * @returns The loaded asset container
  41360. */
  41361. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41362. }
  41363. /**
  41364. * Class used to load scene from various file formats using registered plugins
  41365. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41366. */
  41367. export class SceneLoader {
  41368. /**
  41369. * No logging while loading
  41370. */
  41371. static readonly NO_LOGGING: number;
  41372. /**
  41373. * Minimal logging while loading
  41374. */
  41375. static readonly MINIMAL_LOGGING: number;
  41376. /**
  41377. * Summary logging while loading
  41378. */
  41379. static readonly SUMMARY_LOGGING: number;
  41380. /**
  41381. * Detailled logging while loading
  41382. */
  41383. static readonly DETAILED_LOGGING: number;
  41384. /**
  41385. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41386. */
  41387. static ForceFullSceneLoadingForIncremental: boolean;
  41388. /**
  41389. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41390. */
  41391. static ShowLoadingScreen: boolean;
  41392. /**
  41393. * Defines the current logging level (while loading the scene)
  41394. * @ignorenaming
  41395. */
  41396. static loggingLevel: number;
  41397. /**
  41398. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41399. */
  41400. static CleanBoneMatrixWeights: boolean;
  41401. /**
  41402. * Event raised when a plugin is used to load a scene
  41403. */
  41404. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41405. private static _registeredPlugins;
  41406. private static _getDefaultPlugin;
  41407. private static _getPluginForExtension;
  41408. private static _getPluginForDirectLoad;
  41409. private static _getPluginForFilename;
  41410. private static _getDirectLoad;
  41411. private static _loadData;
  41412. private static _getFileInfo;
  41413. /**
  41414. * Gets a plugin that can load the given extension
  41415. * @param extension defines the extension to load
  41416. * @returns a plugin or null if none works
  41417. */
  41418. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41419. /**
  41420. * Gets a boolean indicating that the given extension can be loaded
  41421. * @param extension defines the extension to load
  41422. * @returns true if the extension is supported
  41423. */
  41424. static IsPluginForExtensionAvailable(extension: string): boolean;
  41425. /**
  41426. * Adds a new plugin to the list of registered plugins
  41427. * @param plugin defines the plugin to add
  41428. */
  41429. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41430. /**
  41431. * Import meshes into a scene
  41432. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41433. * @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)
  41434. * @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)
  41435. * @param scene the instance of BABYLON.Scene to append to
  41436. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41437. * @param onProgress a callback with a progress event for each file being loaded
  41438. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41439. * @param pluginExtension the extension used to determine the plugin
  41440. * @returns The loaded plugin
  41441. */
  41442. 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>;
  41443. /**
  41444. * Import meshes into a scene
  41445. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41446. * @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)
  41447. * @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)
  41448. * @param scene the instance of BABYLON.Scene to append to
  41449. * @param onProgress a callback with a progress event for each file being loaded
  41450. * @param pluginExtension the extension used to determine the plugin
  41451. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41452. */
  41453. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41454. meshes: AbstractMesh[];
  41455. particleSystems: IParticleSystem[];
  41456. skeletons: Skeleton[];
  41457. animationGroups: AnimationGroup[];
  41458. }>;
  41459. /**
  41460. * Load a scene
  41461. * @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)
  41462. * @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)
  41463. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41464. * @param onSuccess a callback with the scene when import succeeds
  41465. * @param onProgress a callback with a progress event for each file being loaded
  41466. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41467. * @param pluginExtension the extension used to determine the plugin
  41468. * @returns The loaded plugin
  41469. */
  41470. 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>;
  41471. /**
  41472. * Load a scene
  41473. * @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)
  41474. * @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)
  41475. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41476. * @param onProgress a callback with a progress event for each file being loaded
  41477. * @param pluginExtension the extension used to determine the plugin
  41478. * @returns The loaded scene
  41479. */
  41480. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41481. /**
  41482. * Append a scene
  41483. * @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)
  41484. * @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)
  41485. * @param scene is the instance of BABYLON.Scene to append to
  41486. * @param onSuccess a callback with the scene when import succeeds
  41487. * @param onProgress a callback with a progress event for each file being loaded
  41488. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41489. * @param pluginExtension the extension used to determine the plugin
  41490. * @returns The loaded plugin
  41491. */
  41492. 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>;
  41493. /**
  41494. * Append a scene
  41495. * @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)
  41496. * @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)
  41497. * @param scene is the instance of BABYLON.Scene to append to
  41498. * @param onProgress a callback with a progress event for each file being loaded
  41499. * @param pluginExtension the extension used to determine the plugin
  41500. * @returns The given scene
  41501. */
  41502. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41503. /**
  41504. * Load a scene into an asset container
  41505. * @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)
  41506. * @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)
  41507. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41508. * @param onSuccess a callback with the scene when import succeeds
  41509. * @param onProgress a callback with a progress event for each file being loaded
  41510. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41511. * @param pluginExtension the extension used to determine the plugin
  41512. * @returns The loaded plugin
  41513. */
  41514. 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>;
  41515. /**
  41516. * Load a scene into an asset container
  41517. * @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)
  41518. * @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)
  41519. * @param scene is the instance of Scene to append to
  41520. * @param onProgress a callback with a progress event for each file being loaded
  41521. * @param pluginExtension the extension used to determine the plugin
  41522. * @returns The loaded asset container
  41523. */
  41524. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41525. }
  41526. }
  41527. declare module BABYLON {
  41528. /**
  41529. * Google Daydream controller
  41530. */
  41531. export class DaydreamController extends WebVRController {
  41532. /**
  41533. * Base Url for the controller model.
  41534. */
  41535. static MODEL_BASE_URL: string;
  41536. /**
  41537. * File name for the controller model.
  41538. */
  41539. static MODEL_FILENAME: string;
  41540. /**
  41541. * Gamepad Id prefix used to identify Daydream Controller.
  41542. */
  41543. static readonly GAMEPAD_ID_PREFIX: string;
  41544. /**
  41545. * Creates a new DaydreamController from a gamepad
  41546. * @param vrGamepad the gamepad that the controller should be created from
  41547. */
  41548. constructor(vrGamepad: any);
  41549. /**
  41550. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41551. * @param scene scene in which to add meshes
  41552. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41553. */
  41554. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41555. /**
  41556. * Called once for each button that changed state since the last frame
  41557. * @param buttonIdx Which button index changed
  41558. * @param state New state of the button
  41559. * @param changes Which properties on the state changed since last frame
  41560. */
  41561. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41562. }
  41563. }
  41564. declare module BABYLON {
  41565. /**
  41566. * Gear VR Controller
  41567. */
  41568. export class GearVRController extends WebVRController {
  41569. /**
  41570. * Base Url for the controller model.
  41571. */
  41572. static MODEL_BASE_URL: string;
  41573. /**
  41574. * File name for the controller model.
  41575. */
  41576. static MODEL_FILENAME: string;
  41577. /**
  41578. * Gamepad Id prefix used to identify this controller.
  41579. */
  41580. static readonly GAMEPAD_ID_PREFIX: string;
  41581. private readonly _buttonIndexToObservableNameMap;
  41582. /**
  41583. * Creates a new GearVRController from a gamepad
  41584. * @param vrGamepad the gamepad that the controller should be created from
  41585. */
  41586. constructor(vrGamepad: any);
  41587. /**
  41588. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41589. * @param scene scene in which to add meshes
  41590. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41591. */
  41592. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41593. /**
  41594. * Called once for each button that changed state since the last frame
  41595. * @param buttonIdx Which button index changed
  41596. * @param state New state of the button
  41597. * @param changes Which properties on the state changed since last frame
  41598. */
  41599. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Generic Controller
  41605. */
  41606. export class GenericController extends WebVRController {
  41607. /**
  41608. * Base Url for the controller model.
  41609. */
  41610. static readonly MODEL_BASE_URL: string;
  41611. /**
  41612. * File name for the controller model.
  41613. */
  41614. static readonly MODEL_FILENAME: string;
  41615. /**
  41616. * Creates a new GenericController from a gamepad
  41617. * @param vrGamepad the gamepad that the controller should be created from
  41618. */
  41619. constructor(vrGamepad: any);
  41620. /**
  41621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41622. * @param scene scene in which to add meshes
  41623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41624. */
  41625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41626. /**
  41627. * Called once for each button that changed state since the last frame
  41628. * @param buttonIdx Which button index changed
  41629. * @param state New state of the button
  41630. * @param changes Which properties on the state changed since last frame
  41631. */
  41632. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41633. }
  41634. }
  41635. declare module BABYLON {
  41636. /**
  41637. * Oculus Touch Controller
  41638. */
  41639. export class OculusTouchController extends WebVRController {
  41640. /**
  41641. * Base Url for the controller model.
  41642. */
  41643. static MODEL_BASE_URL: string;
  41644. /**
  41645. * File name for the left controller model.
  41646. */
  41647. static MODEL_LEFT_FILENAME: string;
  41648. /**
  41649. * File name for the right controller model.
  41650. */
  41651. static MODEL_RIGHT_FILENAME: string;
  41652. /**
  41653. * Fired when the secondary trigger on this controller is modified
  41654. */
  41655. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41656. /**
  41657. * Fired when the thumb rest on this controller is modified
  41658. */
  41659. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41660. /**
  41661. * Creates a new OculusTouchController from a gamepad
  41662. * @param vrGamepad the gamepad that the controller should be created from
  41663. */
  41664. constructor(vrGamepad: any);
  41665. /**
  41666. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41667. * @param scene scene in which to add meshes
  41668. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41669. */
  41670. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41671. /**
  41672. * Fired when the A button on this controller is modified
  41673. */
  41674. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41675. /**
  41676. * Fired when the B button on this controller is modified
  41677. */
  41678. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41679. /**
  41680. * Fired when the X button on this controller is modified
  41681. */
  41682. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41683. /**
  41684. * Fired when the Y button on this controller is modified
  41685. */
  41686. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41687. /**
  41688. * Called once for each button that changed state since the last frame
  41689. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41690. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41691. * 2) secondary trigger (same)
  41692. * 3) A (right) X (left), touch, pressed = value
  41693. * 4) B / Y
  41694. * 5) thumb rest
  41695. * @param buttonIdx Which button index changed
  41696. * @param state New state of the button
  41697. * @param changes Which properties on the state changed since last frame
  41698. */
  41699. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41700. }
  41701. }
  41702. declare module BABYLON {
  41703. /**
  41704. * Vive Controller
  41705. */
  41706. export class ViveController extends WebVRController {
  41707. /**
  41708. * Base Url for the controller model.
  41709. */
  41710. static MODEL_BASE_URL: string;
  41711. /**
  41712. * File name for the controller model.
  41713. */
  41714. static MODEL_FILENAME: string;
  41715. /**
  41716. * Creates a new ViveController from a gamepad
  41717. * @param vrGamepad the gamepad that the controller should be created from
  41718. */
  41719. constructor(vrGamepad: any);
  41720. /**
  41721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41722. * @param scene scene in which to add meshes
  41723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41724. */
  41725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41726. /**
  41727. * Fired when the left button on this controller is modified
  41728. */
  41729. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41730. /**
  41731. * Fired when the right button on this controller is modified
  41732. */
  41733. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41734. /**
  41735. * Fired when the menu button on this controller is modified
  41736. */
  41737. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41738. /**
  41739. * Called once for each button that changed state since the last frame
  41740. * Vive mapping:
  41741. * 0: touchpad
  41742. * 1: trigger
  41743. * 2: left AND right buttons
  41744. * 3: menu button
  41745. * @param buttonIdx Which button index changed
  41746. * @param state New state of the button
  41747. * @param changes Which properties on the state changed since last frame
  41748. */
  41749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41750. }
  41751. }
  41752. declare module BABYLON {
  41753. /**
  41754. * Defines the WindowsMotionController object that the state of the windows motion controller
  41755. */
  41756. export class WindowsMotionController extends WebVRController {
  41757. /**
  41758. * The base url used to load the left and right controller models
  41759. */
  41760. static MODEL_BASE_URL: string;
  41761. /**
  41762. * The name of the left controller model file
  41763. */
  41764. static MODEL_LEFT_FILENAME: string;
  41765. /**
  41766. * The name of the right controller model file
  41767. */
  41768. static MODEL_RIGHT_FILENAME: string;
  41769. /**
  41770. * The controller name prefix for this controller type
  41771. */
  41772. static readonly GAMEPAD_ID_PREFIX: string;
  41773. /**
  41774. * The controller id pattern for this controller type
  41775. */
  41776. private static readonly GAMEPAD_ID_PATTERN;
  41777. private _loadedMeshInfo;
  41778. private readonly _mapping;
  41779. /**
  41780. * Fired when the trackpad on this controller is clicked
  41781. */
  41782. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41783. /**
  41784. * Fired when the trackpad on this controller is modified
  41785. */
  41786. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41787. /**
  41788. * The current x and y values of this controller's trackpad
  41789. */
  41790. trackpad: StickValues;
  41791. /**
  41792. * Creates a new WindowsMotionController from a gamepad
  41793. * @param vrGamepad the gamepad that the controller should be created from
  41794. */
  41795. constructor(vrGamepad: any);
  41796. /**
  41797. * Fired when the trigger on this controller is modified
  41798. */
  41799. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41800. /**
  41801. * Fired when the menu button on this controller is modified
  41802. */
  41803. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41804. /**
  41805. * Fired when the grip button on this controller is modified
  41806. */
  41807. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41808. /**
  41809. * Fired when the thumbstick button on this controller is modified
  41810. */
  41811. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41812. /**
  41813. * Fired when the touchpad button on this controller is modified
  41814. */
  41815. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41816. /**
  41817. * Fired when the touchpad values on this controller are modified
  41818. */
  41819. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41820. private _updateTrackpad;
  41821. /**
  41822. * Called once per frame by the engine.
  41823. */
  41824. update(): void;
  41825. /**
  41826. * Called once for each button that changed state since the last frame
  41827. * @param buttonIdx Which button index changed
  41828. * @param state New state of the button
  41829. * @param changes Which properties on the state changed since last frame
  41830. */
  41831. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41832. /**
  41833. * Moves the buttons on the controller mesh based on their current state
  41834. * @param buttonName the name of the button to move
  41835. * @param buttonValue the value of the button which determines the buttons new position
  41836. */
  41837. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41838. /**
  41839. * Moves the axis on the controller mesh based on its current state
  41840. * @param axis the index of the axis
  41841. * @param axisValue the value of the axis which determines the meshes new position
  41842. * @hidden
  41843. */
  41844. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41845. /**
  41846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41847. * @param scene scene in which to add meshes
  41848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41849. */
  41850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41851. /**
  41852. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41853. * can be transformed by button presses and axes values, based on this._mapping.
  41854. *
  41855. * @param scene scene in which the meshes exist
  41856. * @param meshes list of meshes that make up the controller model to process
  41857. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41858. */
  41859. private processModel;
  41860. private createMeshInfo;
  41861. /**
  41862. * Gets the ray of the controller in the direction the controller is pointing
  41863. * @param length the length the resulting ray should be
  41864. * @returns a ray in the direction the controller is pointing
  41865. */
  41866. getForwardRay(length?: number): Ray;
  41867. /**
  41868. * Disposes of the controller
  41869. */
  41870. dispose(): void;
  41871. }
  41872. }
  41873. declare module BABYLON {
  41874. /**
  41875. * Single axis scale gizmo
  41876. */
  41877. export class AxisScaleGizmo extends Gizmo {
  41878. private _coloredMaterial;
  41879. /**
  41880. * Drag behavior responsible for the gizmos dragging interactions
  41881. */
  41882. dragBehavior: PointerDragBehavior;
  41883. private _pointerObserver;
  41884. /**
  41885. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41886. */
  41887. snapDistance: number;
  41888. /**
  41889. * Event that fires each time the gizmo snaps to a new location.
  41890. * * snapDistance is the the change in distance
  41891. */
  41892. onSnapObservable: Observable<{
  41893. snapDistance: number;
  41894. }>;
  41895. /**
  41896. * If the scaling operation should be done on all axis (default: false)
  41897. */
  41898. uniformScaling: boolean;
  41899. /**
  41900. * Creates an AxisScaleGizmo
  41901. * @param gizmoLayer The utility layer the gizmo will be added to
  41902. * @param dragAxis The axis which the gizmo will be able to scale on
  41903. * @param color The color of the gizmo
  41904. */
  41905. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41906. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41907. /**
  41908. * Disposes of the gizmo
  41909. */
  41910. dispose(): void;
  41911. /**
  41912. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41913. * @param mesh The mesh to replace the default mesh of the gizmo
  41914. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41915. */
  41916. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41917. }
  41918. }
  41919. declare module BABYLON {
  41920. /**
  41921. * Bounding box gizmo
  41922. */
  41923. export class BoundingBoxGizmo extends Gizmo {
  41924. private _lineBoundingBox;
  41925. private _rotateSpheresParent;
  41926. private _scaleBoxesParent;
  41927. private _boundingDimensions;
  41928. private _renderObserver;
  41929. private _pointerObserver;
  41930. private _scaleDragSpeed;
  41931. private _tmpQuaternion;
  41932. private _tmpVector;
  41933. private _tmpRotationMatrix;
  41934. /**
  41935. * 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)
  41936. */
  41937. ignoreChildren: boolean;
  41938. /**
  41939. * 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)
  41940. */
  41941. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41942. /**
  41943. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41944. */
  41945. rotationSphereSize: number;
  41946. /**
  41947. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41948. */
  41949. scaleBoxSize: number;
  41950. /**
  41951. * 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)
  41952. */
  41953. fixedDragMeshScreenSize: boolean;
  41954. /**
  41955. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41956. */
  41957. fixedDragMeshScreenSizeDistanceFactor: number;
  41958. /**
  41959. * Fired when a rotation sphere or scale box is dragged
  41960. */
  41961. onDragStartObservable: Observable<{}>;
  41962. /**
  41963. * Fired when a scale box is dragged
  41964. */
  41965. onScaleBoxDragObservable: Observable<{}>;
  41966. /**
  41967. * Fired when a scale box drag is ended
  41968. */
  41969. onScaleBoxDragEndObservable: Observable<{}>;
  41970. /**
  41971. * Fired when a rotation sphere is dragged
  41972. */
  41973. onRotationSphereDragObservable: Observable<{}>;
  41974. /**
  41975. * Fired when a rotation sphere drag is ended
  41976. */
  41977. onRotationSphereDragEndObservable: Observable<{}>;
  41978. /**
  41979. * 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)
  41980. */
  41981. scalePivot: Nullable<Vector3>;
  41982. private _anchorMesh;
  41983. private _existingMeshScale;
  41984. private _dragMesh;
  41985. private pointerDragBehavior;
  41986. private coloredMaterial;
  41987. private hoverColoredMaterial;
  41988. /**
  41989. * Sets the color of the bounding box gizmo
  41990. * @param color the color to set
  41991. */
  41992. setColor(color: Color3): void;
  41993. /**
  41994. * Creates an BoundingBoxGizmo
  41995. * @param gizmoLayer The utility layer the gizmo will be added to
  41996. * @param color The color of the gizmo
  41997. */
  41998. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41999. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42000. private _selectNode;
  42001. /**
  42002. * Updates the bounding box information for the Gizmo
  42003. */
  42004. updateBoundingBox(): void;
  42005. private _updateRotationSpheres;
  42006. private _updateScaleBoxes;
  42007. /**
  42008. * Enables rotation on the specified axis and disables rotation on the others
  42009. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42010. */
  42011. setEnabledRotationAxis(axis: string): void;
  42012. /**
  42013. * Enables/disables scaling
  42014. * @param enable if scaling should be enabled
  42015. */
  42016. setEnabledScaling(enable: boolean): void;
  42017. private _updateDummy;
  42018. /**
  42019. * Enables a pointer drag behavior on the bounding box of the gizmo
  42020. */
  42021. enableDragBehavior(): void;
  42022. /**
  42023. * Disposes of the gizmo
  42024. */
  42025. dispose(): void;
  42026. /**
  42027. * 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)
  42028. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42029. * @returns the bounding box mesh with the passed in mesh as a child
  42030. */
  42031. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42032. /**
  42033. * CustomMeshes are not supported by this gizmo
  42034. * @param mesh The mesh to replace the default mesh of the gizmo
  42035. */
  42036. setCustomMesh(mesh: Mesh): void;
  42037. }
  42038. }
  42039. declare module BABYLON {
  42040. /**
  42041. * Single plane rotation gizmo
  42042. */
  42043. export class PlaneRotationGizmo extends Gizmo {
  42044. /**
  42045. * Drag behavior responsible for the gizmos dragging interactions
  42046. */
  42047. dragBehavior: PointerDragBehavior;
  42048. private _pointerObserver;
  42049. /**
  42050. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42051. */
  42052. snapDistance: number;
  42053. /**
  42054. * Event that fires each time the gizmo snaps to a new location.
  42055. * * snapDistance is the the change in distance
  42056. */
  42057. onSnapObservable: Observable<{
  42058. snapDistance: number;
  42059. }>;
  42060. /**
  42061. * Creates a PlaneRotationGizmo
  42062. * @param gizmoLayer The utility layer the gizmo will be added to
  42063. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42064. * @param color The color of the gizmo
  42065. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42066. */
  42067. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42068. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42069. /**
  42070. * Disposes of the gizmo
  42071. */
  42072. dispose(): void;
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * Gizmo that enables rotating a mesh along 3 axis
  42078. */
  42079. export class RotationGizmo extends Gizmo {
  42080. /**
  42081. * Internal gizmo used for interactions on the x axis
  42082. */
  42083. xGizmo: PlaneRotationGizmo;
  42084. /**
  42085. * Internal gizmo used for interactions on the y axis
  42086. */
  42087. yGizmo: PlaneRotationGizmo;
  42088. /**
  42089. * Internal gizmo used for interactions on the z axis
  42090. */
  42091. zGizmo: PlaneRotationGizmo;
  42092. /** Fires an event when any of it's sub gizmos are dragged */
  42093. onDragStartObservable: Observable<{}>;
  42094. /** Fires an event when any of it's sub gizmos are released from dragging */
  42095. onDragEndObservable: Observable<{}>;
  42096. attachedMesh: Nullable<AbstractMesh>;
  42097. /**
  42098. * Creates a RotationGizmo
  42099. * @param gizmoLayer The utility layer the gizmo will be added to
  42100. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42101. */
  42102. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42103. updateGizmoRotationToMatchAttachedMesh: boolean;
  42104. /**
  42105. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42106. */
  42107. snapDistance: number;
  42108. /**
  42109. * Ratio for the scale of the gizmo (Default: 1)
  42110. */
  42111. scaleRatio: number;
  42112. /**
  42113. * Disposes of the gizmo
  42114. */
  42115. dispose(): void;
  42116. /**
  42117. * CustomMeshes are not supported by this gizmo
  42118. * @param mesh The mesh to replace the default mesh of the gizmo
  42119. */
  42120. setCustomMesh(mesh: Mesh): void;
  42121. }
  42122. }
  42123. declare module BABYLON {
  42124. /**
  42125. * Gizmo that enables dragging a mesh along 3 axis
  42126. */
  42127. export class PositionGizmo extends Gizmo {
  42128. /**
  42129. * Internal gizmo used for interactions on the x axis
  42130. */
  42131. xGizmo: AxisDragGizmo;
  42132. /**
  42133. * Internal gizmo used for interactions on the y axis
  42134. */
  42135. yGizmo: AxisDragGizmo;
  42136. /**
  42137. * Internal gizmo used for interactions on the z axis
  42138. */
  42139. zGizmo: AxisDragGizmo;
  42140. /** Fires an event when any of it's sub gizmos are dragged */
  42141. onDragStartObservable: Observable<{}>;
  42142. /** Fires an event when any of it's sub gizmos are released from dragging */
  42143. onDragEndObservable: Observable<{}>;
  42144. attachedMesh: Nullable<AbstractMesh>;
  42145. /**
  42146. * Creates a PositionGizmo
  42147. * @param gizmoLayer The utility layer the gizmo will be added to
  42148. */
  42149. constructor(gizmoLayer?: UtilityLayerRenderer);
  42150. updateGizmoRotationToMatchAttachedMesh: boolean;
  42151. /**
  42152. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42153. */
  42154. snapDistance: number;
  42155. /**
  42156. * Ratio for the scale of the gizmo (Default: 1)
  42157. */
  42158. scaleRatio: number;
  42159. /**
  42160. * Disposes of the gizmo
  42161. */
  42162. dispose(): void;
  42163. /**
  42164. * CustomMeshes are not supported by this gizmo
  42165. * @param mesh The mesh to replace the default mesh of the gizmo
  42166. */
  42167. setCustomMesh(mesh: Mesh): void;
  42168. }
  42169. }
  42170. declare module BABYLON {
  42171. /**
  42172. * Class containing static functions to help procedurally build meshes
  42173. */
  42174. export class PolyhedronBuilder {
  42175. /**
  42176. * Creates a polyhedron mesh
  42177. * * 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
  42178. * * The parameter `size` (positive float, default 1) sets the polygon size
  42179. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42180. * * 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`
  42181. * * 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
  42182. * * 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)`)
  42183. * * 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
  42184. * * 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
  42185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42186. * * 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
  42187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42188. * @param name defines the name of the mesh
  42189. * @param options defines the options used to create the mesh
  42190. * @param scene defines the hosting scene
  42191. * @returns the polyhedron mesh
  42192. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42193. */
  42194. static CreatePolyhedron(name: string, options: {
  42195. type?: number;
  42196. size?: number;
  42197. sizeX?: number;
  42198. sizeY?: number;
  42199. sizeZ?: number;
  42200. custom?: any;
  42201. faceUV?: Vector4[];
  42202. faceColors?: Color4[];
  42203. flat?: boolean;
  42204. updatable?: boolean;
  42205. sideOrientation?: number;
  42206. frontUVs?: Vector4;
  42207. backUVs?: Vector4;
  42208. }, scene: Scene): Mesh;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Gizmo that enables scaling a mesh along 3 axis
  42214. */
  42215. export class ScaleGizmo extends Gizmo {
  42216. /**
  42217. * Internal gizmo used for interactions on the x axis
  42218. */
  42219. xGizmo: AxisScaleGizmo;
  42220. /**
  42221. * Internal gizmo used for interactions on the y axis
  42222. */
  42223. yGizmo: AxisScaleGizmo;
  42224. /**
  42225. * Internal gizmo used for interactions on the z axis
  42226. */
  42227. zGizmo: AxisScaleGizmo;
  42228. /**
  42229. * Internal gizmo used to scale all axis equally
  42230. */
  42231. uniformScaleGizmo: AxisScaleGizmo;
  42232. /** Fires an event when any of it's sub gizmos are dragged */
  42233. onDragStartObservable: Observable<{}>;
  42234. /** Fires an event when any of it's sub gizmos are released from dragging */
  42235. onDragEndObservable: Observable<{}>;
  42236. attachedMesh: Nullable<AbstractMesh>;
  42237. /**
  42238. * Creates a ScaleGizmo
  42239. * @param gizmoLayer The utility layer the gizmo will be added to
  42240. */
  42241. constructor(gizmoLayer?: UtilityLayerRenderer);
  42242. updateGizmoRotationToMatchAttachedMesh: boolean;
  42243. /**
  42244. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42245. */
  42246. snapDistance: number;
  42247. /**
  42248. * Ratio for the scale of the gizmo (Default: 1)
  42249. */
  42250. scaleRatio: number;
  42251. /**
  42252. * Disposes of the gizmo
  42253. */
  42254. dispose(): void;
  42255. }
  42256. }
  42257. declare module BABYLON {
  42258. /**
  42259. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42260. */
  42261. export class GizmoManager implements IDisposable {
  42262. private scene;
  42263. /**
  42264. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42265. */
  42266. gizmos: {
  42267. positionGizmo: Nullable<PositionGizmo>;
  42268. rotationGizmo: Nullable<RotationGizmo>;
  42269. scaleGizmo: Nullable<ScaleGizmo>;
  42270. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42271. };
  42272. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42273. clearGizmoOnEmptyPointerEvent: boolean;
  42274. /** Fires an event when the manager is attached to a mesh */
  42275. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42276. private _gizmosEnabled;
  42277. private _pointerObserver;
  42278. private _attachedMesh;
  42279. private _boundingBoxColor;
  42280. private _defaultUtilityLayer;
  42281. private _defaultKeepDepthUtilityLayer;
  42282. /**
  42283. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42284. */
  42285. boundingBoxDragBehavior: SixDofDragBehavior;
  42286. /**
  42287. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42288. */
  42289. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42290. /**
  42291. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42292. */
  42293. usePointerToAttachGizmos: boolean;
  42294. /**
  42295. * Instatiates a gizmo manager
  42296. * @param scene the scene to overlay the gizmos on top of
  42297. */
  42298. constructor(scene: Scene);
  42299. /**
  42300. * Attaches a set of gizmos to the specified mesh
  42301. * @param mesh The mesh the gizmo's should be attached to
  42302. */
  42303. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42304. /**
  42305. * If the position gizmo is enabled
  42306. */
  42307. positionGizmoEnabled: boolean;
  42308. /**
  42309. * If the rotation gizmo is enabled
  42310. */
  42311. rotationGizmoEnabled: boolean;
  42312. /**
  42313. * If the scale gizmo is enabled
  42314. */
  42315. scaleGizmoEnabled: boolean;
  42316. /**
  42317. * If the boundingBox gizmo is enabled
  42318. */
  42319. boundingBoxGizmoEnabled: boolean;
  42320. /**
  42321. * Disposes of the gizmo manager
  42322. */
  42323. dispose(): void;
  42324. }
  42325. }
  42326. declare module BABYLON {
  42327. /**
  42328. * Gizmo that enables viewing a light
  42329. */
  42330. export class LightGizmo extends Gizmo {
  42331. private _box;
  42332. /**
  42333. * Creates a LightGizmo
  42334. * @param gizmoLayer The utility layer the gizmo will be added to
  42335. */
  42336. constructor(gizmoLayer?: UtilityLayerRenderer);
  42337. private _light;
  42338. /**
  42339. * The light that the gizmo is attached to
  42340. */
  42341. light: Nullable<Light>;
  42342. /**
  42343. * @hidden
  42344. * Updates the gizmo to match the attached mesh's position/rotation
  42345. */
  42346. protected _update(): void;
  42347. }
  42348. }
  42349. declare module BABYLON {
  42350. /** @hidden */
  42351. export var backgroundFragmentDeclaration: {
  42352. name: string;
  42353. shader: string;
  42354. };
  42355. }
  42356. declare module BABYLON {
  42357. /** @hidden */
  42358. export var backgroundUboDeclaration: {
  42359. name: string;
  42360. shader: string;
  42361. };
  42362. }
  42363. declare module BABYLON {
  42364. /** @hidden */
  42365. export var backgroundPixelShader: {
  42366. name: string;
  42367. shader: string;
  42368. };
  42369. }
  42370. declare module BABYLON {
  42371. /** @hidden */
  42372. export var backgroundVertexDeclaration: {
  42373. name: string;
  42374. shader: string;
  42375. };
  42376. }
  42377. declare module BABYLON {
  42378. /** @hidden */
  42379. export var backgroundVertexShader: {
  42380. name: string;
  42381. shader: string;
  42382. };
  42383. }
  42384. declare module BABYLON {
  42385. /**
  42386. * Background material used to create an efficient environement around your scene.
  42387. */
  42388. export class BackgroundMaterial extends PushMaterial {
  42389. /**
  42390. * Standard reflectance value at parallel view angle.
  42391. */
  42392. static StandardReflectance0: number;
  42393. /**
  42394. * Standard reflectance value at grazing angle.
  42395. */
  42396. static StandardReflectance90: number;
  42397. protected _primaryColor: Color3;
  42398. /**
  42399. * Key light Color (multiply against the environement texture)
  42400. */
  42401. primaryColor: Color3;
  42402. protected __perceptualColor: Nullable<Color3>;
  42403. /**
  42404. * Experimental Internal Use Only.
  42405. *
  42406. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42407. * This acts as a helper to set the primary color to a more "human friendly" value.
  42408. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42409. * output color as close as possible from the chosen value.
  42410. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42411. * part of lighting setup.)
  42412. */
  42413. _perceptualColor: Nullable<Color3>;
  42414. protected _primaryColorShadowLevel: float;
  42415. /**
  42416. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42417. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42418. */
  42419. primaryColorShadowLevel: float;
  42420. protected _primaryColorHighlightLevel: float;
  42421. /**
  42422. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42423. * The primary color is used at the level chosen to define what the white area would look.
  42424. */
  42425. primaryColorHighlightLevel: float;
  42426. protected _reflectionTexture: Nullable<BaseTexture>;
  42427. /**
  42428. * Reflection Texture used in the material.
  42429. * Should be author in a specific way for the best result (refer to the documentation).
  42430. */
  42431. reflectionTexture: Nullable<BaseTexture>;
  42432. protected _reflectionBlur: float;
  42433. /**
  42434. * Reflection Texture level of blur.
  42435. *
  42436. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42437. * texture twice.
  42438. */
  42439. reflectionBlur: float;
  42440. protected _diffuseTexture: Nullable<BaseTexture>;
  42441. /**
  42442. * Diffuse Texture used in the material.
  42443. * Should be author in a specific way for the best result (refer to the documentation).
  42444. */
  42445. diffuseTexture: Nullable<BaseTexture>;
  42446. protected _shadowLights: Nullable<IShadowLight[]>;
  42447. /**
  42448. * Specify the list of lights casting shadow on the material.
  42449. * All scene shadow lights will be included if null.
  42450. */
  42451. shadowLights: Nullable<IShadowLight[]>;
  42452. protected _shadowLevel: float;
  42453. /**
  42454. * Helps adjusting the shadow to a softer level if required.
  42455. * 0 means black shadows and 1 means no shadows.
  42456. */
  42457. shadowLevel: float;
  42458. protected _sceneCenter: Vector3;
  42459. /**
  42460. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42461. * It is usually zero but might be interesting to modify according to your setup.
  42462. */
  42463. sceneCenter: Vector3;
  42464. protected _opacityFresnel: boolean;
  42465. /**
  42466. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42467. * This helps ensuring a nice transition when the camera goes under the ground.
  42468. */
  42469. opacityFresnel: boolean;
  42470. protected _reflectionFresnel: boolean;
  42471. /**
  42472. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42473. * This helps adding a mirror texture on the ground.
  42474. */
  42475. reflectionFresnel: boolean;
  42476. protected _reflectionFalloffDistance: number;
  42477. /**
  42478. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42479. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42480. */
  42481. reflectionFalloffDistance: number;
  42482. protected _reflectionAmount: number;
  42483. /**
  42484. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42485. */
  42486. reflectionAmount: number;
  42487. protected _reflectionReflectance0: number;
  42488. /**
  42489. * This specifies the weight of the reflection at grazing angle.
  42490. */
  42491. reflectionReflectance0: number;
  42492. protected _reflectionReflectance90: number;
  42493. /**
  42494. * This specifies the weight of the reflection at a perpendicular point of view.
  42495. */
  42496. reflectionReflectance90: number;
  42497. /**
  42498. * Sets the reflection reflectance fresnel values according to the default standard
  42499. * empirically know to work well :-)
  42500. */
  42501. reflectionStandardFresnelWeight: number;
  42502. protected _useRGBColor: boolean;
  42503. /**
  42504. * Helps to directly use the maps channels instead of their level.
  42505. */
  42506. useRGBColor: boolean;
  42507. protected _enableNoise: boolean;
  42508. /**
  42509. * This helps reducing the banding effect that could occur on the background.
  42510. */
  42511. enableNoise: boolean;
  42512. /**
  42513. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42514. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42515. * Recommended to be keep at 1.0 except for special cases.
  42516. */
  42517. fovMultiplier: number;
  42518. private _fovMultiplier;
  42519. /**
  42520. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42521. */
  42522. useEquirectangularFOV: boolean;
  42523. private _maxSimultaneousLights;
  42524. /**
  42525. * Number of Simultaneous lights allowed on the material.
  42526. */
  42527. maxSimultaneousLights: int;
  42528. /**
  42529. * Default configuration related to image processing available in the Background Material.
  42530. */
  42531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42532. /**
  42533. * Keep track of the image processing observer to allow dispose and replace.
  42534. */
  42535. private _imageProcessingObserver;
  42536. /**
  42537. * Attaches a new image processing configuration to the PBR Material.
  42538. * @param configuration (if null the scene configuration will be use)
  42539. */
  42540. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42541. /**
  42542. * Gets the image processing configuration used either in this material.
  42543. */
  42544. /**
  42545. * Sets the Default image processing configuration used either in the this material.
  42546. *
  42547. * If sets to null, the scene one is in use.
  42548. */
  42549. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42550. /**
  42551. * Gets wether the color curves effect is enabled.
  42552. */
  42553. /**
  42554. * Sets wether the color curves effect is enabled.
  42555. */
  42556. cameraColorCurvesEnabled: boolean;
  42557. /**
  42558. * Gets wether the color grading effect is enabled.
  42559. */
  42560. /**
  42561. * Gets wether the color grading effect is enabled.
  42562. */
  42563. cameraColorGradingEnabled: boolean;
  42564. /**
  42565. * Gets wether tonemapping is enabled or not.
  42566. */
  42567. /**
  42568. * Sets wether tonemapping is enabled or not
  42569. */
  42570. cameraToneMappingEnabled: boolean;
  42571. /**
  42572. * The camera exposure used on this material.
  42573. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42574. * This corresponds to a photographic exposure.
  42575. */
  42576. /**
  42577. * The camera exposure used on this material.
  42578. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42579. * This corresponds to a photographic exposure.
  42580. */
  42581. cameraExposure: float;
  42582. /**
  42583. * Gets The camera contrast used on this material.
  42584. */
  42585. /**
  42586. * Sets The camera contrast used on this material.
  42587. */
  42588. cameraContrast: float;
  42589. /**
  42590. * Gets the Color Grading 2D Lookup Texture.
  42591. */
  42592. /**
  42593. * Sets the Color Grading 2D Lookup Texture.
  42594. */
  42595. cameraColorGradingTexture: Nullable<BaseTexture>;
  42596. /**
  42597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42599. * 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;
  42600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42601. */
  42602. /**
  42603. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42604. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42605. * 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;
  42606. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42607. */
  42608. cameraColorCurves: Nullable<ColorCurves>;
  42609. /**
  42610. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42611. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42612. */
  42613. switchToBGR: boolean;
  42614. private _renderTargets;
  42615. private _reflectionControls;
  42616. private _white;
  42617. private _primaryShadowColor;
  42618. private _primaryHighlightColor;
  42619. /**
  42620. * Instantiates a Background Material in the given scene
  42621. * @param name The friendly name of the material
  42622. * @param scene The scene to add the material to
  42623. */
  42624. constructor(name: string, scene: Scene);
  42625. /**
  42626. * Gets a boolean indicating that current material needs to register RTT
  42627. */
  42628. readonly hasRenderTargetTextures: boolean;
  42629. /**
  42630. * The entire material has been created in order to prevent overdraw.
  42631. * @returns false
  42632. */
  42633. needAlphaTesting(): boolean;
  42634. /**
  42635. * The entire material has been created in order to prevent overdraw.
  42636. * @returns true if blending is enable
  42637. */
  42638. needAlphaBlending(): boolean;
  42639. /**
  42640. * Checks wether the material is ready to be rendered for a given mesh.
  42641. * @param mesh The mesh to render
  42642. * @param subMesh The submesh to check against
  42643. * @param useInstances Specify wether or not the material is used with instances
  42644. * @returns true if all the dependencies are ready (Textures, Effects...)
  42645. */
  42646. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42647. /**
  42648. * Compute the primary color according to the chosen perceptual color.
  42649. */
  42650. private _computePrimaryColorFromPerceptualColor;
  42651. /**
  42652. * Compute the highlights and shadow colors according to their chosen levels.
  42653. */
  42654. private _computePrimaryColors;
  42655. /**
  42656. * Build the uniform buffer used in the material.
  42657. */
  42658. buildUniformLayout(): void;
  42659. /**
  42660. * Unbind the material.
  42661. */
  42662. unbind(): void;
  42663. /**
  42664. * Bind only the world matrix to the material.
  42665. * @param world The world matrix to bind.
  42666. */
  42667. bindOnlyWorldMatrix(world: Matrix): void;
  42668. /**
  42669. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42670. * @param world The world matrix to bind.
  42671. * @param subMesh The submesh to bind for.
  42672. */
  42673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42674. /**
  42675. * Dispose the material.
  42676. * @param forceDisposeEffect Force disposal of the associated effect.
  42677. * @param forceDisposeTextures Force disposal of the associated textures.
  42678. */
  42679. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42680. /**
  42681. * Clones the material.
  42682. * @param name The cloned name.
  42683. * @returns The cloned material.
  42684. */
  42685. clone(name: string): BackgroundMaterial;
  42686. /**
  42687. * Serializes the current material to its JSON representation.
  42688. * @returns The JSON representation.
  42689. */
  42690. serialize(): any;
  42691. /**
  42692. * Gets the class name of the material
  42693. * @returns "BackgroundMaterial"
  42694. */
  42695. getClassName(): string;
  42696. /**
  42697. * Parse a JSON input to create back a background material.
  42698. * @param source The JSON data to parse
  42699. * @param scene The scene to create the parsed material in
  42700. * @param rootUrl The root url of the assets the material depends upon
  42701. * @returns the instantiated BackgroundMaterial.
  42702. */
  42703. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42704. }
  42705. }
  42706. declare module BABYLON {
  42707. /**
  42708. * Represents the different options available during the creation of
  42709. * a Environment helper.
  42710. *
  42711. * This can control the default ground, skybox and image processing setup of your scene.
  42712. */
  42713. export interface IEnvironmentHelperOptions {
  42714. /**
  42715. * Specifies wether or not to create a ground.
  42716. * True by default.
  42717. */
  42718. createGround: boolean;
  42719. /**
  42720. * Specifies the ground size.
  42721. * 15 by default.
  42722. */
  42723. groundSize: number;
  42724. /**
  42725. * The texture used on the ground for the main color.
  42726. * Comes from the BabylonJS CDN by default.
  42727. *
  42728. * Remarks: Can be either a texture or a url.
  42729. */
  42730. groundTexture: string | BaseTexture;
  42731. /**
  42732. * The color mixed in the ground texture by default.
  42733. * BabylonJS clearColor by default.
  42734. */
  42735. groundColor: Color3;
  42736. /**
  42737. * Specifies the ground opacity.
  42738. * 1 by default.
  42739. */
  42740. groundOpacity: number;
  42741. /**
  42742. * Enables the ground to receive shadows.
  42743. * True by default.
  42744. */
  42745. enableGroundShadow: boolean;
  42746. /**
  42747. * Helps preventing the shadow to be fully black on the ground.
  42748. * 0.5 by default.
  42749. */
  42750. groundShadowLevel: number;
  42751. /**
  42752. * Creates a mirror texture attach to the ground.
  42753. * false by default.
  42754. */
  42755. enableGroundMirror: boolean;
  42756. /**
  42757. * Specifies the ground mirror size ratio.
  42758. * 0.3 by default as the default kernel is 64.
  42759. */
  42760. groundMirrorSizeRatio: number;
  42761. /**
  42762. * Specifies the ground mirror blur kernel size.
  42763. * 64 by default.
  42764. */
  42765. groundMirrorBlurKernel: number;
  42766. /**
  42767. * Specifies the ground mirror visibility amount.
  42768. * 1 by default
  42769. */
  42770. groundMirrorAmount: number;
  42771. /**
  42772. * Specifies the ground mirror reflectance weight.
  42773. * This uses the standard weight of the background material to setup the fresnel effect
  42774. * of the mirror.
  42775. * 1 by default.
  42776. */
  42777. groundMirrorFresnelWeight: number;
  42778. /**
  42779. * Specifies the ground mirror Falloff distance.
  42780. * This can helps reducing the size of the reflection.
  42781. * 0 by Default.
  42782. */
  42783. groundMirrorFallOffDistance: number;
  42784. /**
  42785. * Specifies the ground mirror texture type.
  42786. * Unsigned Int by Default.
  42787. */
  42788. groundMirrorTextureType: number;
  42789. /**
  42790. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42791. * the shown objects.
  42792. */
  42793. groundYBias: number;
  42794. /**
  42795. * Specifies wether or not to create a skybox.
  42796. * True by default.
  42797. */
  42798. createSkybox: boolean;
  42799. /**
  42800. * Specifies the skybox size.
  42801. * 20 by default.
  42802. */
  42803. skyboxSize: number;
  42804. /**
  42805. * The texture used on the skybox for the main color.
  42806. * Comes from the BabylonJS CDN by default.
  42807. *
  42808. * Remarks: Can be either a texture or a url.
  42809. */
  42810. skyboxTexture: string | BaseTexture;
  42811. /**
  42812. * The color mixed in the skybox texture by default.
  42813. * BabylonJS clearColor by default.
  42814. */
  42815. skyboxColor: Color3;
  42816. /**
  42817. * The background rotation around the Y axis of the scene.
  42818. * This helps aligning the key lights of your scene with the background.
  42819. * 0 by default.
  42820. */
  42821. backgroundYRotation: number;
  42822. /**
  42823. * Compute automatically the size of the elements to best fit with the scene.
  42824. */
  42825. sizeAuto: boolean;
  42826. /**
  42827. * Default position of the rootMesh if autoSize is not true.
  42828. */
  42829. rootPosition: Vector3;
  42830. /**
  42831. * Sets up the image processing in the scene.
  42832. * true by default.
  42833. */
  42834. setupImageProcessing: boolean;
  42835. /**
  42836. * The texture used as your environment texture in the scene.
  42837. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42838. *
  42839. * Remarks: Can be either a texture or a url.
  42840. */
  42841. environmentTexture: string | BaseTexture;
  42842. /**
  42843. * The value of the exposure to apply to the scene.
  42844. * 0.6 by default if setupImageProcessing is true.
  42845. */
  42846. cameraExposure: number;
  42847. /**
  42848. * The value of the contrast to apply to the scene.
  42849. * 1.6 by default if setupImageProcessing is true.
  42850. */
  42851. cameraContrast: number;
  42852. /**
  42853. * Specifies wether or not tonemapping should be enabled in the scene.
  42854. * true by default if setupImageProcessing is true.
  42855. */
  42856. toneMappingEnabled: boolean;
  42857. }
  42858. /**
  42859. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42860. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42861. * It also helps with the default setup of your imageProcessing configuration.
  42862. */
  42863. export class EnvironmentHelper {
  42864. /**
  42865. * Default ground texture URL.
  42866. */
  42867. private static _groundTextureCDNUrl;
  42868. /**
  42869. * Default skybox texture URL.
  42870. */
  42871. private static _skyboxTextureCDNUrl;
  42872. /**
  42873. * Default environment texture URL.
  42874. */
  42875. private static _environmentTextureCDNUrl;
  42876. /**
  42877. * Creates the default options for the helper.
  42878. */
  42879. private static _getDefaultOptions;
  42880. private _rootMesh;
  42881. /**
  42882. * Gets the root mesh created by the helper.
  42883. */
  42884. readonly rootMesh: Mesh;
  42885. private _skybox;
  42886. /**
  42887. * Gets the skybox created by the helper.
  42888. */
  42889. readonly skybox: Nullable<Mesh>;
  42890. private _skyboxTexture;
  42891. /**
  42892. * Gets the skybox texture created by the helper.
  42893. */
  42894. readonly skyboxTexture: Nullable<BaseTexture>;
  42895. private _skyboxMaterial;
  42896. /**
  42897. * Gets the skybox material created by the helper.
  42898. */
  42899. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42900. private _ground;
  42901. /**
  42902. * Gets the ground mesh created by the helper.
  42903. */
  42904. readonly ground: Nullable<Mesh>;
  42905. private _groundTexture;
  42906. /**
  42907. * Gets the ground texture created by the helper.
  42908. */
  42909. readonly groundTexture: Nullable<BaseTexture>;
  42910. private _groundMirror;
  42911. /**
  42912. * Gets the ground mirror created by the helper.
  42913. */
  42914. readonly groundMirror: Nullable<MirrorTexture>;
  42915. /**
  42916. * Gets the ground mirror render list to helps pushing the meshes
  42917. * you wish in the ground reflection.
  42918. */
  42919. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42920. private _groundMaterial;
  42921. /**
  42922. * Gets the ground material created by the helper.
  42923. */
  42924. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42925. /**
  42926. * Stores the creation options.
  42927. */
  42928. private readonly _scene;
  42929. private _options;
  42930. /**
  42931. * This observable will be notified with any error during the creation of the environment,
  42932. * mainly texture creation errors.
  42933. */
  42934. onErrorObservable: Observable<{
  42935. message?: string;
  42936. exception?: any;
  42937. }>;
  42938. /**
  42939. * constructor
  42940. * @param options Defines the options we want to customize the helper
  42941. * @param scene The scene to add the material to
  42942. */
  42943. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42944. /**
  42945. * Updates the background according to the new options
  42946. * @param options
  42947. */
  42948. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42949. /**
  42950. * Sets the primary color of all the available elements.
  42951. * @param color the main color to affect to the ground and the background
  42952. */
  42953. setMainColor(color: Color3): void;
  42954. /**
  42955. * Setup the image processing according to the specified options.
  42956. */
  42957. private _setupImageProcessing;
  42958. /**
  42959. * Setup the environment texture according to the specified options.
  42960. */
  42961. private _setupEnvironmentTexture;
  42962. /**
  42963. * Setup the background according to the specified options.
  42964. */
  42965. private _setupBackground;
  42966. /**
  42967. * Get the scene sizes according to the setup.
  42968. */
  42969. private _getSceneSize;
  42970. /**
  42971. * Setup the ground according to the specified options.
  42972. */
  42973. private _setupGround;
  42974. /**
  42975. * Setup the ground material according to the specified options.
  42976. */
  42977. private _setupGroundMaterial;
  42978. /**
  42979. * Setup the ground diffuse texture according to the specified options.
  42980. */
  42981. private _setupGroundDiffuseTexture;
  42982. /**
  42983. * Setup the ground mirror texture according to the specified options.
  42984. */
  42985. private _setupGroundMirrorTexture;
  42986. /**
  42987. * Setup the ground to receive the mirror texture.
  42988. */
  42989. private _setupMirrorInGroundMaterial;
  42990. /**
  42991. * Setup the skybox according to the specified options.
  42992. */
  42993. private _setupSkybox;
  42994. /**
  42995. * Setup the skybox material according to the specified options.
  42996. */
  42997. private _setupSkyboxMaterial;
  42998. /**
  42999. * Setup the skybox reflection texture according to the specified options.
  43000. */
  43001. private _setupSkyboxReflectionTexture;
  43002. private _errorHandler;
  43003. /**
  43004. * Dispose all the elements created by the Helper.
  43005. */
  43006. dispose(): void;
  43007. }
  43008. }
  43009. declare module BABYLON {
  43010. /**
  43011. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43012. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43013. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43014. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43015. */
  43016. export class PhotoDome extends TransformNode {
  43017. private _useDirectMapping;
  43018. /**
  43019. * The texture being displayed on the sphere
  43020. */
  43021. protected _photoTexture: Texture;
  43022. /**
  43023. * Gets or sets the texture being displayed on the sphere
  43024. */
  43025. photoTexture: Texture;
  43026. /**
  43027. * Observable raised when an error occured while loading the 360 image
  43028. */
  43029. onLoadErrorObservable: Observable<string>;
  43030. /**
  43031. * The skybox material
  43032. */
  43033. protected _material: BackgroundMaterial;
  43034. /**
  43035. * The surface used for the skybox
  43036. */
  43037. protected _mesh: Mesh;
  43038. /**
  43039. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43040. * Also see the options.resolution property.
  43041. */
  43042. fovMultiplier: number;
  43043. /**
  43044. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43045. * @param name Element's name, child elements will append suffixes for their own names.
  43046. * @param urlsOfPhoto defines the url of the photo to display
  43047. * @param options defines an object containing optional or exposed sub element properties
  43048. * @param onError defines a callback called when an error occured while loading the texture
  43049. */
  43050. constructor(name: string, urlOfPhoto: string, options: {
  43051. resolution?: number;
  43052. size?: number;
  43053. useDirectMapping?: boolean;
  43054. faceForward?: boolean;
  43055. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43056. /**
  43057. * Releases resources associated with this node.
  43058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43060. */
  43061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43062. }
  43063. }
  43064. declare module BABYLON {
  43065. /**
  43066. * Class used to host texture specific utilities
  43067. */
  43068. export class TextureTools {
  43069. /**
  43070. * Uses the GPU to create a copy texture rescaled at a given size
  43071. * @param texture Texture to copy from
  43072. * @param width defines the desired width
  43073. * @param height defines the desired height
  43074. * @param useBilinearMode defines if bilinear mode has to be used
  43075. * @return the generated texture
  43076. */
  43077. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43078. /**
  43079. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43080. * @param scene defines the hosting scene
  43081. * @returns the environment BRDF texture
  43082. */
  43083. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43084. private static _environmentBRDFBase64Texture;
  43085. }
  43086. }
  43087. declare module BABYLON {
  43088. /**
  43089. * @hidden
  43090. */
  43091. export interface IMaterialClearCoatDefines {
  43092. CLEARCOAT: boolean;
  43093. CLEARCOAT_DEFAULTIOR: boolean;
  43094. CLEARCOAT_TEXTURE: boolean;
  43095. CLEARCOAT_TEXTUREDIRECTUV: number;
  43096. CLEARCOAT_BUMP: boolean;
  43097. CLEARCOAT_BUMPDIRECTUV: number;
  43098. CLEARCOAT_TINT: boolean;
  43099. CLEARCOAT_TINT_TEXTURE: boolean;
  43100. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43101. /** @hidden */
  43102. _areTexturesDirty: boolean;
  43103. }
  43104. /**
  43105. * Define the code related to the clear coat parameters of the pbr material.
  43106. */
  43107. export class PBRClearCoatConfiguration {
  43108. /**
  43109. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43110. * The default fits with a polyurethane material.
  43111. */
  43112. private static readonly _DefaultIndiceOfRefraction;
  43113. private _isEnabled;
  43114. /**
  43115. * Defines if the clear coat is enabled in the material.
  43116. */
  43117. isEnabled: boolean;
  43118. /**
  43119. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43120. */
  43121. intensity: number;
  43122. /**
  43123. * Defines the clear coat layer roughness.
  43124. */
  43125. roughness: number;
  43126. private _indiceOfRefraction;
  43127. /**
  43128. * Defines the indice of refraction of the clear coat.
  43129. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43130. * The default fits with a polyurethane material.
  43131. * Changing the default value is more performance intensive.
  43132. */
  43133. indiceOfRefraction: number;
  43134. private _texture;
  43135. /**
  43136. * Stores the clear coat values in a texture.
  43137. */
  43138. texture: Nullable<BaseTexture>;
  43139. private _bumpTexture;
  43140. /**
  43141. * Define the clear coat specific bump texture.
  43142. */
  43143. bumpTexture: Nullable<BaseTexture>;
  43144. private _isTintEnabled;
  43145. /**
  43146. * Defines if the clear coat tint is enabled in the material.
  43147. */
  43148. isTintEnabled: boolean;
  43149. /**
  43150. * Defines if the clear coat tint is enabled in the material.
  43151. * This is only use if tint is enabled
  43152. */
  43153. tintColor: Color3;
  43154. /**
  43155. * Defines if the distance at which the tint color should be found in the
  43156. * clear coat media.
  43157. * This is only use if tint is enabled
  43158. */
  43159. tintColorAtDistance: number;
  43160. /**
  43161. * Defines the clear coat layer thickness.
  43162. * This is only use if tint is enabled
  43163. */
  43164. tintThickness: number;
  43165. private _tintTexture;
  43166. /**
  43167. * Stores the clear tint values in a texture.
  43168. * rgb is tint
  43169. * a is a thickness factor
  43170. */
  43171. tintTexture: Nullable<BaseTexture>;
  43172. /** @hidden */
  43173. private _internalMarkAllSubMeshesAsTexturesDirty;
  43174. /** @hidden */
  43175. _markAllSubMeshesAsTexturesDirty(): void;
  43176. /**
  43177. * Instantiate a new istance of clear coat configuration.
  43178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43179. */
  43180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43181. /**
  43182. * Specifies that the submesh is ready to be used.
  43183. * @param defines the list of "defines" to update.
  43184. * @param scene defines the scene the material belongs to.
  43185. * @param engine defines the engine the material belongs to.
  43186. * @param disableBumpMap defines wether the material disables bump or not.
  43187. * @returns - boolean indicating that the submesh is ready or not.
  43188. */
  43189. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43190. /**
  43191. * Checks to see if a texture is used in the material.
  43192. * @param defines the list of "defines" to update.
  43193. * @param scene defines the scene to the material belongs to.
  43194. */
  43195. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43196. /**
  43197. * Binds the material data.
  43198. * @param uniformBuffer defines the Uniform buffer to fill in.
  43199. * @param scene defines the scene the material belongs to.
  43200. * @param engine defines the engine the material belongs to.
  43201. * @param disableBumpMap defines wether the material disables bump or not.
  43202. * @param isFrozen defines wether the material is frozen or not.
  43203. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43204. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43205. */
  43206. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43207. /**
  43208. * Checks to see if a texture is used in the material.
  43209. * @param texture - Base texture to use.
  43210. * @returns - Boolean specifying if a texture is used in the material.
  43211. */
  43212. hasTexture(texture: BaseTexture): boolean;
  43213. /**
  43214. * Returns an array of the actively used textures.
  43215. * @param activeTextures Array of BaseTextures
  43216. */
  43217. getActiveTextures(activeTextures: BaseTexture[]): void;
  43218. /**
  43219. * Returns the animatable textures.
  43220. * @param animatables Array of animatable textures.
  43221. */
  43222. getAnimatables(animatables: IAnimatable[]): void;
  43223. /**
  43224. * Disposes the resources of the material.
  43225. * @param forceDisposeTextures - Forces the disposal of all textures.
  43226. */
  43227. dispose(forceDisposeTextures?: boolean): void;
  43228. /**
  43229. * Get the current class name of the texture useful for serialization or dynamic coding.
  43230. * @returns "PBRClearCoatConfiguration"
  43231. */
  43232. getClassName(): string;
  43233. /**
  43234. * Add fallbacks to the effect fallbacks list.
  43235. * @param defines defines the Base texture to use.
  43236. * @param fallbacks defines the current fallback list.
  43237. * @param currentRank defines the current fallback rank.
  43238. * @returns the new fallback rank.
  43239. */
  43240. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43241. /**
  43242. * Add the required uniforms to the current list.
  43243. * @param uniforms defines the current uniform list.
  43244. */
  43245. static AddUniforms(uniforms: string[]): void;
  43246. /**
  43247. * Add the required samplers to the current list.
  43248. * @param samplers defines the current sampler list.
  43249. */
  43250. static AddSamplers(samplers: string[]): void;
  43251. /**
  43252. * Add the required uniforms to the current buffer.
  43253. * @param uniformBuffer defines the current uniform buffer.
  43254. */
  43255. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43256. /**
  43257. * Makes a duplicate of the current configuration into another one.
  43258. * @param clearCoatConfiguration define the config where to copy the info
  43259. */
  43260. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43261. /**
  43262. * Serializes this clear coat configuration.
  43263. * @returns - An object with the serialized config.
  43264. */
  43265. serialize(): any;
  43266. /**
  43267. * Parses a Clear Coat Configuration from a serialized object.
  43268. * @param source - Serialized object.
  43269. */
  43270. parse(source: any): void;
  43271. }
  43272. }
  43273. declare module BABYLON {
  43274. /**
  43275. * @hidden
  43276. */
  43277. export interface IMaterialAnisotropicDefines {
  43278. ANISOTROPIC: boolean;
  43279. ANISOTROPIC_TEXTURE: boolean;
  43280. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43281. MAINUV1: boolean;
  43282. _areTexturesDirty: boolean;
  43283. _needUVs: boolean;
  43284. }
  43285. /**
  43286. * Define the code related to the anisotropic parameters of the pbr material.
  43287. */
  43288. export class PBRAnisotropicConfiguration {
  43289. private _isEnabled;
  43290. /**
  43291. * Defines if the anisotropy is enabled in the material.
  43292. */
  43293. isEnabled: boolean;
  43294. /**
  43295. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43296. */
  43297. intensity: number;
  43298. /**
  43299. * Defines if the effect is along the tangents, bitangents or in between.
  43300. * By default, the effect is "strectching" the highlights along the tangents.
  43301. */
  43302. direction: Vector2;
  43303. private _texture;
  43304. /**
  43305. * Stores the anisotropy values in a texture.
  43306. * rg is direction (like normal from -1 to 1)
  43307. * b is a intensity
  43308. */
  43309. texture: Nullable<BaseTexture>;
  43310. /** @hidden */
  43311. private _internalMarkAllSubMeshesAsTexturesDirty;
  43312. /** @hidden */
  43313. _markAllSubMeshesAsTexturesDirty(): void;
  43314. /**
  43315. * Instantiate a new istance of anisotropy configuration.
  43316. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43317. */
  43318. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43319. /**
  43320. * Specifies that the submesh is ready to be used.
  43321. * @param defines the list of "defines" to update.
  43322. * @param scene defines the scene the material belongs to.
  43323. * @returns - boolean indicating that the submesh is ready or not.
  43324. */
  43325. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43326. /**
  43327. * Checks to see if a texture is used in the material.
  43328. * @param defines the list of "defines" to update.
  43329. * @param mesh the mesh we are preparing the defines for.
  43330. * @param scene defines the scene the material belongs to.
  43331. */
  43332. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43333. /**
  43334. * Binds the material data.
  43335. * @param uniformBuffer defines the Uniform buffer to fill in.
  43336. * @param scene defines the scene the material belongs to.
  43337. * @param isFrozen defines wether the material is frozen or not.
  43338. */
  43339. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43340. /**
  43341. * Checks to see if a texture is used in the material.
  43342. * @param texture - Base texture to use.
  43343. * @returns - Boolean specifying if a texture is used in the material.
  43344. */
  43345. hasTexture(texture: BaseTexture): boolean;
  43346. /**
  43347. * Returns an array of the actively used textures.
  43348. * @param activeTextures Array of BaseTextures
  43349. */
  43350. getActiveTextures(activeTextures: BaseTexture[]): void;
  43351. /**
  43352. * Returns the animatable textures.
  43353. * @param animatables Array of animatable textures.
  43354. */
  43355. getAnimatables(animatables: IAnimatable[]): void;
  43356. /**
  43357. * Disposes the resources of the material.
  43358. * @param forceDisposeTextures - Forces the disposal of all textures.
  43359. */
  43360. dispose(forceDisposeTextures?: boolean): void;
  43361. /**
  43362. * Get the current class name of the texture useful for serialization or dynamic coding.
  43363. * @returns "PBRAnisotropicConfiguration"
  43364. */
  43365. getClassName(): string;
  43366. /**
  43367. * Add fallbacks to the effect fallbacks list.
  43368. * @param defines defines the Base texture to use.
  43369. * @param fallbacks defines the current fallback list.
  43370. * @param currentRank defines the current fallback rank.
  43371. * @returns the new fallback rank.
  43372. */
  43373. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43374. /**
  43375. * Add the required uniforms to the current list.
  43376. * @param uniforms defines the current uniform list.
  43377. */
  43378. static AddUniforms(uniforms: string[]): void;
  43379. /**
  43380. * Add the required uniforms to the current buffer.
  43381. * @param uniformBuffer defines the current uniform buffer.
  43382. */
  43383. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43384. /**
  43385. * Add the required samplers to the current list.
  43386. * @param samplers defines the current sampler list.
  43387. */
  43388. static AddSamplers(samplers: string[]): void;
  43389. /**
  43390. * Makes a duplicate of the current configuration into another one.
  43391. * @param anisotropicConfiguration define the config where to copy the info
  43392. */
  43393. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43394. /**
  43395. * Serializes this anisotropy configuration.
  43396. * @returns - An object with the serialized config.
  43397. */
  43398. serialize(): any;
  43399. /**
  43400. * Parses a anisotropy Configuration from a serialized object.
  43401. * @param source - Serialized object.
  43402. */
  43403. parse(source: any): void;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * @hidden
  43409. */
  43410. export interface IMaterialBRDFDefines {
  43411. BRDF_V_HEIGHT_CORRELATED: boolean;
  43412. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43413. /** @hidden */
  43414. _areMiscDirty: boolean;
  43415. }
  43416. /**
  43417. * Define the code related to the BRDF parameters of the pbr material.
  43418. */
  43419. export class PBRBRDFConfiguration {
  43420. private _useEnergyConservation;
  43421. /**
  43422. * Defines if the material uses energy conservation.
  43423. */
  43424. useEnergyConservation: boolean;
  43425. private _useSmithVisibilityHeightCorrelated;
  43426. /**
  43427. * LEGACY Mode set to false
  43428. * Defines if the material uses height smith correlated visibility term.
  43429. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43430. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43431. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43432. * Not relying on height correlated will also disable energy conservation.
  43433. */
  43434. useSmithVisibilityHeightCorrelated: boolean;
  43435. /** @hidden */
  43436. private _internalMarkAllSubMeshesAsMiscDirty;
  43437. /** @hidden */
  43438. _markAllSubMeshesAsMiscDirty(): void;
  43439. /**
  43440. * Instantiate a new istance of clear coat configuration.
  43441. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43442. */
  43443. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43444. /**
  43445. * Checks to see if a texture is used in the material.
  43446. * @param defines the list of "defines" to update.
  43447. */
  43448. prepareDefines(defines: IMaterialBRDFDefines): void;
  43449. /**
  43450. * Get the current class name of the texture useful for serialization or dynamic coding.
  43451. * @returns "PBRClearCoatConfiguration"
  43452. */
  43453. getClassName(): string;
  43454. /**
  43455. * Makes a duplicate of the current configuration into another one.
  43456. * @param brdfConfiguration define the config where to copy the info
  43457. */
  43458. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43459. /**
  43460. * Serializes this BRDF configuration.
  43461. * @returns - An object with the serialized config.
  43462. */
  43463. serialize(): any;
  43464. /**
  43465. * Parses a BRDF Configuration from a serialized object.
  43466. * @param source - Serialized object.
  43467. */
  43468. parse(source: any): void;
  43469. }
  43470. }
  43471. declare module BABYLON {
  43472. /**
  43473. * @hidden
  43474. */
  43475. export interface IMaterialSheenDefines {
  43476. SHEEN: boolean;
  43477. SHEEN_TEXTURE: boolean;
  43478. SHEEN_TEXTUREDIRECTUV: number;
  43479. SHEEN_LINKWITHALBEDO: boolean;
  43480. /** @hidden */
  43481. _areTexturesDirty: boolean;
  43482. }
  43483. /**
  43484. * Define the code related to the Sheen parameters of the pbr material.
  43485. */
  43486. export class PBRSheenConfiguration {
  43487. private _isEnabled;
  43488. /**
  43489. * Defines if the material uses sheen.
  43490. */
  43491. isEnabled: boolean;
  43492. private _linkSheenWithAlbedo;
  43493. /**
  43494. * Defines if the sheen is linked to the sheen color.
  43495. */
  43496. linkSheenWithAlbedo: boolean;
  43497. /**
  43498. * Defines the sheen intensity.
  43499. */
  43500. intensity: number;
  43501. /**
  43502. * Defines the sheen color.
  43503. */
  43504. color: Color3;
  43505. private _texture;
  43506. /**
  43507. * Stores the sheen tint values in a texture.
  43508. * rgb is tint
  43509. * a is a intensity
  43510. */
  43511. texture: Nullable<BaseTexture>;
  43512. /** @hidden */
  43513. private _internalMarkAllSubMeshesAsTexturesDirty;
  43514. /** @hidden */
  43515. _markAllSubMeshesAsTexturesDirty(): void;
  43516. /**
  43517. * Instantiate a new istance of clear coat configuration.
  43518. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43519. */
  43520. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43521. /**
  43522. * Specifies that the submesh is ready to be used.
  43523. * @param defines the list of "defines" to update.
  43524. * @param scene defines the scene the material belongs to.
  43525. * @returns - boolean indicating that the submesh is ready or not.
  43526. */
  43527. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43528. /**
  43529. * Checks to see if a texture is used in the material.
  43530. * @param defines the list of "defines" to update.
  43531. * @param scene defines the scene the material belongs to.
  43532. */
  43533. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43534. /**
  43535. * Binds the material data.
  43536. * @param uniformBuffer defines the Uniform buffer to fill in.
  43537. * @param scene defines the scene the material belongs to.
  43538. * @param isFrozen defines wether the material is frozen or not.
  43539. */
  43540. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43541. /**
  43542. * Checks to see if a texture is used in the material.
  43543. * @param texture - Base texture to use.
  43544. * @returns - Boolean specifying if a texture is used in the material.
  43545. */
  43546. hasTexture(texture: BaseTexture): boolean;
  43547. /**
  43548. * Returns an array of the actively used textures.
  43549. * @param activeTextures Array of BaseTextures
  43550. */
  43551. getActiveTextures(activeTextures: BaseTexture[]): void;
  43552. /**
  43553. * Returns the animatable textures.
  43554. * @param animatables Array of animatable textures.
  43555. */
  43556. getAnimatables(animatables: IAnimatable[]): void;
  43557. /**
  43558. * Disposes the resources of the material.
  43559. * @param forceDisposeTextures - Forces the disposal of all textures.
  43560. */
  43561. dispose(forceDisposeTextures?: boolean): void;
  43562. /**
  43563. * Get the current class name of the texture useful for serialization or dynamic coding.
  43564. * @returns "PBRSheenConfiguration"
  43565. */
  43566. getClassName(): string;
  43567. /**
  43568. * Add fallbacks to the effect fallbacks list.
  43569. * @param defines defines the Base texture to use.
  43570. * @param fallbacks defines the current fallback list.
  43571. * @param currentRank defines the current fallback rank.
  43572. * @returns the new fallback rank.
  43573. */
  43574. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43575. /**
  43576. * Add the required uniforms to the current list.
  43577. * @param uniforms defines the current uniform list.
  43578. */
  43579. static AddUniforms(uniforms: string[]): void;
  43580. /**
  43581. * Add the required uniforms to the current buffer.
  43582. * @param uniformBuffer defines the current uniform buffer.
  43583. */
  43584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43585. /**
  43586. * Add the required samplers to the current list.
  43587. * @param samplers defines the current sampler list.
  43588. */
  43589. static AddSamplers(samplers: string[]): void;
  43590. /**
  43591. * Makes a duplicate of the current configuration into another one.
  43592. * @param sheenConfiguration define the config where to copy the info
  43593. */
  43594. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43595. /**
  43596. * Serializes this BRDF configuration.
  43597. * @returns - An object with the serialized config.
  43598. */
  43599. serialize(): any;
  43600. /**
  43601. * Parses a Sheen Configuration from a serialized object.
  43602. * @param source - Serialized object.
  43603. */
  43604. parse(source: any): void;
  43605. }
  43606. }
  43607. declare module BABYLON {
  43608. /** @hidden */
  43609. export var pbrFragmentDeclaration: {
  43610. name: string;
  43611. shader: string;
  43612. };
  43613. }
  43614. declare module BABYLON {
  43615. /** @hidden */
  43616. export var pbrUboDeclaration: {
  43617. name: string;
  43618. shader: string;
  43619. };
  43620. }
  43621. declare module BABYLON {
  43622. /** @hidden */
  43623. export var pbrFragmentExtraDeclaration: {
  43624. name: string;
  43625. shader: string;
  43626. };
  43627. }
  43628. declare module BABYLON {
  43629. /** @hidden */
  43630. export var pbrFragmentSamplersDeclaration: {
  43631. name: string;
  43632. shader: string;
  43633. };
  43634. }
  43635. declare module BABYLON {
  43636. /** @hidden */
  43637. export var pbrHelperFunctions: {
  43638. name: string;
  43639. shader: string;
  43640. };
  43641. }
  43642. declare module BABYLON {
  43643. /** @hidden */
  43644. export var harmonicsFunctions: {
  43645. name: string;
  43646. shader: string;
  43647. };
  43648. }
  43649. declare module BABYLON {
  43650. /** @hidden */
  43651. export var pbrDirectLightingSetupFunctions: {
  43652. name: string;
  43653. shader: string;
  43654. };
  43655. }
  43656. declare module BABYLON {
  43657. /** @hidden */
  43658. export var pbrDirectLightingFalloffFunctions: {
  43659. name: string;
  43660. shader: string;
  43661. };
  43662. }
  43663. declare module BABYLON {
  43664. /** @hidden */
  43665. export var pbrBRDFFunctions: {
  43666. name: string;
  43667. shader: string;
  43668. };
  43669. }
  43670. declare module BABYLON {
  43671. /** @hidden */
  43672. export var pbrDirectLightingFunctions: {
  43673. name: string;
  43674. shader: string;
  43675. };
  43676. }
  43677. declare module BABYLON {
  43678. /** @hidden */
  43679. export var pbrIBLFunctions: {
  43680. name: string;
  43681. shader: string;
  43682. };
  43683. }
  43684. declare module BABYLON {
  43685. /** @hidden */
  43686. export var pbrDebug: {
  43687. name: string;
  43688. shader: string;
  43689. };
  43690. }
  43691. declare module BABYLON {
  43692. /** @hidden */
  43693. export var pbrPixelShader: {
  43694. name: string;
  43695. shader: string;
  43696. };
  43697. }
  43698. declare module BABYLON {
  43699. /** @hidden */
  43700. export var pbrVertexDeclaration: {
  43701. name: string;
  43702. shader: string;
  43703. };
  43704. }
  43705. declare module BABYLON {
  43706. /** @hidden */
  43707. export var pbrVertexShader: {
  43708. name: string;
  43709. shader: string;
  43710. };
  43711. }
  43712. declare module BABYLON {
  43713. /**
  43714. * The Physically based material base class of BJS.
  43715. *
  43716. * This offers the main features of a standard PBR material.
  43717. * For more information, please refer to the documentation :
  43718. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43719. */
  43720. export abstract class PBRBaseMaterial extends PushMaterial {
  43721. /**
  43722. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43723. */
  43724. static readonly PBRMATERIAL_OPAQUE: number;
  43725. /**
  43726. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43727. */
  43728. static readonly PBRMATERIAL_ALPHATEST: number;
  43729. /**
  43730. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43731. */
  43732. static readonly PBRMATERIAL_ALPHABLEND: number;
  43733. /**
  43734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43735. * They are also discarded below the alpha cutoff threshold to improve performances.
  43736. */
  43737. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43738. /**
  43739. * Defines the default value of how much AO map is occluding the analytical lights
  43740. * (point spot...).
  43741. */
  43742. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43743. /**
  43744. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43745. */
  43746. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43747. /**
  43748. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43749. * to enhance interoperability with other engines.
  43750. */
  43751. static readonly LIGHTFALLOFF_GLTF: number;
  43752. /**
  43753. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43754. * to enhance interoperability with other materials.
  43755. */
  43756. static readonly LIGHTFALLOFF_STANDARD: number;
  43757. /**
  43758. * Intensity of the direct lights e.g. the four lights available in your scene.
  43759. * This impacts both the direct diffuse and specular highlights.
  43760. */
  43761. protected _directIntensity: number;
  43762. /**
  43763. * Intensity of the emissive part of the material.
  43764. * This helps controlling the emissive effect without modifying the emissive color.
  43765. */
  43766. protected _emissiveIntensity: number;
  43767. /**
  43768. * Intensity of the environment e.g. how much the environment will light the object
  43769. * either through harmonics for rough material or through the refelction for shiny ones.
  43770. */
  43771. protected _environmentIntensity: number;
  43772. /**
  43773. * This is a special control allowing the reduction of the specular highlights coming from the
  43774. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43775. */
  43776. protected _specularIntensity: number;
  43777. /**
  43778. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43779. */
  43780. private _lightingInfos;
  43781. /**
  43782. * Debug Control allowing disabling the bump map on this material.
  43783. */
  43784. protected _disableBumpMap: boolean;
  43785. /**
  43786. * AKA Diffuse Texture in standard nomenclature.
  43787. */
  43788. protected _albedoTexture: BaseTexture;
  43789. /**
  43790. * AKA Occlusion Texture in other nomenclature.
  43791. */
  43792. protected _ambientTexture: BaseTexture;
  43793. /**
  43794. * AKA Occlusion Texture Intensity in other nomenclature.
  43795. */
  43796. protected _ambientTextureStrength: number;
  43797. /**
  43798. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43799. * 1 means it completely occludes it
  43800. * 0 mean it has no impact
  43801. */
  43802. protected _ambientTextureImpactOnAnalyticalLights: number;
  43803. /**
  43804. * Stores the alpha values in a texture.
  43805. */
  43806. protected _opacityTexture: BaseTexture;
  43807. /**
  43808. * Stores the reflection values in a texture.
  43809. */
  43810. protected _reflectionTexture: BaseTexture;
  43811. /**
  43812. * Stores the refraction values in a texture.
  43813. */
  43814. protected _refractionTexture: BaseTexture;
  43815. /**
  43816. * Stores the emissive values in a texture.
  43817. */
  43818. protected _emissiveTexture: BaseTexture;
  43819. /**
  43820. * AKA Specular texture in other nomenclature.
  43821. */
  43822. protected _reflectivityTexture: BaseTexture;
  43823. /**
  43824. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43825. */
  43826. protected _metallicTexture: BaseTexture;
  43827. /**
  43828. * Specifies the metallic scalar of the metallic/roughness workflow.
  43829. * Can also be used to scale the metalness values of the metallic texture.
  43830. */
  43831. protected _metallic: Nullable<number>;
  43832. /**
  43833. * Specifies the roughness scalar of the metallic/roughness workflow.
  43834. * Can also be used to scale the roughness values of the metallic texture.
  43835. */
  43836. protected _roughness: Nullable<number>;
  43837. /**
  43838. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43839. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43840. */
  43841. protected _microSurfaceTexture: BaseTexture;
  43842. /**
  43843. * Stores surface normal data used to displace a mesh in a texture.
  43844. */
  43845. protected _bumpTexture: BaseTexture;
  43846. /**
  43847. * Stores the pre-calculated light information of a mesh in a texture.
  43848. */
  43849. protected _lightmapTexture: BaseTexture;
  43850. /**
  43851. * The color of a material in ambient lighting.
  43852. */
  43853. protected _ambientColor: Color3;
  43854. /**
  43855. * AKA Diffuse Color in other nomenclature.
  43856. */
  43857. protected _albedoColor: Color3;
  43858. /**
  43859. * AKA Specular Color in other nomenclature.
  43860. */
  43861. protected _reflectivityColor: Color3;
  43862. /**
  43863. * The color applied when light is reflected from a material.
  43864. */
  43865. protected _reflectionColor: Color3;
  43866. /**
  43867. * The color applied when light is emitted from a material.
  43868. */
  43869. protected _emissiveColor: Color3;
  43870. /**
  43871. * AKA Glossiness in other nomenclature.
  43872. */
  43873. protected _microSurface: number;
  43874. /**
  43875. * source material index of refraction (IOR)' / 'destination material IOR.
  43876. */
  43877. protected _indexOfRefraction: number;
  43878. /**
  43879. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43880. */
  43881. protected _invertRefractionY: boolean;
  43882. /**
  43883. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43884. * Materials half opaque for instance using refraction could benefit from this control.
  43885. */
  43886. protected _linkRefractionWithTransparency: boolean;
  43887. /**
  43888. * Specifies that the material will use the light map as a show map.
  43889. */
  43890. protected _useLightmapAsShadowmap: boolean;
  43891. /**
  43892. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43893. * makes the reflect vector face the model (under horizon).
  43894. */
  43895. protected _useHorizonOcclusion: boolean;
  43896. /**
  43897. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43898. * too much the area relying on ambient texture to define their ambient occlusion.
  43899. */
  43900. protected _useRadianceOcclusion: boolean;
  43901. /**
  43902. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43903. */
  43904. protected _useAlphaFromAlbedoTexture: boolean;
  43905. /**
  43906. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43907. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43908. */
  43909. protected _useSpecularOverAlpha: boolean;
  43910. /**
  43911. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43912. */
  43913. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43914. /**
  43915. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43916. */
  43917. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43918. /**
  43919. * Specifies if the metallic texture contains the roughness information in its green channel.
  43920. */
  43921. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43922. /**
  43923. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43924. */
  43925. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43926. /**
  43927. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43928. */
  43929. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43930. /**
  43931. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43932. */
  43933. protected _useAmbientInGrayScale: boolean;
  43934. /**
  43935. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43936. * The material will try to infer what glossiness each pixel should be.
  43937. */
  43938. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43939. /**
  43940. * Defines the falloff type used in this material.
  43941. * It by default is Physical.
  43942. */
  43943. protected _lightFalloff: number;
  43944. /**
  43945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43947. */
  43948. protected _useRadianceOverAlpha: boolean;
  43949. /**
  43950. * Allows using an object space normal map (instead of tangent space).
  43951. */
  43952. protected _useObjectSpaceNormalMap: boolean;
  43953. /**
  43954. * Allows using the bump map in parallax mode.
  43955. */
  43956. protected _useParallax: boolean;
  43957. /**
  43958. * Allows using the bump map in parallax occlusion mode.
  43959. */
  43960. protected _useParallaxOcclusion: boolean;
  43961. /**
  43962. * Controls the scale bias of the parallax mode.
  43963. */
  43964. protected _parallaxScaleBias: number;
  43965. /**
  43966. * If sets to true, disables all the lights affecting the material.
  43967. */
  43968. protected _disableLighting: boolean;
  43969. /**
  43970. * Number of Simultaneous lights allowed on the material.
  43971. */
  43972. protected _maxSimultaneousLights: number;
  43973. /**
  43974. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43975. */
  43976. protected _invertNormalMapX: boolean;
  43977. /**
  43978. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43979. */
  43980. protected _invertNormalMapY: boolean;
  43981. /**
  43982. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43983. */
  43984. protected _twoSidedLighting: boolean;
  43985. /**
  43986. * Defines the alpha limits in alpha test mode.
  43987. */
  43988. protected _alphaCutOff: number;
  43989. /**
  43990. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43991. */
  43992. protected _forceAlphaTest: boolean;
  43993. /**
  43994. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43995. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43996. */
  43997. protected _useAlphaFresnel: boolean;
  43998. /**
  43999. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44000. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44001. */
  44002. protected _useLinearAlphaFresnel: boolean;
  44003. /**
  44004. * The transparency mode of the material.
  44005. */
  44006. protected _transparencyMode: Nullable<number>;
  44007. /**
  44008. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44009. * from cos thetav and roughness:
  44010. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44011. */
  44012. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44013. /**
  44014. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44015. */
  44016. protected _forceIrradianceInFragment: boolean;
  44017. /**
  44018. * Force normal to face away from face.
  44019. */
  44020. protected _forceNormalForward: boolean;
  44021. /**
  44022. * Enables specular anti aliasing in the PBR shader.
  44023. * It will both interacts on the Geometry for analytical and IBL lighting.
  44024. * It also prefilter the roughness map based on the bump values.
  44025. */
  44026. protected _enableSpecularAntiAliasing: boolean;
  44027. /**
  44028. * Default configuration related to image processing available in the PBR Material.
  44029. */
  44030. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44031. /**
  44032. * Keep track of the image processing observer to allow dispose and replace.
  44033. */
  44034. private _imageProcessingObserver;
  44035. /**
  44036. * Attaches a new image processing configuration to the PBR Material.
  44037. * @param configuration
  44038. */
  44039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44040. /**
  44041. * Stores the available render targets.
  44042. */
  44043. private _renderTargets;
  44044. /**
  44045. * Sets the global ambient color for the material used in lighting calculations.
  44046. */
  44047. private _globalAmbientColor;
  44048. /**
  44049. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44050. */
  44051. private _useLogarithmicDepth;
  44052. /**
  44053. * If set to true, no lighting calculations will be applied.
  44054. */
  44055. private _unlit;
  44056. private _debugMode;
  44057. /**
  44058. * @hidden
  44059. * This is reserved for the inspector.
  44060. * Defines the material debug mode.
  44061. * It helps seeing only some components of the material while troubleshooting.
  44062. */
  44063. debugMode: number;
  44064. /**
  44065. * @hidden
  44066. * This is reserved for the inspector.
  44067. * Specify from where on screen the debug mode should start.
  44068. * The value goes from -1 (full screen) to 1 (not visible)
  44069. * It helps with side by side comparison against the final render
  44070. * This defaults to -1
  44071. */
  44072. private debugLimit;
  44073. /**
  44074. * @hidden
  44075. * This is reserved for the inspector.
  44076. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44077. * You can use the factor to better multiply the final value.
  44078. */
  44079. private debugFactor;
  44080. /**
  44081. * Defines the clear coat layer parameters for the material.
  44082. */
  44083. readonly clearCoat: PBRClearCoatConfiguration;
  44084. /**
  44085. * Defines the anisotropic parameters for the material.
  44086. */
  44087. readonly anisotropy: PBRAnisotropicConfiguration;
  44088. /**
  44089. * Defines the BRDF parameters for the material.
  44090. */
  44091. readonly brdf: PBRBRDFConfiguration;
  44092. /**
  44093. * Defines the Sheen parameters for the material.
  44094. */
  44095. readonly sheen: PBRSheenConfiguration;
  44096. /**
  44097. * Instantiates a new PBRMaterial instance.
  44098. *
  44099. * @param name The material name
  44100. * @param scene The scene the material will be use in.
  44101. */
  44102. constructor(name: string, scene: Scene);
  44103. /**
  44104. * Gets a boolean indicating that current material needs to register RTT
  44105. */
  44106. readonly hasRenderTargetTextures: boolean;
  44107. /**
  44108. * Gets the name of the material class.
  44109. */
  44110. getClassName(): string;
  44111. /**
  44112. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44113. */
  44114. /**
  44115. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44116. */
  44117. useLogarithmicDepth: boolean;
  44118. /**
  44119. * Gets the current transparency mode.
  44120. */
  44121. /**
  44122. * Sets the transparency mode of the material.
  44123. *
  44124. * | Value | Type | Description |
  44125. * | ----- | ----------------------------------- | ----------- |
  44126. * | 0 | OPAQUE | |
  44127. * | 1 | ALPHATEST | |
  44128. * | 2 | ALPHABLEND | |
  44129. * | 3 | ALPHATESTANDBLEND | |
  44130. *
  44131. */
  44132. transparencyMode: Nullable<number>;
  44133. /**
  44134. * Returns true if alpha blending should be disabled.
  44135. */
  44136. private readonly _disableAlphaBlending;
  44137. /**
  44138. * Specifies whether or not this material should be rendered in alpha blend mode.
  44139. */
  44140. needAlphaBlending(): boolean;
  44141. /**
  44142. * Specifies if the mesh will require alpha blending.
  44143. * @param mesh - BJS mesh.
  44144. */
  44145. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44146. /**
  44147. * Specifies whether or not this material should be rendered in alpha test mode.
  44148. */
  44149. needAlphaTesting(): boolean;
  44150. /**
  44151. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44152. */
  44153. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44154. /**
  44155. * Gets the texture used for the alpha test.
  44156. */
  44157. getAlphaTestTexture(): BaseTexture;
  44158. /**
  44159. * Specifies that the submesh is ready to be used.
  44160. * @param mesh - BJS mesh.
  44161. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44162. * @param useInstances - Specifies that instances should be used.
  44163. * @returns - boolean indicating that the submesh is ready or not.
  44164. */
  44165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44166. /**
  44167. * Specifies if the material uses metallic roughness workflow.
  44168. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44169. */
  44170. isMetallicWorkflow(): boolean;
  44171. private _prepareEffect;
  44172. private _prepareDefines;
  44173. /**
  44174. * Force shader compilation
  44175. */
  44176. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44177. clipPlane: boolean;
  44178. }>): void;
  44179. /**
  44180. * Initializes the uniform buffer layout for the shader.
  44181. */
  44182. buildUniformLayout(): void;
  44183. /**
  44184. * Unbinds the textures.
  44185. */
  44186. unbind(): void;
  44187. /**
  44188. * Binds the submesh data.
  44189. * @param world - The world matrix.
  44190. * @param mesh - The BJS mesh.
  44191. * @param subMesh - A submesh of the BJS mesh.
  44192. */
  44193. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44194. /**
  44195. * Returns the animatable textures.
  44196. * @returns - Array of animatable textures.
  44197. */
  44198. getAnimatables(): IAnimatable[];
  44199. /**
  44200. * Returns the texture used for reflections.
  44201. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44202. */
  44203. private _getReflectionTexture;
  44204. /**
  44205. * Returns the texture used for refraction or null if none is used.
  44206. * @returns - Refection texture if present. If no refraction texture and refraction
  44207. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44208. */
  44209. private _getRefractionTexture;
  44210. /**
  44211. * Returns an array of the actively used textures.
  44212. * @returns - Array of BaseTextures
  44213. */
  44214. getActiveTextures(): BaseTexture[];
  44215. /**
  44216. * Checks to see if a texture is used in the material.
  44217. * @param texture - Base texture to use.
  44218. * @returns - Boolean specifying if a texture is used in the material.
  44219. */
  44220. hasTexture(texture: BaseTexture): boolean;
  44221. /**
  44222. * Disposes the resources of the material.
  44223. * @param forceDisposeEffect - Forces the disposal of effects.
  44224. * @param forceDisposeTextures - Forces the disposal of all textures.
  44225. */
  44226. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44227. }
  44228. }
  44229. declare module BABYLON {
  44230. /**
  44231. * The Physically based material of BJS.
  44232. *
  44233. * This offers the main features of a standard PBR material.
  44234. * For more information, please refer to the documentation :
  44235. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44236. */
  44237. export class PBRMaterial extends PBRBaseMaterial {
  44238. /**
  44239. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44240. */
  44241. static readonly PBRMATERIAL_OPAQUE: number;
  44242. /**
  44243. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44244. */
  44245. static readonly PBRMATERIAL_ALPHATEST: number;
  44246. /**
  44247. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44248. */
  44249. static readonly PBRMATERIAL_ALPHABLEND: number;
  44250. /**
  44251. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44252. * They are also discarded below the alpha cutoff threshold to improve performances.
  44253. */
  44254. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44255. /**
  44256. * Defines the default value of how much AO map is occluding the analytical lights
  44257. * (point spot...).
  44258. */
  44259. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44260. /**
  44261. * Intensity of the direct lights e.g. the four lights available in your scene.
  44262. * This impacts both the direct diffuse and specular highlights.
  44263. */
  44264. directIntensity: number;
  44265. /**
  44266. * Intensity of the emissive part of the material.
  44267. * This helps controlling the emissive effect without modifying the emissive color.
  44268. */
  44269. emissiveIntensity: number;
  44270. /**
  44271. * Intensity of the environment e.g. how much the environment will light the object
  44272. * either through harmonics for rough material or through the refelction for shiny ones.
  44273. */
  44274. environmentIntensity: number;
  44275. /**
  44276. * This is a special control allowing the reduction of the specular highlights coming from the
  44277. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44278. */
  44279. specularIntensity: number;
  44280. /**
  44281. * Debug Control allowing disabling the bump map on this material.
  44282. */
  44283. disableBumpMap: boolean;
  44284. /**
  44285. * AKA Diffuse Texture in standard nomenclature.
  44286. */
  44287. albedoTexture: BaseTexture;
  44288. /**
  44289. * AKA Occlusion Texture in other nomenclature.
  44290. */
  44291. ambientTexture: BaseTexture;
  44292. /**
  44293. * AKA Occlusion Texture Intensity in other nomenclature.
  44294. */
  44295. ambientTextureStrength: number;
  44296. /**
  44297. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44298. * 1 means it completely occludes it
  44299. * 0 mean it has no impact
  44300. */
  44301. ambientTextureImpactOnAnalyticalLights: number;
  44302. /**
  44303. * Stores the alpha values in a texture.
  44304. */
  44305. opacityTexture: BaseTexture;
  44306. /**
  44307. * Stores the reflection values in a texture.
  44308. */
  44309. reflectionTexture: Nullable<BaseTexture>;
  44310. /**
  44311. * Stores the emissive values in a texture.
  44312. */
  44313. emissiveTexture: BaseTexture;
  44314. /**
  44315. * AKA Specular texture in other nomenclature.
  44316. */
  44317. reflectivityTexture: BaseTexture;
  44318. /**
  44319. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44320. */
  44321. metallicTexture: BaseTexture;
  44322. /**
  44323. * Specifies the metallic scalar of the metallic/roughness workflow.
  44324. * Can also be used to scale the metalness values of the metallic texture.
  44325. */
  44326. metallic: Nullable<number>;
  44327. /**
  44328. * Specifies the roughness scalar of the metallic/roughness workflow.
  44329. * Can also be used to scale the roughness values of the metallic texture.
  44330. */
  44331. roughness: Nullable<number>;
  44332. /**
  44333. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44334. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44335. */
  44336. microSurfaceTexture: BaseTexture;
  44337. /**
  44338. * Stores surface normal data used to displace a mesh in a texture.
  44339. */
  44340. bumpTexture: BaseTexture;
  44341. /**
  44342. * Stores the pre-calculated light information of a mesh in a texture.
  44343. */
  44344. lightmapTexture: BaseTexture;
  44345. /**
  44346. * Stores the refracted light information in a texture.
  44347. */
  44348. refractionTexture: BaseTexture;
  44349. /**
  44350. * The color of a material in ambient lighting.
  44351. */
  44352. ambientColor: Color3;
  44353. /**
  44354. * AKA Diffuse Color in other nomenclature.
  44355. */
  44356. albedoColor: Color3;
  44357. /**
  44358. * AKA Specular Color in other nomenclature.
  44359. */
  44360. reflectivityColor: Color3;
  44361. /**
  44362. * The color reflected from the material.
  44363. */
  44364. reflectionColor: Color3;
  44365. /**
  44366. * The color emitted from the material.
  44367. */
  44368. emissiveColor: Color3;
  44369. /**
  44370. * AKA Glossiness in other nomenclature.
  44371. */
  44372. microSurface: number;
  44373. /**
  44374. * source material index of refraction (IOR)' / 'destination material IOR.
  44375. */
  44376. indexOfRefraction: number;
  44377. /**
  44378. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44379. */
  44380. invertRefractionY: boolean;
  44381. /**
  44382. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44383. * Materials half opaque for instance using refraction could benefit from this control.
  44384. */
  44385. linkRefractionWithTransparency: boolean;
  44386. /**
  44387. * If true, the light map contains occlusion information instead of lighting info.
  44388. */
  44389. useLightmapAsShadowmap: boolean;
  44390. /**
  44391. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44392. */
  44393. useAlphaFromAlbedoTexture: boolean;
  44394. /**
  44395. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44396. */
  44397. forceAlphaTest: boolean;
  44398. /**
  44399. * Defines the alpha limits in alpha test mode.
  44400. */
  44401. alphaCutOff: number;
  44402. /**
  44403. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44404. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44405. */
  44406. useSpecularOverAlpha: boolean;
  44407. /**
  44408. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44409. */
  44410. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44411. /**
  44412. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44413. */
  44414. useRoughnessFromMetallicTextureAlpha: boolean;
  44415. /**
  44416. * Specifies if the metallic texture contains the roughness information in its green channel.
  44417. */
  44418. useRoughnessFromMetallicTextureGreen: boolean;
  44419. /**
  44420. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44421. */
  44422. useMetallnessFromMetallicTextureBlue: boolean;
  44423. /**
  44424. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44425. */
  44426. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44427. /**
  44428. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44429. */
  44430. useAmbientInGrayScale: boolean;
  44431. /**
  44432. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44433. * The material will try to infer what glossiness each pixel should be.
  44434. */
  44435. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44436. /**
  44437. * BJS is using an harcoded light falloff based on a manually sets up range.
  44438. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44439. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44440. */
  44441. /**
  44442. * BJS is using an harcoded light falloff based on a manually sets up range.
  44443. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44444. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44445. */
  44446. usePhysicalLightFalloff: boolean;
  44447. /**
  44448. * In order to support the falloff compatibility with gltf, a special mode has been added
  44449. * to reproduce the gltf light falloff.
  44450. */
  44451. /**
  44452. * In order to support the falloff compatibility with gltf, a special mode has been added
  44453. * to reproduce the gltf light falloff.
  44454. */
  44455. useGLTFLightFalloff: boolean;
  44456. /**
  44457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44459. */
  44460. useRadianceOverAlpha: boolean;
  44461. /**
  44462. * Allows using an object space normal map (instead of tangent space).
  44463. */
  44464. useObjectSpaceNormalMap: boolean;
  44465. /**
  44466. * Allows using the bump map in parallax mode.
  44467. */
  44468. useParallax: boolean;
  44469. /**
  44470. * Allows using the bump map in parallax occlusion mode.
  44471. */
  44472. useParallaxOcclusion: boolean;
  44473. /**
  44474. * Controls the scale bias of the parallax mode.
  44475. */
  44476. parallaxScaleBias: number;
  44477. /**
  44478. * If sets to true, disables all the lights affecting the material.
  44479. */
  44480. disableLighting: boolean;
  44481. /**
  44482. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44483. */
  44484. forceIrradianceInFragment: boolean;
  44485. /**
  44486. * Number of Simultaneous lights allowed on the material.
  44487. */
  44488. maxSimultaneousLights: number;
  44489. /**
  44490. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44491. */
  44492. invertNormalMapX: boolean;
  44493. /**
  44494. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44495. */
  44496. invertNormalMapY: boolean;
  44497. /**
  44498. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44499. */
  44500. twoSidedLighting: boolean;
  44501. /**
  44502. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44503. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44504. */
  44505. useAlphaFresnel: boolean;
  44506. /**
  44507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44508. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44509. */
  44510. useLinearAlphaFresnel: boolean;
  44511. /**
  44512. * Let user defines the brdf lookup texture used for IBL.
  44513. * A default 8bit version is embedded but you could point at :
  44514. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44515. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44516. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44517. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44518. */
  44519. environmentBRDFTexture: Nullable<BaseTexture>;
  44520. /**
  44521. * Force normal to face away from face.
  44522. */
  44523. forceNormalForward: boolean;
  44524. /**
  44525. * Enables specular anti aliasing in the PBR shader.
  44526. * It will both interacts on the Geometry for analytical and IBL lighting.
  44527. * It also prefilter the roughness map based on the bump values.
  44528. */
  44529. enableSpecularAntiAliasing: boolean;
  44530. /**
  44531. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44532. * makes the reflect vector face the model (under horizon).
  44533. */
  44534. useHorizonOcclusion: boolean;
  44535. /**
  44536. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44537. * too much the area relying on ambient texture to define their ambient occlusion.
  44538. */
  44539. useRadianceOcclusion: boolean;
  44540. /**
  44541. * If set to true, no lighting calculations will be applied.
  44542. */
  44543. unlit: boolean;
  44544. /**
  44545. * Gets the image processing configuration used either in this material.
  44546. */
  44547. /**
  44548. * Sets the Default image processing configuration used either in the this material.
  44549. *
  44550. * If sets to null, the scene one is in use.
  44551. */
  44552. imageProcessingConfiguration: ImageProcessingConfiguration;
  44553. /**
  44554. * Gets wether the color curves effect is enabled.
  44555. */
  44556. /**
  44557. * Sets wether the color curves effect is enabled.
  44558. */
  44559. cameraColorCurvesEnabled: boolean;
  44560. /**
  44561. * Gets wether the color grading effect is enabled.
  44562. */
  44563. /**
  44564. * Gets wether the color grading effect is enabled.
  44565. */
  44566. cameraColorGradingEnabled: boolean;
  44567. /**
  44568. * Gets wether tonemapping is enabled or not.
  44569. */
  44570. /**
  44571. * Sets wether tonemapping is enabled or not
  44572. */
  44573. cameraToneMappingEnabled: boolean;
  44574. /**
  44575. * The camera exposure used on this material.
  44576. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44577. * This corresponds to a photographic exposure.
  44578. */
  44579. /**
  44580. * The camera exposure used on this material.
  44581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44582. * This corresponds to a photographic exposure.
  44583. */
  44584. cameraExposure: number;
  44585. /**
  44586. * Gets The camera contrast used on this material.
  44587. */
  44588. /**
  44589. * Sets The camera contrast used on this material.
  44590. */
  44591. cameraContrast: number;
  44592. /**
  44593. * Gets the Color Grading 2D Lookup Texture.
  44594. */
  44595. /**
  44596. * Sets the Color Grading 2D Lookup Texture.
  44597. */
  44598. cameraColorGradingTexture: Nullable<BaseTexture>;
  44599. /**
  44600. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44601. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44602. * 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;
  44603. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44604. */
  44605. /**
  44606. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44607. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44608. * 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;
  44609. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44610. */
  44611. cameraColorCurves: Nullable<ColorCurves>;
  44612. /**
  44613. * Instantiates a new PBRMaterial instance.
  44614. *
  44615. * @param name The material name
  44616. * @param scene The scene the material will be use in.
  44617. */
  44618. constructor(name: string, scene: Scene);
  44619. /**
  44620. * Returns the name of this material class.
  44621. */
  44622. getClassName(): string;
  44623. /**
  44624. * Makes a duplicate of the current material.
  44625. * @param name - name to use for the new material.
  44626. */
  44627. clone(name: string): PBRMaterial;
  44628. /**
  44629. * Serializes this PBR Material.
  44630. * @returns - An object with the serialized material.
  44631. */
  44632. serialize(): any;
  44633. /**
  44634. * Parses a PBR Material from a serialized object.
  44635. * @param source - Serialized object.
  44636. * @param scene - BJS scene instance.
  44637. * @param rootUrl - url for the scene object
  44638. * @returns - PBRMaterial
  44639. */
  44640. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44641. }
  44642. }
  44643. declare module BABYLON {
  44644. /**
  44645. * Direct draw surface info
  44646. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  44647. */
  44648. export interface DDSInfo {
  44649. /**
  44650. * Width of the texture
  44651. */
  44652. width: number;
  44653. /**
  44654. * Width of the texture
  44655. */
  44656. height: number;
  44657. /**
  44658. * Number of Mipmaps for the texture
  44659. * @see https://en.wikipedia.org/wiki/Mipmap
  44660. */
  44661. mipmapCount: number;
  44662. /**
  44663. * If the textures format is a known fourCC format
  44664. * @see https://www.fourcc.org/
  44665. */
  44666. isFourCC: boolean;
  44667. /**
  44668. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  44669. */
  44670. isRGB: boolean;
  44671. /**
  44672. * If the texture is a lumincance format
  44673. */
  44674. isLuminance: boolean;
  44675. /**
  44676. * If this is a cube texture
  44677. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  44678. */
  44679. isCube: boolean;
  44680. /**
  44681. * If the texture is a compressed format eg. FOURCC_DXT1
  44682. */
  44683. isCompressed: boolean;
  44684. /**
  44685. * The dxgiFormat of the texture
  44686. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  44687. */
  44688. dxgiFormat: number;
  44689. /**
  44690. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  44691. */
  44692. textureType: number;
  44693. /**
  44694. * Sphericle polynomial created for the dds texture
  44695. */
  44696. sphericalPolynomial?: SphericalPolynomial;
  44697. }
  44698. /**
  44699. * Class used to provide DDS decompression tools
  44700. */
  44701. export class DDSTools {
  44702. /**
  44703. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  44704. */
  44705. static StoreLODInAlphaChannel: boolean;
  44706. /**
  44707. * Gets DDS information from an array buffer
  44708. * @param arrayBuffer defines the array buffer to read data from
  44709. * @returns the DDS information
  44710. */
  44711. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  44712. private static _FloatView;
  44713. private static _Int32View;
  44714. private static _ToHalfFloat;
  44715. private static _FromHalfFloat;
  44716. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  44717. private static _GetHalfFloatRGBAArrayBuffer;
  44718. private static _GetFloatRGBAArrayBuffer;
  44719. private static _GetFloatAsUIntRGBAArrayBuffer;
  44720. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  44721. private static _GetRGBAArrayBuffer;
  44722. private static _ExtractLongWordOrder;
  44723. private static _GetRGBArrayBuffer;
  44724. private static _GetLuminanceArrayBuffer;
  44725. /**
  44726. * Uploads DDS Levels to a Babylon Texture
  44727. * @hidden
  44728. */
  44729. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  44730. }
  44731. interface Engine {
  44732. /**
  44733. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  44734. * @param rootUrl defines the url where the file to load is located
  44735. * @param scene defines the current scene
  44736. * @param lodScale defines scale to apply to the mip map selection
  44737. * @param lodOffset defines offset to apply to the mip map selection
  44738. * @param onLoad defines an optional callback raised when the texture is loaded
  44739. * @param onError defines an optional callback raised if there is an issue to load the texture
  44740. * @param format defines the format of the data
  44741. * @param forcedExtension defines the extension to use to pick the right loader
  44742. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  44743. * @returns the cube texture as an InternalTexture
  44744. */
  44745. 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;
  44746. }
  44747. }
  44748. declare module BABYLON {
  44749. /**
  44750. * Implementation of the DDS Texture Loader.
  44751. * @hidden
  44752. */
  44753. export class _DDSTextureLoader implements IInternalTextureLoader {
  44754. /**
  44755. * Defines wether the loader supports cascade loading the different faces.
  44756. */
  44757. readonly supportCascades: boolean;
  44758. /**
  44759. * This returns if the loader support the current file information.
  44760. * @param extension defines the file extension of the file being loaded
  44761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44762. * @param fallback defines the fallback internal texture if any
  44763. * @param isBase64 defines whether the texture is encoded as a base64
  44764. * @param isBuffer defines whether the texture data are stored as a buffer
  44765. * @returns true if the loader can load the specified file
  44766. */
  44767. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  44768. /**
  44769. * Transform the url before loading if required.
  44770. * @param rootUrl the url of the texture
  44771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44772. * @returns the transformed texture
  44773. */
  44774. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  44775. /**
  44776. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  44777. * @param rootUrl the url of the texture
  44778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44779. * @returns the fallback texture
  44780. */
  44781. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  44782. /**
  44783. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  44784. * @param data contains the texture data
  44785. * @param texture defines the BabylonJS internal texture
  44786. * @param createPolynomials will be true if polynomials have been requested
  44787. * @param onLoad defines the callback to trigger once the texture is ready
  44788. * @param onError defines the callback to trigger in case of error
  44789. */
  44790. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  44791. /**
  44792. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  44793. * @param data contains the texture data
  44794. * @param texture defines the BabylonJS internal texture
  44795. * @param callback defines the method to call once ready to upload
  44796. */
  44797. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. /** @hidden */
  44802. export var rgbdEncodePixelShader: {
  44803. name: string;
  44804. shader: string;
  44805. };
  44806. }
  44807. declare module BABYLON {
  44808. /** @hidden */
  44809. export var rgbdDecodePixelShader: {
  44810. name: string;
  44811. shader: string;
  44812. };
  44813. }
  44814. declare module BABYLON {
  44815. /**
  44816. * Raw texture data and descriptor sufficient for WebGL texture upload
  44817. */
  44818. export interface EnvironmentTextureInfo {
  44819. /**
  44820. * Version of the environment map
  44821. */
  44822. version: number;
  44823. /**
  44824. * Width of image
  44825. */
  44826. width: number;
  44827. /**
  44828. * Irradiance information stored in the file.
  44829. */
  44830. irradiance: any;
  44831. /**
  44832. * Specular information stored in the file.
  44833. */
  44834. specular: any;
  44835. }
  44836. /**
  44837. * Sets of helpers addressing the serialization and deserialization of environment texture
  44838. * stored in a BabylonJS env file.
  44839. * Those files are usually stored as .env files.
  44840. */
  44841. export class EnvironmentTextureTools {
  44842. /**
  44843. * Magic number identifying the env file.
  44844. */
  44845. private static _MagicBytes;
  44846. /**
  44847. * Gets the environment info from an env file.
  44848. * @param data The array buffer containing the .env bytes.
  44849. * @returns the environment file info (the json header) if successfully parsed.
  44850. */
  44851. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44852. /**
  44853. * Creates an environment texture from a loaded cube texture.
  44854. * @param texture defines the cube texture to convert in env file
  44855. * @return a promise containing the environment data if succesfull.
  44856. */
  44857. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44858. /**
  44859. * Creates a JSON representation of the spherical data.
  44860. * @param texture defines the texture containing the polynomials
  44861. * @return the JSON representation of the spherical info
  44862. */
  44863. private static _CreateEnvTextureIrradiance;
  44864. /**
  44865. * Uploads the texture info contained in the env file to the GPU.
  44866. * @param texture defines the internal texture to upload to
  44867. * @param arrayBuffer defines the buffer cotaining the data to load
  44868. * @param info defines the texture info retrieved through the GetEnvInfo method
  44869. * @returns a promise
  44870. */
  44871. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44872. /**
  44873. * Uploads the levels of image data to the GPU.
  44874. * @param texture defines the internal texture to upload to
  44875. * @param imageData defines the array buffer views of image data [mipmap][face]
  44876. * @returns a promise
  44877. */
  44878. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44879. /**
  44880. * Uploads spherical polynomials information to the texture.
  44881. * @param texture defines the texture we are trying to upload the information to
  44882. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44883. */
  44884. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44885. /** @hidden */
  44886. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44887. }
  44888. }
  44889. declare module BABYLON {
  44890. /**
  44891. * Implementation of the ENV Texture Loader.
  44892. * @hidden
  44893. */
  44894. export class _ENVTextureLoader implements IInternalTextureLoader {
  44895. /**
  44896. * Defines wether the loader supports cascade loading the different faces.
  44897. */
  44898. readonly supportCascades: boolean;
  44899. /**
  44900. * This returns if the loader support the current file information.
  44901. * @param extension defines the file extension of the file being loaded
  44902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44903. * @param fallback defines the fallback internal texture if any
  44904. * @param isBase64 defines whether the texture is encoded as a base64
  44905. * @param isBuffer defines whether the texture data are stored as a buffer
  44906. * @returns true if the loader can load the specified file
  44907. */
  44908. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  44909. /**
  44910. * Transform the url before loading if required.
  44911. * @param rootUrl the url of the texture
  44912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44913. * @returns the transformed texture
  44914. */
  44915. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  44916. /**
  44917. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  44918. * @param rootUrl the url of the texture
  44919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44920. * @returns the fallback texture
  44921. */
  44922. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  44923. /**
  44924. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  44925. * @param data contains the texture data
  44926. * @param texture defines the BabylonJS internal texture
  44927. * @param createPolynomials will be true if polynomials have been requested
  44928. * @param onLoad defines the callback to trigger once the texture is ready
  44929. * @param onError defines the callback to trigger in case of error
  44930. */
  44931. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  44932. /**
  44933. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  44934. * @param data contains the texture data
  44935. * @param texture defines the BabylonJS internal texture
  44936. * @param callback defines the method to call once ready to upload
  44937. */
  44938. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  44939. }
  44940. }
  44941. declare module BABYLON {
  44942. /**
  44943. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  44944. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  44945. */
  44946. export class KhronosTextureContainer {
  44947. /** contents of the KTX container file */
  44948. arrayBuffer: any;
  44949. private static HEADER_LEN;
  44950. private static COMPRESSED_2D;
  44951. private static COMPRESSED_3D;
  44952. private static TEX_2D;
  44953. private static TEX_3D;
  44954. /**
  44955. * Gets the openGL type
  44956. */
  44957. glType: number;
  44958. /**
  44959. * Gets the openGL type size
  44960. */
  44961. glTypeSize: number;
  44962. /**
  44963. * Gets the openGL format
  44964. */
  44965. glFormat: number;
  44966. /**
  44967. * Gets the openGL internal format
  44968. */
  44969. glInternalFormat: number;
  44970. /**
  44971. * Gets the base internal format
  44972. */
  44973. glBaseInternalFormat: number;
  44974. /**
  44975. * Gets image width in pixel
  44976. */
  44977. pixelWidth: number;
  44978. /**
  44979. * Gets image height in pixel
  44980. */
  44981. pixelHeight: number;
  44982. /**
  44983. * Gets image depth in pixels
  44984. */
  44985. pixelDepth: number;
  44986. /**
  44987. * Gets the number of array elements
  44988. */
  44989. numberOfArrayElements: number;
  44990. /**
  44991. * Gets the number of faces
  44992. */
  44993. numberOfFaces: number;
  44994. /**
  44995. * Gets the number of mipmap levels
  44996. */
  44997. numberOfMipmapLevels: number;
  44998. /**
  44999. * Gets the bytes of key value data
  45000. */
  45001. bytesOfKeyValueData: number;
  45002. /**
  45003. * Gets the load type
  45004. */
  45005. loadType: number;
  45006. /**
  45007. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45008. */
  45009. isInvalid: boolean;
  45010. /**
  45011. * Creates a new KhronosTextureContainer
  45012. * @param arrayBuffer contents of the KTX container file
  45013. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45014. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45015. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45016. */
  45017. constructor(
  45018. /** contents of the KTX container file */
  45019. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45020. /**
  45021. * Uploads KTX content to a Babylon Texture.
  45022. * It is assumed that the texture has already been created & is currently bound
  45023. * @hidden
  45024. */
  45025. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45026. private _upload2DCompressedLevels;
  45027. }
  45028. }
  45029. declare module BABYLON {
  45030. /**
  45031. * Implementation of the KTX Texture Loader.
  45032. * @hidden
  45033. */
  45034. export class _KTXTextureLoader implements IInternalTextureLoader {
  45035. /**
  45036. * Defines wether the loader supports cascade loading the different faces.
  45037. */
  45038. readonly supportCascades: boolean;
  45039. /**
  45040. * This returns if the loader support the current file information.
  45041. * @param extension defines the file extension of the file being loaded
  45042. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45043. * @param fallback defines the fallback internal texture if any
  45044. * @param isBase64 defines whether the texture is encoded as a base64
  45045. * @param isBuffer defines whether the texture data are stored as a buffer
  45046. * @returns true if the loader can load the specified file
  45047. */
  45048. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45049. /**
  45050. * Transform the url before loading if required.
  45051. * @param rootUrl the url of the texture
  45052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45053. * @returns the transformed texture
  45054. */
  45055. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45056. /**
  45057. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45058. * @param rootUrl the url of the texture
  45059. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45060. * @returns the fallback texture
  45061. */
  45062. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45063. /**
  45064. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45065. * @param data contains the texture data
  45066. * @param texture defines the BabylonJS internal texture
  45067. * @param createPolynomials will be true if polynomials have been requested
  45068. * @param onLoad defines the callback to trigger once the texture is ready
  45069. * @param onError defines the callback to trigger in case of error
  45070. */
  45071. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45072. /**
  45073. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45074. * @param data contains the texture data
  45075. * @param texture defines the BabylonJS internal texture
  45076. * @param callback defines the method to call once ready to upload
  45077. */
  45078. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45079. }
  45080. }
  45081. declare module BABYLON {
  45082. /** @hidden */
  45083. export var _forceSceneHelpersToBundle: boolean;
  45084. interface Scene {
  45085. /**
  45086. * Creates a default light for the scene.
  45087. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45088. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45089. */
  45090. createDefaultLight(replace?: boolean): void;
  45091. /**
  45092. * Creates a default camera for the scene.
  45093. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45094. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45095. * @param replace has default false, when true replaces the active camera in the scene
  45096. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45097. */
  45098. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45099. /**
  45100. * Creates a default camera and a default light.
  45101. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45102. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45103. * @param replace has the default false, when true replaces the active camera/light in the scene
  45104. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45105. */
  45106. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45107. /**
  45108. * Creates a new sky box
  45109. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45110. * @param environmentTexture defines the texture to use as environment texture
  45111. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45112. * @param scale defines the overall scale of the skybox
  45113. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45114. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45115. * @returns a new mesh holding the sky box
  45116. */
  45117. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45118. /**
  45119. * Creates a new environment
  45120. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45121. * @param options defines the options you can use to configure the environment
  45122. * @returns the new EnvironmentHelper
  45123. */
  45124. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45125. /**
  45126. * Creates a new VREXperienceHelper
  45127. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45128. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45129. * @returns a new VREXperienceHelper
  45130. */
  45131. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45132. /**
  45133. * Creates a new XREXperienceHelper
  45134. * @see http://doc.babylonjs.com/how_to/webxr
  45135. * @returns a promise for a new XREXperienceHelper
  45136. */
  45137. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45138. }
  45139. }
  45140. declare module BABYLON {
  45141. /**
  45142. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45143. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45144. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45145. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45146. */
  45147. export class VideoDome extends TransformNode {
  45148. /**
  45149. * Define the video source as a Monoscopic panoramic 360 video.
  45150. */
  45151. static readonly MODE_MONOSCOPIC: number;
  45152. /**
  45153. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45154. */
  45155. static readonly MODE_TOPBOTTOM: number;
  45156. /**
  45157. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45158. */
  45159. static readonly MODE_SIDEBYSIDE: number;
  45160. private _useDirectMapping;
  45161. /**
  45162. * The video texture being displayed on the sphere
  45163. */
  45164. protected _videoTexture: VideoTexture;
  45165. /**
  45166. * Gets the video texture being displayed on the sphere
  45167. */
  45168. readonly videoTexture: VideoTexture;
  45169. /**
  45170. * The skybox material
  45171. */
  45172. protected _material: BackgroundMaterial;
  45173. /**
  45174. * The surface used for the skybox
  45175. */
  45176. protected _mesh: Mesh;
  45177. /**
  45178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45179. * Also see the options.resolution property.
  45180. */
  45181. fovMultiplier: number;
  45182. private _videoMode;
  45183. /**
  45184. * Gets or set the current video mode for the video. It can be:
  45185. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45186. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45187. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45188. */
  45189. videoMode: number;
  45190. /**
  45191. * Oberserver used in Stereoscopic VR Mode.
  45192. */
  45193. private _onBeforeCameraRenderObserver;
  45194. /**
  45195. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45196. * @param name Element's name, child elements will append suffixes for their own names.
  45197. * @param urlsOrVideo defines the url(s) or the video element to use
  45198. * @param options An object containing optional or exposed sub element properties
  45199. */
  45200. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45201. resolution?: number;
  45202. clickToPlay?: boolean;
  45203. autoPlay?: boolean;
  45204. loop?: boolean;
  45205. size?: number;
  45206. poster?: string;
  45207. faceForward?: boolean;
  45208. useDirectMapping?: boolean;
  45209. }, scene: Scene);
  45210. private _changeVideoMode;
  45211. /**
  45212. * Releases resources associated with this node.
  45213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45215. */
  45216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45217. }
  45218. }
  45219. declare module BABYLON {
  45220. /**
  45221. * This class can be used to get instrumentation data from a Babylon engine
  45222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45223. */
  45224. export class EngineInstrumentation implements IDisposable {
  45225. /**
  45226. * Define the instrumented engine.
  45227. */
  45228. engine: Engine;
  45229. private _captureGPUFrameTime;
  45230. private _gpuFrameTimeToken;
  45231. private _gpuFrameTime;
  45232. private _captureShaderCompilationTime;
  45233. private _shaderCompilationTime;
  45234. private _onBeginFrameObserver;
  45235. private _onEndFrameObserver;
  45236. private _onBeforeShaderCompilationObserver;
  45237. private _onAfterShaderCompilationObserver;
  45238. /**
  45239. * Gets the perf counter used for GPU frame time
  45240. */
  45241. readonly gpuFrameTimeCounter: PerfCounter;
  45242. /**
  45243. * Gets the GPU frame time capture status
  45244. */
  45245. /**
  45246. * Enable or disable the GPU frame time capture
  45247. */
  45248. captureGPUFrameTime: boolean;
  45249. /**
  45250. * Gets the perf counter used for shader compilation time
  45251. */
  45252. readonly shaderCompilationTimeCounter: PerfCounter;
  45253. /**
  45254. * Gets the shader compilation time capture status
  45255. */
  45256. /**
  45257. * Enable or disable the shader compilation time capture
  45258. */
  45259. captureShaderCompilationTime: boolean;
  45260. /**
  45261. * Instantiates a new engine instrumentation.
  45262. * This class can be used to get instrumentation data from a Babylon engine
  45263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45264. * @param engine Defines the engine to instrument
  45265. */
  45266. constructor(
  45267. /**
  45268. * Define the instrumented engine.
  45269. */
  45270. engine: Engine);
  45271. /**
  45272. * Dispose and release associated resources.
  45273. */
  45274. dispose(): void;
  45275. }
  45276. }
  45277. declare module BABYLON {
  45278. /**
  45279. * This class can be used to get instrumentation data from a Babylon engine
  45280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45281. */
  45282. export class SceneInstrumentation implements IDisposable {
  45283. /**
  45284. * Defines the scene to instrument
  45285. */
  45286. scene: Scene;
  45287. private _captureActiveMeshesEvaluationTime;
  45288. private _activeMeshesEvaluationTime;
  45289. private _captureRenderTargetsRenderTime;
  45290. private _renderTargetsRenderTime;
  45291. private _captureFrameTime;
  45292. private _frameTime;
  45293. private _captureRenderTime;
  45294. private _renderTime;
  45295. private _captureInterFrameTime;
  45296. private _interFrameTime;
  45297. private _captureParticlesRenderTime;
  45298. private _particlesRenderTime;
  45299. private _captureSpritesRenderTime;
  45300. private _spritesRenderTime;
  45301. private _capturePhysicsTime;
  45302. private _physicsTime;
  45303. private _captureAnimationsTime;
  45304. private _animationsTime;
  45305. private _captureCameraRenderTime;
  45306. private _cameraRenderTime;
  45307. private _onBeforeActiveMeshesEvaluationObserver;
  45308. private _onAfterActiveMeshesEvaluationObserver;
  45309. private _onBeforeRenderTargetsRenderObserver;
  45310. private _onAfterRenderTargetsRenderObserver;
  45311. private _onAfterRenderObserver;
  45312. private _onBeforeDrawPhaseObserver;
  45313. private _onAfterDrawPhaseObserver;
  45314. private _onBeforeAnimationsObserver;
  45315. private _onBeforeParticlesRenderingObserver;
  45316. private _onAfterParticlesRenderingObserver;
  45317. private _onBeforeSpritesRenderingObserver;
  45318. private _onAfterSpritesRenderingObserver;
  45319. private _onBeforePhysicsObserver;
  45320. private _onAfterPhysicsObserver;
  45321. private _onAfterAnimationsObserver;
  45322. private _onBeforeCameraRenderObserver;
  45323. private _onAfterCameraRenderObserver;
  45324. /**
  45325. * Gets the perf counter used for active meshes evaluation time
  45326. */
  45327. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45328. /**
  45329. * Gets the active meshes evaluation time capture status
  45330. */
  45331. /**
  45332. * Enable or disable the active meshes evaluation time capture
  45333. */
  45334. captureActiveMeshesEvaluationTime: boolean;
  45335. /**
  45336. * Gets the perf counter used for render targets render time
  45337. */
  45338. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45339. /**
  45340. * Gets the render targets render time capture status
  45341. */
  45342. /**
  45343. * Enable or disable the render targets render time capture
  45344. */
  45345. captureRenderTargetsRenderTime: boolean;
  45346. /**
  45347. * Gets the perf counter used for particles render time
  45348. */
  45349. readonly particlesRenderTimeCounter: PerfCounter;
  45350. /**
  45351. * Gets the particles render time capture status
  45352. */
  45353. /**
  45354. * Enable or disable the particles render time capture
  45355. */
  45356. captureParticlesRenderTime: boolean;
  45357. /**
  45358. * Gets the perf counter used for sprites render time
  45359. */
  45360. readonly spritesRenderTimeCounter: PerfCounter;
  45361. /**
  45362. * Gets the sprites render time capture status
  45363. */
  45364. /**
  45365. * Enable or disable the sprites render time capture
  45366. */
  45367. captureSpritesRenderTime: boolean;
  45368. /**
  45369. * Gets the perf counter used for physics time
  45370. */
  45371. readonly physicsTimeCounter: PerfCounter;
  45372. /**
  45373. * Gets the physics time capture status
  45374. */
  45375. /**
  45376. * Enable or disable the physics time capture
  45377. */
  45378. capturePhysicsTime: boolean;
  45379. /**
  45380. * Gets the perf counter used for animations time
  45381. */
  45382. readonly animationsTimeCounter: PerfCounter;
  45383. /**
  45384. * Gets the animations time capture status
  45385. */
  45386. /**
  45387. * Enable or disable the animations time capture
  45388. */
  45389. captureAnimationsTime: boolean;
  45390. /**
  45391. * Gets the perf counter used for frame time capture
  45392. */
  45393. readonly frameTimeCounter: PerfCounter;
  45394. /**
  45395. * Gets the frame time capture status
  45396. */
  45397. /**
  45398. * Enable or disable the frame time capture
  45399. */
  45400. captureFrameTime: boolean;
  45401. /**
  45402. * Gets the perf counter used for inter-frames time capture
  45403. */
  45404. readonly interFrameTimeCounter: PerfCounter;
  45405. /**
  45406. * Gets the inter-frames time capture status
  45407. */
  45408. /**
  45409. * Enable or disable the inter-frames time capture
  45410. */
  45411. captureInterFrameTime: boolean;
  45412. /**
  45413. * Gets the perf counter used for render time capture
  45414. */
  45415. readonly renderTimeCounter: PerfCounter;
  45416. /**
  45417. * Gets the render time capture status
  45418. */
  45419. /**
  45420. * Enable or disable the render time capture
  45421. */
  45422. captureRenderTime: boolean;
  45423. /**
  45424. * Gets the perf counter used for camera render time capture
  45425. */
  45426. readonly cameraRenderTimeCounter: PerfCounter;
  45427. /**
  45428. * Gets the camera render time capture status
  45429. */
  45430. /**
  45431. * Enable or disable the camera render time capture
  45432. */
  45433. captureCameraRenderTime: boolean;
  45434. /**
  45435. * Gets the perf counter used for draw calls
  45436. */
  45437. readonly drawCallsCounter: PerfCounter;
  45438. /**
  45439. * Gets the perf counter used for texture collisions
  45440. */
  45441. readonly textureCollisionsCounter: PerfCounter;
  45442. /**
  45443. * Instantiates a new scene instrumentation.
  45444. * This class can be used to get instrumentation data from a Babylon engine
  45445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45446. * @param scene Defines the scene to instrument
  45447. */
  45448. constructor(
  45449. /**
  45450. * Defines the scene to instrument
  45451. */
  45452. scene: Scene);
  45453. /**
  45454. * Dispose and release associated resources.
  45455. */
  45456. dispose(): void;
  45457. }
  45458. }
  45459. declare module BABYLON {
  45460. /** @hidden */
  45461. export var glowMapGenerationPixelShader: {
  45462. name: string;
  45463. shader: string;
  45464. };
  45465. }
  45466. declare module BABYLON {
  45467. /** @hidden */
  45468. export var glowMapGenerationVertexShader: {
  45469. name: string;
  45470. shader: string;
  45471. };
  45472. }
  45473. declare module BABYLON {
  45474. /**
  45475. * Effect layer options. This helps customizing the behaviour
  45476. * of the effect layer.
  45477. */
  45478. export interface IEffectLayerOptions {
  45479. /**
  45480. * Multiplication factor apply to the canvas size to compute the render target size
  45481. * used to generated the objects (the smaller the faster).
  45482. */
  45483. mainTextureRatio: number;
  45484. /**
  45485. * Enforces a fixed size texture to ensure effect stability across devices.
  45486. */
  45487. mainTextureFixedSize?: number;
  45488. /**
  45489. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45490. */
  45491. alphaBlendingMode: number;
  45492. /**
  45493. * The camera attached to the layer.
  45494. */
  45495. camera: Nullable<Camera>;
  45496. /**
  45497. * The rendering group to draw the layer in.
  45498. */
  45499. renderingGroupId: number;
  45500. }
  45501. /**
  45502. * The effect layer Helps adding post process effect blended with the main pass.
  45503. *
  45504. * This can be for instance use to generate glow or higlight effects on the scene.
  45505. *
  45506. * The effect layer class can not be used directly and is intented to inherited from to be
  45507. * customized per effects.
  45508. */
  45509. export abstract class EffectLayer {
  45510. private _vertexBuffers;
  45511. private _indexBuffer;
  45512. private _cachedDefines;
  45513. private _effectLayerMapGenerationEffect;
  45514. private _effectLayerOptions;
  45515. private _mergeEffect;
  45516. protected _scene: Scene;
  45517. protected _engine: Engine;
  45518. protected _maxSize: number;
  45519. protected _mainTextureDesiredSize: ISize;
  45520. protected _mainTexture: RenderTargetTexture;
  45521. protected _shouldRender: boolean;
  45522. protected _postProcesses: PostProcess[];
  45523. protected _textures: BaseTexture[];
  45524. protected _emissiveTextureAndColor: {
  45525. texture: Nullable<BaseTexture>;
  45526. color: Color4;
  45527. };
  45528. /**
  45529. * The name of the layer
  45530. */
  45531. name: string;
  45532. /**
  45533. * The clear color of the texture used to generate the glow map.
  45534. */
  45535. neutralColor: Color4;
  45536. /**
  45537. * Specifies wether the highlight layer is enabled or not.
  45538. */
  45539. isEnabled: boolean;
  45540. /**
  45541. * Gets the camera attached to the layer.
  45542. */
  45543. readonly camera: Nullable<Camera>;
  45544. /**
  45545. * Gets the rendering group id the layer should render in.
  45546. */
  45547. readonly renderingGroupId: number;
  45548. /**
  45549. * An event triggered when the effect layer has been disposed.
  45550. */
  45551. onDisposeObservable: Observable<EffectLayer>;
  45552. /**
  45553. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45554. */
  45555. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45556. /**
  45557. * An event triggered when the generated texture is being merged in the scene.
  45558. */
  45559. onBeforeComposeObservable: Observable<EffectLayer>;
  45560. /**
  45561. * An event triggered when the generated texture has been merged in the scene.
  45562. */
  45563. onAfterComposeObservable: Observable<EffectLayer>;
  45564. /**
  45565. * An event triggered when the efffect layer changes its size.
  45566. */
  45567. onSizeChangedObservable: Observable<EffectLayer>;
  45568. /** @hidden */
  45569. static _SceneComponentInitialization: (scene: Scene) => void;
  45570. /**
  45571. * Instantiates a new effect Layer and references it in the scene.
  45572. * @param name The name of the layer
  45573. * @param scene The scene to use the layer in
  45574. */
  45575. constructor(
  45576. /** The Friendly of the effect in the scene */
  45577. name: string, scene: Scene);
  45578. /**
  45579. * Get the effect name of the layer.
  45580. * @return The effect name
  45581. */
  45582. abstract getEffectName(): string;
  45583. /**
  45584. * Checks for the readiness of the element composing the layer.
  45585. * @param subMesh the mesh to check for
  45586. * @param useInstances specify wether or not to use instances to render the mesh
  45587. * @return true if ready otherwise, false
  45588. */
  45589. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45590. /**
  45591. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45592. * @returns true if the effect requires stencil during the main canvas render pass.
  45593. */
  45594. abstract needStencil(): boolean;
  45595. /**
  45596. * Create the merge effect. This is the shader use to blit the information back
  45597. * to the main canvas at the end of the scene rendering.
  45598. * @returns The effect containing the shader used to merge the effect on the main canvas
  45599. */
  45600. protected abstract _createMergeEffect(): Effect;
  45601. /**
  45602. * Creates the render target textures and post processes used in the effect layer.
  45603. */
  45604. protected abstract _createTextureAndPostProcesses(): void;
  45605. /**
  45606. * Implementation specific of rendering the generating effect on the main canvas.
  45607. * @param effect The effect used to render through
  45608. */
  45609. protected abstract _internalRender(effect: Effect): void;
  45610. /**
  45611. * Sets the required values for both the emissive texture and and the main color.
  45612. */
  45613. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45614. /**
  45615. * Free any resources and references associated to a mesh.
  45616. * Internal use
  45617. * @param mesh The mesh to free.
  45618. */
  45619. abstract _disposeMesh(mesh: Mesh): void;
  45620. /**
  45621. * Serializes this layer (Glow or Highlight for example)
  45622. * @returns a serialized layer object
  45623. */
  45624. abstract serialize?(): any;
  45625. /**
  45626. * Initializes the effect layer with the required options.
  45627. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45628. */
  45629. protected _init(options: Partial<IEffectLayerOptions>): void;
  45630. /**
  45631. * Generates the index buffer of the full screen quad blending to the main canvas.
  45632. */
  45633. private _generateIndexBuffer;
  45634. /**
  45635. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45636. */
  45637. private _genrateVertexBuffer;
  45638. /**
  45639. * Sets the main texture desired size which is the closest power of two
  45640. * of the engine canvas size.
  45641. */
  45642. private _setMainTextureSize;
  45643. /**
  45644. * Creates the main texture for the effect layer.
  45645. */
  45646. protected _createMainTexture(): void;
  45647. /**
  45648. * Adds specific effects defines.
  45649. * @param defines The defines to add specifics to.
  45650. */
  45651. protected _addCustomEffectDefines(defines: string[]): void;
  45652. /**
  45653. * Checks for the readiness of the element composing the layer.
  45654. * @param subMesh the mesh to check for
  45655. * @param useInstances specify wether or not to use instances to render the mesh
  45656. * @param emissiveTexture the associated emissive texture used to generate the glow
  45657. * @return true if ready otherwise, false
  45658. */
  45659. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45660. /**
  45661. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45662. */
  45663. render(): void;
  45664. /**
  45665. * Determine if a given mesh will be used in the current effect.
  45666. * @param mesh mesh to test
  45667. * @returns true if the mesh will be used
  45668. */
  45669. hasMesh(mesh: AbstractMesh): boolean;
  45670. /**
  45671. * Returns true if the layer contains information to display, otherwise false.
  45672. * @returns true if the glow layer should be rendered
  45673. */
  45674. shouldRender(): boolean;
  45675. /**
  45676. * Returns true if the mesh should render, otherwise false.
  45677. * @param mesh The mesh to render
  45678. * @returns true if it should render otherwise false
  45679. */
  45680. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45681. /**
  45682. * Returns true if the mesh can be rendered, otherwise false.
  45683. * @param mesh The mesh to render
  45684. * @param material The material used on the mesh
  45685. * @returns true if it can be rendered otherwise false
  45686. */
  45687. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45688. /**
  45689. * Returns true if the mesh should render, otherwise false.
  45690. * @param mesh The mesh to render
  45691. * @returns true if it should render otherwise false
  45692. */
  45693. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45694. /**
  45695. * Renders the submesh passed in parameter to the generation map.
  45696. */
  45697. protected _renderSubMesh(subMesh: SubMesh): void;
  45698. /**
  45699. * Rebuild the required buffers.
  45700. * @hidden Internal use only.
  45701. */
  45702. _rebuild(): void;
  45703. /**
  45704. * Dispose only the render target textures and post process.
  45705. */
  45706. private _disposeTextureAndPostProcesses;
  45707. /**
  45708. * Dispose the highlight layer and free resources.
  45709. */
  45710. dispose(): void;
  45711. /**
  45712. * Gets the class name of the effect layer
  45713. * @returns the string with the class name of the effect layer
  45714. */
  45715. getClassName(): string;
  45716. /**
  45717. * Creates an effect layer from parsed effect layer data
  45718. * @param parsedEffectLayer defines effect layer data
  45719. * @param scene defines the current scene
  45720. * @param rootUrl defines the root URL containing the effect layer information
  45721. * @returns a parsed effect Layer
  45722. */
  45723. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45724. }
  45725. }
  45726. declare module BABYLON {
  45727. interface AbstractScene {
  45728. /**
  45729. * The list of effect layers (highlights/glow) added to the scene
  45730. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45731. * @see http://doc.babylonjs.com/how_to/glow_layer
  45732. */
  45733. effectLayers: Array<EffectLayer>;
  45734. /**
  45735. * Removes the given effect layer from this scene.
  45736. * @param toRemove defines the effect layer to remove
  45737. * @returns the index of the removed effect layer
  45738. */
  45739. removeEffectLayer(toRemove: EffectLayer): number;
  45740. /**
  45741. * Adds the given effect layer to this scene
  45742. * @param newEffectLayer defines the effect layer to add
  45743. */
  45744. addEffectLayer(newEffectLayer: EffectLayer): void;
  45745. }
  45746. /**
  45747. * Defines the layer scene component responsible to manage any effect layers
  45748. * in a given scene.
  45749. */
  45750. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45751. /**
  45752. * The component name helpfull to identify the component in the list of scene components.
  45753. */
  45754. readonly name: string;
  45755. /**
  45756. * The scene the component belongs to.
  45757. */
  45758. scene: Scene;
  45759. private _engine;
  45760. private _renderEffects;
  45761. private _needStencil;
  45762. private _previousStencilState;
  45763. /**
  45764. * Creates a new instance of the component for the given scene
  45765. * @param scene Defines the scene to register the component in
  45766. */
  45767. constructor(scene: Scene);
  45768. /**
  45769. * Registers the component in a given scene
  45770. */
  45771. register(): void;
  45772. /**
  45773. * Rebuilds the elements related to this component in case of
  45774. * context lost for instance.
  45775. */
  45776. rebuild(): void;
  45777. /**
  45778. * Serializes the component data to the specified json object
  45779. * @param serializationObject The object to serialize to
  45780. */
  45781. serialize(serializationObject: any): void;
  45782. /**
  45783. * Adds all the element from the container to the scene
  45784. * @param container the container holding the elements
  45785. */
  45786. addFromContainer(container: AbstractScene): void;
  45787. /**
  45788. * Removes all the elements in the container from the scene
  45789. * @param container contains the elements to remove
  45790. */
  45791. removeFromContainer(container: AbstractScene): void;
  45792. /**
  45793. * Disposes the component and the associated ressources.
  45794. */
  45795. dispose(): void;
  45796. private _isReadyForMesh;
  45797. private _renderMainTexture;
  45798. private _setStencil;
  45799. private _setStencilBack;
  45800. private _draw;
  45801. private _drawCamera;
  45802. private _drawRenderingGroup;
  45803. }
  45804. }
  45805. declare module BABYLON {
  45806. /** @hidden */
  45807. export var glowMapMergePixelShader: {
  45808. name: string;
  45809. shader: string;
  45810. };
  45811. }
  45812. declare module BABYLON {
  45813. /** @hidden */
  45814. export var glowMapMergeVertexShader: {
  45815. name: string;
  45816. shader: string;
  45817. };
  45818. }
  45819. declare module BABYLON {
  45820. interface AbstractScene {
  45821. /**
  45822. * Return a the first highlight layer of the scene with a given name.
  45823. * @param name The name of the highlight layer to look for.
  45824. * @return The highlight layer if found otherwise null.
  45825. */
  45826. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45827. }
  45828. /**
  45829. * Glow layer options. This helps customizing the behaviour
  45830. * of the glow layer.
  45831. */
  45832. export interface IGlowLayerOptions {
  45833. /**
  45834. * Multiplication factor apply to the canvas size to compute the render target size
  45835. * used to generated the glowing objects (the smaller the faster).
  45836. */
  45837. mainTextureRatio: number;
  45838. /**
  45839. * Enforces a fixed size texture to ensure resize independant blur.
  45840. */
  45841. mainTextureFixedSize?: number;
  45842. /**
  45843. * How big is the kernel of the blur texture.
  45844. */
  45845. blurKernelSize: number;
  45846. /**
  45847. * The camera attached to the layer.
  45848. */
  45849. camera: Nullable<Camera>;
  45850. /**
  45851. * Enable MSAA by chosing the number of samples.
  45852. */
  45853. mainTextureSamples?: number;
  45854. /**
  45855. * The rendering group to draw the layer in.
  45856. */
  45857. renderingGroupId: number;
  45858. }
  45859. /**
  45860. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45861. *
  45862. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45863. * glowy meshes to your scene.
  45864. *
  45865. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45866. */
  45867. export class GlowLayer extends EffectLayer {
  45868. /**
  45869. * Effect Name of the layer.
  45870. */
  45871. static readonly EffectName: string;
  45872. /**
  45873. * The default blur kernel size used for the glow.
  45874. */
  45875. static DefaultBlurKernelSize: number;
  45876. /**
  45877. * The default texture size ratio used for the glow.
  45878. */
  45879. static DefaultTextureRatio: number;
  45880. /**
  45881. * Sets the kernel size of the blur.
  45882. */
  45883. /**
  45884. * Gets the kernel size of the blur.
  45885. */
  45886. blurKernelSize: number;
  45887. /**
  45888. * Sets the glow intensity.
  45889. */
  45890. /**
  45891. * Gets the glow intensity.
  45892. */
  45893. intensity: number;
  45894. private _options;
  45895. private _intensity;
  45896. private _horizontalBlurPostprocess1;
  45897. private _verticalBlurPostprocess1;
  45898. private _horizontalBlurPostprocess2;
  45899. private _verticalBlurPostprocess2;
  45900. private _blurTexture1;
  45901. private _blurTexture2;
  45902. private _postProcesses1;
  45903. private _postProcesses2;
  45904. private _includedOnlyMeshes;
  45905. private _excludedMeshes;
  45906. /**
  45907. * Callback used to let the user override the color selection on a per mesh basis
  45908. */
  45909. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45910. /**
  45911. * Callback used to let the user override the texture selection on a per mesh basis
  45912. */
  45913. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45914. /**
  45915. * Instantiates a new glow Layer and references it to the scene.
  45916. * @param name The name of the layer
  45917. * @param scene The scene to use the layer in
  45918. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45919. */
  45920. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45921. /**
  45922. * Get the effect name of the layer.
  45923. * @return The effect name
  45924. */
  45925. getEffectName(): string;
  45926. /**
  45927. * Create the merge effect. This is the shader use to blit the information back
  45928. * to the main canvas at the end of the scene rendering.
  45929. */
  45930. protected _createMergeEffect(): Effect;
  45931. /**
  45932. * Creates the render target textures and post processes used in the glow layer.
  45933. */
  45934. protected _createTextureAndPostProcesses(): void;
  45935. /**
  45936. * Checks for the readiness of the element composing the layer.
  45937. * @param subMesh the mesh to check for
  45938. * @param useInstances specify wether or not to use instances to render the mesh
  45939. * @param emissiveTexture the associated emissive texture used to generate the glow
  45940. * @return true if ready otherwise, false
  45941. */
  45942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45943. /**
  45944. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45945. */
  45946. needStencil(): boolean;
  45947. /**
  45948. * Returns true if the mesh can be rendered, otherwise false.
  45949. * @param mesh The mesh to render
  45950. * @param material The material used on the mesh
  45951. * @returns true if it can be rendered otherwise false
  45952. */
  45953. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45954. /**
  45955. * Implementation specific of rendering the generating effect on the main canvas.
  45956. * @param effect The effect used to render through
  45957. */
  45958. protected _internalRender(effect: Effect): void;
  45959. /**
  45960. * Sets the required values for both the emissive texture and and the main color.
  45961. */
  45962. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45963. /**
  45964. * Returns true if the mesh should render, otherwise false.
  45965. * @param mesh The mesh to render
  45966. * @returns true if it should render otherwise false
  45967. */
  45968. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45969. /**
  45970. * Adds specific effects defines.
  45971. * @param defines The defines to add specifics to.
  45972. */
  45973. protected _addCustomEffectDefines(defines: string[]): void;
  45974. /**
  45975. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45976. * @param mesh The mesh to exclude from the glow layer
  45977. */
  45978. addExcludedMesh(mesh: Mesh): void;
  45979. /**
  45980. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45981. * @param mesh The mesh to remove
  45982. */
  45983. removeExcludedMesh(mesh: Mesh): void;
  45984. /**
  45985. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45986. * @param mesh The mesh to include in the glow layer
  45987. */
  45988. addIncludedOnlyMesh(mesh: Mesh): void;
  45989. /**
  45990. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45991. * @param mesh The mesh to remove
  45992. */
  45993. removeIncludedOnlyMesh(mesh: Mesh): void;
  45994. /**
  45995. * Determine if a given mesh will be used in the glow layer
  45996. * @param mesh The mesh to test
  45997. * @returns true if the mesh will be highlighted by the current glow layer
  45998. */
  45999. hasMesh(mesh: AbstractMesh): boolean;
  46000. /**
  46001. * Free any resources and references associated to a mesh.
  46002. * Internal use
  46003. * @param mesh The mesh to free.
  46004. * @hidden
  46005. */
  46006. _disposeMesh(mesh: Mesh): void;
  46007. /**
  46008. * Gets the class name of the effect layer
  46009. * @returns the string with the class name of the effect layer
  46010. */
  46011. getClassName(): string;
  46012. /**
  46013. * Serializes this glow layer
  46014. * @returns a serialized glow layer object
  46015. */
  46016. serialize(): any;
  46017. /**
  46018. * Creates a Glow Layer from parsed glow layer data
  46019. * @param parsedGlowLayer defines glow layer data
  46020. * @param scene defines the current scene
  46021. * @param rootUrl defines the root URL containing the glow layer information
  46022. * @returns a parsed Glow Layer
  46023. */
  46024. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46025. }
  46026. }
  46027. declare module BABYLON {
  46028. /** @hidden */
  46029. export var glowBlurPostProcessPixelShader: {
  46030. name: string;
  46031. shader: string;
  46032. };
  46033. }
  46034. declare module BABYLON {
  46035. interface AbstractScene {
  46036. /**
  46037. * Return a the first highlight layer of the scene with a given name.
  46038. * @param name The name of the highlight layer to look for.
  46039. * @return The highlight layer if found otherwise null.
  46040. */
  46041. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46042. }
  46043. /**
  46044. * Highlight layer options. This helps customizing the behaviour
  46045. * of the highlight layer.
  46046. */
  46047. export interface IHighlightLayerOptions {
  46048. /**
  46049. * Multiplication factor apply to the canvas size to compute the render target size
  46050. * used to generated the glowing objects (the smaller the faster).
  46051. */
  46052. mainTextureRatio: number;
  46053. /**
  46054. * Enforces a fixed size texture to ensure resize independant blur.
  46055. */
  46056. mainTextureFixedSize?: number;
  46057. /**
  46058. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46059. * of the picture to blur (the smaller the faster).
  46060. */
  46061. blurTextureSizeRatio: number;
  46062. /**
  46063. * How big in texel of the blur texture is the vertical blur.
  46064. */
  46065. blurVerticalSize: number;
  46066. /**
  46067. * How big in texel of the blur texture is the horizontal blur.
  46068. */
  46069. blurHorizontalSize: number;
  46070. /**
  46071. * Alpha blending mode used to apply the blur. Default is combine.
  46072. */
  46073. alphaBlendingMode: number;
  46074. /**
  46075. * The camera attached to the layer.
  46076. */
  46077. camera: Nullable<Camera>;
  46078. /**
  46079. * Should we display highlight as a solid stroke?
  46080. */
  46081. isStroke?: boolean;
  46082. /**
  46083. * The rendering group to draw the layer in.
  46084. */
  46085. renderingGroupId: number;
  46086. }
  46087. /**
  46088. * The highlight layer Helps adding a glow effect around a mesh.
  46089. *
  46090. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46091. * glowy meshes to your scene.
  46092. *
  46093. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46094. */
  46095. export class HighlightLayer extends EffectLayer {
  46096. name: string;
  46097. /**
  46098. * Effect Name of the highlight layer.
  46099. */
  46100. static readonly EffectName: string;
  46101. /**
  46102. * The neutral color used during the preparation of the glow effect.
  46103. * This is black by default as the blend operation is a blend operation.
  46104. */
  46105. static NeutralColor: Color4;
  46106. /**
  46107. * Stencil value used for glowing meshes.
  46108. */
  46109. static GlowingMeshStencilReference: number;
  46110. /**
  46111. * Stencil value used for the other meshes in the scene.
  46112. */
  46113. static NormalMeshStencilReference: number;
  46114. /**
  46115. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46116. */
  46117. innerGlow: boolean;
  46118. /**
  46119. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46120. */
  46121. outerGlow: boolean;
  46122. /**
  46123. * Specifies the horizontal size of the blur.
  46124. */
  46125. /**
  46126. * Gets the horizontal size of the blur.
  46127. */
  46128. blurHorizontalSize: number;
  46129. /**
  46130. * Specifies the vertical size of the blur.
  46131. */
  46132. /**
  46133. * Gets the vertical size of the blur.
  46134. */
  46135. blurVerticalSize: number;
  46136. /**
  46137. * An event triggered when the highlight layer is being blurred.
  46138. */
  46139. onBeforeBlurObservable: Observable<HighlightLayer>;
  46140. /**
  46141. * An event triggered when the highlight layer has been blurred.
  46142. */
  46143. onAfterBlurObservable: Observable<HighlightLayer>;
  46144. private _instanceGlowingMeshStencilReference;
  46145. private _options;
  46146. private _downSamplePostprocess;
  46147. private _horizontalBlurPostprocess;
  46148. private _verticalBlurPostprocess;
  46149. private _blurTexture;
  46150. private _meshes;
  46151. private _excludedMeshes;
  46152. /**
  46153. * Instantiates a new highlight Layer and references it to the scene..
  46154. * @param name The name of the layer
  46155. * @param scene The scene to use the layer in
  46156. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46157. */
  46158. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46159. /**
  46160. * Get the effect name of the layer.
  46161. * @return The effect name
  46162. */
  46163. getEffectName(): string;
  46164. /**
  46165. * Create the merge effect. This is the shader use to blit the information back
  46166. * to the main canvas at the end of the scene rendering.
  46167. */
  46168. protected _createMergeEffect(): Effect;
  46169. /**
  46170. * Creates the render target textures and post processes used in the highlight layer.
  46171. */
  46172. protected _createTextureAndPostProcesses(): void;
  46173. /**
  46174. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46175. */
  46176. needStencil(): boolean;
  46177. /**
  46178. * Checks for the readiness of the element composing the layer.
  46179. * @param subMesh the mesh to check for
  46180. * @param useInstances specify wether or not to use instances to render the mesh
  46181. * @param emissiveTexture the associated emissive texture used to generate the glow
  46182. * @return true if ready otherwise, false
  46183. */
  46184. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46185. /**
  46186. * Implementation specific of rendering the generating effect on the main canvas.
  46187. * @param effect The effect used to render through
  46188. */
  46189. protected _internalRender(effect: Effect): void;
  46190. /**
  46191. * Returns true if the layer contains information to display, otherwise false.
  46192. */
  46193. shouldRender(): boolean;
  46194. /**
  46195. * Returns true if the mesh should render, otherwise false.
  46196. * @param mesh The mesh to render
  46197. * @returns true if it should render otherwise false
  46198. */
  46199. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46200. /**
  46201. * Sets the required values for both the emissive texture and and the main color.
  46202. */
  46203. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46204. /**
  46205. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46206. * @param mesh The mesh to exclude from the highlight layer
  46207. */
  46208. addExcludedMesh(mesh: Mesh): void;
  46209. /**
  46210. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46211. * @param mesh The mesh to highlight
  46212. */
  46213. removeExcludedMesh(mesh: Mesh): void;
  46214. /**
  46215. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46216. * @param mesh mesh to test
  46217. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46218. */
  46219. hasMesh(mesh: AbstractMesh): boolean;
  46220. /**
  46221. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46222. * @param mesh The mesh to highlight
  46223. * @param color The color of the highlight
  46224. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46225. */
  46226. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46227. /**
  46228. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46229. * @param mesh The mesh to highlight
  46230. */
  46231. removeMesh(mesh: Mesh): void;
  46232. /**
  46233. * Force the stencil to the normal expected value for none glowing parts
  46234. */
  46235. private _defaultStencilReference;
  46236. /**
  46237. * Free any resources and references associated to a mesh.
  46238. * Internal use
  46239. * @param mesh The mesh to free.
  46240. * @hidden
  46241. */
  46242. _disposeMesh(mesh: Mesh): void;
  46243. /**
  46244. * Dispose the highlight layer and free resources.
  46245. */
  46246. dispose(): void;
  46247. /**
  46248. * Gets the class name of the effect layer
  46249. * @returns the string with the class name of the effect layer
  46250. */
  46251. getClassName(): string;
  46252. /**
  46253. * Serializes this Highlight layer
  46254. * @returns a serialized Highlight layer object
  46255. */
  46256. serialize(): any;
  46257. /**
  46258. * Creates a Highlight layer from parsed Highlight layer data
  46259. * @param parsedHightlightLayer defines the Highlight layer data
  46260. * @param scene defines the current scene
  46261. * @param rootUrl defines the root URL containing the Highlight layer information
  46262. * @returns a parsed Highlight layer
  46263. */
  46264. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46265. }
  46266. }
  46267. declare module BABYLON {
  46268. /** @hidden */
  46269. export var lensFlarePixelShader: {
  46270. name: string;
  46271. shader: string;
  46272. };
  46273. }
  46274. declare module BABYLON {
  46275. /** @hidden */
  46276. export var lensFlareVertexShader: {
  46277. name: string;
  46278. shader: string;
  46279. };
  46280. }
  46281. declare module BABYLON {
  46282. /**
  46283. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46284. * It is usually composed of several `lensFlare`.
  46285. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46286. */
  46287. export class LensFlareSystem {
  46288. /**
  46289. * Define the name of the lens flare system
  46290. */
  46291. name: string;
  46292. /**
  46293. * List of lens flares used in this system.
  46294. */
  46295. lensFlares: LensFlare[];
  46296. /**
  46297. * Define a limit from the border the lens flare can be visible.
  46298. */
  46299. borderLimit: number;
  46300. /**
  46301. * Define a viewport border we do not want to see the lens flare in.
  46302. */
  46303. viewportBorder: number;
  46304. /**
  46305. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46306. */
  46307. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46308. /**
  46309. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46310. */
  46311. layerMask: number;
  46312. /**
  46313. * Define the id of the lens flare system in the scene.
  46314. * (equal to name by default)
  46315. */
  46316. id: string;
  46317. private _scene;
  46318. private _emitter;
  46319. private _vertexBuffers;
  46320. private _indexBuffer;
  46321. private _effect;
  46322. private _positionX;
  46323. private _positionY;
  46324. private _isEnabled;
  46325. /** @hidden */
  46326. static _SceneComponentInitialization: (scene: Scene) => void;
  46327. /**
  46328. * Instantiates a lens flare system.
  46329. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46330. * It is usually composed of several `lensFlare`.
  46331. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46332. * @param name Define the name of the lens flare system in the scene
  46333. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46334. * @param scene Define the scene the lens flare system belongs to
  46335. */
  46336. constructor(
  46337. /**
  46338. * Define the name of the lens flare system
  46339. */
  46340. name: string, emitter: any, scene: Scene);
  46341. /**
  46342. * Define if the lens flare system is enabled.
  46343. */
  46344. isEnabled: boolean;
  46345. /**
  46346. * Get the scene the effects belongs to.
  46347. * @returns the scene holding the lens flare system
  46348. */
  46349. getScene(): Scene;
  46350. /**
  46351. * Get the emitter of the lens flare system.
  46352. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46353. * @returns the emitter of the lens flare system
  46354. */
  46355. getEmitter(): any;
  46356. /**
  46357. * Set the emitter of the lens flare system.
  46358. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46359. * @param newEmitter Define the new emitter of the system
  46360. */
  46361. setEmitter(newEmitter: any): void;
  46362. /**
  46363. * Get the lens flare system emitter position.
  46364. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46365. * @returns the position
  46366. */
  46367. getEmitterPosition(): Vector3;
  46368. /**
  46369. * @hidden
  46370. */
  46371. computeEffectivePosition(globalViewport: Viewport): boolean;
  46372. /** @hidden */
  46373. _isVisible(): boolean;
  46374. /**
  46375. * @hidden
  46376. */
  46377. render(): boolean;
  46378. /**
  46379. * Dispose and release the lens flare with its associated resources.
  46380. */
  46381. dispose(): void;
  46382. /**
  46383. * Parse a lens flare system from a JSON repressentation
  46384. * @param parsedLensFlareSystem Define the JSON to parse
  46385. * @param scene Define the scene the parsed system should be instantiated in
  46386. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46387. * @returns the parsed system
  46388. */
  46389. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46390. /**
  46391. * Serialize the current Lens Flare System into a JSON representation.
  46392. * @returns the serialized JSON
  46393. */
  46394. serialize(): any;
  46395. }
  46396. }
  46397. declare module BABYLON {
  46398. /**
  46399. * This represents one of the lens effect in a `lensFlareSystem`.
  46400. * It controls one of the indiviual texture used in the effect.
  46401. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46402. */
  46403. export class LensFlare {
  46404. /**
  46405. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46406. */
  46407. size: number;
  46408. /**
  46409. * 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.
  46410. */
  46411. position: number;
  46412. /**
  46413. * Define the lens color.
  46414. */
  46415. color: Color3;
  46416. /**
  46417. * Define the lens texture.
  46418. */
  46419. texture: Nullable<Texture>;
  46420. /**
  46421. * Define the alpha mode to render this particular lens.
  46422. */
  46423. alphaMode: number;
  46424. private _system;
  46425. /**
  46426. * Creates a new Lens Flare.
  46427. * This represents one of the lens effect in a `lensFlareSystem`.
  46428. * It controls one of the indiviual texture used in the effect.
  46429. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46430. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46431. * @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.
  46432. * @param color Define the lens color
  46433. * @param imgUrl Define the lens texture url
  46434. * @param system Define the `lensFlareSystem` this flare is part of
  46435. * @returns The newly created Lens Flare
  46436. */
  46437. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46438. /**
  46439. * Instantiates a new Lens Flare.
  46440. * This represents one of the lens effect in a `lensFlareSystem`.
  46441. * It controls one of the indiviual texture used in the effect.
  46442. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46443. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46444. * @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.
  46445. * @param color Define the lens color
  46446. * @param imgUrl Define the lens texture url
  46447. * @param system Define the `lensFlareSystem` this flare is part of
  46448. */
  46449. constructor(
  46450. /**
  46451. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46452. */
  46453. size: number,
  46454. /**
  46455. * 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.
  46456. */
  46457. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46458. /**
  46459. * Dispose and release the lens flare with its associated resources.
  46460. */
  46461. dispose(): void;
  46462. }
  46463. }
  46464. declare module BABYLON {
  46465. interface AbstractScene {
  46466. /**
  46467. * The list of lens flare system added to the scene
  46468. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46469. */
  46470. lensFlareSystems: Array<LensFlareSystem>;
  46471. /**
  46472. * Removes the given lens flare system from this scene.
  46473. * @param toRemove The lens flare system to remove
  46474. * @returns The index of the removed lens flare system
  46475. */
  46476. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46477. /**
  46478. * Adds the given lens flare system to this scene
  46479. * @param newLensFlareSystem The lens flare system to add
  46480. */
  46481. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46482. /**
  46483. * Gets a lens flare system using its name
  46484. * @param name defines the name to look for
  46485. * @returns the lens flare system or null if not found
  46486. */
  46487. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46488. /**
  46489. * Gets a lens flare system using its id
  46490. * @param id defines the id to look for
  46491. * @returns the lens flare system or null if not found
  46492. */
  46493. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46494. }
  46495. /**
  46496. * Defines the lens flare scene component responsible to manage any lens flares
  46497. * in a given scene.
  46498. */
  46499. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46500. /**
  46501. * The component name helpfull to identify the component in the list of scene components.
  46502. */
  46503. readonly name: string;
  46504. /**
  46505. * The scene the component belongs to.
  46506. */
  46507. scene: Scene;
  46508. /**
  46509. * Creates a new instance of the component for the given scene
  46510. * @param scene Defines the scene to register the component in
  46511. */
  46512. constructor(scene: Scene);
  46513. /**
  46514. * Registers the component in a given scene
  46515. */
  46516. register(): void;
  46517. /**
  46518. * Rebuilds the elements related to this component in case of
  46519. * context lost for instance.
  46520. */
  46521. rebuild(): void;
  46522. /**
  46523. * Adds all the element from the container to the scene
  46524. * @param container the container holding the elements
  46525. */
  46526. addFromContainer(container: AbstractScene): void;
  46527. /**
  46528. * Removes all the elements in the container from the scene
  46529. * @param container contains the elements to remove
  46530. */
  46531. removeFromContainer(container: AbstractScene): void;
  46532. /**
  46533. * Serializes the component data to the specified json object
  46534. * @param serializationObject The object to serialize to
  46535. */
  46536. serialize(serializationObject: any): void;
  46537. /**
  46538. * Disposes the component and the associated ressources.
  46539. */
  46540. dispose(): void;
  46541. private _draw;
  46542. }
  46543. }
  46544. declare module BABYLON {
  46545. /**
  46546. * Defines the shadow generator component responsible to manage any shadow generators
  46547. * in a given scene.
  46548. */
  46549. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46550. /**
  46551. * The component name helpfull to identify the component in the list of scene components.
  46552. */
  46553. readonly name: string;
  46554. /**
  46555. * The scene the component belongs to.
  46556. */
  46557. scene: Scene;
  46558. /**
  46559. * Creates a new instance of the component for the given scene
  46560. * @param scene Defines the scene to register the component in
  46561. */
  46562. constructor(scene: Scene);
  46563. /**
  46564. * Registers the component in a given scene
  46565. */
  46566. register(): void;
  46567. /**
  46568. * Rebuilds the elements related to this component in case of
  46569. * context lost for instance.
  46570. */
  46571. rebuild(): void;
  46572. /**
  46573. * Serializes the component data to the specified json object
  46574. * @param serializationObject The object to serialize to
  46575. */
  46576. serialize(serializationObject: any): void;
  46577. /**
  46578. * Adds all the element from the container to the scene
  46579. * @param container the container holding the elements
  46580. */
  46581. addFromContainer(container: AbstractScene): void;
  46582. /**
  46583. * Removes all the elements in the container from the scene
  46584. * @param container contains the elements to remove
  46585. */
  46586. removeFromContainer(container: AbstractScene): void;
  46587. /**
  46588. * Rebuilds the elements related to this component in case of
  46589. * context lost for instance.
  46590. */
  46591. dispose(): void;
  46592. private _gatherRenderTargets;
  46593. }
  46594. }
  46595. declare module BABYLON {
  46596. /**
  46597. * A directional light is defined by a direction (what a surprise!).
  46598. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46599. * 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.
  46600. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46601. */
  46602. export class DirectionalLight extends ShadowLight {
  46603. private _shadowFrustumSize;
  46604. /**
  46605. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46606. */
  46607. /**
  46608. * Specifies a fix frustum size for the shadow generation.
  46609. */
  46610. shadowFrustumSize: number;
  46611. private _shadowOrthoScale;
  46612. /**
  46613. * Gets the shadow projection scale against the optimal computed one.
  46614. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46615. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46616. */
  46617. /**
  46618. * Sets the shadow projection scale against the optimal computed one.
  46619. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46620. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46621. */
  46622. shadowOrthoScale: number;
  46623. /**
  46624. * Automatically compute the projection matrix to best fit (including all the casters)
  46625. * on each frame.
  46626. */
  46627. autoUpdateExtends: boolean;
  46628. private _orthoLeft;
  46629. private _orthoRight;
  46630. private _orthoTop;
  46631. private _orthoBottom;
  46632. /**
  46633. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46634. * The directional light is emitted from everywhere in the given direction.
  46635. * It can cast shadows.
  46636. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46637. * @param name The friendly name of the light
  46638. * @param direction The direction of the light
  46639. * @param scene The scene the light belongs to
  46640. */
  46641. constructor(name: string, direction: Vector3, scene: Scene);
  46642. /**
  46643. * Returns the string "DirectionalLight".
  46644. * @return The class name
  46645. */
  46646. getClassName(): string;
  46647. /**
  46648. * Returns the integer 1.
  46649. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46650. */
  46651. getTypeID(): number;
  46652. /**
  46653. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46654. * Returns the DirectionalLight Shadow projection matrix.
  46655. */
  46656. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46657. /**
  46658. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46659. * Returns the DirectionalLight Shadow projection matrix.
  46660. */
  46661. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46662. /**
  46663. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46664. * Returns the DirectionalLight Shadow projection matrix.
  46665. */
  46666. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46667. protected _buildUniformLayout(): void;
  46668. /**
  46669. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46670. * @param effect The effect to update
  46671. * @param lightIndex The index of the light in the effect to update
  46672. * @returns The directional light
  46673. */
  46674. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46675. /**
  46676. * Gets the minZ used for shadow according to both the scene and the light.
  46677. *
  46678. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46679. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46680. * @param activeCamera The camera we are returning the min for
  46681. * @returns the depth min z
  46682. */
  46683. getDepthMinZ(activeCamera: Camera): number;
  46684. /**
  46685. * Gets the maxZ used for shadow according to both the scene and the light.
  46686. *
  46687. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46688. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46689. * @param activeCamera The camera we are returning the max for
  46690. * @returns the depth max z
  46691. */
  46692. getDepthMaxZ(activeCamera: Camera): number;
  46693. /**
  46694. * Prepares the list of defines specific to the light type.
  46695. * @param defines the list of defines
  46696. * @param lightIndex defines the index of the light for the effect
  46697. */
  46698. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46699. }
  46700. }
  46701. declare module BABYLON {
  46702. /**
  46703. * A point light is a light defined by an unique point in world space.
  46704. * The light is emitted in every direction from this point.
  46705. * A good example of a point light is a standard light bulb.
  46706. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46707. */
  46708. export class PointLight extends ShadowLight {
  46709. private _shadowAngle;
  46710. /**
  46711. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46712. * This specifies what angle the shadow will use to be created.
  46713. *
  46714. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46715. */
  46716. /**
  46717. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46718. * This specifies what angle the shadow will use to be created.
  46719. *
  46720. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46721. */
  46722. shadowAngle: number;
  46723. /**
  46724. * Gets the direction if it has been set.
  46725. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46726. */
  46727. /**
  46728. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46729. */
  46730. direction: Vector3;
  46731. /**
  46732. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46733. * A PointLight emits the light in every direction.
  46734. * It can cast shadows.
  46735. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46736. * ```javascript
  46737. * var pointLight = new PointLight("pl", camera.position, scene);
  46738. * ```
  46739. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46740. * @param name The light friendly name
  46741. * @param position The position of the point light in the scene
  46742. * @param scene The scene the lights belongs to
  46743. */
  46744. constructor(name: string, position: Vector3, scene: Scene);
  46745. /**
  46746. * Returns the string "PointLight"
  46747. * @returns the class name
  46748. */
  46749. getClassName(): string;
  46750. /**
  46751. * Returns the integer 0.
  46752. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46753. */
  46754. getTypeID(): number;
  46755. /**
  46756. * Specifies wether or not the shadowmap should be a cube texture.
  46757. * @returns true if the shadowmap needs to be a cube texture.
  46758. */
  46759. needCube(): boolean;
  46760. /**
  46761. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46762. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46763. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46764. */
  46765. getShadowDirection(faceIndex?: number): Vector3;
  46766. /**
  46767. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46768. * - fov = PI / 2
  46769. * - aspect ratio : 1.0
  46770. * - z-near and far equal to the active camera minZ and maxZ.
  46771. * Returns the PointLight.
  46772. */
  46773. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46774. protected _buildUniformLayout(): void;
  46775. /**
  46776. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46777. * @param effect The effect to update
  46778. * @param lightIndex The index of the light in the effect to update
  46779. * @returns The point light
  46780. */
  46781. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46782. /**
  46783. * Prepares the list of defines specific to the light type.
  46784. * @param defines the list of defines
  46785. * @param lightIndex defines the index of the light for the effect
  46786. */
  46787. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46788. }
  46789. }
  46790. declare module BABYLON {
  46791. /**
  46792. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46793. * These values define a cone of light starting from the position, emitting toward the direction.
  46794. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46795. * and the exponent defines the speed of the decay of the light with distance (reach).
  46796. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46797. */
  46798. export class SpotLight extends ShadowLight {
  46799. private _angle;
  46800. private _innerAngle;
  46801. private _cosHalfAngle;
  46802. private _lightAngleScale;
  46803. private _lightAngleOffset;
  46804. /**
  46805. * Gets the cone angle of the spot light in Radians.
  46806. */
  46807. /**
  46808. * Sets the cone angle of the spot light in Radians.
  46809. */
  46810. angle: number;
  46811. /**
  46812. * Only used in gltf falloff mode, this defines the angle where
  46813. * the directional falloff will start before cutting at angle which could be seen
  46814. * as outer angle.
  46815. */
  46816. /**
  46817. * Only used in gltf falloff mode, this defines the angle where
  46818. * the directional falloff will start before cutting at angle which could be seen
  46819. * as outer angle.
  46820. */
  46821. innerAngle: number;
  46822. private _shadowAngleScale;
  46823. /**
  46824. * Allows scaling the angle of the light for shadow generation only.
  46825. */
  46826. /**
  46827. * Allows scaling the angle of the light for shadow generation only.
  46828. */
  46829. shadowAngleScale: number;
  46830. /**
  46831. * The light decay speed with the distance from the emission spot.
  46832. */
  46833. exponent: number;
  46834. private _projectionTextureMatrix;
  46835. /**
  46836. * Allows reading the projecton texture
  46837. */
  46838. readonly projectionTextureMatrix: Matrix;
  46839. protected _projectionTextureLightNear: number;
  46840. /**
  46841. * Gets the near clip of the Spotlight for texture projection.
  46842. */
  46843. /**
  46844. * Sets the near clip of the Spotlight for texture projection.
  46845. */
  46846. projectionTextureLightNear: number;
  46847. protected _projectionTextureLightFar: number;
  46848. /**
  46849. * Gets the far clip of the Spotlight for texture projection.
  46850. */
  46851. /**
  46852. * Sets the far clip of the Spotlight for texture projection.
  46853. */
  46854. projectionTextureLightFar: number;
  46855. protected _projectionTextureUpDirection: Vector3;
  46856. /**
  46857. * Gets the Up vector of the Spotlight for texture projection.
  46858. */
  46859. /**
  46860. * Sets the Up vector of the Spotlight for texture projection.
  46861. */
  46862. projectionTextureUpDirection: Vector3;
  46863. private _projectionTexture;
  46864. /**
  46865. * Gets the projection texture of the light.
  46866. */
  46867. /**
  46868. * Sets the projection texture of the light.
  46869. */
  46870. projectionTexture: Nullable<BaseTexture>;
  46871. private _projectionTextureViewLightDirty;
  46872. private _projectionTextureProjectionLightDirty;
  46873. private _projectionTextureDirty;
  46874. private _projectionTextureViewTargetVector;
  46875. private _projectionTextureViewLightMatrix;
  46876. private _projectionTextureProjectionLightMatrix;
  46877. private _projectionTextureScalingMatrix;
  46878. /**
  46879. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46880. * It can cast shadows.
  46881. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46882. * @param name The light friendly name
  46883. * @param position The position of the spot light in the scene
  46884. * @param direction The direction of the light in the scene
  46885. * @param angle The cone angle of the light in Radians
  46886. * @param exponent The light decay speed with the distance from the emission spot
  46887. * @param scene The scene the lights belongs to
  46888. */
  46889. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46890. /**
  46891. * Returns the string "SpotLight".
  46892. * @returns the class name
  46893. */
  46894. getClassName(): string;
  46895. /**
  46896. * Returns the integer 2.
  46897. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46898. */
  46899. getTypeID(): number;
  46900. /**
  46901. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46902. */
  46903. protected _setDirection(value: Vector3): void;
  46904. /**
  46905. * Overrides the position setter to recompute the projection texture view light Matrix.
  46906. */
  46907. protected _setPosition(value: Vector3): void;
  46908. /**
  46909. * 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.
  46910. * Returns the SpotLight.
  46911. */
  46912. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46913. protected _computeProjectionTextureViewLightMatrix(): void;
  46914. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46915. /**
  46916. * Main function for light texture projection matrix computing.
  46917. */
  46918. protected _computeProjectionTextureMatrix(): void;
  46919. protected _buildUniformLayout(): void;
  46920. private _computeAngleValues;
  46921. /**
  46922. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46923. * @param effect The effect to update
  46924. * @param lightIndex The index of the light in the effect to update
  46925. * @returns The spot light
  46926. */
  46927. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46928. /**
  46929. * Disposes the light and the associated resources.
  46930. */
  46931. dispose(): void;
  46932. /**
  46933. * Prepares the list of defines specific to the light type.
  46934. * @param defines the list of defines
  46935. * @param lightIndex defines the index of the light for the effect
  46936. */
  46937. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46938. }
  46939. }
  46940. declare module BABYLON {
  46941. /**
  46942. * Header information of HDR texture files.
  46943. */
  46944. export interface HDRInfo {
  46945. /**
  46946. * The height of the texture in pixels.
  46947. */
  46948. height: number;
  46949. /**
  46950. * The width of the texture in pixels.
  46951. */
  46952. width: number;
  46953. /**
  46954. * The index of the beginning of the data in the binary file.
  46955. */
  46956. dataPosition: number;
  46957. }
  46958. /**
  46959. * This groups tools to convert HDR texture to native colors array.
  46960. */
  46961. export class HDRTools {
  46962. private static Ldexp;
  46963. private static Rgbe2float;
  46964. private static readStringLine;
  46965. /**
  46966. * Reads header information from an RGBE texture stored in a native array.
  46967. * More information on this format are available here:
  46968. * https://en.wikipedia.org/wiki/RGBE_image_format
  46969. *
  46970. * @param uint8array The binary file stored in native array.
  46971. * @return The header information.
  46972. */
  46973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46974. /**
  46975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46976. * This RGBE texture needs to store the information as a panorama.
  46977. *
  46978. * More information on this format are available here:
  46979. * https://en.wikipedia.org/wiki/RGBE_image_format
  46980. *
  46981. * @param buffer The binary file stored in an array buffer.
  46982. * @param size The expected size of the extracted cubemap.
  46983. * @return The Cube Map information.
  46984. */
  46985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46986. /**
  46987. * Returns the pixels data extracted from an RGBE texture.
  46988. * This pixels will be stored left to right up to down in the R G B order in one array.
  46989. *
  46990. * More information on this format are available here:
  46991. * https://en.wikipedia.org/wiki/RGBE_image_format
  46992. *
  46993. * @param uint8array The binary file stored in an array buffer.
  46994. * @param hdrInfo The header information of the file.
  46995. * @return The pixels data in RGB right to left up to down order.
  46996. */
  46997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46998. private static RGBE_ReadPixels_RLE;
  46999. }
  47000. }
  47001. declare module BABYLON {
  47002. /**
  47003. * This represents a texture coming from an HDR input.
  47004. *
  47005. * The only supported format is currently panorama picture stored in RGBE format.
  47006. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47007. */
  47008. export class HDRCubeTexture extends BaseTexture {
  47009. private static _facesMapping;
  47010. private _generateHarmonics;
  47011. private _noMipmap;
  47012. private _textureMatrix;
  47013. private _size;
  47014. private _onLoad;
  47015. private _onError;
  47016. /**
  47017. * The texture URL.
  47018. */
  47019. url: string;
  47020. /**
  47021. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47022. */
  47023. coordinatesMode: number;
  47024. protected _isBlocking: boolean;
  47025. /**
  47026. * Sets wether or not the texture is blocking during loading.
  47027. */
  47028. /**
  47029. * Gets wether or not the texture is blocking during loading.
  47030. */
  47031. isBlocking: boolean;
  47032. protected _rotationY: number;
  47033. /**
  47034. * Sets texture matrix rotation angle around Y axis in radians.
  47035. */
  47036. /**
  47037. * Gets texture matrix rotation angle around Y axis radians.
  47038. */
  47039. rotationY: number;
  47040. /**
  47041. * Gets or sets the center of the bounding box associated with the cube texture
  47042. * It must define where the camera used to render the texture was set
  47043. */
  47044. boundingBoxPosition: Vector3;
  47045. private _boundingBoxSize;
  47046. /**
  47047. * Gets or sets the size of the bounding box associated with the cube texture
  47048. * When defined, the cubemap will switch to local mode
  47049. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47050. * @example https://www.babylonjs-playground.com/#RNASML
  47051. */
  47052. boundingBoxSize: Vector3;
  47053. /**
  47054. * Instantiates an HDRTexture from the following parameters.
  47055. *
  47056. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47057. * @param scene The scene the texture will be used in
  47058. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47059. * @param noMipmap Forces to not generate the mipmap if true
  47060. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47061. * @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)
  47062. * @param reserved Reserved flag for internal use.
  47063. */
  47064. 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>);
  47065. /**
  47066. * Get the current class name of the texture useful for serialization or dynamic coding.
  47067. * @returns "HDRCubeTexture"
  47068. */
  47069. getClassName(): string;
  47070. /**
  47071. * Occurs when the file is raw .hdr file.
  47072. */
  47073. private loadTexture;
  47074. clone(): HDRCubeTexture;
  47075. delayLoad(): void;
  47076. /**
  47077. * Get the texture reflection matrix used to rotate/transform the reflection.
  47078. * @returns the reflection matrix
  47079. */
  47080. getReflectionTextureMatrix(): Matrix;
  47081. /**
  47082. * Set the texture reflection matrix used to rotate/transform the reflection.
  47083. * @param value Define the reflection matrix to set
  47084. */
  47085. setReflectionTextureMatrix(value: Matrix): void;
  47086. /**
  47087. * Parses a JSON representation of an HDR Texture in order to create the texture
  47088. * @param parsedTexture Define the JSON representation
  47089. * @param scene Define the scene the texture should be created in
  47090. * @param rootUrl Define the root url in case we need to load relative dependencies
  47091. * @returns the newly created texture after parsing
  47092. */
  47093. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47094. serialize(): any;
  47095. }
  47096. }
  47097. declare module BABYLON {
  47098. /**
  47099. * Class used to control physics engine
  47100. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47101. */
  47102. export class PhysicsEngine implements IPhysicsEngine {
  47103. private _physicsPlugin;
  47104. /**
  47105. * Global value used to control the smallest number supported by the simulation
  47106. */
  47107. static Epsilon: number;
  47108. private _impostors;
  47109. private _joints;
  47110. /**
  47111. * Gets the gravity vector used by the simulation
  47112. */
  47113. gravity: Vector3;
  47114. /**
  47115. * Factory used to create the default physics plugin.
  47116. * @returns The default physics plugin
  47117. */
  47118. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47119. /**
  47120. * Creates a new Physics Engine
  47121. * @param gravity defines the gravity vector used by the simulation
  47122. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47123. */
  47124. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47125. /**
  47126. * Sets the gravity vector used by the simulation
  47127. * @param gravity defines the gravity vector to use
  47128. */
  47129. setGravity(gravity: Vector3): void;
  47130. /**
  47131. * Set the time step of the physics engine.
  47132. * Default is 1/60.
  47133. * To slow it down, enter 1/600 for example.
  47134. * To speed it up, 1/30
  47135. * @param newTimeStep defines the new timestep to apply to this world.
  47136. */
  47137. setTimeStep(newTimeStep?: number): void;
  47138. /**
  47139. * Get the time step of the physics engine.
  47140. * @returns the current time step
  47141. */
  47142. getTimeStep(): number;
  47143. /**
  47144. * Release all resources
  47145. */
  47146. dispose(): void;
  47147. /**
  47148. * Gets the name of the current physics plugin
  47149. * @returns the name of the plugin
  47150. */
  47151. getPhysicsPluginName(): string;
  47152. /**
  47153. * Adding a new impostor for the impostor tracking.
  47154. * This will be done by the impostor itself.
  47155. * @param impostor the impostor to add
  47156. */
  47157. addImpostor(impostor: PhysicsImpostor): void;
  47158. /**
  47159. * Remove an impostor from the engine.
  47160. * This impostor and its mesh will not longer be updated by the physics engine.
  47161. * @param impostor the impostor to remove
  47162. */
  47163. removeImpostor(impostor: PhysicsImpostor): void;
  47164. /**
  47165. * Add a joint to the physics engine
  47166. * @param mainImpostor defines the main impostor to which the joint is added.
  47167. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47168. * @param joint defines the joint that will connect both impostors.
  47169. */
  47170. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47171. /**
  47172. * Removes a joint from the simulation
  47173. * @param mainImpostor defines the impostor used with the joint
  47174. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47175. * @param joint defines the joint to remove
  47176. */
  47177. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47178. /**
  47179. * Called by the scene. No need to call it.
  47180. * @param delta defines the timespam between frames
  47181. */
  47182. _step(delta: number): void;
  47183. /**
  47184. * Gets the current plugin used to run the simulation
  47185. * @returns current plugin
  47186. */
  47187. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47188. /**
  47189. * Gets the list of physic impostors
  47190. * @returns an array of PhysicsImpostor
  47191. */
  47192. getImpostors(): Array<PhysicsImpostor>;
  47193. /**
  47194. * Gets the impostor for a physics enabled object
  47195. * @param object defines the object impersonated by the impostor
  47196. * @returns the PhysicsImpostor or null if not found
  47197. */
  47198. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47199. /**
  47200. * Gets the impostor for a physics body object
  47201. * @param body defines physics body used by the impostor
  47202. * @returns the PhysicsImpostor or null if not found
  47203. */
  47204. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47205. /**
  47206. * Does a raycast in the physics world
  47207. * @param from when should the ray start?
  47208. * @param to when should the ray end?
  47209. * @returns PhysicsRaycastResult
  47210. */
  47211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47212. }
  47213. }
  47214. declare module BABYLON {
  47215. /** @hidden */
  47216. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47217. private _useDeltaForWorldStep;
  47218. world: any;
  47219. name: string;
  47220. private _physicsMaterials;
  47221. private _fixedTimeStep;
  47222. private _cannonRaycastResult;
  47223. private _raycastResult;
  47224. BJSCANNON: any;
  47225. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47226. setGravity(gravity: Vector3): void;
  47227. setTimeStep(timeStep: number): void;
  47228. getTimeStep(): number;
  47229. executeStep(delta: number): void;
  47230. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47231. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47232. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47233. private _processChildMeshes;
  47234. removePhysicsBody(impostor: PhysicsImpostor): void;
  47235. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47236. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47237. private _addMaterial;
  47238. private _checkWithEpsilon;
  47239. private _createShape;
  47240. private _createHeightmap;
  47241. private _minus90X;
  47242. private _plus90X;
  47243. private _tmpPosition;
  47244. private _tmpDeltaPosition;
  47245. private _tmpUnityRotation;
  47246. private _updatePhysicsBodyTransformation;
  47247. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47248. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47249. isSupported(): boolean;
  47250. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47251. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47252. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47253. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47254. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47255. getBodyMass(impostor: PhysicsImpostor): number;
  47256. getBodyFriction(impostor: PhysicsImpostor): number;
  47257. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47258. getBodyRestitution(impostor: PhysicsImpostor): number;
  47259. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47260. sleepBody(impostor: PhysicsImpostor): void;
  47261. wakeUpBody(impostor: PhysicsImpostor): void;
  47262. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47263. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47264. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47265. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47266. getRadius(impostor: PhysicsImpostor): number;
  47267. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47268. dispose(): void;
  47269. private _extendNamespace;
  47270. /**
  47271. * Does a raycast in the physics world
  47272. * @param from when should the ray start?
  47273. * @param to when should the ray end?
  47274. * @returns PhysicsRaycastResult
  47275. */
  47276. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47277. }
  47278. }
  47279. declare module BABYLON {
  47280. /** @hidden */
  47281. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47282. world: any;
  47283. name: string;
  47284. BJSOIMO: any;
  47285. private _raycastResult;
  47286. constructor(iterations?: number, oimoInjection?: any);
  47287. setGravity(gravity: Vector3): void;
  47288. setTimeStep(timeStep: number): void;
  47289. getTimeStep(): number;
  47290. private _tmpImpostorsArray;
  47291. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47292. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47293. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47294. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47295. private _tmpPositionVector;
  47296. removePhysicsBody(impostor: PhysicsImpostor): void;
  47297. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47298. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47299. isSupported(): boolean;
  47300. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47301. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47302. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47303. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47304. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47305. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47306. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47307. getBodyMass(impostor: PhysicsImpostor): number;
  47308. getBodyFriction(impostor: PhysicsImpostor): number;
  47309. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47310. getBodyRestitution(impostor: PhysicsImpostor): number;
  47311. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47312. sleepBody(impostor: PhysicsImpostor): void;
  47313. wakeUpBody(impostor: PhysicsImpostor): void;
  47314. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47315. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47316. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47317. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47318. getRadius(impostor: PhysicsImpostor): number;
  47319. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47320. dispose(): void;
  47321. /**
  47322. * Does a raycast in the physics world
  47323. * @param from when should the ray start?
  47324. * @param to when should the ray end?
  47325. * @returns PhysicsRaycastResult
  47326. */
  47327. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47328. }
  47329. }
  47330. declare module BABYLON {
  47331. interface AbstractScene {
  47332. /**
  47333. * The list of reflection probes added to the scene
  47334. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47335. */
  47336. reflectionProbes: Array<ReflectionProbe>;
  47337. /**
  47338. * Removes the given reflection probe from this scene.
  47339. * @param toRemove The reflection probe to remove
  47340. * @returns The index of the removed reflection probe
  47341. */
  47342. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47343. /**
  47344. * Adds the given reflection probe to this scene.
  47345. * @param newReflectionProbe The reflection probe to add
  47346. */
  47347. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47348. }
  47349. /**
  47350. * Class used to generate realtime reflection / refraction cube textures
  47351. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47352. */
  47353. export class ReflectionProbe {
  47354. /** defines the name of the probe */
  47355. name: string;
  47356. private _scene;
  47357. private _renderTargetTexture;
  47358. private _projectionMatrix;
  47359. private _viewMatrix;
  47360. private _target;
  47361. private _add;
  47362. private _attachedMesh;
  47363. private _invertYAxis;
  47364. /** Gets or sets probe position (center of the cube map) */
  47365. position: Vector3;
  47366. /**
  47367. * Creates a new reflection probe
  47368. * @param name defines the name of the probe
  47369. * @param size defines the texture resolution (for each face)
  47370. * @param scene defines the hosting scene
  47371. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47372. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47373. */
  47374. constructor(
  47375. /** defines the name of the probe */
  47376. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47377. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47378. samples: number;
  47379. /** Gets or sets the refresh rate to use (on every frame by default) */
  47380. refreshRate: number;
  47381. /**
  47382. * Gets the hosting scene
  47383. * @returns a Scene
  47384. */
  47385. getScene(): Scene;
  47386. /** Gets the internal CubeTexture used to render to */
  47387. readonly cubeTexture: RenderTargetTexture;
  47388. /** Gets the list of meshes to render */
  47389. readonly renderList: Nullable<AbstractMesh[]>;
  47390. /**
  47391. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47392. * @param mesh defines the mesh to attach to
  47393. */
  47394. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47395. /**
  47396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47397. * @param renderingGroupId The rendering group id corresponding to its index
  47398. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47399. */
  47400. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47401. /**
  47402. * Clean all associated resources
  47403. */
  47404. dispose(): void;
  47405. /**
  47406. * Converts the reflection probe information to a readable string for debug purpose.
  47407. * @param fullDetails Supports for multiple levels of logging within scene loading
  47408. * @returns the human readable reflection probe info
  47409. */
  47410. toString(fullDetails?: boolean): string;
  47411. /**
  47412. * Get the class name of the relfection probe.
  47413. * @returns "ReflectionProbe"
  47414. */
  47415. getClassName(): string;
  47416. /**
  47417. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47418. * @returns The JSON representation of the texture
  47419. */
  47420. serialize(): any;
  47421. /**
  47422. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47423. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47424. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47425. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47426. * @returns The parsed reflection probe if successful
  47427. */
  47428. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47429. }
  47430. }
  47431. declare module BABYLON {
  47432. /** @hidden */
  47433. export var _BabylonLoaderRegistered: boolean;
  47434. }
  47435. declare module BABYLON {
  47436. /**
  47437. * The Physically based simple base material of BJS.
  47438. *
  47439. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47440. * It is used as the base class for both the specGloss and metalRough conventions.
  47441. */
  47442. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47443. /**
  47444. * Number of Simultaneous lights allowed on the material.
  47445. */
  47446. maxSimultaneousLights: number;
  47447. /**
  47448. * If sets to true, disables all the lights affecting the material.
  47449. */
  47450. disableLighting: boolean;
  47451. /**
  47452. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47453. */
  47454. environmentTexture: BaseTexture;
  47455. /**
  47456. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47457. */
  47458. invertNormalMapX: boolean;
  47459. /**
  47460. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47461. */
  47462. invertNormalMapY: boolean;
  47463. /**
  47464. * Normal map used in the model.
  47465. */
  47466. normalTexture: BaseTexture;
  47467. /**
  47468. * Emissivie color used to self-illuminate the model.
  47469. */
  47470. emissiveColor: Color3;
  47471. /**
  47472. * Emissivie texture used to self-illuminate the model.
  47473. */
  47474. emissiveTexture: BaseTexture;
  47475. /**
  47476. * Occlusion Channel Strenght.
  47477. */
  47478. occlusionStrength: number;
  47479. /**
  47480. * Occlusion Texture of the material (adding extra occlusion effects).
  47481. */
  47482. occlusionTexture: BaseTexture;
  47483. /**
  47484. * Defines the alpha limits in alpha test mode.
  47485. */
  47486. alphaCutOff: number;
  47487. /**
  47488. * Gets the current double sided mode.
  47489. */
  47490. /**
  47491. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47492. */
  47493. doubleSided: boolean;
  47494. /**
  47495. * Stores the pre-calculated light information of a mesh in a texture.
  47496. */
  47497. lightmapTexture: BaseTexture;
  47498. /**
  47499. * If true, the light map contains occlusion information instead of lighting info.
  47500. */
  47501. useLightmapAsShadowmap: boolean;
  47502. /**
  47503. * Instantiates a new PBRMaterial instance.
  47504. *
  47505. * @param name The material name
  47506. * @param scene The scene the material will be use in.
  47507. */
  47508. constructor(name: string, scene: Scene);
  47509. getClassName(): string;
  47510. }
  47511. }
  47512. declare module BABYLON {
  47513. /**
  47514. * The PBR material of BJS following the metal roughness convention.
  47515. *
  47516. * This fits to the PBR convention in the GLTF definition:
  47517. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47518. */
  47519. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47520. /**
  47521. * The base color has two different interpretations depending on the value of metalness.
  47522. * When the material is a metal, the base color is the specific measured reflectance value
  47523. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47524. * of the material.
  47525. */
  47526. baseColor: Color3;
  47527. /**
  47528. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47529. * well as opacity information in the alpha channel.
  47530. */
  47531. baseTexture: BaseTexture;
  47532. /**
  47533. * Specifies the metallic scalar value of the material.
  47534. * Can also be used to scale the metalness values of the metallic texture.
  47535. */
  47536. metallic: number;
  47537. /**
  47538. * Specifies the roughness scalar value of the material.
  47539. * Can also be used to scale the roughness values of the metallic texture.
  47540. */
  47541. roughness: number;
  47542. /**
  47543. * Texture containing both the metallic value in the B channel and the
  47544. * roughness value in the G channel to keep better precision.
  47545. */
  47546. metallicRoughnessTexture: BaseTexture;
  47547. /**
  47548. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47549. *
  47550. * @param name The material name
  47551. * @param scene The scene the material will be use in.
  47552. */
  47553. constructor(name: string, scene: Scene);
  47554. /**
  47555. * Return the currrent class name of the material.
  47556. */
  47557. getClassName(): string;
  47558. /**
  47559. * Makes a duplicate of the current material.
  47560. * @param name - name to use for the new material.
  47561. */
  47562. clone(name: string): PBRMetallicRoughnessMaterial;
  47563. /**
  47564. * Serialize the material to a parsable JSON object.
  47565. */
  47566. serialize(): any;
  47567. /**
  47568. * Parses a JSON object correponding to the serialize function.
  47569. */
  47570. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47571. }
  47572. }
  47573. declare module BABYLON {
  47574. /**
  47575. * The PBR material of BJS following the specular glossiness convention.
  47576. *
  47577. * This fits to the PBR convention in the GLTF definition:
  47578. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47579. */
  47580. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47581. /**
  47582. * Specifies the diffuse color of the material.
  47583. */
  47584. diffuseColor: Color3;
  47585. /**
  47586. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47587. * channel.
  47588. */
  47589. diffuseTexture: BaseTexture;
  47590. /**
  47591. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47592. */
  47593. specularColor: Color3;
  47594. /**
  47595. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47596. */
  47597. glossiness: number;
  47598. /**
  47599. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47600. */
  47601. specularGlossinessTexture: BaseTexture;
  47602. /**
  47603. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47604. *
  47605. * @param name The material name
  47606. * @param scene The scene the material will be use in.
  47607. */
  47608. constructor(name: string, scene: Scene);
  47609. /**
  47610. * Return the currrent class name of the material.
  47611. */
  47612. getClassName(): string;
  47613. /**
  47614. * Makes a duplicate of the current material.
  47615. * @param name - name to use for the new material.
  47616. */
  47617. clone(name: string): PBRSpecularGlossinessMaterial;
  47618. /**
  47619. * Serialize the material to a parsable JSON object.
  47620. */
  47621. serialize(): any;
  47622. /**
  47623. * Parses a JSON object correponding to the serialize function.
  47624. */
  47625. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47626. }
  47627. }
  47628. declare module BABYLON {
  47629. /**
  47630. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47631. * It can help converting any input color in a desired output one. This can then be used to create effects
  47632. * from sepia, black and white to sixties or futuristic rendering...
  47633. *
  47634. * The only supported format is currently 3dl.
  47635. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47636. */
  47637. export class ColorGradingTexture extends BaseTexture {
  47638. /**
  47639. * The current texture matrix. (will always be identity in color grading texture)
  47640. */
  47641. private _textureMatrix;
  47642. /**
  47643. * The texture URL.
  47644. */
  47645. url: string;
  47646. /**
  47647. * Empty line regex stored for GC.
  47648. */
  47649. private static _noneEmptyLineRegex;
  47650. private _engine;
  47651. /**
  47652. * Instantiates a ColorGradingTexture from the following parameters.
  47653. *
  47654. * @param url The location of the color gradind data (currently only supporting 3dl)
  47655. * @param scene The scene the texture will be used in
  47656. */
  47657. constructor(url: string, scene: Scene);
  47658. /**
  47659. * Returns the texture matrix used in most of the material.
  47660. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47661. */
  47662. getTextureMatrix(): Matrix;
  47663. /**
  47664. * Occurs when the file being loaded is a .3dl LUT file.
  47665. */
  47666. private load3dlTexture;
  47667. /**
  47668. * Starts the loading process of the texture.
  47669. */
  47670. private loadTexture;
  47671. /**
  47672. * Clones the color gradind texture.
  47673. */
  47674. clone(): ColorGradingTexture;
  47675. /**
  47676. * Called during delayed load for textures.
  47677. */
  47678. delayLoad(): void;
  47679. /**
  47680. * Parses a color grading texture serialized by Babylon.
  47681. * @param parsedTexture The texture information being parsedTexture
  47682. * @param scene The scene to load the texture in
  47683. * @param rootUrl The root url of the data assets to load
  47684. * @return A color gradind texture
  47685. */
  47686. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47687. /**
  47688. * Serializes the LUT texture to json format.
  47689. */
  47690. serialize(): any;
  47691. }
  47692. }
  47693. declare module BABYLON {
  47694. /**
  47695. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  47696. */
  47697. export class EquiRectangularCubeTexture extends BaseTexture {
  47698. /** The six faces of the cube. */
  47699. private static _FacesMapping;
  47700. private _noMipmap;
  47701. private _onLoad;
  47702. private _onError;
  47703. /** The size of the cubemap. */
  47704. private _size;
  47705. /** The buffer of the image. */
  47706. private _buffer;
  47707. /** The width of the input image. */
  47708. private _width;
  47709. /** The height of the input image. */
  47710. private _height;
  47711. /** The URL to the image. */
  47712. url: string;
  47713. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  47714. coordinatesMode: number;
  47715. /**
  47716. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  47717. * @param url The location of the image
  47718. * @param scene The scene the texture will be used in
  47719. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47720. * @param noMipmap Forces to not generate the mipmap if true
  47721. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  47722. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  47723. * @param onLoad — defines a callback called when texture is loaded
  47724. * @param onError — defines a callback called if there is an error
  47725. */
  47726. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  47727. /**
  47728. * Load the image data, by putting the image on a canvas and extracting its buffer.
  47729. */
  47730. private loadImage;
  47731. /**
  47732. * Convert the image buffer into a cubemap and create a CubeTexture.
  47733. */
  47734. private loadTexture;
  47735. /**
  47736. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  47737. * @param buffer The ArrayBuffer that should be converted.
  47738. * @returns The buffer as Float32Array.
  47739. */
  47740. private getFloat32ArrayFromArrayBuffer;
  47741. /**
  47742. * Get the current class name of the texture useful for serialization or dynamic coding.
  47743. * @returns "EquiRectangularCubeTexture"
  47744. */
  47745. getClassName(): string;
  47746. /**
  47747. * Create a clone of the current EquiRectangularCubeTexture and return it.
  47748. * @returns A clone of the current EquiRectangularCubeTexture.
  47749. */
  47750. clone(): EquiRectangularCubeTexture;
  47751. }
  47752. }
  47753. declare module BABYLON {
  47754. /**
  47755. * Based on jsTGALoader - Javascript loader for TGA file
  47756. * By Vincent Thibault
  47757. * @see http://blog.robrowser.com/javascript-tga-loader.html
  47758. */
  47759. export class TGATools {
  47760. private static _TYPE_INDEXED;
  47761. private static _TYPE_RGB;
  47762. private static _TYPE_GREY;
  47763. private static _TYPE_RLE_INDEXED;
  47764. private static _TYPE_RLE_RGB;
  47765. private static _TYPE_RLE_GREY;
  47766. private static _ORIGIN_MASK;
  47767. private static _ORIGIN_SHIFT;
  47768. private static _ORIGIN_BL;
  47769. private static _ORIGIN_BR;
  47770. private static _ORIGIN_UL;
  47771. private static _ORIGIN_UR;
  47772. /**
  47773. * Gets the header of a TGA file
  47774. * @param data defines the TGA data
  47775. * @returns the header
  47776. */
  47777. static GetTGAHeader(data: Uint8Array): any;
  47778. /**
  47779. * Uploads TGA content to a Babylon Texture
  47780. * @hidden
  47781. */
  47782. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  47783. /** @hidden */
  47784. 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;
  47785. /** @hidden */
  47786. 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;
  47787. /** @hidden */
  47788. 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;
  47789. /** @hidden */
  47790. 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;
  47791. /** @hidden */
  47792. 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;
  47793. /** @hidden */
  47794. 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;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. /**
  47799. * Implementation of the TGA Texture Loader.
  47800. * @hidden
  47801. */
  47802. export class _TGATextureLoader implements IInternalTextureLoader {
  47803. /**
  47804. * Defines wether the loader supports cascade loading the different faces.
  47805. */
  47806. readonly supportCascades: boolean;
  47807. /**
  47808. * This returns if the loader support the current file information.
  47809. * @param extension defines the file extension of the file being loaded
  47810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47811. * @param fallback defines the fallback internal texture if any
  47812. * @param isBase64 defines whether the texture is encoded as a base64
  47813. * @param isBuffer defines whether the texture data are stored as a buffer
  47814. * @returns true if the loader can load the specified file
  47815. */
  47816. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47817. /**
  47818. * Transform the url before loading if required.
  47819. * @param rootUrl the url of the texture
  47820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47821. * @returns the transformed texture
  47822. */
  47823. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47824. /**
  47825. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47826. * @param rootUrl the url of the texture
  47827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47828. * @returns the fallback texture
  47829. */
  47830. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47831. /**
  47832. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47833. * @param data contains the texture data
  47834. * @param texture defines the BabylonJS internal texture
  47835. * @param createPolynomials will be true if polynomials have been requested
  47836. * @param onLoad defines the callback to trigger once the texture is ready
  47837. * @param onError defines the callback to trigger in case of error
  47838. */
  47839. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47840. /**
  47841. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47842. * @param data contains the texture data
  47843. * @param texture defines the BabylonJS internal texture
  47844. * @param callback defines the method to call once ready to upload
  47845. */
  47846. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47847. }
  47848. }
  47849. declare module BABYLON {
  47850. /**
  47851. * 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.
  47852. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47854. */
  47855. export class CustomProceduralTexture extends ProceduralTexture {
  47856. private _animate;
  47857. private _time;
  47858. private _config;
  47859. private _texturePath;
  47860. /**
  47861. * Instantiates a new Custom Procedural Texture.
  47862. * 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.
  47863. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47864. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47865. * @param name Define the name of the texture
  47866. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  47867. * @param size Define the size of the texture to create
  47868. * @param scene Define the scene the texture belongs to
  47869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  47870. * @param generateMipMaps Define if the texture should creates mip maps or not
  47871. */
  47872. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47873. private _loadJson;
  47874. /**
  47875. * Is the texture ready to be used ? (rendered at least once)
  47876. * @returns true if ready, otherwise, false.
  47877. */
  47878. isReady(): boolean;
  47879. /**
  47880. * Render the texture to its associated render target.
  47881. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  47882. */
  47883. render(useCameraPostProcess?: boolean): void;
  47884. /**
  47885. * Update the list of dependant textures samplers in the shader.
  47886. */
  47887. updateTextures(): void;
  47888. /**
  47889. * Update the uniform values of the procedural texture in the shader.
  47890. */
  47891. updateShaderUniforms(): void;
  47892. /**
  47893. * Define if the texture animates or not.
  47894. */
  47895. animate: boolean;
  47896. }
  47897. }
  47898. declare module BABYLON {
  47899. /** @hidden */
  47900. export var noisePixelShader: {
  47901. name: string;
  47902. shader: string;
  47903. };
  47904. }
  47905. declare module BABYLON {
  47906. /**
  47907. * Class used to generate noise procedural textures
  47908. */
  47909. export class NoiseProceduralTexture extends ProceduralTexture {
  47910. private _time;
  47911. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  47912. brightness: number;
  47913. /** Defines the number of octaves to process */
  47914. octaves: number;
  47915. /** Defines the level of persistence (0.8 by default) */
  47916. persistence: number;
  47917. /** Gets or sets animation speed factor (default is 1) */
  47918. animationSpeedFactor: number;
  47919. /**
  47920. * Creates a new NoiseProceduralTexture
  47921. * @param name defines the name fo the texture
  47922. * @param size defines the size of the texture (default is 256)
  47923. * @param scene defines the hosting scene
  47924. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  47925. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  47926. */
  47927. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47928. private _updateShaderUniforms;
  47929. protected _getDefines(): string;
  47930. /** Generate the current state of the procedural texture */
  47931. render(useCameraPostProcess?: boolean): void;
  47932. /**
  47933. * Serializes this noise procedural texture
  47934. * @returns a serialized noise procedural texture object
  47935. */
  47936. serialize(): any;
  47937. /**
  47938. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  47939. * @param parsedTexture defines parsed texture data
  47940. * @param scene defines the current scene
  47941. * @param rootUrl defines the root URL containing noise procedural texture information
  47942. * @returns a parsed NoiseProceduralTexture
  47943. */
  47944. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  47945. }
  47946. }
  47947. declare module BABYLON {
  47948. /**
  47949. * Raw cube texture where the raw buffers are passed in
  47950. */
  47951. export class RawCubeTexture extends CubeTexture {
  47952. /**
  47953. * Creates a cube texture where the raw buffers are passed in.
  47954. * @param scene defines the scene the texture is attached to
  47955. * @param data defines the array of data to use to create each face
  47956. * @param size defines the size of the textures
  47957. * @param format defines the format of the data
  47958. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47959. * @param generateMipMaps defines if the engine should generate the mip levels
  47960. * @param invertY defines if data must be stored with Y axis inverted
  47961. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47962. * @param compression defines the compression used (null by default)
  47963. */
  47964. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47965. /**
  47966. * Updates the raw cube texture.
  47967. * @param data defines the data to store
  47968. * @param format defines the data format
  47969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47970. * @param invertY defines if data must be stored with Y axis inverted
  47971. * @param compression defines the compression used (null by default)
  47972. * @param level defines which level of the texture to update
  47973. */
  47974. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  47975. /**
  47976. * Updates a raw cube texture with RGBD encoded data.
  47977. * @param data defines the array of data [mipmap][face] to use to create each face
  47978. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47979. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47980. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47981. * @returns a promsie that resolves when the operation is complete
  47982. */
  47983. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47984. /**
  47985. * Clones the raw cube texture.
  47986. * @return a new cube texture
  47987. */
  47988. clone(): CubeTexture;
  47989. /** @hidden */
  47990. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47991. }
  47992. }
  47993. declare module BABYLON {
  47994. /**
  47995. * Class used to store 3D textures containing user data
  47996. */
  47997. export class RawTexture3D extends Texture {
  47998. /** Gets or sets the texture format to use */
  47999. format: number;
  48000. private _engine;
  48001. /**
  48002. * Create a new RawTexture3D
  48003. * @param data defines the data of the texture
  48004. * @param width defines the width of the texture
  48005. * @param height defines the height of the texture
  48006. * @param depth defines the depth of the texture
  48007. * @param format defines the texture format to use
  48008. * @param scene defines the hosting scene
  48009. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48010. * @param invertY defines if texture must be stored with Y axis inverted
  48011. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48012. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48013. */
  48014. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48015. /** Gets or sets the texture format to use */
  48016. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48017. /**
  48018. * Update the texture with new data
  48019. * @param data defines the data to store in the texture
  48020. */
  48021. update(data: ArrayBufferView): void;
  48022. }
  48023. }
  48024. declare module BABYLON {
  48025. /**
  48026. * Creates a refraction texture used by refraction channel of the standard material.
  48027. * It is like a mirror but to see through a material.
  48028. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48029. */
  48030. export class RefractionTexture extends RenderTargetTexture {
  48031. /**
  48032. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48033. * 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.
  48034. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48035. */
  48036. refractionPlane: Plane;
  48037. /**
  48038. * Define how deep under the surface we should see.
  48039. */
  48040. depth: number;
  48041. /**
  48042. * Creates a refraction texture used by refraction channel of the standard material.
  48043. * It is like a mirror but to see through a material.
  48044. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48045. * @param name Define the texture name
  48046. * @param size Define the size of the underlying texture
  48047. * @param scene Define the scene the refraction belongs to
  48048. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48049. */
  48050. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48051. /**
  48052. * Clone the refraction texture.
  48053. * @returns the cloned texture
  48054. */
  48055. clone(): RefractionTexture;
  48056. /**
  48057. * Serialize the texture to a JSON representation you could use in Parse later on
  48058. * @returns the serialized JSON representation
  48059. */
  48060. serialize(): any;
  48061. }
  48062. }
  48063. declare module BABYLON {
  48064. /**
  48065. * Configuration for Draco compression
  48066. */
  48067. export interface IDracoCompressionConfiguration {
  48068. /**
  48069. * Configuration for the decoder.
  48070. */
  48071. decoder?: {
  48072. /**
  48073. * The url to the WebAssembly module.
  48074. */
  48075. wasmUrl?: string;
  48076. /**
  48077. * The url to the WebAssembly binary.
  48078. */
  48079. wasmBinaryUrl?: string;
  48080. /**
  48081. * The url to the fallback JavaScript module.
  48082. */
  48083. fallbackUrl?: string;
  48084. };
  48085. }
  48086. /**
  48087. * Draco compression (https://google.github.io/draco/)
  48088. *
  48089. * This class wraps the Draco module.
  48090. *
  48091. * **Encoder**
  48092. *
  48093. * The encoder is not currently implemented.
  48094. *
  48095. * **Decoder**
  48096. *
  48097. * 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.
  48098. *
  48099. * To update the configuration, use the following code:
  48100. * ```javascript
  48101. * DracoCompression.Configuration = {
  48102. * decoder: {
  48103. * wasmUrl: "<url to the WebAssembly library>",
  48104. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48105. * fallbackUrl: "<url to the fallback JavaScript library>",
  48106. * }
  48107. * };
  48108. * ```
  48109. *
  48110. * 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.
  48111. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48112. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48113. *
  48114. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48115. * ```javascript
  48116. * var dracoCompression = new DracoCompression();
  48117. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48118. * [VertexBuffer.PositionKind]: 0
  48119. * });
  48120. * ```
  48121. *
  48122. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48123. */
  48124. export class DracoCompression implements IDisposable {
  48125. private static _DecoderModulePromise;
  48126. /**
  48127. * The configuration. Defaults to the following urls:
  48128. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48129. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48130. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48131. */
  48132. static Configuration: IDracoCompressionConfiguration;
  48133. /**
  48134. * Returns true if the decoder is available.
  48135. */
  48136. static readonly DecoderAvailable: boolean;
  48137. /**
  48138. * Constructor
  48139. */
  48140. constructor();
  48141. /**
  48142. * Stop all async operations and release resources.
  48143. */
  48144. dispose(): void;
  48145. /**
  48146. * Decode Draco compressed mesh data to vertex data.
  48147. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48148. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48149. * @returns A promise that resolves with the decoded vertex data
  48150. */
  48151. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48152. [kind: string]: number;
  48153. }): Promise<VertexData>;
  48154. private static _GetDecoderModule;
  48155. private static _LoadScriptAsync;
  48156. private static _LoadFileAsync;
  48157. }
  48158. }
  48159. declare module BABYLON {
  48160. /**
  48161. * Class for building Constructive Solid Geometry
  48162. */
  48163. export class CSG {
  48164. private polygons;
  48165. /**
  48166. * The world matrix
  48167. */
  48168. matrix: Matrix;
  48169. /**
  48170. * Stores the position
  48171. */
  48172. position: Vector3;
  48173. /**
  48174. * Stores the rotation
  48175. */
  48176. rotation: Vector3;
  48177. /**
  48178. * Stores the rotation quaternion
  48179. */
  48180. rotationQuaternion: Nullable<Quaternion>;
  48181. /**
  48182. * Stores the scaling vector
  48183. */
  48184. scaling: Vector3;
  48185. /**
  48186. * Convert the Mesh to CSG
  48187. * @param mesh The Mesh to convert to CSG
  48188. * @returns A new CSG from the Mesh
  48189. */
  48190. static FromMesh(mesh: Mesh): CSG;
  48191. /**
  48192. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48193. * @param polygons Polygons used to construct a CSG solid
  48194. */
  48195. private static FromPolygons;
  48196. /**
  48197. * Clones, or makes a deep copy, of the CSG
  48198. * @returns A new CSG
  48199. */
  48200. clone(): CSG;
  48201. /**
  48202. * Unions this CSG with another CSG
  48203. * @param csg The CSG to union against this CSG
  48204. * @returns The unioned CSG
  48205. */
  48206. union(csg: CSG): CSG;
  48207. /**
  48208. * Unions this CSG with another CSG in place
  48209. * @param csg The CSG to union against this CSG
  48210. */
  48211. unionInPlace(csg: CSG): void;
  48212. /**
  48213. * Subtracts this CSG with another CSG
  48214. * @param csg The CSG to subtract against this CSG
  48215. * @returns A new CSG
  48216. */
  48217. subtract(csg: CSG): CSG;
  48218. /**
  48219. * Subtracts this CSG with another CSG in place
  48220. * @param csg The CSG to subtact against this CSG
  48221. */
  48222. subtractInPlace(csg: CSG): void;
  48223. /**
  48224. * Intersect this CSG with another CSG
  48225. * @param csg The CSG to intersect against this CSG
  48226. * @returns A new CSG
  48227. */
  48228. intersect(csg: CSG): CSG;
  48229. /**
  48230. * Intersects this CSG with another CSG in place
  48231. * @param csg The CSG to intersect against this CSG
  48232. */
  48233. intersectInPlace(csg: CSG): void;
  48234. /**
  48235. * Return a new CSG solid with solid and empty space switched. This solid is
  48236. * not modified.
  48237. * @returns A new CSG solid with solid and empty space switched
  48238. */
  48239. inverse(): CSG;
  48240. /**
  48241. * Inverses the CSG in place
  48242. */
  48243. inverseInPlace(): void;
  48244. /**
  48245. * This is used to keep meshes transformations so they can be restored
  48246. * when we build back a Babylon Mesh
  48247. * NB : All CSG operations are performed in world coordinates
  48248. * @param csg The CSG to copy the transform attributes from
  48249. * @returns This CSG
  48250. */
  48251. copyTransformAttributes(csg: CSG): CSG;
  48252. /**
  48253. * Build Raw mesh from CSG
  48254. * Coordinates here are in world space
  48255. * @param name The name of the mesh geometry
  48256. * @param scene The Scene
  48257. * @param keepSubMeshes Specifies if the submeshes should be kept
  48258. * @returns A new Mesh
  48259. */
  48260. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48261. /**
  48262. * Build Mesh from CSG taking material and transforms into account
  48263. * @param name The name of the Mesh
  48264. * @param material The material of the Mesh
  48265. * @param scene The Scene
  48266. * @param keepSubMeshes Specifies if submeshes should be kept
  48267. * @returns The new Mesh
  48268. */
  48269. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48270. }
  48271. }
  48272. declare module BABYLON {
  48273. /**
  48274. * Class used to create a trail following a mesh
  48275. */
  48276. export class TrailMesh extends Mesh {
  48277. private _generator;
  48278. private _autoStart;
  48279. private _running;
  48280. private _diameter;
  48281. private _length;
  48282. private _sectionPolygonPointsCount;
  48283. private _sectionVectors;
  48284. private _sectionNormalVectors;
  48285. private _beforeRenderObserver;
  48286. /**
  48287. * @constructor
  48288. * @param name The value used by scene.getMeshByName() to do a lookup.
  48289. * @param generator The mesh to generate a trail.
  48290. * @param scene The scene to add this mesh to.
  48291. * @param diameter Diameter of trailing mesh. Default is 1.
  48292. * @param length Length of trailing mesh. Default is 60.
  48293. * @param autoStart Automatically start trailing mesh. Default true.
  48294. */
  48295. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48296. /**
  48297. * "TrailMesh"
  48298. * @returns "TrailMesh"
  48299. */
  48300. getClassName(): string;
  48301. private _createMesh;
  48302. /**
  48303. * Start trailing mesh.
  48304. */
  48305. start(): void;
  48306. /**
  48307. * Stop trailing mesh.
  48308. */
  48309. stop(): void;
  48310. /**
  48311. * Update trailing mesh geometry.
  48312. */
  48313. update(): void;
  48314. /**
  48315. * Returns a new TrailMesh object.
  48316. * @param name is a string, the name given to the new mesh
  48317. * @param newGenerator use new generator object for cloned trail mesh
  48318. * @returns a new mesh
  48319. */
  48320. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48321. /**
  48322. * Serializes this trail mesh
  48323. * @param serializationObject object to write serialization to
  48324. */
  48325. serialize(serializationObject: any): void;
  48326. /**
  48327. * Parses a serialized trail mesh
  48328. * @param parsedMesh the serialized mesh
  48329. * @param scene the scene to create the trail mesh in
  48330. * @returns the created trail mesh
  48331. */
  48332. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48333. }
  48334. }
  48335. declare module BABYLON {
  48336. /**
  48337. * Class containing static functions to help procedurally build meshes
  48338. */
  48339. export class RibbonBuilder {
  48340. /**
  48341. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48342. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48343. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48344. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48345. * * 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
  48346. * * 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
  48347. * * 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
  48348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48349. * * 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
  48350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48351. * * 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
  48352. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48353. * * 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
  48354. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48356. * @param name defines the name of the mesh
  48357. * @param options defines the options used to create the mesh
  48358. * @param scene defines the hosting scene
  48359. * @returns the ribbon mesh
  48360. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48362. */
  48363. static CreateRibbon(name: string, options: {
  48364. pathArray: Vector3[][];
  48365. closeArray?: boolean;
  48366. closePath?: boolean;
  48367. offset?: number;
  48368. updatable?: boolean;
  48369. sideOrientation?: number;
  48370. frontUVs?: Vector4;
  48371. backUVs?: Vector4;
  48372. instance?: Mesh;
  48373. invertUV?: boolean;
  48374. uvs?: Vector2[];
  48375. colors?: Color4[];
  48376. }, scene?: Nullable<Scene>): Mesh;
  48377. }
  48378. }
  48379. declare module BABYLON {
  48380. /**
  48381. * Class containing static functions to help procedurally build meshes
  48382. */
  48383. export class TorusKnotBuilder {
  48384. /**
  48385. * Creates a torus knot mesh
  48386. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48387. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48388. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48389. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48391. * * 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
  48392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48393. * @param name defines the name of the mesh
  48394. * @param options defines the options used to create the mesh
  48395. * @param scene defines the hosting scene
  48396. * @returns the torus knot mesh
  48397. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48398. */
  48399. static CreateTorusKnot(name: string, options: {
  48400. radius?: number;
  48401. tube?: number;
  48402. radialSegments?: number;
  48403. tubularSegments?: number;
  48404. p?: number;
  48405. q?: number;
  48406. updatable?: boolean;
  48407. sideOrientation?: number;
  48408. frontUVs?: Vector4;
  48409. backUVs?: Vector4;
  48410. }, scene: any): Mesh;
  48411. }
  48412. }
  48413. declare module BABYLON {
  48414. /**
  48415. * Polygon
  48416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48417. */
  48418. export class Polygon {
  48419. /**
  48420. * Creates a rectangle
  48421. * @param xmin bottom X coord
  48422. * @param ymin bottom Y coord
  48423. * @param xmax top X coord
  48424. * @param ymax top Y coord
  48425. * @returns points that make the resulting rectation
  48426. */
  48427. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48428. /**
  48429. * Creates a circle
  48430. * @param radius radius of circle
  48431. * @param cx scale in x
  48432. * @param cy scale in y
  48433. * @param numberOfSides number of sides that make up the circle
  48434. * @returns points that make the resulting circle
  48435. */
  48436. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48437. /**
  48438. * Creates a polygon from input string
  48439. * @param input Input polygon data
  48440. * @returns the parsed points
  48441. */
  48442. static Parse(input: string): Vector2[];
  48443. /**
  48444. * Starts building a polygon from x and y coordinates
  48445. * @param x x coordinate
  48446. * @param y y coordinate
  48447. * @returns the started path2
  48448. */
  48449. static StartingAt(x: number, y: number): Path2;
  48450. }
  48451. /**
  48452. * Builds a polygon
  48453. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48454. */
  48455. export class PolygonMeshBuilder {
  48456. private _points;
  48457. private _outlinepoints;
  48458. private _holes;
  48459. private _name;
  48460. private _scene;
  48461. private _epoints;
  48462. private _eholes;
  48463. private _addToepoint;
  48464. /**
  48465. * Babylon reference to the earcut plugin.
  48466. */
  48467. bjsEarcut: any;
  48468. /**
  48469. * Creates a PolygonMeshBuilder
  48470. * @param name name of the builder
  48471. * @param contours Path of the polygon
  48472. * @param scene scene to add to when creating the mesh
  48473. * @param earcutInjection can be used to inject your own earcut reference
  48474. */
  48475. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48476. /**
  48477. * Adds a whole within the polygon
  48478. * @param hole Array of points defining the hole
  48479. * @returns this
  48480. */
  48481. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48482. /**
  48483. * Creates the polygon
  48484. * @param updatable If the mesh should be updatable
  48485. * @param depth The depth of the mesh created
  48486. * @returns the created mesh
  48487. */
  48488. build(updatable?: boolean, depth?: number): Mesh;
  48489. /**
  48490. * Creates the polygon
  48491. * @param depth The depth of the mesh created
  48492. * @returns the created VertexData
  48493. */
  48494. buildVertexData(depth?: number): VertexData;
  48495. /**
  48496. * Adds a side to the polygon
  48497. * @param positions points that make the polygon
  48498. * @param normals normals of the polygon
  48499. * @param uvs uvs of the polygon
  48500. * @param indices indices of the polygon
  48501. * @param bounds bounds of the polygon
  48502. * @param points points of the polygon
  48503. * @param depth depth of the polygon
  48504. * @param flip flip of the polygon
  48505. */
  48506. private addSide;
  48507. }
  48508. }
  48509. declare module BABYLON {
  48510. /**
  48511. * Class containing static functions to help procedurally build meshes
  48512. */
  48513. export class PolygonBuilder {
  48514. /**
  48515. * Creates a polygon mesh
  48516. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48517. * * 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
  48518. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48520. * * 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)
  48521. * * Remember you can only change the shape positions, not their number when updating a polygon
  48522. * @param name defines the name of the mesh
  48523. * @param options defines the options used to create the mesh
  48524. * @param scene defines the hosting scene
  48525. * @param earcutInjection can be used to inject your own earcut reference
  48526. * @returns the polygon mesh
  48527. */
  48528. static CreatePolygon(name: string, options: {
  48529. shape: Vector3[];
  48530. holes?: Vector3[][];
  48531. depth?: number;
  48532. faceUV?: Vector4[];
  48533. faceColors?: Color4[];
  48534. updatable?: boolean;
  48535. sideOrientation?: number;
  48536. frontUVs?: Vector4;
  48537. backUVs?: Vector4;
  48538. }, scene: Scene, earcutInjection?: any): Mesh;
  48539. /**
  48540. * Creates an extruded polygon mesh, with depth in the Y direction.
  48541. * * 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)
  48542. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48543. * @param name defines the name of the mesh
  48544. * @param options defines the options used to create the mesh
  48545. * @param scene defines the hosting scene
  48546. * @param earcutInjection can be used to inject your own earcut reference
  48547. * @returns the polygon mesh
  48548. */
  48549. static ExtrudePolygon(name: string, options: {
  48550. shape: Vector3[];
  48551. holes?: Vector3[][];
  48552. depth?: number;
  48553. faceUV?: Vector4[];
  48554. faceColors?: Color4[];
  48555. updatable?: boolean;
  48556. sideOrientation?: number;
  48557. frontUVs?: Vector4;
  48558. backUVs?: Vector4;
  48559. }, scene: Scene, earcutInjection?: any): Mesh;
  48560. }
  48561. }
  48562. declare module BABYLON {
  48563. /**
  48564. * Class containing static functions to help procedurally build meshes
  48565. */
  48566. export class ShapeBuilder {
  48567. /**
  48568. * 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.
  48569. * * 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.
  48570. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48571. * * 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.
  48572. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48573. * * 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
  48574. * * 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
  48575. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48577. * * 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
  48578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48580. * @param name defines the name of the mesh
  48581. * @param options defines the options used to create the mesh
  48582. * @param scene defines the hosting scene
  48583. * @returns the extruded shape mesh
  48584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48586. */
  48587. static ExtrudeShape(name: string, options: {
  48588. shape: Vector3[];
  48589. path: Vector3[];
  48590. scale?: number;
  48591. rotation?: number;
  48592. cap?: number;
  48593. updatable?: boolean;
  48594. sideOrientation?: number;
  48595. frontUVs?: Vector4;
  48596. backUVs?: Vector4;
  48597. instance?: Mesh;
  48598. invertUV?: boolean;
  48599. }, scene?: Nullable<Scene>): Mesh;
  48600. /**
  48601. * Creates an custom extruded shape mesh.
  48602. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48603. * * 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.
  48604. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48605. * * 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
  48606. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48607. * * 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
  48608. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48609. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48610. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48611. * * 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
  48612. * * 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
  48613. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48615. * * 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
  48616. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48618. * @param name defines the name of the mesh
  48619. * @param options defines the options used to create the mesh
  48620. * @param scene defines the hosting scene
  48621. * @returns the custom extruded shape mesh
  48622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48623. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48625. */
  48626. static ExtrudeShapeCustom(name: string, options: {
  48627. shape: Vector3[];
  48628. path: Vector3[];
  48629. scaleFunction?: any;
  48630. rotationFunction?: any;
  48631. ribbonCloseArray?: boolean;
  48632. ribbonClosePath?: boolean;
  48633. cap?: number;
  48634. updatable?: boolean;
  48635. sideOrientation?: number;
  48636. frontUVs?: Vector4;
  48637. backUVs?: Vector4;
  48638. instance?: Mesh;
  48639. invertUV?: boolean;
  48640. }, scene: Scene): Mesh;
  48641. private static _ExtrudeShapeGeneric;
  48642. }
  48643. }
  48644. declare module BABYLON {
  48645. /**
  48646. * Class containing static functions to help procedurally build meshes
  48647. */
  48648. export class LatheBuilder {
  48649. /**
  48650. * Creates lathe mesh.
  48651. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  48652. * * 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
  48653. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  48654. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  48655. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  48656. * * 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
  48657. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  48658. * * 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
  48659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48660. * * 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
  48661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48663. * @param name defines the name of the mesh
  48664. * @param options defines the options used to create the mesh
  48665. * @param scene defines the hosting scene
  48666. * @returns the lathe mesh
  48667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  48668. */
  48669. static CreateLathe(name: string, options: {
  48670. shape: Vector3[];
  48671. radius?: number;
  48672. tessellation?: number;
  48673. clip?: number;
  48674. arc?: number;
  48675. closed?: boolean;
  48676. updatable?: boolean;
  48677. sideOrientation?: number;
  48678. frontUVs?: Vector4;
  48679. backUVs?: Vector4;
  48680. cap?: number;
  48681. invertUV?: boolean;
  48682. }, scene: Scene): Mesh;
  48683. }
  48684. }
  48685. declare module BABYLON {
  48686. /**
  48687. * Class containing static functions to help procedurally build meshes
  48688. */
  48689. export class TubeBuilder {
  48690. /**
  48691. * Creates a tube mesh.
  48692. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48693. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  48694. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  48695. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  48696. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  48697. * * 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)
  48698. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  48699. * * 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
  48700. * * 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
  48701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48702. * * 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
  48703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48705. * @param name defines the name of the mesh
  48706. * @param options defines the options used to create the mesh
  48707. * @param scene defines the hosting scene
  48708. * @returns the tube mesh
  48709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48710. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  48711. */
  48712. static CreateTube(name: string, options: {
  48713. path: Vector3[];
  48714. radius?: number;
  48715. tessellation?: number;
  48716. radiusFunction?: {
  48717. (i: number, distance: number): number;
  48718. };
  48719. cap?: number;
  48720. arc?: number;
  48721. updatable?: boolean;
  48722. sideOrientation?: number;
  48723. frontUVs?: Vector4;
  48724. backUVs?: Vector4;
  48725. instance?: Mesh;
  48726. invertUV?: boolean;
  48727. }, scene: Scene): Mesh;
  48728. }
  48729. }
  48730. declare module BABYLON {
  48731. /**
  48732. * Class containing static functions to help procedurally build meshes
  48733. */
  48734. export class IcoSphereBuilder {
  48735. /**
  48736. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  48737. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  48738. * * 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`)
  48739. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  48740. * * 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
  48741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48742. * * 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
  48743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48744. * @param name defines the name of the mesh
  48745. * @param options defines the options used to create the mesh
  48746. * @param scene defines the hosting scene
  48747. * @returns the icosahedron mesh
  48748. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  48749. */
  48750. static CreateIcoSphere(name: string, options: {
  48751. radius?: number;
  48752. radiusX?: number;
  48753. radiusY?: number;
  48754. radiusZ?: number;
  48755. flat?: boolean;
  48756. subdivisions?: number;
  48757. sideOrientation?: number;
  48758. frontUVs?: Vector4;
  48759. backUVs?: Vector4;
  48760. updatable?: boolean;
  48761. }, scene: Scene): Mesh;
  48762. }
  48763. }
  48764. declare module BABYLON {
  48765. /**
  48766. * Class containing static functions to help procedurally build meshes
  48767. */
  48768. export class DecalBuilder {
  48769. /**
  48770. * Creates a decal mesh.
  48771. * 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
  48772. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  48773. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  48774. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  48775. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  48776. * @param name defines the name of the mesh
  48777. * @param sourceMesh defines the mesh where the decal must be applied
  48778. * @param options defines the options used to create the mesh
  48779. * @param scene defines the hosting scene
  48780. * @returns the decal mesh
  48781. * @see https://doc.babylonjs.com/how_to/decals
  48782. */
  48783. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  48784. position?: Vector3;
  48785. normal?: Vector3;
  48786. size?: Vector3;
  48787. angle?: number;
  48788. }): Mesh;
  48789. }
  48790. }
  48791. declare module BABYLON {
  48792. /**
  48793. * Class containing static functions to help procedurally build meshes
  48794. */
  48795. export class MeshBuilder {
  48796. /**
  48797. * Creates a box mesh
  48798. * * The parameter `size` sets the size (float) of each box side (default 1)
  48799. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48800. * * 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)
  48801. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48803. * * 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
  48804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48805. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48806. * @param name defines the name of the mesh
  48807. * @param options defines the options used to create the mesh
  48808. * @param scene defines the hosting scene
  48809. * @returns the box mesh
  48810. */
  48811. static CreateBox(name: string, options: {
  48812. size?: number;
  48813. width?: number;
  48814. height?: number;
  48815. depth?: number;
  48816. faceUV?: Vector4[];
  48817. faceColors?: Color4[];
  48818. sideOrientation?: number;
  48819. frontUVs?: Vector4;
  48820. backUVs?: Vector4;
  48821. updatable?: boolean;
  48822. }, scene?: Nullable<Scene>): Mesh;
  48823. /**
  48824. * Creates a sphere mesh
  48825. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48826. * * 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`)
  48827. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48828. * * 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
  48829. * * 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)
  48830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48831. * * 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
  48832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48833. * @param name defines the name of the mesh
  48834. * @param options defines the options used to create the mesh
  48835. * @param scene defines the hosting scene
  48836. * @returns the sphere mesh
  48837. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48838. */
  48839. static CreateSphere(name: string, options: {
  48840. segments?: number;
  48841. diameter?: number;
  48842. diameterX?: number;
  48843. diameterY?: number;
  48844. diameterZ?: number;
  48845. arc?: number;
  48846. slice?: number;
  48847. sideOrientation?: number;
  48848. frontUVs?: Vector4;
  48849. backUVs?: Vector4;
  48850. updatable?: boolean;
  48851. }, scene: any): Mesh;
  48852. /**
  48853. * Creates a plane polygonal mesh. By default, this is a disc
  48854. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  48855. * * 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
  48856. * * 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
  48857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48858. * * 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
  48859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48860. * @param name defines the name of the mesh
  48861. * @param options defines the options used to create the mesh
  48862. * @param scene defines the hosting scene
  48863. * @returns the plane polygonal mesh
  48864. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  48865. */
  48866. static CreateDisc(name: string, options: {
  48867. radius?: number;
  48868. tessellation?: number;
  48869. arc?: number;
  48870. updatable?: boolean;
  48871. sideOrientation?: number;
  48872. frontUVs?: Vector4;
  48873. backUVs?: Vector4;
  48874. }, scene?: Nullable<Scene>): Mesh;
  48875. /**
  48876. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  48877. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  48878. * * 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`)
  48879. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  48880. * * 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
  48881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48882. * * 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
  48883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48884. * @param name defines the name of the mesh
  48885. * @param options defines the options used to create the mesh
  48886. * @param scene defines the hosting scene
  48887. * @returns the icosahedron mesh
  48888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  48889. */
  48890. static CreateIcoSphere(name: string, options: {
  48891. radius?: number;
  48892. radiusX?: number;
  48893. radiusY?: number;
  48894. radiusZ?: number;
  48895. flat?: boolean;
  48896. subdivisions?: number;
  48897. sideOrientation?: number;
  48898. frontUVs?: Vector4;
  48899. backUVs?: Vector4;
  48900. updatable?: boolean;
  48901. }, scene: Scene): Mesh;
  48902. /**
  48903. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48904. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48905. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48906. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48907. * * 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
  48908. * * 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
  48909. * * 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
  48910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48911. * * 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
  48912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48913. * * 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
  48914. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48915. * * 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
  48916. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48918. * @param name defines the name of the mesh
  48919. * @param options defines the options used to create the mesh
  48920. * @param scene defines the hosting scene
  48921. * @returns the ribbon mesh
  48922. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48924. */
  48925. static CreateRibbon(name: string, options: {
  48926. pathArray: Vector3[][];
  48927. closeArray?: boolean;
  48928. closePath?: boolean;
  48929. offset?: number;
  48930. updatable?: boolean;
  48931. sideOrientation?: number;
  48932. frontUVs?: Vector4;
  48933. backUVs?: Vector4;
  48934. instance?: Mesh;
  48935. invertUV?: boolean;
  48936. uvs?: Vector2[];
  48937. colors?: Color4[];
  48938. }, scene?: Nullable<Scene>): Mesh;
  48939. /**
  48940. * Creates a cylinder or a cone mesh
  48941. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48942. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48943. * * 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.
  48944. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48945. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48946. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48947. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48948. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48949. * * 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).
  48950. * * 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
  48951. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48952. * * 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
  48953. * * 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.
  48954. * * If `enclose` is false, a ring surface is one element.
  48955. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48956. * * 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
  48957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48958. * * 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
  48959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48960. * @param name defines the name of the mesh
  48961. * @param options defines the options used to create the mesh
  48962. * @param scene defines the hosting scene
  48963. * @returns the cylinder mesh
  48964. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48965. */
  48966. static CreateCylinder(name: string, options: {
  48967. height?: number;
  48968. diameterTop?: number;
  48969. diameterBottom?: number;
  48970. diameter?: number;
  48971. tessellation?: number;
  48972. subdivisions?: number;
  48973. arc?: number;
  48974. faceColors?: Color4[];
  48975. faceUV?: Vector4[];
  48976. updatable?: boolean;
  48977. hasRings?: boolean;
  48978. enclose?: boolean;
  48979. sideOrientation?: number;
  48980. frontUVs?: Vector4;
  48981. backUVs?: Vector4;
  48982. }, scene: any): Mesh;
  48983. /**
  48984. * Creates a torus mesh
  48985. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48986. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48987. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48989. * * 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
  48990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48991. * @param name defines the name of the mesh
  48992. * @param options defines the options used to create the mesh
  48993. * @param scene defines the hosting scene
  48994. * @returns the torus mesh
  48995. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48996. */
  48997. static CreateTorus(name: string, options: {
  48998. diameter?: number;
  48999. thickness?: number;
  49000. tessellation?: number;
  49001. updatable?: boolean;
  49002. sideOrientation?: number;
  49003. frontUVs?: Vector4;
  49004. backUVs?: Vector4;
  49005. }, scene: any): Mesh;
  49006. /**
  49007. * Creates a torus knot mesh
  49008. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49009. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49010. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49011. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49013. * * 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
  49014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49015. * @param name defines the name of the mesh
  49016. * @param options defines the options used to create the mesh
  49017. * @param scene defines the hosting scene
  49018. * @returns the torus knot mesh
  49019. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49020. */
  49021. static CreateTorusKnot(name: string, options: {
  49022. radius?: number;
  49023. tube?: number;
  49024. radialSegments?: number;
  49025. tubularSegments?: number;
  49026. p?: number;
  49027. q?: number;
  49028. updatable?: boolean;
  49029. sideOrientation?: number;
  49030. frontUVs?: Vector4;
  49031. backUVs?: Vector4;
  49032. }, scene: any): Mesh;
  49033. /**
  49034. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49035. * * 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
  49036. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49037. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49038. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49039. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49040. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49041. * * 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
  49042. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49045. * @param name defines the name of the new line system
  49046. * @param options defines the options used to create the line system
  49047. * @param scene defines the hosting scene
  49048. * @returns a new line system mesh
  49049. */
  49050. static CreateLineSystem(name: string, options: {
  49051. lines: Vector3[][];
  49052. updatable?: boolean;
  49053. instance?: Nullable<LinesMesh>;
  49054. colors?: Nullable<Color4[][]>;
  49055. useVertexAlpha?: boolean;
  49056. }, scene: Nullable<Scene>): LinesMesh;
  49057. /**
  49058. * Creates a line mesh
  49059. * 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
  49060. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49061. * * The parameter `points` is an array successive Vector3
  49062. * * 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
  49063. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49064. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49065. * * When updating an instance, remember that only point positions can change, not the number of points
  49066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49068. * @param name defines the name of the new line system
  49069. * @param options defines the options used to create the line system
  49070. * @param scene defines the hosting scene
  49071. * @returns a new line mesh
  49072. */
  49073. static CreateLines(name: string, options: {
  49074. points: Vector3[];
  49075. updatable?: boolean;
  49076. instance?: Nullable<LinesMesh>;
  49077. colors?: Color4[];
  49078. useVertexAlpha?: boolean;
  49079. }, scene?: Nullable<Scene>): LinesMesh;
  49080. /**
  49081. * Creates a dashed line mesh
  49082. * * 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
  49083. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49084. * * The parameter `points` is an array successive Vector3
  49085. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49086. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49087. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49088. * * 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
  49089. * * When updating an instance, remember that only point positions can change, not the number of points
  49090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49091. * @param name defines the name of the mesh
  49092. * @param options defines the options used to create the mesh
  49093. * @param scene defines the hosting scene
  49094. * @returns the dashed line mesh
  49095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49096. */
  49097. static CreateDashedLines(name: string, options: {
  49098. points: Vector3[];
  49099. dashSize?: number;
  49100. gapSize?: number;
  49101. dashNb?: number;
  49102. updatable?: boolean;
  49103. instance?: LinesMesh;
  49104. }, scene?: Nullable<Scene>): LinesMesh;
  49105. /**
  49106. * 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.
  49107. * * 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.
  49108. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49109. * * 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.
  49110. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49111. * * 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
  49112. * * 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
  49113. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49115. * * 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
  49116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49118. * @param name defines the name of the mesh
  49119. * @param options defines the options used to create the mesh
  49120. * @param scene defines the hosting scene
  49121. * @returns the extruded shape mesh
  49122. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49124. */
  49125. static ExtrudeShape(name: string, options: {
  49126. shape: Vector3[];
  49127. path: Vector3[];
  49128. scale?: number;
  49129. rotation?: number;
  49130. cap?: number;
  49131. updatable?: boolean;
  49132. sideOrientation?: number;
  49133. frontUVs?: Vector4;
  49134. backUVs?: Vector4;
  49135. instance?: Mesh;
  49136. invertUV?: boolean;
  49137. }, scene?: Nullable<Scene>): Mesh;
  49138. /**
  49139. * Creates an custom extruded shape mesh.
  49140. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49141. * * 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.
  49142. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49143. * * 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
  49144. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49145. * * 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
  49146. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49147. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49148. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49149. * * 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
  49150. * * 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
  49151. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49153. * * 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
  49154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49156. * @param name defines the name of the mesh
  49157. * @param options defines the options used to create the mesh
  49158. * @param scene defines the hosting scene
  49159. * @returns the custom extruded shape mesh
  49160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49163. */
  49164. static ExtrudeShapeCustom(name: string, options: {
  49165. shape: Vector3[];
  49166. path: Vector3[];
  49167. scaleFunction?: any;
  49168. rotationFunction?: any;
  49169. ribbonCloseArray?: boolean;
  49170. ribbonClosePath?: boolean;
  49171. cap?: number;
  49172. updatable?: boolean;
  49173. sideOrientation?: number;
  49174. frontUVs?: Vector4;
  49175. backUVs?: Vector4;
  49176. instance?: Mesh;
  49177. invertUV?: boolean;
  49178. }, scene: Scene): Mesh;
  49179. /**
  49180. * Creates lathe mesh.
  49181. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49182. * * 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
  49183. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49184. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49185. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49186. * * 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
  49187. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49188. * * 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
  49189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49190. * * 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
  49191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49193. * @param name defines the name of the mesh
  49194. * @param options defines the options used to create the mesh
  49195. * @param scene defines the hosting scene
  49196. * @returns the lathe mesh
  49197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49198. */
  49199. static CreateLathe(name: string, options: {
  49200. shape: Vector3[];
  49201. radius?: number;
  49202. tessellation?: number;
  49203. clip?: number;
  49204. arc?: number;
  49205. closed?: boolean;
  49206. updatable?: boolean;
  49207. sideOrientation?: number;
  49208. frontUVs?: Vector4;
  49209. backUVs?: Vector4;
  49210. cap?: number;
  49211. invertUV?: boolean;
  49212. }, scene: Scene): Mesh;
  49213. /**
  49214. * Creates a plane mesh
  49215. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49216. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49217. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49219. * * 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
  49220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49221. * @param name defines the name of the mesh
  49222. * @param options defines the options used to create the mesh
  49223. * @param scene defines the hosting scene
  49224. * @returns the plane mesh
  49225. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49226. */
  49227. static CreatePlane(name: string, options: {
  49228. size?: number;
  49229. width?: number;
  49230. height?: number;
  49231. sideOrientation?: number;
  49232. frontUVs?: Vector4;
  49233. backUVs?: Vector4;
  49234. updatable?: boolean;
  49235. sourcePlane?: Plane;
  49236. }, scene: Scene): Mesh;
  49237. /**
  49238. * Creates a ground mesh
  49239. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49240. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49242. * @param name defines the name of the mesh
  49243. * @param options defines the options used to create the mesh
  49244. * @param scene defines the hosting scene
  49245. * @returns the ground mesh
  49246. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49247. */
  49248. static CreateGround(name: string, options: {
  49249. width?: number;
  49250. height?: number;
  49251. subdivisions?: number;
  49252. subdivisionsX?: number;
  49253. subdivisionsY?: number;
  49254. updatable?: boolean;
  49255. }, scene: any): Mesh;
  49256. /**
  49257. * Creates a tiled ground mesh
  49258. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49259. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49260. * * 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
  49261. * * 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
  49262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49263. * @param name defines the name of the mesh
  49264. * @param options defines the options used to create the mesh
  49265. * @param scene defines the hosting scene
  49266. * @returns the tiled ground mesh
  49267. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49268. */
  49269. static CreateTiledGround(name: string, options: {
  49270. xmin: number;
  49271. zmin: number;
  49272. xmax: number;
  49273. zmax: number;
  49274. subdivisions?: {
  49275. w: number;
  49276. h: number;
  49277. };
  49278. precision?: {
  49279. w: number;
  49280. h: number;
  49281. };
  49282. updatable?: boolean;
  49283. }, scene: Scene): Mesh;
  49284. /**
  49285. * Creates a ground mesh from a height map
  49286. * * The parameter `url` sets the URL of the height map image resource.
  49287. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49288. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49289. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49290. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49291. * * 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.
  49292. * * 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).
  49293. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49295. * @param name defines the name of the mesh
  49296. * @param url defines the url to the height map
  49297. * @param options defines the options used to create the mesh
  49298. * @param scene defines the hosting scene
  49299. * @returns the ground mesh
  49300. * @see https://doc.babylonjs.com/babylon101/height_map
  49301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49302. */
  49303. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49304. width?: number;
  49305. height?: number;
  49306. subdivisions?: number;
  49307. minHeight?: number;
  49308. maxHeight?: number;
  49309. colorFilter?: Color3;
  49310. alphaFilter?: number;
  49311. updatable?: boolean;
  49312. onReady?: (mesh: GroundMesh) => void;
  49313. }, scene: Scene): GroundMesh;
  49314. /**
  49315. * Creates a polygon mesh
  49316. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49317. * * 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
  49318. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49320. * * 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)
  49321. * * Remember you can only change the shape positions, not their number when updating a polygon
  49322. * @param name defines the name of the mesh
  49323. * @param options defines the options used to create the mesh
  49324. * @param scene defines the hosting scene
  49325. * @param earcutInjection can be used to inject your own earcut reference
  49326. * @returns the polygon mesh
  49327. */
  49328. static CreatePolygon(name: string, options: {
  49329. shape: Vector3[];
  49330. holes?: Vector3[][];
  49331. depth?: number;
  49332. faceUV?: Vector4[];
  49333. faceColors?: Color4[];
  49334. updatable?: boolean;
  49335. sideOrientation?: number;
  49336. frontUVs?: Vector4;
  49337. backUVs?: Vector4;
  49338. }, scene: Scene, earcutInjection?: any): Mesh;
  49339. /**
  49340. * Creates an extruded polygon mesh, with depth in the Y direction.
  49341. * * 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)
  49342. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49343. * @param name defines the name of the mesh
  49344. * @param options defines the options used to create the mesh
  49345. * @param scene defines the hosting scene
  49346. * @param earcutInjection can be used to inject your own earcut reference
  49347. * @returns the polygon mesh
  49348. */
  49349. static ExtrudePolygon(name: string, options: {
  49350. shape: Vector3[];
  49351. holes?: Vector3[][];
  49352. depth?: number;
  49353. faceUV?: Vector4[];
  49354. faceColors?: Color4[];
  49355. updatable?: boolean;
  49356. sideOrientation?: number;
  49357. frontUVs?: Vector4;
  49358. backUVs?: Vector4;
  49359. }, scene: Scene, earcutInjection?: any): Mesh;
  49360. /**
  49361. * Creates a tube mesh.
  49362. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49363. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49364. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49365. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49366. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49367. * * 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)
  49368. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49369. * * 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
  49370. * * 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
  49371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49372. * * 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
  49373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49375. * @param name defines the name of the mesh
  49376. * @param options defines the options used to create the mesh
  49377. * @param scene defines the hosting scene
  49378. * @returns the tube mesh
  49379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49380. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49381. */
  49382. static CreateTube(name: string, options: {
  49383. path: Vector3[];
  49384. radius?: number;
  49385. tessellation?: number;
  49386. radiusFunction?: {
  49387. (i: number, distance: number): number;
  49388. };
  49389. cap?: number;
  49390. arc?: number;
  49391. updatable?: boolean;
  49392. sideOrientation?: number;
  49393. frontUVs?: Vector4;
  49394. backUVs?: Vector4;
  49395. instance?: Mesh;
  49396. invertUV?: boolean;
  49397. }, scene: Scene): Mesh;
  49398. /**
  49399. * Creates a polyhedron mesh
  49400. * * 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
  49401. * * The parameter `size` (positive float, default 1) sets the polygon size
  49402. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49403. * * 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`
  49404. * * 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
  49405. * * 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)`)
  49406. * * 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
  49407. * * 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
  49408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49409. * * 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
  49410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49411. * @param name defines the name of the mesh
  49412. * @param options defines the options used to create the mesh
  49413. * @param scene defines the hosting scene
  49414. * @returns the polyhedron mesh
  49415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49416. */
  49417. static CreatePolyhedron(name: string, options: {
  49418. type?: number;
  49419. size?: number;
  49420. sizeX?: number;
  49421. sizeY?: number;
  49422. sizeZ?: number;
  49423. custom?: any;
  49424. faceUV?: Vector4[];
  49425. faceColors?: Color4[];
  49426. flat?: boolean;
  49427. updatable?: boolean;
  49428. sideOrientation?: number;
  49429. frontUVs?: Vector4;
  49430. backUVs?: Vector4;
  49431. }, scene: Scene): Mesh;
  49432. /**
  49433. * Creates a decal mesh.
  49434. * 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
  49435. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49436. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49437. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49438. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49439. * @param name defines the name of the mesh
  49440. * @param sourceMesh defines the mesh where the decal must be applied
  49441. * @param options defines the options used to create the mesh
  49442. * @param scene defines the hosting scene
  49443. * @returns the decal mesh
  49444. * @see https://doc.babylonjs.com/how_to/decals
  49445. */
  49446. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49447. position?: Vector3;
  49448. normal?: Vector3;
  49449. size?: Vector3;
  49450. angle?: number;
  49451. }): Mesh;
  49452. }
  49453. }
  49454. declare module BABYLON {
  49455. /**
  49456. * A simplifier interface for future simplification implementations
  49457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49458. */
  49459. export interface ISimplifier {
  49460. /**
  49461. * Simplification of a given mesh according to the given settings.
  49462. * Since this requires computation, it is assumed that the function runs async.
  49463. * @param settings The settings of the simplification, including quality and distance
  49464. * @param successCallback A callback that will be called after the mesh was simplified.
  49465. * @param errorCallback in case of an error, this callback will be called. optional.
  49466. */
  49467. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49468. }
  49469. /**
  49470. * Expected simplification settings.
  49471. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49473. */
  49474. export interface ISimplificationSettings {
  49475. /**
  49476. * Gets or sets the expected quality
  49477. */
  49478. quality: number;
  49479. /**
  49480. * Gets or sets the distance when this optimized version should be used
  49481. */
  49482. distance: number;
  49483. /**
  49484. * Gets an already optimized mesh
  49485. */
  49486. optimizeMesh?: boolean;
  49487. }
  49488. /**
  49489. * Class used to specify simplification options
  49490. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49491. */
  49492. export class SimplificationSettings implements ISimplificationSettings {
  49493. /** expected quality */
  49494. quality: number;
  49495. /** distance when this optimized version should be used */
  49496. distance: number;
  49497. /** already optimized mesh */
  49498. optimizeMesh?: boolean | undefined;
  49499. /**
  49500. * Creates a SimplificationSettings
  49501. * @param quality expected quality
  49502. * @param distance distance when this optimized version should be used
  49503. * @param optimizeMesh already optimized mesh
  49504. */
  49505. constructor(
  49506. /** expected quality */
  49507. quality: number,
  49508. /** distance when this optimized version should be used */
  49509. distance: number,
  49510. /** already optimized mesh */
  49511. optimizeMesh?: boolean | undefined);
  49512. }
  49513. /**
  49514. * Interface used to define a simplification task
  49515. */
  49516. export interface ISimplificationTask {
  49517. /**
  49518. * Array of settings
  49519. */
  49520. settings: Array<ISimplificationSettings>;
  49521. /**
  49522. * Simplification type
  49523. */
  49524. simplificationType: SimplificationType;
  49525. /**
  49526. * Mesh to simplify
  49527. */
  49528. mesh: Mesh;
  49529. /**
  49530. * Callback called on success
  49531. */
  49532. successCallback?: () => void;
  49533. /**
  49534. * Defines if parallel processing can be used
  49535. */
  49536. parallelProcessing: boolean;
  49537. }
  49538. /**
  49539. * Queue used to order the simplification tasks
  49540. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49541. */
  49542. export class SimplificationQueue {
  49543. private _simplificationArray;
  49544. /**
  49545. * Gets a boolean indicating that the process is still running
  49546. */
  49547. running: boolean;
  49548. /**
  49549. * Creates a new queue
  49550. */
  49551. constructor();
  49552. /**
  49553. * Adds a new simplification task
  49554. * @param task defines a task to add
  49555. */
  49556. addTask(task: ISimplificationTask): void;
  49557. /**
  49558. * Execute next task
  49559. */
  49560. executeNext(): void;
  49561. /**
  49562. * Execute a simplification task
  49563. * @param task defines the task to run
  49564. */
  49565. runSimplification(task: ISimplificationTask): void;
  49566. private getSimplifier;
  49567. }
  49568. /**
  49569. * The implemented types of simplification
  49570. * At the moment only Quadratic Error Decimation is implemented
  49571. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49572. */
  49573. export enum SimplificationType {
  49574. /** Quadratic error decimation */
  49575. QUADRATIC = 0
  49576. }
  49577. }
  49578. declare module BABYLON {
  49579. interface Scene {
  49580. /** @hidden (Backing field) */
  49581. _simplificationQueue: SimplificationQueue;
  49582. /**
  49583. * Gets or sets the simplification queue attached to the scene
  49584. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49585. */
  49586. simplificationQueue: SimplificationQueue;
  49587. }
  49588. interface Mesh {
  49589. /**
  49590. * Simplify the mesh according to the given array of settings.
  49591. * Function will return immediately and will simplify async
  49592. * @param settings a collection of simplification settings
  49593. * @param parallelProcessing should all levels calculate parallel or one after the other
  49594. * @param simplificationType the type of simplification to run
  49595. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49596. * @returns the current mesh
  49597. */
  49598. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49599. }
  49600. /**
  49601. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49602. * created in a scene
  49603. */
  49604. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49605. /**
  49606. * The component name helpfull to identify the component in the list of scene components.
  49607. */
  49608. readonly name: string;
  49609. /**
  49610. * The scene the component belongs to.
  49611. */
  49612. scene: Scene;
  49613. /**
  49614. * Creates a new instance of the component for the given scene
  49615. * @param scene Defines the scene to register the component in
  49616. */
  49617. constructor(scene: Scene);
  49618. /**
  49619. * Registers the component in a given scene
  49620. */
  49621. register(): void;
  49622. /**
  49623. * Rebuilds the elements related to this component in case of
  49624. * context lost for instance.
  49625. */
  49626. rebuild(): void;
  49627. /**
  49628. * Disposes the component and the associated ressources
  49629. */
  49630. dispose(): void;
  49631. private _beforeCameraUpdate;
  49632. }
  49633. }
  49634. declare module BABYLON {
  49635. /**
  49636. * Class used to enable access to IndexedDB
  49637. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49638. */
  49639. export class Database implements IOfflineProvider {
  49640. private _callbackManifestChecked;
  49641. private _currentSceneUrl;
  49642. private _db;
  49643. private _enableSceneOffline;
  49644. private _enableTexturesOffline;
  49645. private _manifestVersionFound;
  49646. private _mustUpdateRessources;
  49647. private _hasReachedQuota;
  49648. private _isSupported;
  49649. private _idbFactory;
  49650. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49651. private static IsUASupportingBlobStorage;
  49652. /**
  49653. * Gets a boolean indicating if Database storate is enabled (off by default)
  49654. */
  49655. static IDBStorageEnabled: boolean;
  49656. /**
  49657. * Gets a boolean indicating if scene must be saved in the database
  49658. */
  49659. readonly enableSceneOffline: boolean;
  49660. /**
  49661. * Gets a boolean indicating if textures must be saved in the database
  49662. */
  49663. readonly enableTexturesOffline: boolean;
  49664. /**
  49665. * Creates a new Database
  49666. * @param urlToScene defines the url to load the scene
  49667. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49668. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49669. */
  49670. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49671. private static _ParseURL;
  49672. private static _ReturnFullUrlLocation;
  49673. private _checkManifestFile;
  49674. /**
  49675. * Open the database and make it available
  49676. * @param successCallback defines the callback to call on success
  49677. * @param errorCallback defines the callback to call on error
  49678. */
  49679. open(successCallback: () => void, errorCallback: () => void): void;
  49680. /**
  49681. * Loads an image from the database
  49682. * @param url defines the url to load from
  49683. * @param image defines the target DOM image
  49684. */
  49685. loadImage(url: string, image: HTMLImageElement): void;
  49686. private _loadImageFromDBAsync;
  49687. private _saveImageIntoDBAsync;
  49688. private _checkVersionFromDB;
  49689. private _loadVersionFromDBAsync;
  49690. private _saveVersionIntoDBAsync;
  49691. /**
  49692. * Loads a file from database
  49693. * @param url defines the URL to load from
  49694. * @param sceneLoaded defines a callback to call on success
  49695. * @param progressCallBack defines a callback to call when progress changed
  49696. * @param errorCallback defines a callback to call on error
  49697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49698. */
  49699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49700. private _loadFileAsync;
  49701. private _saveFileAsync;
  49702. /**
  49703. * Validates if xhr data is correct
  49704. * @param xhr defines the request to validate
  49705. * @param dataType defines the expected data type
  49706. * @returns true if data is correct
  49707. */
  49708. private static _ValidateXHRData;
  49709. }
  49710. }
  49711. declare module BABYLON {
  49712. /** @hidden */
  49713. export var gpuUpdateParticlesPixelShader: {
  49714. name: string;
  49715. shader: string;
  49716. };
  49717. }
  49718. declare module BABYLON {
  49719. /** @hidden */
  49720. export var gpuUpdateParticlesVertexShader: {
  49721. name: string;
  49722. shader: string;
  49723. };
  49724. }
  49725. declare module BABYLON {
  49726. /** @hidden */
  49727. export var clipPlaneFragmentDeclaration2: {
  49728. name: string;
  49729. shader: string;
  49730. };
  49731. }
  49732. declare module BABYLON {
  49733. /** @hidden */
  49734. export var gpuRenderParticlesPixelShader: {
  49735. name: string;
  49736. shader: string;
  49737. };
  49738. }
  49739. declare module BABYLON {
  49740. /** @hidden */
  49741. export var clipPlaneVertexDeclaration2: {
  49742. name: string;
  49743. shader: string;
  49744. };
  49745. }
  49746. declare module BABYLON {
  49747. /** @hidden */
  49748. export var gpuRenderParticlesVertexShader: {
  49749. name: string;
  49750. shader: string;
  49751. };
  49752. }
  49753. declare module BABYLON {
  49754. /**
  49755. * This represents a GPU particle system in Babylon
  49756. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49757. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49758. */
  49759. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49760. /**
  49761. * The layer mask we are rendering the particles through.
  49762. */
  49763. layerMask: number;
  49764. private _capacity;
  49765. private _activeCount;
  49766. private _currentActiveCount;
  49767. private _accumulatedCount;
  49768. private _renderEffect;
  49769. private _updateEffect;
  49770. private _buffer0;
  49771. private _buffer1;
  49772. private _spriteBuffer;
  49773. private _updateVAO;
  49774. private _renderVAO;
  49775. private _targetIndex;
  49776. private _sourceBuffer;
  49777. private _targetBuffer;
  49778. private _engine;
  49779. private _currentRenderId;
  49780. private _started;
  49781. private _stopped;
  49782. private _timeDelta;
  49783. private _randomTexture;
  49784. private _randomTexture2;
  49785. private _attributesStrideSize;
  49786. private _updateEffectOptions;
  49787. private _randomTextureSize;
  49788. private _actualFrame;
  49789. private readonly _rawTextureWidth;
  49790. /**
  49791. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49792. */
  49793. static readonly IsSupported: boolean;
  49794. /**
  49795. * An event triggered when the system is disposed.
  49796. */
  49797. onDisposeObservable: Observable<GPUParticleSystem>;
  49798. /**
  49799. * Gets the maximum number of particles active at the same time.
  49800. * @returns The max number of active particles.
  49801. */
  49802. getCapacity(): number;
  49803. /**
  49804. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49805. * to override the particles.
  49806. */
  49807. forceDepthWrite: boolean;
  49808. /**
  49809. * Gets or set the number of active particles
  49810. */
  49811. activeParticleCount: number;
  49812. private _preWarmDone;
  49813. /**
  49814. * Is this system ready to be used/rendered
  49815. * @return true if the system is ready
  49816. */
  49817. isReady(): boolean;
  49818. /**
  49819. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49820. * @returns True if it has been started, otherwise false.
  49821. */
  49822. isStarted(): boolean;
  49823. /**
  49824. * Starts the particle system and begins to emit
  49825. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49826. */
  49827. start(delay?: number): void;
  49828. /**
  49829. * Stops the particle system.
  49830. */
  49831. stop(): void;
  49832. /**
  49833. * Remove all active particles
  49834. */
  49835. reset(): void;
  49836. /**
  49837. * Returns the string "GPUParticleSystem"
  49838. * @returns a string containing the class name
  49839. */
  49840. getClassName(): string;
  49841. private _colorGradientsTexture;
  49842. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49843. /**
  49844. * Adds a new color gradient
  49845. * @param gradient defines the gradient to use (between 0 and 1)
  49846. * @param color1 defines the color to affect to the specified gradient
  49847. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49848. * @returns the current particle system
  49849. */
  49850. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49851. /**
  49852. * Remove a specific color gradient
  49853. * @param gradient defines the gradient to remove
  49854. * @returns the current particle system
  49855. */
  49856. removeColorGradient(gradient: number): GPUParticleSystem;
  49857. private _angularSpeedGradientsTexture;
  49858. private _sizeGradientsTexture;
  49859. private _velocityGradientsTexture;
  49860. private _limitVelocityGradientsTexture;
  49861. private _dragGradientsTexture;
  49862. private _addFactorGradient;
  49863. /**
  49864. * Adds a new size gradient
  49865. * @param gradient defines the gradient to use (between 0 and 1)
  49866. * @param factor defines the size factor to affect to the specified gradient
  49867. * @returns the current particle system
  49868. */
  49869. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49870. /**
  49871. * Remove a specific size gradient
  49872. * @param gradient defines the gradient to remove
  49873. * @returns the current particle system
  49874. */
  49875. removeSizeGradient(gradient: number): GPUParticleSystem;
  49876. /**
  49877. * Adds a new angular speed gradient
  49878. * @param gradient defines the gradient to use (between 0 and 1)
  49879. * @param factor defines the angular speed to affect to the specified gradient
  49880. * @returns the current particle system
  49881. */
  49882. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49883. /**
  49884. * Remove a specific angular speed gradient
  49885. * @param gradient defines the gradient to remove
  49886. * @returns the current particle system
  49887. */
  49888. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49889. /**
  49890. * Adds a new velocity gradient
  49891. * @param gradient defines the gradient to use (between 0 and 1)
  49892. * @param factor defines the velocity to affect to the specified gradient
  49893. * @returns the current particle system
  49894. */
  49895. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49896. /**
  49897. * Remove a specific velocity gradient
  49898. * @param gradient defines the gradient to remove
  49899. * @returns the current particle system
  49900. */
  49901. removeVelocityGradient(gradient: number): GPUParticleSystem;
  49902. /**
  49903. * Adds a new limit velocity gradient
  49904. * @param gradient defines the gradient to use (between 0 and 1)
  49905. * @param factor defines the limit velocity value to affect to the specified gradient
  49906. * @returns the current particle system
  49907. */
  49908. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49909. /**
  49910. * Remove a specific limit velocity gradient
  49911. * @param gradient defines the gradient to remove
  49912. * @returns the current particle system
  49913. */
  49914. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  49915. /**
  49916. * Adds a new drag gradient
  49917. * @param gradient defines the gradient to use (between 0 and 1)
  49918. * @param factor defines the drag value to affect to the specified gradient
  49919. * @returns the current particle system
  49920. */
  49921. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  49922. /**
  49923. * Remove a specific drag gradient
  49924. * @param gradient defines the gradient to remove
  49925. * @returns the current particle system
  49926. */
  49927. removeDragGradient(gradient: number): GPUParticleSystem;
  49928. /**
  49929. * Not supported by GPUParticleSystem
  49930. * @param gradient defines the gradient to use (between 0 and 1)
  49931. * @param factor defines the emit rate value to affect to the specified gradient
  49932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49933. * @returns the current particle system
  49934. */
  49935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49936. /**
  49937. * Not supported by GPUParticleSystem
  49938. * @param gradient defines the gradient to remove
  49939. * @returns the current particle system
  49940. */
  49941. removeEmitRateGradient(gradient: number): IParticleSystem;
  49942. /**
  49943. * Not supported by GPUParticleSystem
  49944. * @param gradient defines the gradient to use (between 0 and 1)
  49945. * @param factor defines the start size value to affect to the specified gradient
  49946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49947. * @returns the current particle system
  49948. */
  49949. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49950. /**
  49951. * Not supported by GPUParticleSystem
  49952. * @param gradient defines the gradient to remove
  49953. * @returns the current particle system
  49954. */
  49955. removeStartSizeGradient(gradient: number): IParticleSystem;
  49956. /**
  49957. * Not supported by GPUParticleSystem
  49958. * @param gradient defines the gradient to use (between 0 and 1)
  49959. * @param min defines the color remap minimal range
  49960. * @param max defines the color remap maximal range
  49961. * @returns the current particle system
  49962. */
  49963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49964. /**
  49965. * Not supported by GPUParticleSystem
  49966. * @param gradient defines the gradient to remove
  49967. * @returns the current particle system
  49968. */
  49969. removeColorRemapGradient(): IParticleSystem;
  49970. /**
  49971. * Not supported by GPUParticleSystem
  49972. * @param gradient defines the gradient to use (between 0 and 1)
  49973. * @param min defines the alpha remap minimal range
  49974. * @param max defines the alpha remap maximal range
  49975. * @returns the current particle system
  49976. */
  49977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49978. /**
  49979. * Not supported by GPUParticleSystem
  49980. * @param gradient defines the gradient to remove
  49981. * @returns the current particle system
  49982. */
  49983. removeAlphaRemapGradient(): IParticleSystem;
  49984. /**
  49985. * Not supported by GPUParticleSystem
  49986. * @param gradient defines the gradient to use (between 0 and 1)
  49987. * @param color defines the color to affect to the specified gradient
  49988. * @returns the current particle system
  49989. */
  49990. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  49991. /**
  49992. * Not supported by GPUParticleSystem
  49993. * @param gradient defines the gradient to remove
  49994. * @returns the current particle system
  49995. */
  49996. removeRampGradient(): IParticleSystem;
  49997. /**
  49998. * Not supported by GPUParticleSystem
  49999. * @returns the list of ramp gradients
  50000. */
  50001. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50002. /**
  50003. * Not supported by GPUParticleSystem
  50004. * Gets or sets a boolean indicating that ramp gradients must be used
  50005. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50006. */
  50007. useRampGradients: boolean;
  50008. /**
  50009. * Not supported by GPUParticleSystem
  50010. * @param gradient defines the gradient to use (between 0 and 1)
  50011. * @param factor defines the life time factor to affect to the specified gradient
  50012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50013. * @returns the current particle system
  50014. */
  50015. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50016. /**
  50017. * Not supported by GPUParticleSystem
  50018. * @param gradient defines the gradient to remove
  50019. * @returns the current particle system
  50020. */
  50021. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50022. /**
  50023. * Instantiates a GPU particle system.
  50024. * 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.
  50025. * @param name The name of the particle system
  50026. * @param options The options used to create the system
  50027. * @param scene The scene the particle system belongs to
  50028. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50029. */
  50030. constructor(name: string, options: Partial<{
  50031. capacity: number;
  50032. randomTextureSize: number;
  50033. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50034. protected _reset(): void;
  50035. private _createUpdateVAO;
  50036. private _createRenderVAO;
  50037. private _initialize;
  50038. /** @hidden */
  50039. _recreateUpdateEffect(): void;
  50040. /** @hidden */
  50041. _recreateRenderEffect(): void;
  50042. /**
  50043. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50044. * @param preWarm defines if we are in the pre-warmimg phase
  50045. */
  50046. animate(preWarm?: boolean): void;
  50047. private _createFactorGradientTexture;
  50048. private _createSizeGradientTexture;
  50049. private _createAngularSpeedGradientTexture;
  50050. private _createVelocityGradientTexture;
  50051. private _createLimitVelocityGradientTexture;
  50052. private _createDragGradientTexture;
  50053. private _createColorGradientTexture;
  50054. /**
  50055. * Renders the particle system in its current state
  50056. * @param preWarm defines if the system should only update the particles but not render them
  50057. * @returns the current number of particles
  50058. */
  50059. render(preWarm?: boolean): number;
  50060. /**
  50061. * Rebuilds the particle system
  50062. */
  50063. rebuild(): void;
  50064. private _releaseBuffers;
  50065. private _releaseVAOs;
  50066. /**
  50067. * Disposes the particle system and free the associated resources
  50068. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50069. */
  50070. dispose(disposeTexture?: boolean): void;
  50071. /**
  50072. * Clones the particle system.
  50073. * @param name The name of the cloned object
  50074. * @param newEmitter The new emitter to use
  50075. * @returns the cloned particle system
  50076. */
  50077. clone(name: string, newEmitter: any): GPUParticleSystem;
  50078. /**
  50079. * Serializes the particle system to a JSON object.
  50080. * @returns the JSON object
  50081. */
  50082. serialize(): any;
  50083. /**
  50084. * Parses a JSON object to create a GPU particle system.
  50085. * @param parsedParticleSystem The JSON object to parse
  50086. * @param scene The scene to create the particle system in
  50087. * @param rootUrl The root url to use to load external dependencies like texture
  50088. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50089. * @returns the parsed GPU particle system
  50090. */
  50091. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50092. }
  50093. }
  50094. declare module BABYLON {
  50095. /**
  50096. * Represents a set of particle systems working together to create a specific effect
  50097. */
  50098. export class ParticleSystemSet implements IDisposable {
  50099. private _emitterCreationOptions;
  50100. private _emitterNode;
  50101. /**
  50102. * Gets the particle system list
  50103. */
  50104. systems: IParticleSystem[];
  50105. /**
  50106. * Gets the emitter node used with this set
  50107. */
  50108. readonly emitterNode: Nullable<TransformNode>;
  50109. /**
  50110. * Creates a new emitter mesh as a sphere
  50111. * @param options defines the options used to create the sphere
  50112. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50113. * @param scene defines the hosting scene
  50114. */
  50115. setEmitterAsSphere(options: {
  50116. diameter: number;
  50117. segments: number;
  50118. color: Color3;
  50119. }, renderingGroupId: number, scene: Scene): void;
  50120. /**
  50121. * Starts all particle systems of the set
  50122. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50123. */
  50124. start(emitter?: AbstractMesh): void;
  50125. /**
  50126. * Release all associated resources
  50127. */
  50128. dispose(): void;
  50129. /**
  50130. * Serialize the set into a JSON compatible object
  50131. * @returns a JSON compatible representation of the set
  50132. */
  50133. serialize(): any;
  50134. /**
  50135. * Parse a new ParticleSystemSet from a serialized source
  50136. * @param data defines a JSON compatible representation of the set
  50137. * @param scene defines the hosting scene
  50138. * @param gpu defines if we want GPU particles or CPU particles
  50139. * @returns a new ParticleSystemSet
  50140. */
  50141. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50142. }
  50143. }
  50144. declare module BABYLON {
  50145. /**
  50146. * This class is made for on one-liner static method to help creating particle system set.
  50147. */
  50148. export class ParticleHelper {
  50149. /**
  50150. * Gets or sets base Assets URL
  50151. */
  50152. static BaseAssetsUrl: string;
  50153. /**
  50154. * Create a default particle system that you can tweak
  50155. * @param emitter defines the emitter to use
  50156. * @param capacity defines the system capacity (default is 500 particles)
  50157. * @param scene defines the hosting scene
  50158. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50159. * @returns the new Particle system
  50160. */
  50161. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50162. /**
  50163. * This is the main static method (one-liner) of this helper to create different particle systems
  50164. * @param type This string represents the type to the particle system to create
  50165. * @param scene The scene where the particle system should live
  50166. * @param gpu If the system will use gpu
  50167. * @returns the ParticleSystemSet created
  50168. */
  50169. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50170. /**
  50171. * Static function used to export a particle system to a ParticleSystemSet variable.
  50172. * Please note that the emitter shape is not exported
  50173. * @param systems defines the particle systems to export
  50174. * @returns the created particle system set
  50175. */
  50176. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50177. }
  50178. }
  50179. declare module BABYLON {
  50180. interface Engine {
  50181. /**
  50182. * Create an effect to use with particle systems.
  50183. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50184. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50185. * @param uniformsNames defines a list of attribute names
  50186. * @param samplers defines an array of string used to represent textures
  50187. * @param defines defines the string containing the defines to use to compile the shaders
  50188. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50189. * @param onCompiled defines a function to call when the effect creation is successful
  50190. * @param onError defines a function to call when the effect creation has failed
  50191. * @returns the new Effect
  50192. */
  50193. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50194. }
  50195. interface Mesh {
  50196. /**
  50197. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50198. * @returns an array of IParticleSystem
  50199. */
  50200. getEmittedParticleSystems(): IParticleSystem[];
  50201. /**
  50202. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50203. * @returns an array of IParticleSystem
  50204. */
  50205. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50206. }
  50207. /**
  50208. * @hidden
  50209. */
  50210. export var _IDoNeedToBeInTheBuild: number;
  50211. }
  50212. declare module BABYLON {
  50213. interface Scene {
  50214. /** @hidden (Backing field) */
  50215. _physicsEngine: Nullable<IPhysicsEngine>;
  50216. /**
  50217. * Gets the current physics engine
  50218. * @returns a IPhysicsEngine or null if none attached
  50219. */
  50220. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50221. /**
  50222. * Enables physics to the current scene
  50223. * @param gravity defines the scene's gravity for the physics engine
  50224. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50225. * @return a boolean indicating if the physics engine was initialized
  50226. */
  50227. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50228. /**
  50229. * Disables and disposes the physics engine associated with the scene
  50230. */
  50231. disablePhysicsEngine(): void;
  50232. /**
  50233. * Gets a boolean indicating if there is an active physics engine
  50234. * @returns a boolean indicating if there is an active physics engine
  50235. */
  50236. isPhysicsEnabled(): boolean;
  50237. /**
  50238. * Deletes a physics compound impostor
  50239. * @param compound defines the compound to delete
  50240. */
  50241. deleteCompoundImpostor(compound: any): void;
  50242. /**
  50243. * An event triggered when physic simulation is about to be run
  50244. */
  50245. onBeforePhysicsObservable: Observable<Scene>;
  50246. /**
  50247. * An event triggered when physic simulation has been done
  50248. */
  50249. onAfterPhysicsObservable: Observable<Scene>;
  50250. }
  50251. interface AbstractMesh {
  50252. /** @hidden */
  50253. _physicsImpostor: Nullable<PhysicsImpostor>;
  50254. /**
  50255. * Gets or sets impostor used for physic simulation
  50256. * @see http://doc.babylonjs.com/features/physics_engine
  50257. */
  50258. physicsImpostor: Nullable<PhysicsImpostor>;
  50259. /**
  50260. * Gets the current physics impostor
  50261. * @see http://doc.babylonjs.com/features/physics_engine
  50262. * @returns a physics impostor or null
  50263. */
  50264. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50265. /** Apply a physic impulse to the mesh
  50266. * @param force defines the force to apply
  50267. * @param contactPoint defines where to apply the force
  50268. * @returns the current mesh
  50269. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50270. */
  50271. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50272. /**
  50273. * Creates a physic joint between two meshes
  50274. * @param otherMesh defines the other mesh to use
  50275. * @param pivot1 defines the pivot to use on this mesh
  50276. * @param pivot2 defines the pivot to use on the other mesh
  50277. * @param options defines additional options (can be plugin dependent)
  50278. * @returns the current mesh
  50279. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50280. */
  50281. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50282. /** @hidden */
  50283. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50284. }
  50285. /**
  50286. * Defines the physics engine scene component responsible to manage a physics engine
  50287. */
  50288. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50289. /**
  50290. * The component name helpful to identify the component in the list of scene components.
  50291. */
  50292. readonly name: string;
  50293. /**
  50294. * The scene the component belongs to.
  50295. */
  50296. scene: Scene;
  50297. /**
  50298. * Creates a new instance of the component for the given scene
  50299. * @param scene Defines the scene to register the component in
  50300. */
  50301. constructor(scene: Scene);
  50302. /**
  50303. * Registers the component in a given scene
  50304. */
  50305. register(): void;
  50306. /**
  50307. * Rebuilds the elements related to this component in case of
  50308. * context lost for instance.
  50309. */
  50310. rebuild(): void;
  50311. /**
  50312. * Disposes the component and the associated ressources
  50313. */
  50314. dispose(): void;
  50315. }
  50316. }
  50317. declare module BABYLON {
  50318. /**
  50319. * A helper for physics simulations
  50320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50321. */
  50322. export class PhysicsHelper {
  50323. private _scene;
  50324. private _physicsEngine;
  50325. /**
  50326. * Initializes the Physics helper
  50327. * @param scene Babylon.js scene
  50328. */
  50329. constructor(scene: Scene);
  50330. /**
  50331. * Applies a radial explosion impulse
  50332. * @param origin the origin of the explosion
  50333. * @param radiusOrEventOptions the radius or the options of radial explosion
  50334. * @param strength the explosion strength
  50335. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50336. * @returns A physics radial explosion event, or null
  50337. */
  50338. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50339. /**
  50340. * Applies a radial explosion force
  50341. * @param origin the origin of the explosion
  50342. * @param radiusOrEventOptions the radius or the options of radial explosion
  50343. * @param strength the explosion strength
  50344. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50345. * @returns A physics radial explosion event, or null
  50346. */
  50347. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50348. /**
  50349. * Creates a gravitational field
  50350. * @param origin the origin of the explosion
  50351. * @param radiusOrEventOptions the radius or the options of radial explosion
  50352. * @param strength the explosion strength
  50353. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50354. * @returns A physics gravitational field event, or null
  50355. */
  50356. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50357. /**
  50358. * Creates a physics updraft event
  50359. * @param origin the origin of the updraft
  50360. * @param radiusOrEventOptions the radius or the options of the updraft
  50361. * @param strength the strength of the updraft
  50362. * @param height the height of the updraft
  50363. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50364. * @returns A physics updraft event, or null
  50365. */
  50366. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50367. /**
  50368. * Creates a physics vortex event
  50369. * @param origin the of the vortex
  50370. * @param radiusOrEventOptions the radius or the options of the vortex
  50371. * @param strength the strength of the vortex
  50372. * @param height the height of the vortex
  50373. * @returns a Physics vortex event, or null
  50374. * A physics vortex event or null
  50375. */
  50376. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50377. }
  50378. /**
  50379. * Represents a physics radial explosion event
  50380. */
  50381. class PhysicsRadialExplosionEvent {
  50382. private _scene;
  50383. private _options;
  50384. private _sphere;
  50385. private _dataFetched;
  50386. /**
  50387. * Initializes a radial explosioin event
  50388. * @param _scene BabylonJS scene
  50389. * @param _options The options for the vortex event
  50390. */
  50391. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50392. /**
  50393. * Returns the data related to the radial explosion event (sphere).
  50394. * @returns The radial explosion event data
  50395. */
  50396. getData(): PhysicsRadialExplosionEventData;
  50397. /**
  50398. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50399. * @param impostor A physics imposter
  50400. * @param origin the origin of the explosion
  50401. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50402. */
  50403. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  50404. /**
  50405. * Disposes the sphere.
  50406. * @param force Specifies if the sphere should be disposed by force
  50407. */
  50408. dispose(force?: boolean): void;
  50409. /*** Helpers ***/
  50410. private _prepareSphere;
  50411. private _intersectsWithSphere;
  50412. }
  50413. /**
  50414. * Represents a gravitational field event
  50415. */
  50416. class PhysicsGravitationalFieldEvent {
  50417. private _physicsHelper;
  50418. private _scene;
  50419. private _origin;
  50420. private _options;
  50421. private _tickCallback;
  50422. private _sphere;
  50423. private _dataFetched;
  50424. /**
  50425. * Initializes the physics gravitational field event
  50426. * @param _physicsHelper A physics helper
  50427. * @param _scene BabylonJS scene
  50428. * @param _origin The origin position of the gravitational field event
  50429. * @param _options The options for the vortex event
  50430. */
  50431. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50432. /**
  50433. * Returns the data related to the gravitational field event (sphere).
  50434. * @returns A gravitational field event
  50435. */
  50436. getData(): PhysicsGravitationalFieldEventData;
  50437. /**
  50438. * Enables the gravitational field.
  50439. */
  50440. enable(): void;
  50441. /**
  50442. * Disables the gravitational field.
  50443. */
  50444. disable(): void;
  50445. /**
  50446. * Disposes the sphere.
  50447. * @param force The force to dispose from the gravitational field event
  50448. */
  50449. dispose(force?: boolean): void;
  50450. private _tick;
  50451. }
  50452. /**
  50453. * Represents a physics updraft event
  50454. */
  50455. class PhysicsUpdraftEvent {
  50456. private _scene;
  50457. private _origin;
  50458. private _options;
  50459. private _physicsEngine;
  50460. private _originTop;
  50461. private _originDirection;
  50462. private _tickCallback;
  50463. private _cylinder;
  50464. private _cylinderPosition;
  50465. private _dataFetched;
  50466. /**
  50467. * Initializes the physics updraft event
  50468. * @param _scene BabylonJS scene
  50469. * @param _origin The origin position of the updraft
  50470. * @param _options The options for the updraft event
  50471. */
  50472. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50473. /**
  50474. * Returns the data related to the updraft event (cylinder).
  50475. * @returns A physics updraft event
  50476. */
  50477. getData(): PhysicsUpdraftEventData;
  50478. /**
  50479. * Enables the updraft.
  50480. */
  50481. enable(): void;
  50482. /**
  50483. * Disables the updraft.
  50484. */
  50485. disable(): void;
  50486. /**
  50487. * Disposes the cylinder.
  50488. * @param force Specifies if the updraft should be disposed by force
  50489. */
  50490. dispose(force?: boolean): void;
  50491. private getImpostorForceAndContactPoint;
  50492. private _tick;
  50493. /*** Helpers ***/
  50494. private _prepareCylinder;
  50495. private _intersectsWithCylinder;
  50496. }
  50497. /**
  50498. * Represents a physics vortex event
  50499. */
  50500. class PhysicsVortexEvent {
  50501. private _scene;
  50502. private _origin;
  50503. private _options;
  50504. private _physicsEngine;
  50505. private _originTop;
  50506. private _tickCallback;
  50507. private _cylinder;
  50508. private _cylinderPosition;
  50509. private _dataFetched;
  50510. /**
  50511. * Initializes the physics vortex event
  50512. * @param _scene The BabylonJS scene
  50513. * @param _origin The origin position of the vortex
  50514. * @param _options The options for the vortex event
  50515. */
  50516. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50517. /**
  50518. * Returns the data related to the vortex event (cylinder).
  50519. * @returns The physics vortex event data
  50520. */
  50521. getData(): PhysicsVortexEventData;
  50522. /**
  50523. * Enables the vortex.
  50524. */
  50525. enable(): void;
  50526. /**
  50527. * Disables the cortex.
  50528. */
  50529. disable(): void;
  50530. /**
  50531. * Disposes the sphere.
  50532. * @param force
  50533. */
  50534. dispose(force?: boolean): void;
  50535. private getImpostorForceAndContactPoint;
  50536. private _tick;
  50537. /*** Helpers ***/
  50538. private _prepareCylinder;
  50539. private _intersectsWithCylinder;
  50540. }
  50541. /**
  50542. * Options fot the radial explosion event
  50543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50544. */
  50545. export class PhysicsRadialExplosionEventOptions {
  50546. /**
  50547. * The radius of the sphere for the radial explosion.
  50548. */
  50549. radius: number;
  50550. /**
  50551. * The strenth of the explosion.
  50552. */
  50553. strength: number;
  50554. /**
  50555. * The strenght of the force in correspondence to the distance of the affected object
  50556. */
  50557. falloff: PhysicsRadialImpulseFalloff;
  50558. /**
  50559. * Sphere options for the radial explosion.
  50560. */
  50561. sphere: {
  50562. segments: number;
  50563. diameter: number;
  50564. };
  50565. }
  50566. /**
  50567. * Options fot the updraft event
  50568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50569. */
  50570. export class PhysicsUpdraftEventOptions {
  50571. /**
  50572. * The radius of the cylinder for the vortex
  50573. */
  50574. radius: number;
  50575. /**
  50576. * The strenth of the updraft.
  50577. */
  50578. strength: number;
  50579. /**
  50580. * The height of the cylinder for the updraft.
  50581. */
  50582. height: number;
  50583. /**
  50584. * The mode for the the updraft.
  50585. */
  50586. updraftMode: PhysicsUpdraftMode;
  50587. }
  50588. /**
  50589. * Options fot the vortex event
  50590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50591. */
  50592. export class PhysicsVortexEventOptions {
  50593. /**
  50594. * The radius of the cylinder for the vortex
  50595. */
  50596. radius: number;
  50597. /**
  50598. * The strenth of the vortex.
  50599. */
  50600. strength: number;
  50601. /**
  50602. * The height of the cylinder for the vortex.
  50603. */
  50604. height: number;
  50605. /**
  50606. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  50607. */
  50608. centripetalForceThreshold: number;
  50609. /**
  50610. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  50611. */
  50612. centripetalForceMultiplier: number;
  50613. /**
  50614. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  50615. */
  50616. centrifugalForceMultiplier: number;
  50617. /**
  50618. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  50619. */
  50620. updraftForceMultiplier: number;
  50621. }
  50622. /**
  50623. * The strenght of the force in correspondence to the distance of the affected object
  50624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50625. */
  50626. export enum PhysicsRadialImpulseFalloff {
  50627. /** Defines that impulse is constant in strength across it's whole radius */
  50628. Constant = 0,
  50629. /** Defines that impulse gets weaker if it's further from the origin */
  50630. Linear = 1
  50631. }
  50632. /**
  50633. * The strength of the force in correspondence to the distance of the affected object
  50634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50635. */
  50636. export enum PhysicsUpdraftMode {
  50637. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50638. Center = 0,
  50639. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50640. Perpendicular = 1
  50641. }
  50642. /**
  50643. * Interface for a physics force and contact point
  50644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50645. */
  50646. export interface PhysicsForceAndContactPoint {
  50647. /**
  50648. * The force applied at the contact point
  50649. */
  50650. force: Vector3;
  50651. /**
  50652. * The contact point
  50653. */
  50654. contactPoint: Vector3;
  50655. }
  50656. /**
  50657. * Interface for radial explosion event data
  50658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50659. */
  50660. export interface PhysicsRadialExplosionEventData {
  50661. /**
  50662. * A sphere used for the radial explosion event
  50663. */
  50664. sphere: Mesh;
  50665. }
  50666. /**
  50667. * Interface for gravitational field event data
  50668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50669. */
  50670. export interface PhysicsGravitationalFieldEventData {
  50671. /**
  50672. * A sphere mesh used for the gravitational field event
  50673. */
  50674. sphere: Mesh;
  50675. }
  50676. /**
  50677. * Interface for updraft event data
  50678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50679. */
  50680. export interface PhysicsUpdraftEventData {
  50681. /**
  50682. * A cylinder used for the updraft event
  50683. */
  50684. cylinder: Mesh;
  50685. }
  50686. /**
  50687. * Interface for vortex event data
  50688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50689. */
  50690. export interface PhysicsVortexEventData {
  50691. /**
  50692. * A cylinder used for the vortex event
  50693. */
  50694. cylinder: Mesh;
  50695. }
  50696. }
  50697. declare module BABYLON {
  50698. /**
  50699. * AmmoJS Physics plugin
  50700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50701. * @see https://github.com/kripken/ammo.js/
  50702. */
  50703. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50704. private _useDeltaForWorldStep;
  50705. /**
  50706. * Reference to the Ammo library
  50707. */
  50708. bjsAMMO: any;
  50709. /**
  50710. * Created ammoJS world which physics bodies are added to
  50711. */
  50712. world: any;
  50713. /**
  50714. * Name of the plugin
  50715. */
  50716. name: string;
  50717. private _timeStep;
  50718. private _fixedTimeStep;
  50719. private _maxSteps;
  50720. private _tmpQuaternion;
  50721. private _tmpAmmoTransform;
  50722. private _tmpAmmoQuaternion;
  50723. private _tmpAmmoConcreteContactResultCallback;
  50724. private _collisionConfiguration;
  50725. private _dispatcher;
  50726. private _overlappingPairCache;
  50727. private _solver;
  50728. private _softBodySolver;
  50729. private _tmpAmmoVectorA;
  50730. private _tmpAmmoVectorB;
  50731. private _tmpAmmoVectorC;
  50732. private _tmpAmmoVectorD;
  50733. private _tmpContactCallbackResult;
  50734. private _tmpAmmoVectorRCA;
  50735. private _tmpAmmoVectorRCB;
  50736. private _raycastResult;
  50737. private static readonly DISABLE_COLLISION_FLAG;
  50738. private static readonly KINEMATIC_FLAG;
  50739. private static readonly DISABLE_DEACTIVATION_FLAG;
  50740. /**
  50741. * Initializes the ammoJS plugin
  50742. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50743. * @param ammoInjection can be used to inject your own ammo reference
  50744. */
  50745. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50746. /**
  50747. * Sets the gravity of the physics world (m/(s^2))
  50748. * @param gravity Gravity to set
  50749. */
  50750. setGravity(gravity: Vector3): void;
  50751. /**
  50752. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50753. * @param timeStep timestep to use in seconds
  50754. */
  50755. setTimeStep(timeStep: number): void;
  50756. /**
  50757. * 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)
  50758. * @param fixedTimeStep fixedTimeStep to use in seconds
  50759. */
  50760. setFixedTimeStep(fixedTimeStep: number): void;
  50761. /**
  50762. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50763. * @param maxSteps the maximum number of steps by the physics engine per frame
  50764. */
  50765. setMaxSteps(maxSteps: number): void;
  50766. /**
  50767. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50768. * @returns the current timestep in seconds
  50769. */
  50770. getTimeStep(): number;
  50771. private _isImpostorInContact;
  50772. private _isImpostorPairInContact;
  50773. private _stepSimulation;
  50774. /**
  50775. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50776. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50777. * After the step the babylon meshes are set to the position of the physics imposters
  50778. * @param delta amount of time to step forward
  50779. * @param impostors array of imposters to update before/after the step
  50780. */
  50781. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50782. /**
  50783. * Update babylon mesh to match physics world object
  50784. * @param impostor imposter to match
  50785. */
  50786. private _afterSoftStep;
  50787. /**
  50788. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50789. * @param impostor imposter to match
  50790. */
  50791. private _ropeStep;
  50792. /**
  50793. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50794. * @param impostor imposter to match
  50795. */
  50796. private _softbodyOrClothStep;
  50797. private _tmpVector;
  50798. private _tmpMatrix;
  50799. /**
  50800. * Applies an impulse on the imposter
  50801. * @param impostor imposter to apply impulse to
  50802. * @param force amount of force to be applied to the imposter
  50803. * @param contactPoint the location to apply the impulse on the imposter
  50804. */
  50805. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50806. /**
  50807. * Applies a force on the imposter
  50808. * @param impostor imposter to apply force
  50809. * @param force amount of force to be applied to the imposter
  50810. * @param contactPoint the location to apply the force on the imposter
  50811. */
  50812. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50813. /**
  50814. * Creates a physics body using the plugin
  50815. * @param impostor the imposter to create the physics body on
  50816. */
  50817. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50818. /**
  50819. * Removes the physics body from the imposter and disposes of the body's memory
  50820. * @param impostor imposter to remove the physics body from
  50821. */
  50822. removePhysicsBody(impostor: PhysicsImpostor): void;
  50823. /**
  50824. * Generates a joint
  50825. * @param impostorJoint the imposter joint to create the joint with
  50826. */
  50827. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50828. /**
  50829. * Removes a joint
  50830. * @param impostorJoint the imposter joint to remove the joint from
  50831. */
  50832. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50833. private _addMeshVerts;
  50834. /**
  50835. * Initialise the soft body vertices to match its object's (mesh) vertices
  50836. * Softbody vertices (nodes) are in world space and to match this
  50837. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50838. * @param impostor to create the softbody for
  50839. */
  50840. private _softVertexData;
  50841. /**
  50842. * Create an impostor's soft body
  50843. * @param impostor to create the softbody for
  50844. */
  50845. private _createSoftbody;
  50846. /**
  50847. * Create cloth for an impostor
  50848. * @param impostor to create the softbody for
  50849. */
  50850. private _createCloth;
  50851. /**
  50852. * Create rope for an impostor
  50853. * @param impostor to create the softbody for
  50854. */
  50855. private _createRope;
  50856. private _addHullVerts;
  50857. private _createShape;
  50858. /**
  50859. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50860. * @param impostor imposter containing the physics body and babylon object
  50861. */
  50862. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50863. /**
  50864. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50865. * @param impostor imposter containing the physics body and babylon object
  50866. * @param newPosition new position
  50867. * @param newRotation new rotation
  50868. */
  50869. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50870. /**
  50871. * If this plugin is supported
  50872. * @returns true if its supported
  50873. */
  50874. isSupported(): boolean;
  50875. /**
  50876. * Sets the linear velocity of the physics body
  50877. * @param impostor imposter to set the velocity on
  50878. * @param velocity velocity to set
  50879. */
  50880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50881. /**
  50882. * Sets the angular velocity of the physics body
  50883. * @param impostor imposter to set the velocity on
  50884. * @param velocity velocity to set
  50885. */
  50886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50887. /**
  50888. * gets the linear velocity
  50889. * @param impostor imposter to get linear velocity from
  50890. * @returns linear velocity
  50891. */
  50892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50893. /**
  50894. * gets the angular velocity
  50895. * @param impostor imposter to get angular velocity from
  50896. * @returns angular velocity
  50897. */
  50898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50899. /**
  50900. * Sets the mass of physics body
  50901. * @param impostor imposter to set the mass on
  50902. * @param mass mass to set
  50903. */
  50904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50905. /**
  50906. * Gets the mass of the physics body
  50907. * @param impostor imposter to get the mass from
  50908. * @returns mass
  50909. */
  50910. getBodyMass(impostor: PhysicsImpostor): number;
  50911. /**
  50912. * Gets friction of the impostor
  50913. * @param impostor impostor to get friction from
  50914. * @returns friction value
  50915. */
  50916. getBodyFriction(impostor: PhysicsImpostor): number;
  50917. /**
  50918. * Sets friction of the impostor
  50919. * @param impostor impostor to set friction on
  50920. * @param friction friction value
  50921. */
  50922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50923. /**
  50924. * Gets restitution of the impostor
  50925. * @param impostor impostor to get restitution from
  50926. * @returns restitution value
  50927. */
  50928. getBodyRestitution(impostor: PhysicsImpostor): number;
  50929. /**
  50930. * Sets resitution of the impostor
  50931. * @param impostor impostor to set resitution on
  50932. * @param restitution resitution value
  50933. */
  50934. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50935. /**
  50936. * Gets pressure inside the impostor
  50937. * @param impostor impostor to get pressure from
  50938. * @returns pressure value
  50939. */
  50940. getBodyPressure(impostor: PhysicsImpostor): number;
  50941. /**
  50942. * Sets pressure inside a soft body impostor
  50943. * Cloth and rope must remain 0 pressure
  50944. * @param impostor impostor to set pressure on
  50945. * @param pressure pressure value
  50946. */
  50947. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50948. /**
  50949. * Gets stiffness of the impostor
  50950. * @param impostor impostor to get stiffness from
  50951. * @returns pressure value
  50952. */
  50953. getBodyStiffness(impostor: PhysicsImpostor): number;
  50954. /**
  50955. * Sets stiffness of the impostor
  50956. * @param impostor impostor to set stiffness on
  50957. * @param stiffness stiffness value from 0 to 1
  50958. */
  50959. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50960. /**
  50961. * Gets velocityIterations of the impostor
  50962. * @param impostor impostor to get velocity iterations from
  50963. * @returns velocityIterations value
  50964. */
  50965. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50966. /**
  50967. * Sets velocityIterations of the impostor
  50968. * @param impostor impostor to set velocity iterations on
  50969. * @param velocityIterations velocityIterations value
  50970. */
  50971. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50972. /**
  50973. * Gets positionIterations of the impostor
  50974. * @param impostor impostor to get position iterations from
  50975. * @returns positionIterations value
  50976. */
  50977. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50978. /**
  50979. * Sets positionIterations of the impostor
  50980. * @param impostor impostor to set position on
  50981. * @param positionIterations positionIterations value
  50982. */
  50983. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50984. /**
  50985. * Append an anchor to a cloth object
  50986. * @param impostor is the cloth impostor to add anchor to
  50987. * @param otherImpostor is the rigid impostor to anchor to
  50988. * @param width ratio across width from 0 to 1
  50989. * @param height ratio up height from 0 to 1
  50990. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50991. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50992. */
  50993. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50994. /**
  50995. * Append an hook to a rope object
  50996. * @param impostor is the rope impostor to add hook to
  50997. * @param otherImpostor is the rigid impostor to hook to
  50998. * @param length ratio along the rope from 0 to 1
  50999. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51000. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51001. */
  51002. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51003. /**
  51004. * Sleeps the physics body and stops it from being active
  51005. * @param impostor impostor to sleep
  51006. */
  51007. sleepBody(impostor: PhysicsImpostor): void;
  51008. /**
  51009. * Activates the physics body
  51010. * @param impostor impostor to activate
  51011. */
  51012. wakeUpBody(impostor: PhysicsImpostor): void;
  51013. /**
  51014. * Updates the distance parameters of the joint
  51015. * @param joint joint to update
  51016. * @param maxDistance maximum distance of the joint
  51017. * @param minDistance minimum distance of the joint
  51018. */
  51019. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51020. /**
  51021. * Sets a motor on the joint
  51022. * @param joint joint to set motor on
  51023. * @param speed speed of the motor
  51024. * @param maxForce maximum force of the motor
  51025. * @param motorIndex index of the motor
  51026. */
  51027. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51028. /**
  51029. * Sets the motors limit
  51030. * @param joint joint to set limit on
  51031. * @param upperLimit upper limit
  51032. * @param lowerLimit lower limit
  51033. */
  51034. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51035. /**
  51036. * Syncs the position and rotation of a mesh with the impostor
  51037. * @param mesh mesh to sync
  51038. * @param impostor impostor to update the mesh with
  51039. */
  51040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51041. /**
  51042. * Gets the radius of the impostor
  51043. * @param impostor impostor to get radius from
  51044. * @returns the radius
  51045. */
  51046. getRadius(impostor: PhysicsImpostor): number;
  51047. /**
  51048. * Gets the box size of the impostor
  51049. * @param impostor impostor to get box size from
  51050. * @param result the resulting box size
  51051. */
  51052. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51053. /**
  51054. * Disposes of the impostor
  51055. */
  51056. dispose(): void;
  51057. /**
  51058. * Does a raycast in the physics world
  51059. * @param from when should the ray start?
  51060. * @param to when should the ray end?
  51061. * @returns PhysicsRaycastResult
  51062. */
  51063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /** @hidden */
  51068. export var blackAndWhitePixelShader: {
  51069. name: string;
  51070. shader: string;
  51071. };
  51072. }
  51073. declare module BABYLON {
  51074. /**
  51075. * Post process used to render in black and white
  51076. */
  51077. export class BlackAndWhitePostProcess extends PostProcess {
  51078. /**
  51079. * Linear about to convert he result to black and white (default: 1)
  51080. */
  51081. degree: number;
  51082. /**
  51083. * Creates a black and white post process
  51084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51085. * @param name The name of the effect.
  51086. * @param options The required width/height ratio to downsize to before computing the render pass.
  51087. * @param camera The camera to apply the render pass to.
  51088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51089. * @param engine The engine which the post process will be applied. (default: current engine)
  51090. * @param reusable If the post process can be reused on the same frame. (default: false)
  51091. */
  51092. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51093. }
  51094. }
  51095. declare module BABYLON {
  51096. /**
  51097. * This represents a set of one or more post processes in Babylon.
  51098. * A post process can be used to apply a shader to a texture after it is rendered.
  51099. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51100. */
  51101. export class PostProcessRenderEffect {
  51102. private _postProcesses;
  51103. private _getPostProcesses;
  51104. private _singleInstance;
  51105. private _cameras;
  51106. private _indicesForCamera;
  51107. /**
  51108. * Name of the effect
  51109. * @hidden
  51110. */
  51111. _name: string;
  51112. /**
  51113. * Instantiates a post process render effect.
  51114. * A post process can be used to apply a shader to a texture after it is rendered.
  51115. * @param engine The engine the effect is tied to
  51116. * @param name The name of the effect
  51117. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51118. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51119. */
  51120. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51121. /**
  51122. * Checks if all the post processes in the effect are supported.
  51123. */
  51124. readonly isSupported: boolean;
  51125. /**
  51126. * Updates the current state of the effect
  51127. * @hidden
  51128. */
  51129. _update(): void;
  51130. /**
  51131. * Attaches the effect on cameras
  51132. * @param cameras The camera to attach to.
  51133. * @hidden
  51134. */
  51135. _attachCameras(cameras: Camera): void;
  51136. /**
  51137. * Attaches the effect on cameras
  51138. * @param cameras The camera to attach to.
  51139. * @hidden
  51140. */
  51141. _attachCameras(cameras: Camera[]): void;
  51142. /**
  51143. * Detatches the effect on cameras
  51144. * @param cameras The camera to detatch from.
  51145. * @hidden
  51146. */
  51147. _detachCameras(cameras: Camera): void;
  51148. /**
  51149. * Detatches the effect on cameras
  51150. * @param cameras The camera to detatch from.
  51151. * @hidden
  51152. */
  51153. _detachCameras(cameras: Camera[]): void;
  51154. /**
  51155. * Enables the effect on given cameras
  51156. * @param cameras The camera to enable.
  51157. * @hidden
  51158. */
  51159. _enable(cameras: Camera): void;
  51160. /**
  51161. * Enables the effect on given cameras
  51162. * @param cameras The camera to enable.
  51163. * @hidden
  51164. */
  51165. _enable(cameras: Nullable<Camera[]>): void;
  51166. /**
  51167. * Disables the effect on the given cameras
  51168. * @param cameras The camera to disable.
  51169. * @hidden
  51170. */
  51171. _disable(cameras: Camera): void;
  51172. /**
  51173. * Disables the effect on the given cameras
  51174. * @param cameras The camera to disable.
  51175. * @hidden
  51176. */
  51177. _disable(cameras: Nullable<Camera[]>): void;
  51178. /**
  51179. * Gets a list of the post processes contained in the effect.
  51180. * @param camera The camera to get the post processes on.
  51181. * @returns The list of the post processes in the effect.
  51182. */
  51183. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51184. }
  51185. }
  51186. declare module BABYLON {
  51187. /** @hidden */
  51188. export var extractHighlightsPixelShader: {
  51189. name: string;
  51190. shader: string;
  51191. };
  51192. }
  51193. declare module BABYLON {
  51194. /**
  51195. * 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.
  51196. */
  51197. export class ExtractHighlightsPostProcess extends PostProcess {
  51198. /**
  51199. * The luminance threshold, pixels below this value will be set to black.
  51200. */
  51201. threshold: number;
  51202. /** @hidden */
  51203. _exposure: number;
  51204. /**
  51205. * Post process which has the input texture to be used when performing highlight extraction
  51206. * @hidden
  51207. */
  51208. _inputPostProcess: Nullable<PostProcess>;
  51209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51210. }
  51211. }
  51212. declare module BABYLON {
  51213. /** @hidden */
  51214. export var bloomMergePixelShader: {
  51215. name: string;
  51216. shader: string;
  51217. };
  51218. }
  51219. declare module BABYLON {
  51220. /**
  51221. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51222. */
  51223. export class BloomMergePostProcess extends PostProcess {
  51224. /** Weight of the bloom to be added to the original input. */
  51225. weight: number;
  51226. /**
  51227. * Creates a new instance of @see BloomMergePostProcess
  51228. * @param name The name of the effect.
  51229. * @param originalFromInput Post process which's input will be used for the merge.
  51230. * @param blurred Blurred highlights post process which's output will be used.
  51231. * @param weight Weight of the bloom to be added to the original input.
  51232. * @param options The required width/height ratio to downsize to before computing the render pass.
  51233. * @param camera The camera to apply the render pass to.
  51234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51235. * @param engine The engine which the post process will be applied. (default: current engine)
  51236. * @param reusable If the post process can be reused on the same frame. (default: false)
  51237. * @param textureType Type of textures used when performing the post process. (default: 0)
  51238. * @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)
  51239. */
  51240. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51241. /** Weight of the bloom to be added to the original input. */
  51242. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51243. }
  51244. }
  51245. declare module BABYLON {
  51246. /**
  51247. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51248. */
  51249. export class BloomEffect extends PostProcessRenderEffect {
  51250. private bloomScale;
  51251. /**
  51252. * @hidden Internal
  51253. */
  51254. _effects: Array<PostProcess>;
  51255. /**
  51256. * @hidden Internal
  51257. */
  51258. _downscale: ExtractHighlightsPostProcess;
  51259. private _blurX;
  51260. private _blurY;
  51261. private _merge;
  51262. /**
  51263. * The luminance threshold to find bright areas of the image to bloom.
  51264. */
  51265. threshold: number;
  51266. /**
  51267. * The strength of the bloom.
  51268. */
  51269. weight: number;
  51270. /**
  51271. * Specifies the size of the bloom blur kernel, relative to the final output size
  51272. */
  51273. kernel: number;
  51274. /**
  51275. * Creates a new instance of @see BloomEffect
  51276. * @param scene The scene the effect belongs to.
  51277. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51278. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51279. * @param bloomWeight The the strength of bloom.
  51280. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51281. * @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)
  51282. */
  51283. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51284. /**
  51285. * Disposes each of the internal effects for a given camera.
  51286. * @param camera The camera to dispose the effect on.
  51287. */
  51288. disposeEffects(camera: Camera): void;
  51289. /**
  51290. * @hidden Internal
  51291. */
  51292. _updateEffects(): void;
  51293. /**
  51294. * Internal
  51295. * @returns if all the contained post processes are ready.
  51296. * @hidden
  51297. */
  51298. _isReady(): boolean;
  51299. }
  51300. }
  51301. declare module BABYLON {
  51302. /** @hidden */
  51303. export var chromaticAberrationPixelShader: {
  51304. name: string;
  51305. shader: string;
  51306. };
  51307. }
  51308. declare module BABYLON {
  51309. /**
  51310. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51311. */
  51312. export class ChromaticAberrationPostProcess extends PostProcess {
  51313. /**
  51314. * The amount of seperation of rgb channels (default: 30)
  51315. */
  51316. aberrationAmount: number;
  51317. /**
  51318. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51319. */
  51320. radialIntensity: number;
  51321. /**
  51322. * 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))
  51323. */
  51324. direction: Vector2;
  51325. /**
  51326. * 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))
  51327. */
  51328. centerPosition: Vector2;
  51329. /**
  51330. * Creates a new instance ChromaticAberrationPostProcess
  51331. * @param name The name of the effect.
  51332. * @param screenWidth The width of the screen to apply the effect on.
  51333. * @param screenHeight The height of the screen to apply the effect on.
  51334. * @param options The required width/height ratio to downsize to before computing the render pass.
  51335. * @param camera The camera to apply the render pass to.
  51336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51337. * @param engine The engine which the post process will be applied. (default: current engine)
  51338. * @param reusable If the post process can be reused on the same frame. (default: false)
  51339. * @param textureType Type of textures used when performing the post process. (default: 0)
  51340. * @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)
  51341. */
  51342. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51343. }
  51344. }
  51345. declare module BABYLON {
  51346. /** @hidden */
  51347. export var circleOfConfusionPixelShader: {
  51348. name: string;
  51349. shader: string;
  51350. };
  51351. }
  51352. declare module BABYLON {
  51353. /**
  51354. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51355. */
  51356. export class CircleOfConfusionPostProcess extends PostProcess {
  51357. /**
  51358. * 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.
  51359. */
  51360. lensSize: number;
  51361. /**
  51362. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51363. */
  51364. fStop: number;
  51365. /**
  51366. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51367. */
  51368. focusDistance: number;
  51369. /**
  51370. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51371. */
  51372. focalLength: number;
  51373. private _depthTexture;
  51374. /**
  51375. * Creates a new instance CircleOfConfusionPostProcess
  51376. * @param name The name of the effect.
  51377. * @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.
  51378. * @param options The required width/height ratio to downsize to before computing the render pass.
  51379. * @param camera The camera to apply the render pass to.
  51380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51381. * @param engine The engine which the post process will be applied. (default: current engine)
  51382. * @param reusable If the post process can be reused on the same frame. (default: false)
  51383. * @param textureType Type of textures used when performing the post process. (default: 0)
  51384. * @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)
  51385. */
  51386. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51387. /**
  51388. * 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.
  51389. */
  51390. depthTexture: RenderTargetTexture;
  51391. }
  51392. }
  51393. declare module BABYLON {
  51394. /** @hidden */
  51395. export var colorCorrectionPixelShader: {
  51396. name: string;
  51397. shader: string;
  51398. };
  51399. }
  51400. declare module BABYLON {
  51401. /**
  51402. *
  51403. * This post-process allows the modification of rendered colors by using
  51404. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51405. *
  51406. * The object needs to be provided an url to a texture containing the color
  51407. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51408. * Use an image editing software to tweak the LUT to match your needs.
  51409. *
  51410. * For an example of a color LUT, see here:
  51411. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51412. * For explanations on color grading, see here:
  51413. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51414. *
  51415. */
  51416. export class ColorCorrectionPostProcess extends PostProcess {
  51417. private _colorTableTexture;
  51418. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51419. }
  51420. }
  51421. declare module BABYLON {
  51422. /** @hidden */
  51423. export var convolutionPixelShader: {
  51424. name: string;
  51425. shader: string;
  51426. };
  51427. }
  51428. declare module BABYLON {
  51429. /**
  51430. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51431. * input texture to perform effects such as edge detection or sharpening
  51432. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51433. */
  51434. export class ConvolutionPostProcess extends PostProcess {
  51435. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51436. kernel: number[];
  51437. /**
  51438. * Creates a new instance ConvolutionPostProcess
  51439. * @param name The name of the effect.
  51440. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51441. * @param options The required width/height ratio to downsize to before computing the render pass.
  51442. * @param camera The camera to apply the render pass to.
  51443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51444. * @param engine The engine which the post process will be applied. (default: current engine)
  51445. * @param reusable If the post process can be reused on the same frame. (default: false)
  51446. * @param textureType Type of textures used when performing the post process. (default: 0)
  51447. */
  51448. constructor(name: string,
  51449. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51450. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51451. /**
  51452. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51453. */
  51454. static EdgeDetect0Kernel: number[];
  51455. /**
  51456. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51457. */
  51458. static EdgeDetect1Kernel: number[];
  51459. /**
  51460. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51461. */
  51462. static EdgeDetect2Kernel: number[];
  51463. /**
  51464. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51465. */
  51466. static SharpenKernel: number[];
  51467. /**
  51468. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51469. */
  51470. static EmbossKernel: number[];
  51471. /**
  51472. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51473. */
  51474. static GaussianKernel: number[];
  51475. }
  51476. }
  51477. declare module BABYLON {
  51478. /**
  51479. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51480. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51481. * based on samples that have a large difference in distance than the center pixel.
  51482. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51483. */
  51484. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51485. direction: Vector2;
  51486. /**
  51487. * Creates a new instance CircleOfConfusionPostProcess
  51488. * @param name The name of the effect.
  51489. * @param scene The scene the effect belongs to.
  51490. * @param direction The direction the blur should be applied.
  51491. * @param kernel The size of the kernel used to blur.
  51492. * @param options The required width/height ratio to downsize to before computing the render pass.
  51493. * @param camera The camera to apply the render pass to.
  51494. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51495. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51497. * @param engine The engine which the post process will be applied. (default: current engine)
  51498. * @param reusable If the post process can be reused on the same frame. (default: false)
  51499. * @param textureType Type of textures used when performing the post process. (default: 0)
  51500. * @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)
  51501. */
  51502. 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);
  51503. }
  51504. }
  51505. declare module BABYLON {
  51506. /** @hidden */
  51507. export var depthOfFieldMergePixelShader: {
  51508. name: string;
  51509. shader: string;
  51510. };
  51511. }
  51512. declare module BABYLON {
  51513. /**
  51514. * Options to be set when merging outputs from the default pipeline.
  51515. */
  51516. export class DepthOfFieldMergePostProcessOptions {
  51517. /**
  51518. * The original image to merge on top of
  51519. */
  51520. originalFromInput: PostProcess;
  51521. /**
  51522. * Parameters to perform the merge of the depth of field effect
  51523. */
  51524. depthOfField?: {
  51525. circleOfConfusion: PostProcess;
  51526. blurSteps: Array<PostProcess>;
  51527. };
  51528. /**
  51529. * Parameters to perform the merge of bloom effect
  51530. */
  51531. bloom?: {
  51532. blurred: PostProcess;
  51533. weight: number;
  51534. };
  51535. }
  51536. /**
  51537. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51538. */
  51539. export class DepthOfFieldMergePostProcess extends PostProcess {
  51540. private blurSteps;
  51541. /**
  51542. * Creates a new instance of DepthOfFieldMergePostProcess
  51543. * @param name The name of the effect.
  51544. * @param originalFromInput Post process which's input will be used for the merge.
  51545. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51546. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51547. * @param options The required width/height ratio to downsize to before computing the render pass.
  51548. * @param camera The camera to apply the render pass to.
  51549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51550. * @param engine The engine which the post process will be applied. (default: current engine)
  51551. * @param reusable If the post process can be reused on the same frame. (default: false)
  51552. * @param textureType Type of textures used when performing the post process. (default: 0)
  51553. * @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)
  51554. */
  51555. 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);
  51556. /**
  51557. * Updates the effect with the current post process compile time values and recompiles the shader.
  51558. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51559. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51560. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51561. * @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
  51562. * @param onCompiled Called when the shader has been compiled.
  51563. * @param onError Called if there is an error when compiling a shader.
  51564. */
  51565. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51566. }
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Specifies the level of max blur that should be applied when using the depth of field effect
  51571. */
  51572. export enum DepthOfFieldEffectBlurLevel {
  51573. /**
  51574. * Subtle blur
  51575. */
  51576. Low = 0,
  51577. /**
  51578. * Medium blur
  51579. */
  51580. Medium = 1,
  51581. /**
  51582. * Large blur
  51583. */
  51584. High = 2
  51585. }
  51586. /**
  51587. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51588. */
  51589. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51590. private _circleOfConfusion;
  51591. /**
  51592. * @hidden Internal, blurs from high to low
  51593. */
  51594. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51595. private _depthOfFieldBlurY;
  51596. private _dofMerge;
  51597. /**
  51598. * @hidden Internal post processes in depth of field effect
  51599. */
  51600. _effects: Array<PostProcess>;
  51601. /**
  51602. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51603. */
  51604. focalLength: number;
  51605. /**
  51606. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51607. */
  51608. fStop: number;
  51609. /**
  51610. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51611. */
  51612. focusDistance: number;
  51613. /**
  51614. * 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.
  51615. */
  51616. lensSize: number;
  51617. /**
  51618. * Creates a new instance DepthOfFieldEffect
  51619. * @param scene The scene the effect belongs to.
  51620. * @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.
  51621. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51622. * @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)
  51623. */
  51624. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51625. /**
  51626. * 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.
  51627. */
  51628. depthTexture: RenderTargetTexture;
  51629. /**
  51630. * Disposes each of the internal effects for a given camera.
  51631. * @param camera The camera to dispose the effect on.
  51632. */
  51633. disposeEffects(camera: Camera): void;
  51634. /**
  51635. * @hidden Internal
  51636. */
  51637. _updateEffects(): void;
  51638. /**
  51639. * Internal
  51640. * @returns if all the contained post processes are ready.
  51641. * @hidden
  51642. */
  51643. _isReady(): boolean;
  51644. }
  51645. }
  51646. declare module BABYLON {
  51647. /** @hidden */
  51648. export var displayPassPixelShader: {
  51649. name: string;
  51650. shader: string;
  51651. };
  51652. }
  51653. declare module BABYLON {
  51654. /**
  51655. * DisplayPassPostProcess which produces an output the same as it's input
  51656. */
  51657. export class DisplayPassPostProcess extends PostProcess {
  51658. /**
  51659. * Creates the DisplayPassPostProcess
  51660. * @param name The name of the effect.
  51661. * @param options The required width/height ratio to downsize to before computing the render pass.
  51662. * @param camera The camera to apply the render pass to.
  51663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51664. * @param engine The engine which the post process will be applied. (default: current engine)
  51665. * @param reusable If the post process can be reused on the same frame. (default: false)
  51666. */
  51667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51668. }
  51669. }
  51670. declare module BABYLON {
  51671. /** @hidden */
  51672. export var filterPixelShader: {
  51673. name: string;
  51674. shader: string;
  51675. };
  51676. }
  51677. declare module BABYLON {
  51678. /**
  51679. * Applies a kernel filter to the image
  51680. */
  51681. export class FilterPostProcess extends PostProcess {
  51682. /** The matrix to be applied to the image */
  51683. kernelMatrix: Matrix;
  51684. /**
  51685. *
  51686. * @param name The name of the effect.
  51687. * @param kernelMatrix The matrix to be applied to the image
  51688. * @param options The required width/height ratio to downsize to before computing the render pass.
  51689. * @param camera The camera to apply the render pass to.
  51690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51691. * @param engine The engine which the post process will be applied. (default: current engine)
  51692. * @param reusable If the post process can be reused on the same frame. (default: false)
  51693. */
  51694. constructor(name: string,
  51695. /** The matrix to be applied to the image */
  51696. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51697. }
  51698. }
  51699. declare module BABYLON {
  51700. /** @hidden */
  51701. export var fxaaPixelShader: {
  51702. name: string;
  51703. shader: string;
  51704. };
  51705. }
  51706. declare module BABYLON {
  51707. /** @hidden */
  51708. export var fxaaVertexShader: {
  51709. name: string;
  51710. shader: string;
  51711. };
  51712. }
  51713. declare module BABYLON {
  51714. /**
  51715. * Fxaa post process
  51716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51717. */
  51718. export class FxaaPostProcess extends PostProcess {
  51719. /** @hidden */
  51720. texelWidth: number;
  51721. /** @hidden */
  51722. texelHeight: number;
  51723. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51724. private _getDefines;
  51725. }
  51726. }
  51727. declare module BABYLON {
  51728. /** @hidden */
  51729. export var grainPixelShader: {
  51730. name: string;
  51731. shader: string;
  51732. };
  51733. }
  51734. declare module BABYLON {
  51735. /**
  51736. * The GrainPostProcess adds noise to the image at mid luminance levels
  51737. */
  51738. export class GrainPostProcess extends PostProcess {
  51739. /**
  51740. * The intensity of the grain added (default: 30)
  51741. */
  51742. intensity: number;
  51743. /**
  51744. * If the grain should be randomized on every frame
  51745. */
  51746. animated: boolean;
  51747. /**
  51748. * Creates a new instance of @see GrainPostProcess
  51749. * @param name The name of the effect.
  51750. * @param options The required width/height ratio to downsize to before computing the render pass.
  51751. * @param camera The camera to apply the render pass to.
  51752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51753. * @param engine The engine which the post process will be applied. (default: current engine)
  51754. * @param reusable If the post process can be reused on the same frame. (default: false)
  51755. * @param textureType Type of textures used when performing the post process. (default: 0)
  51756. * @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)
  51757. */
  51758. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51759. }
  51760. }
  51761. declare module BABYLON {
  51762. /** @hidden */
  51763. export var highlightsPixelShader: {
  51764. name: string;
  51765. shader: string;
  51766. };
  51767. }
  51768. declare module BABYLON {
  51769. /**
  51770. * Extracts highlights from the image
  51771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51772. */
  51773. export class HighlightsPostProcess extends PostProcess {
  51774. /**
  51775. * Extracts highlights from the image
  51776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51777. * @param name The name of the effect.
  51778. * @param options The required width/height ratio to downsize to before computing the render pass.
  51779. * @param camera The camera to apply the render pass to.
  51780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51781. * @param engine The engine which the post process will be applied. (default: current engine)
  51782. * @param reusable If the post process can be reused on the same frame. (default: false)
  51783. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51784. */
  51785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51786. }
  51787. }
  51788. declare module BABYLON {
  51789. /** @hidden */
  51790. export var mrtFragmentDeclaration: {
  51791. name: string;
  51792. shader: string;
  51793. };
  51794. }
  51795. declare module BABYLON {
  51796. /** @hidden */
  51797. export var geometryPixelShader: {
  51798. name: string;
  51799. shader: string;
  51800. };
  51801. }
  51802. declare module BABYLON {
  51803. /** @hidden */
  51804. export var geometryVertexShader: {
  51805. name: string;
  51806. shader: string;
  51807. };
  51808. }
  51809. declare module BABYLON {
  51810. /**
  51811. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51812. */
  51813. export class GeometryBufferRenderer {
  51814. /**
  51815. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51816. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51817. */
  51818. static readonly POSITION_TEXTURE_TYPE: number;
  51819. /**
  51820. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51821. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51822. */
  51823. static readonly VELOCITY_TEXTURE_TYPE: number;
  51824. /**
  51825. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51826. * in order to compute objects velocities when enableVelocity is set to "true"
  51827. * @hidden
  51828. */
  51829. _previousTransformationMatrices: {
  51830. [index: number]: Matrix;
  51831. };
  51832. private _scene;
  51833. private _multiRenderTarget;
  51834. private _ratio;
  51835. private _enablePosition;
  51836. private _enableVelocity;
  51837. private _positionIndex;
  51838. private _velocityIndex;
  51839. protected _effect: Effect;
  51840. protected _cachedDefines: string;
  51841. /**
  51842. * Set the render list (meshes to be rendered) used in the G buffer.
  51843. */
  51844. renderList: Mesh[];
  51845. /**
  51846. * Gets wether or not G buffer are supported by the running hardware.
  51847. * This requires draw buffer supports
  51848. */
  51849. readonly isSupported: boolean;
  51850. /**
  51851. * Returns the index of the given texture type in the G-Buffer textures array
  51852. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51853. * @returns the index of the given texture type in the G-Buffer textures array
  51854. */
  51855. getTextureIndex(textureType: number): number;
  51856. /**
  51857. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51858. */
  51859. /**
  51860. * Sets whether or not objects positions are enabled for the G buffer.
  51861. */
  51862. enablePosition: boolean;
  51863. /**
  51864. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51865. */
  51866. /**
  51867. * Sets wether or not objects velocities are enabled for the G buffer.
  51868. */
  51869. enableVelocity: boolean;
  51870. /**
  51871. * Gets the scene associated with the buffer.
  51872. */
  51873. readonly scene: Scene;
  51874. /**
  51875. * Gets the ratio used by the buffer during its creation.
  51876. * How big is the buffer related to the main canvas.
  51877. */
  51878. readonly ratio: number;
  51879. /** @hidden */
  51880. static _SceneComponentInitialization: (scene: Scene) => void;
  51881. /**
  51882. * Creates a new G Buffer for the scene
  51883. * @param scene The scene the buffer belongs to
  51884. * @param ratio How big is the buffer related to the main canvas.
  51885. */
  51886. constructor(scene: Scene, ratio?: number);
  51887. /**
  51888. * Checks wether everything is ready to render a submesh to the G buffer.
  51889. * @param subMesh the submesh to check readiness for
  51890. * @param useInstances is the mesh drawn using instance or not
  51891. * @returns true if ready otherwise false
  51892. */
  51893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51894. /**
  51895. * Gets the current underlying G Buffer.
  51896. * @returns the buffer
  51897. */
  51898. getGBuffer(): MultiRenderTarget;
  51899. /**
  51900. * Gets the number of samples used to render the buffer (anti aliasing).
  51901. */
  51902. /**
  51903. * Sets the number of samples used to render the buffer (anti aliasing).
  51904. */
  51905. samples: number;
  51906. /**
  51907. * Disposes the renderer and frees up associated resources.
  51908. */
  51909. dispose(): void;
  51910. protected _createRenderTargets(): void;
  51911. }
  51912. }
  51913. declare module BABYLON {
  51914. interface Scene {
  51915. /** @hidden (Backing field) */
  51916. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51917. /**
  51918. * Gets or Sets the current geometry buffer associated to the scene.
  51919. */
  51920. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51921. /**
  51922. * Enables a GeometryBufferRender and associates it with the scene
  51923. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51924. * @returns the GeometryBufferRenderer
  51925. */
  51926. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51927. /**
  51928. * Disables the GeometryBufferRender associated with the scene
  51929. */
  51930. disableGeometryBufferRenderer(): void;
  51931. }
  51932. /**
  51933. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51934. * in several rendering techniques.
  51935. */
  51936. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51937. /**
  51938. * The component name helpful to identify the component in the list of scene components.
  51939. */
  51940. readonly name: string;
  51941. /**
  51942. * The scene the component belongs to.
  51943. */
  51944. scene: Scene;
  51945. /**
  51946. * Creates a new instance of the component for the given scene
  51947. * @param scene Defines the scene to register the component in
  51948. */
  51949. constructor(scene: Scene);
  51950. /**
  51951. * Registers the component in a given scene
  51952. */
  51953. register(): void;
  51954. /**
  51955. * Rebuilds the elements related to this component in case of
  51956. * context lost for instance.
  51957. */
  51958. rebuild(): void;
  51959. /**
  51960. * Disposes the component and the associated ressources
  51961. */
  51962. dispose(): void;
  51963. private _gatherRenderTargets;
  51964. }
  51965. }
  51966. declare module BABYLON {
  51967. /** @hidden */
  51968. export var motionBlurPixelShader: {
  51969. name: string;
  51970. shader: string;
  51971. };
  51972. }
  51973. declare module BABYLON {
  51974. /**
  51975. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51976. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51977. * As an example, all you have to do is to create the post-process:
  51978. * var mb = new BABYLON.MotionBlurPostProcess(
  51979. * 'mb', // The name of the effect.
  51980. * scene, // The scene containing the objects to blur according to their velocity.
  51981. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51982. * camera // The camera to apply the render pass to.
  51983. * );
  51984. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51985. */
  51986. export class MotionBlurPostProcess extends PostProcess {
  51987. /**
  51988. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51989. */
  51990. motionStrength: number;
  51991. /**
  51992. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51993. */
  51994. /**
  51995. * Sets the number of iterations to be used for motion blur quality
  51996. */
  51997. motionBlurSamples: number;
  51998. private _motionBlurSamples;
  51999. private _geometryBufferRenderer;
  52000. /**
  52001. * Creates a new instance MotionBlurPostProcess
  52002. * @param name The name of the effect.
  52003. * @param scene The scene containing the objects to blur according to their velocity.
  52004. * @param options The required width/height ratio to downsize to before computing the render pass.
  52005. * @param camera The camera to apply the render pass to.
  52006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52007. * @param engine The engine which the post process will be applied. (default: current engine)
  52008. * @param reusable If the post process can be reused on the same frame. (default: false)
  52009. * @param textureType Type of textures used when performing the post process. (default: 0)
  52010. * @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)
  52011. */
  52012. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52013. /**
  52014. * Disposes the post process.
  52015. * @param camera The camera to dispose the post process on.
  52016. */
  52017. dispose(camera?: Camera): void;
  52018. }
  52019. }
  52020. declare module BABYLON {
  52021. /** @hidden */
  52022. export var refractionPixelShader: {
  52023. name: string;
  52024. shader: string;
  52025. };
  52026. }
  52027. declare module BABYLON {
  52028. /**
  52029. * Post process which applies a refractin texture
  52030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52031. */
  52032. export class RefractionPostProcess extends PostProcess {
  52033. /** the base color of the refraction (used to taint the rendering) */
  52034. color: Color3;
  52035. /** simulated refraction depth */
  52036. depth: number;
  52037. /** the coefficient of the base color (0 to remove base color tainting) */
  52038. colorLevel: number;
  52039. private _refTexture;
  52040. private _ownRefractionTexture;
  52041. /**
  52042. * Gets or sets the refraction texture
  52043. * Please note that you are responsible for disposing the texture if you set it manually
  52044. */
  52045. refractionTexture: Texture;
  52046. /**
  52047. * Initializes the RefractionPostProcess
  52048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52049. * @param name The name of the effect.
  52050. * @param refractionTextureUrl Url of the refraction texture to use
  52051. * @param color the base color of the refraction (used to taint the rendering)
  52052. * @param depth simulated refraction depth
  52053. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52054. * @param camera The camera to apply the render pass to.
  52055. * @param options The required width/height ratio to downsize to before computing the render pass.
  52056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52057. * @param engine The engine which the post process will be applied. (default: current engine)
  52058. * @param reusable If the post process can be reused on the same frame. (default: false)
  52059. */
  52060. constructor(name: string, refractionTextureUrl: string,
  52061. /** the base color of the refraction (used to taint the rendering) */
  52062. color: Color3,
  52063. /** simulated refraction depth */
  52064. depth: number,
  52065. /** the coefficient of the base color (0 to remove base color tainting) */
  52066. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52067. /**
  52068. * Disposes of the post process
  52069. * @param camera Camera to dispose post process on
  52070. */
  52071. dispose(camera: Camera): void;
  52072. }
  52073. }
  52074. declare module BABYLON {
  52075. /** @hidden */
  52076. export var sharpenPixelShader: {
  52077. name: string;
  52078. shader: string;
  52079. };
  52080. }
  52081. declare module BABYLON {
  52082. /**
  52083. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52084. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52085. */
  52086. export class SharpenPostProcess extends PostProcess {
  52087. /**
  52088. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52089. */
  52090. colorAmount: number;
  52091. /**
  52092. * How much sharpness should be applied (default: 0.3)
  52093. */
  52094. edgeAmount: number;
  52095. /**
  52096. * Creates a new instance ConvolutionPostProcess
  52097. * @param name The name of the effect.
  52098. * @param options The required width/height ratio to downsize to before computing the render pass.
  52099. * @param camera The camera to apply the render pass to.
  52100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52101. * @param engine The engine which the post process will be applied. (default: current engine)
  52102. * @param reusable If the post process can be reused on the same frame. (default: false)
  52103. * @param textureType Type of textures used when performing the post process. (default: 0)
  52104. * @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)
  52105. */
  52106. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52107. }
  52108. }
  52109. declare module BABYLON {
  52110. /**
  52111. * PostProcessRenderPipeline
  52112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52113. */
  52114. export class PostProcessRenderPipeline {
  52115. private engine;
  52116. private _renderEffects;
  52117. private _renderEffectsForIsolatedPass;
  52118. /**
  52119. * List of inspectable custom properties (used by the Inspector)
  52120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52121. */
  52122. inspectableCustomProperties: IInspectable[];
  52123. /**
  52124. * @hidden
  52125. */
  52126. protected _cameras: Camera[];
  52127. /** @hidden */
  52128. _name: string;
  52129. /**
  52130. * Gets pipeline name
  52131. */
  52132. readonly name: string;
  52133. /**
  52134. * Initializes a PostProcessRenderPipeline
  52135. * @param engine engine to add the pipeline to
  52136. * @param name name of the pipeline
  52137. */
  52138. constructor(engine: Engine, name: string);
  52139. /**
  52140. * Gets the class name
  52141. * @returns "PostProcessRenderPipeline"
  52142. */
  52143. getClassName(): string;
  52144. /**
  52145. * If all the render effects in the pipeline are supported
  52146. */
  52147. readonly isSupported: boolean;
  52148. /**
  52149. * Adds an effect to the pipeline
  52150. * @param renderEffect the effect to add
  52151. */
  52152. addEffect(renderEffect: PostProcessRenderEffect): void;
  52153. /** @hidden */
  52154. _rebuild(): void;
  52155. /** @hidden */
  52156. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52157. /** @hidden */
  52158. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52159. /** @hidden */
  52160. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52161. /** @hidden */
  52162. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52163. /** @hidden */
  52164. _attachCameras(cameras: Camera, unique: boolean): void;
  52165. /** @hidden */
  52166. _attachCameras(cameras: Camera[], unique: boolean): void;
  52167. /** @hidden */
  52168. _detachCameras(cameras: Camera): void;
  52169. /** @hidden */
  52170. _detachCameras(cameras: Nullable<Camera[]>): void;
  52171. /** @hidden */
  52172. _update(): void;
  52173. /** @hidden */
  52174. _reset(): void;
  52175. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52176. /**
  52177. * Disposes of the pipeline
  52178. */
  52179. dispose(): void;
  52180. }
  52181. }
  52182. declare module BABYLON {
  52183. /**
  52184. * PostProcessRenderPipelineManager class
  52185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52186. */
  52187. export class PostProcessRenderPipelineManager {
  52188. private _renderPipelines;
  52189. /**
  52190. * Initializes a PostProcessRenderPipelineManager
  52191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52192. */
  52193. constructor();
  52194. /**
  52195. * Gets the list of supported render pipelines
  52196. */
  52197. readonly supportedPipelines: PostProcessRenderPipeline[];
  52198. /**
  52199. * Adds a pipeline to the manager
  52200. * @param renderPipeline The pipeline to add
  52201. */
  52202. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52203. /**
  52204. * Attaches a camera to the pipeline
  52205. * @param renderPipelineName The name of the pipeline to attach to
  52206. * @param cameras the camera to attach
  52207. * @param unique if the camera can be attached multiple times to the pipeline
  52208. */
  52209. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52210. /**
  52211. * Detaches a camera from the pipeline
  52212. * @param renderPipelineName The name of the pipeline to detach from
  52213. * @param cameras the camera to detach
  52214. */
  52215. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52216. /**
  52217. * Enables an effect by name on a pipeline
  52218. * @param renderPipelineName the name of the pipeline to enable the effect in
  52219. * @param renderEffectName the name of the effect to enable
  52220. * @param cameras the cameras that the effect should be enabled on
  52221. */
  52222. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52223. /**
  52224. * Disables an effect by name on a pipeline
  52225. * @param renderPipelineName the name of the pipeline to disable the effect in
  52226. * @param renderEffectName the name of the effect to disable
  52227. * @param cameras the cameras that the effect should be disabled on
  52228. */
  52229. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52230. /**
  52231. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52232. */
  52233. update(): void;
  52234. /** @hidden */
  52235. _rebuild(): void;
  52236. /**
  52237. * Disposes of the manager and pipelines
  52238. */
  52239. dispose(): void;
  52240. }
  52241. }
  52242. declare module BABYLON {
  52243. interface Scene {
  52244. /** @hidden (Backing field) */
  52245. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52246. /**
  52247. * Gets the postprocess render pipeline manager
  52248. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52249. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52250. */
  52251. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52252. }
  52253. /**
  52254. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52255. */
  52256. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52257. /**
  52258. * The component name helpfull to identify the component in the list of scene components.
  52259. */
  52260. readonly name: string;
  52261. /**
  52262. * The scene the component belongs to.
  52263. */
  52264. scene: Scene;
  52265. /**
  52266. * Creates a new instance of the component for the given scene
  52267. * @param scene Defines the scene to register the component in
  52268. */
  52269. constructor(scene: Scene);
  52270. /**
  52271. * Registers the component in a given scene
  52272. */
  52273. register(): void;
  52274. /**
  52275. * Rebuilds the elements related to this component in case of
  52276. * context lost for instance.
  52277. */
  52278. rebuild(): void;
  52279. /**
  52280. * Disposes the component and the associated ressources
  52281. */
  52282. dispose(): void;
  52283. private _gatherRenderTargets;
  52284. }
  52285. }
  52286. declare module BABYLON {
  52287. /**
  52288. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52289. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52290. */
  52291. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52292. private _scene;
  52293. private _camerasToBeAttached;
  52294. /**
  52295. * ID of the sharpen post process,
  52296. */
  52297. private readonly SharpenPostProcessId;
  52298. /**
  52299. * @ignore
  52300. * ID of the image processing post process;
  52301. */
  52302. readonly ImageProcessingPostProcessId: string;
  52303. /**
  52304. * @ignore
  52305. * ID of the Fast Approximate Anti-Aliasing post process;
  52306. */
  52307. readonly FxaaPostProcessId: string;
  52308. /**
  52309. * ID of the chromatic aberration post process,
  52310. */
  52311. private readonly ChromaticAberrationPostProcessId;
  52312. /**
  52313. * ID of the grain post process
  52314. */
  52315. private readonly GrainPostProcessId;
  52316. /**
  52317. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52318. */
  52319. sharpen: SharpenPostProcess;
  52320. private _sharpenEffect;
  52321. private bloom;
  52322. /**
  52323. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52324. */
  52325. depthOfField: DepthOfFieldEffect;
  52326. /**
  52327. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52328. */
  52329. fxaa: FxaaPostProcess;
  52330. /**
  52331. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52332. */
  52333. imageProcessing: ImageProcessingPostProcess;
  52334. /**
  52335. * Chromatic aberration post process which will shift rgb colors in the image
  52336. */
  52337. chromaticAberration: ChromaticAberrationPostProcess;
  52338. private _chromaticAberrationEffect;
  52339. /**
  52340. * Grain post process which add noise to the image
  52341. */
  52342. grain: GrainPostProcess;
  52343. private _grainEffect;
  52344. /**
  52345. * Glow post process which adds a glow to emissive areas of the image
  52346. */
  52347. private _glowLayer;
  52348. /**
  52349. * Animations which can be used to tweak settings over a period of time
  52350. */
  52351. animations: Animation[];
  52352. private _imageProcessingConfigurationObserver;
  52353. private _sharpenEnabled;
  52354. private _bloomEnabled;
  52355. private _depthOfFieldEnabled;
  52356. private _depthOfFieldBlurLevel;
  52357. private _fxaaEnabled;
  52358. private _imageProcessingEnabled;
  52359. private _defaultPipelineTextureType;
  52360. private _bloomScale;
  52361. private _chromaticAberrationEnabled;
  52362. private _grainEnabled;
  52363. private _buildAllowed;
  52364. /**
  52365. * Gets active scene
  52366. */
  52367. readonly scene: Scene;
  52368. /**
  52369. * Enable or disable the sharpen process from the pipeline
  52370. */
  52371. sharpenEnabled: boolean;
  52372. private _resizeObserver;
  52373. private _hardwareScaleLevel;
  52374. private _bloomKernel;
  52375. /**
  52376. * Specifies the size of the bloom blur kernel, relative to the final output size
  52377. */
  52378. bloomKernel: number;
  52379. /**
  52380. * Specifies the weight of the bloom in the final rendering
  52381. */
  52382. private _bloomWeight;
  52383. /**
  52384. * Specifies the luma threshold for the area that will be blurred by the bloom
  52385. */
  52386. private _bloomThreshold;
  52387. private _hdr;
  52388. /**
  52389. * The strength of the bloom.
  52390. */
  52391. bloomWeight: number;
  52392. /**
  52393. * The strength of the bloom.
  52394. */
  52395. bloomThreshold: number;
  52396. /**
  52397. * The scale of the bloom, lower value will provide better performance.
  52398. */
  52399. bloomScale: number;
  52400. /**
  52401. * Enable or disable the bloom from the pipeline
  52402. */
  52403. bloomEnabled: boolean;
  52404. private _rebuildBloom;
  52405. /**
  52406. * If the depth of field is enabled.
  52407. */
  52408. depthOfFieldEnabled: boolean;
  52409. /**
  52410. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52411. */
  52412. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52413. /**
  52414. * If the anti aliasing is enabled.
  52415. */
  52416. fxaaEnabled: boolean;
  52417. private _samples;
  52418. /**
  52419. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52420. */
  52421. samples: number;
  52422. /**
  52423. * If image processing is enabled.
  52424. */
  52425. imageProcessingEnabled: boolean;
  52426. /**
  52427. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52428. */
  52429. glowLayerEnabled: boolean;
  52430. /**
  52431. * Enable or disable the chromaticAberration process from the pipeline
  52432. */
  52433. chromaticAberrationEnabled: boolean;
  52434. /**
  52435. * Enable or disable the grain process from the pipeline
  52436. */
  52437. grainEnabled: boolean;
  52438. /**
  52439. * @constructor
  52440. * @param name - The rendering pipeline name (default: "")
  52441. * @param hdr - If high dynamic range textures should be used (default: true)
  52442. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52443. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52444. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52445. */
  52446. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52447. /**
  52448. * Get the class name
  52449. * @returns "DefaultRenderingPipeline"
  52450. */
  52451. getClassName(): string;
  52452. /**
  52453. * Force the compilation of the entire pipeline.
  52454. */
  52455. prepare(): void;
  52456. private _hasCleared;
  52457. private _prevPostProcess;
  52458. private _prevPrevPostProcess;
  52459. private _setAutoClearAndTextureSharing;
  52460. private _depthOfFieldSceneObserver;
  52461. private _buildPipeline;
  52462. private _disposePostProcesses;
  52463. /**
  52464. * Adds a camera to the pipeline
  52465. * @param camera the camera to be added
  52466. */
  52467. addCamera(camera: Camera): void;
  52468. /**
  52469. * Removes a camera from the pipeline
  52470. * @param camera the camera to remove
  52471. */
  52472. removeCamera(camera: Camera): void;
  52473. /**
  52474. * Dispose of the pipeline and stop all post processes
  52475. */
  52476. dispose(): void;
  52477. /**
  52478. * Serialize the rendering pipeline (Used when exporting)
  52479. * @returns the serialized object
  52480. */
  52481. serialize(): any;
  52482. /**
  52483. * Parse the serialized pipeline
  52484. * @param source Source pipeline.
  52485. * @param scene The scene to load the pipeline to.
  52486. * @param rootUrl The URL of the serialized pipeline.
  52487. * @returns An instantiated pipeline from the serialized object.
  52488. */
  52489. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52490. }
  52491. }
  52492. declare module BABYLON {
  52493. /** @hidden */
  52494. export var lensHighlightsPixelShader: {
  52495. name: string;
  52496. shader: string;
  52497. };
  52498. }
  52499. declare module BABYLON {
  52500. /** @hidden */
  52501. export var depthOfFieldPixelShader: {
  52502. name: string;
  52503. shader: string;
  52504. };
  52505. }
  52506. declare module BABYLON {
  52507. /**
  52508. * BABYLON.JS Chromatic Aberration GLSL Shader
  52509. * Author: Olivier Guyot
  52510. * Separates very slightly R, G and B colors on the edges of the screen
  52511. * Inspired by Francois Tarlier & Martins Upitis
  52512. */
  52513. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52514. /**
  52515. * @ignore
  52516. * The chromatic aberration PostProcess id in the pipeline
  52517. */
  52518. LensChromaticAberrationEffect: string;
  52519. /**
  52520. * @ignore
  52521. * The highlights enhancing PostProcess id in the pipeline
  52522. */
  52523. HighlightsEnhancingEffect: string;
  52524. /**
  52525. * @ignore
  52526. * The depth-of-field PostProcess id in the pipeline
  52527. */
  52528. LensDepthOfFieldEffect: string;
  52529. private _scene;
  52530. private _depthTexture;
  52531. private _grainTexture;
  52532. private _chromaticAberrationPostProcess;
  52533. private _highlightsPostProcess;
  52534. private _depthOfFieldPostProcess;
  52535. private _edgeBlur;
  52536. private _grainAmount;
  52537. private _chromaticAberration;
  52538. private _distortion;
  52539. private _highlightsGain;
  52540. private _highlightsThreshold;
  52541. private _dofDistance;
  52542. private _dofAperture;
  52543. private _dofDarken;
  52544. private _dofPentagon;
  52545. private _blurNoise;
  52546. /**
  52547. * @constructor
  52548. *
  52549. * Effect parameters are as follow:
  52550. * {
  52551. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52552. * edge_blur: number; // from 0 to x (1 for realism)
  52553. * distortion: number; // from 0 to x (1 for realism)
  52554. * grain_amount: number; // from 0 to 1
  52555. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52556. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52557. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52558. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52559. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52560. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52561. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52562. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52563. * }
  52564. * Note: if an effect parameter is unset, effect is disabled
  52565. *
  52566. * @param name The rendering pipeline name
  52567. * @param parameters - An object containing all parameters (see above)
  52568. * @param scene The scene linked to this pipeline
  52569. * @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)
  52570. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52571. */
  52572. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52573. /**
  52574. * Get the class name
  52575. * @returns "LensRenderingPipeline"
  52576. */
  52577. getClassName(): string;
  52578. /**
  52579. * Gets associated scene
  52580. */
  52581. readonly scene: Scene;
  52582. /**
  52583. * Gets or sets the edge blur
  52584. */
  52585. edgeBlur: number;
  52586. /**
  52587. * Gets or sets the grain amount
  52588. */
  52589. grainAmount: number;
  52590. /**
  52591. * Gets or sets the chromatic aberration amount
  52592. */
  52593. chromaticAberration: number;
  52594. /**
  52595. * Gets or sets the depth of field aperture
  52596. */
  52597. dofAperture: number;
  52598. /**
  52599. * Gets or sets the edge distortion
  52600. */
  52601. edgeDistortion: number;
  52602. /**
  52603. * Gets or sets the depth of field distortion
  52604. */
  52605. dofDistortion: number;
  52606. /**
  52607. * Gets or sets the darken out of focus amount
  52608. */
  52609. darkenOutOfFocus: number;
  52610. /**
  52611. * Gets or sets a boolean indicating if blur noise is enabled
  52612. */
  52613. blurNoise: boolean;
  52614. /**
  52615. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52616. */
  52617. pentagonBokeh: boolean;
  52618. /**
  52619. * Gets or sets the highlight grain amount
  52620. */
  52621. highlightsGain: number;
  52622. /**
  52623. * Gets or sets the highlight threshold
  52624. */
  52625. highlightsThreshold: number;
  52626. /**
  52627. * Sets the amount of blur at the edges
  52628. * @param amount blur amount
  52629. */
  52630. setEdgeBlur(amount: number): void;
  52631. /**
  52632. * Sets edge blur to 0
  52633. */
  52634. disableEdgeBlur(): void;
  52635. /**
  52636. * Sets the amout of grain
  52637. * @param amount Amount of grain
  52638. */
  52639. setGrainAmount(amount: number): void;
  52640. /**
  52641. * Set grain amount to 0
  52642. */
  52643. disableGrain(): void;
  52644. /**
  52645. * Sets the chromatic aberration amount
  52646. * @param amount amount of chromatic aberration
  52647. */
  52648. setChromaticAberration(amount: number): void;
  52649. /**
  52650. * Sets chromatic aberration amount to 0
  52651. */
  52652. disableChromaticAberration(): void;
  52653. /**
  52654. * Sets the EdgeDistortion amount
  52655. * @param amount amount of EdgeDistortion
  52656. */
  52657. setEdgeDistortion(amount: number): void;
  52658. /**
  52659. * Sets edge distortion to 0
  52660. */
  52661. disableEdgeDistortion(): void;
  52662. /**
  52663. * Sets the FocusDistance amount
  52664. * @param amount amount of FocusDistance
  52665. */
  52666. setFocusDistance(amount: number): void;
  52667. /**
  52668. * Disables depth of field
  52669. */
  52670. disableDepthOfField(): void;
  52671. /**
  52672. * Sets the Aperture amount
  52673. * @param amount amount of Aperture
  52674. */
  52675. setAperture(amount: number): void;
  52676. /**
  52677. * Sets the DarkenOutOfFocus amount
  52678. * @param amount amount of DarkenOutOfFocus
  52679. */
  52680. setDarkenOutOfFocus(amount: number): void;
  52681. private _pentagonBokehIsEnabled;
  52682. /**
  52683. * Creates a pentagon bokeh effect
  52684. */
  52685. enablePentagonBokeh(): void;
  52686. /**
  52687. * Disables the pentagon bokeh effect
  52688. */
  52689. disablePentagonBokeh(): void;
  52690. /**
  52691. * Enables noise blur
  52692. */
  52693. enableNoiseBlur(): void;
  52694. /**
  52695. * Disables noise blur
  52696. */
  52697. disableNoiseBlur(): void;
  52698. /**
  52699. * Sets the HighlightsGain amount
  52700. * @param amount amount of HighlightsGain
  52701. */
  52702. setHighlightsGain(amount: number): void;
  52703. /**
  52704. * Sets the HighlightsThreshold amount
  52705. * @param amount amount of HighlightsThreshold
  52706. */
  52707. setHighlightsThreshold(amount: number): void;
  52708. /**
  52709. * Disables highlights
  52710. */
  52711. disableHighlights(): void;
  52712. /**
  52713. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52714. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52715. */
  52716. dispose(disableDepthRender?: boolean): void;
  52717. private _createChromaticAberrationPostProcess;
  52718. private _createHighlightsPostProcess;
  52719. private _createDepthOfFieldPostProcess;
  52720. private _createGrainTexture;
  52721. }
  52722. }
  52723. declare module BABYLON {
  52724. /** @hidden */
  52725. export var ssao2PixelShader: {
  52726. name: string;
  52727. shader: string;
  52728. };
  52729. }
  52730. declare module BABYLON {
  52731. /** @hidden */
  52732. export var ssaoCombinePixelShader: {
  52733. name: string;
  52734. shader: string;
  52735. };
  52736. }
  52737. declare module BABYLON {
  52738. /**
  52739. * Render pipeline to produce ssao effect
  52740. */
  52741. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52742. /**
  52743. * @ignore
  52744. * The PassPostProcess id in the pipeline that contains the original scene color
  52745. */
  52746. SSAOOriginalSceneColorEffect: string;
  52747. /**
  52748. * @ignore
  52749. * The SSAO PostProcess id in the pipeline
  52750. */
  52751. SSAORenderEffect: string;
  52752. /**
  52753. * @ignore
  52754. * The horizontal blur PostProcess id in the pipeline
  52755. */
  52756. SSAOBlurHRenderEffect: string;
  52757. /**
  52758. * @ignore
  52759. * The vertical blur PostProcess id in the pipeline
  52760. */
  52761. SSAOBlurVRenderEffect: string;
  52762. /**
  52763. * @ignore
  52764. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52765. */
  52766. SSAOCombineRenderEffect: string;
  52767. /**
  52768. * The output strength of the SSAO post-process. Default value is 1.0.
  52769. */
  52770. totalStrength: number;
  52771. /**
  52772. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52773. */
  52774. maxZ: number;
  52775. /**
  52776. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52777. */
  52778. minZAspect: number;
  52779. private _samples;
  52780. /**
  52781. * Number of samples used for the SSAO calculations. Default value is 8
  52782. */
  52783. samples: number;
  52784. private _textureSamples;
  52785. /**
  52786. * Number of samples to use for antialiasing
  52787. */
  52788. textureSamples: number;
  52789. /**
  52790. * Ratio object used for SSAO ratio and blur ratio
  52791. */
  52792. private _ratio;
  52793. /**
  52794. * Dynamically generated sphere sampler.
  52795. */
  52796. private _sampleSphere;
  52797. /**
  52798. * Blur filter offsets
  52799. */
  52800. private _samplerOffsets;
  52801. private _expensiveBlur;
  52802. /**
  52803. * If bilateral blur should be used
  52804. */
  52805. expensiveBlur: boolean;
  52806. /**
  52807. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52808. */
  52809. radius: number;
  52810. /**
  52811. * The base color of the SSAO post-process
  52812. * The final result is "base + ssao" between [0, 1]
  52813. */
  52814. base: number;
  52815. /**
  52816. * Support test.
  52817. */
  52818. static readonly IsSupported: boolean;
  52819. private _scene;
  52820. private _depthTexture;
  52821. private _normalTexture;
  52822. private _randomTexture;
  52823. private _originalColorPostProcess;
  52824. private _ssaoPostProcess;
  52825. private _blurHPostProcess;
  52826. private _blurVPostProcess;
  52827. private _ssaoCombinePostProcess;
  52828. private _firstUpdate;
  52829. /**
  52830. * Gets active scene
  52831. */
  52832. readonly scene: Scene;
  52833. /**
  52834. * @constructor
  52835. * @param name The rendering pipeline name
  52836. * @param scene The scene linked to this pipeline
  52837. * @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 }
  52838. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52839. */
  52840. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52841. /**
  52842. * Get the class name
  52843. * @returns "SSAO2RenderingPipeline"
  52844. */
  52845. getClassName(): string;
  52846. /**
  52847. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52848. */
  52849. dispose(disableGeometryBufferRenderer?: boolean): void;
  52850. private _createBlurPostProcess;
  52851. /** @hidden */
  52852. _rebuild(): void;
  52853. private _bits;
  52854. private _radicalInverse_VdC;
  52855. private _hammersley;
  52856. private _hemisphereSample_uniform;
  52857. private _generateHemisphere;
  52858. private _createSSAOPostProcess;
  52859. private _createSSAOCombinePostProcess;
  52860. private _createRandomTexture;
  52861. /**
  52862. * Serialize the rendering pipeline (Used when exporting)
  52863. * @returns the serialized object
  52864. */
  52865. serialize(): any;
  52866. /**
  52867. * Parse the serialized pipeline
  52868. * @param source Source pipeline.
  52869. * @param scene The scene to load the pipeline to.
  52870. * @param rootUrl The URL of the serialized pipeline.
  52871. * @returns An instantiated pipeline from the serialized object.
  52872. */
  52873. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52874. }
  52875. }
  52876. declare module BABYLON {
  52877. /** @hidden */
  52878. export var ssaoPixelShader: {
  52879. name: string;
  52880. shader: string;
  52881. };
  52882. }
  52883. declare module BABYLON {
  52884. /**
  52885. * Render pipeline to produce ssao effect
  52886. */
  52887. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52888. /**
  52889. * @ignore
  52890. * The PassPostProcess id in the pipeline that contains the original scene color
  52891. */
  52892. SSAOOriginalSceneColorEffect: string;
  52893. /**
  52894. * @ignore
  52895. * The SSAO PostProcess id in the pipeline
  52896. */
  52897. SSAORenderEffect: string;
  52898. /**
  52899. * @ignore
  52900. * The horizontal blur PostProcess id in the pipeline
  52901. */
  52902. SSAOBlurHRenderEffect: string;
  52903. /**
  52904. * @ignore
  52905. * The vertical blur PostProcess id in the pipeline
  52906. */
  52907. SSAOBlurVRenderEffect: string;
  52908. /**
  52909. * @ignore
  52910. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52911. */
  52912. SSAOCombineRenderEffect: string;
  52913. /**
  52914. * The output strength of the SSAO post-process. Default value is 1.0.
  52915. */
  52916. totalStrength: number;
  52917. /**
  52918. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52919. */
  52920. radius: number;
  52921. /**
  52922. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52923. * Must not be equal to fallOff and superior to fallOff.
  52924. * Default value is 0.0075
  52925. */
  52926. area: number;
  52927. /**
  52928. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52929. * Must not be equal to area and inferior to area.
  52930. * Default value is 0.000001
  52931. */
  52932. fallOff: number;
  52933. /**
  52934. * The base color of the SSAO post-process
  52935. * The final result is "base + ssao" between [0, 1]
  52936. */
  52937. base: number;
  52938. private _scene;
  52939. private _depthTexture;
  52940. private _randomTexture;
  52941. private _originalColorPostProcess;
  52942. private _ssaoPostProcess;
  52943. private _blurHPostProcess;
  52944. private _blurVPostProcess;
  52945. private _ssaoCombinePostProcess;
  52946. private _firstUpdate;
  52947. /**
  52948. * Gets active scene
  52949. */
  52950. readonly scene: Scene;
  52951. /**
  52952. * @constructor
  52953. * @param name - The rendering pipeline name
  52954. * @param scene - The scene linked to this pipeline
  52955. * @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 }
  52956. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52957. */
  52958. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52959. /**
  52960. * Get the class name
  52961. * @returns "SSAORenderingPipeline"
  52962. */
  52963. getClassName(): string;
  52964. /**
  52965. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52966. */
  52967. dispose(disableDepthRender?: boolean): void;
  52968. private _createBlurPostProcess;
  52969. /** @hidden */
  52970. _rebuild(): void;
  52971. private _createSSAOPostProcess;
  52972. private _createSSAOCombinePostProcess;
  52973. private _createRandomTexture;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /** @hidden */
  52978. export var standardPixelShader: {
  52979. name: string;
  52980. shader: string;
  52981. };
  52982. }
  52983. declare module BABYLON {
  52984. /**
  52985. * Standard rendering pipeline
  52986. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52987. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52988. */
  52989. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52990. /**
  52991. * Public members
  52992. */
  52993. /**
  52994. * Post-process which contains the original scene color before the pipeline applies all the effects
  52995. */
  52996. originalPostProcess: Nullable<PostProcess>;
  52997. /**
  52998. * Post-process used to down scale an image x4
  52999. */
  53000. downSampleX4PostProcess: Nullable<PostProcess>;
  53001. /**
  53002. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53003. */
  53004. brightPassPostProcess: Nullable<PostProcess>;
  53005. /**
  53006. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53007. */
  53008. blurHPostProcesses: PostProcess[];
  53009. /**
  53010. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53011. */
  53012. blurVPostProcesses: PostProcess[];
  53013. /**
  53014. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53015. */
  53016. textureAdderPostProcess: Nullable<PostProcess>;
  53017. /**
  53018. * Post-process used to create volumetric lighting effect
  53019. */
  53020. volumetricLightPostProcess: Nullable<PostProcess>;
  53021. /**
  53022. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53023. */
  53024. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53025. /**
  53026. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53027. */
  53028. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53029. /**
  53030. * Post-process used to merge the volumetric light effect and the real scene color
  53031. */
  53032. volumetricLightMergePostProces: Nullable<PostProcess>;
  53033. /**
  53034. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53035. */
  53036. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53037. /**
  53038. * Base post-process used to calculate the average luminance of the final image for HDR
  53039. */
  53040. luminancePostProcess: Nullable<PostProcess>;
  53041. /**
  53042. * Post-processes used to create down sample post-processes in order to get
  53043. * the average luminance of the final image for HDR
  53044. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53045. */
  53046. luminanceDownSamplePostProcesses: PostProcess[];
  53047. /**
  53048. * Post-process used to create a HDR effect (light adaptation)
  53049. */
  53050. hdrPostProcess: Nullable<PostProcess>;
  53051. /**
  53052. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53053. */
  53054. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53055. /**
  53056. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53057. */
  53058. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53059. /**
  53060. * Post-process used to merge the final HDR post-process and the real scene color
  53061. */
  53062. hdrFinalPostProcess: Nullable<PostProcess>;
  53063. /**
  53064. * Post-process used to create a lens flare effect
  53065. */
  53066. lensFlarePostProcess: Nullable<PostProcess>;
  53067. /**
  53068. * Post-process that merges the result of the lens flare post-process and the real scene color
  53069. */
  53070. lensFlareComposePostProcess: Nullable<PostProcess>;
  53071. /**
  53072. * Post-process used to create a motion blur effect
  53073. */
  53074. motionBlurPostProcess: Nullable<PostProcess>;
  53075. /**
  53076. * Post-process used to create a depth of field effect
  53077. */
  53078. depthOfFieldPostProcess: Nullable<PostProcess>;
  53079. /**
  53080. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53081. */
  53082. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53083. /**
  53084. * Represents the brightness threshold in order to configure the illuminated surfaces
  53085. */
  53086. brightThreshold: number;
  53087. /**
  53088. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53089. */
  53090. blurWidth: number;
  53091. /**
  53092. * Sets if the blur for highlighted surfaces must be only horizontal
  53093. */
  53094. horizontalBlur: boolean;
  53095. /**
  53096. * Sets the overall exposure used by the pipeline
  53097. */
  53098. exposure: number;
  53099. /**
  53100. * Texture used typically to simulate "dirty" on camera lens
  53101. */
  53102. lensTexture: Nullable<Texture>;
  53103. /**
  53104. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53105. */
  53106. volumetricLightCoefficient: number;
  53107. /**
  53108. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53109. */
  53110. volumetricLightPower: number;
  53111. /**
  53112. * Used the set the blur intensity to smooth the volumetric lights
  53113. */
  53114. volumetricLightBlurScale: number;
  53115. /**
  53116. * Light (spot or directional) used to generate the volumetric lights rays
  53117. * The source light must have a shadow generate so the pipeline can get its
  53118. * depth map
  53119. */
  53120. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53121. /**
  53122. * For eye adaptation, represents the minimum luminance the eye can see
  53123. */
  53124. hdrMinimumLuminance: number;
  53125. /**
  53126. * For eye adaptation, represents the decrease luminance speed
  53127. */
  53128. hdrDecreaseRate: number;
  53129. /**
  53130. * For eye adaptation, represents the increase luminance speed
  53131. */
  53132. hdrIncreaseRate: number;
  53133. /**
  53134. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53135. */
  53136. lensColorTexture: Nullable<Texture>;
  53137. /**
  53138. * The overall strengh for the lens flare effect
  53139. */
  53140. lensFlareStrength: number;
  53141. /**
  53142. * Dispersion coefficient for lens flare ghosts
  53143. */
  53144. lensFlareGhostDispersal: number;
  53145. /**
  53146. * Main lens flare halo width
  53147. */
  53148. lensFlareHaloWidth: number;
  53149. /**
  53150. * Based on the lens distortion effect, defines how much the lens flare result
  53151. * is distorted
  53152. */
  53153. lensFlareDistortionStrength: number;
  53154. /**
  53155. * Lens star texture must be used to simulate rays on the flares and is available
  53156. * in the documentation
  53157. */
  53158. lensStarTexture: Nullable<Texture>;
  53159. /**
  53160. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53161. * flare effect by taking account of the dirt texture
  53162. */
  53163. lensFlareDirtTexture: Nullable<Texture>;
  53164. /**
  53165. * Represents the focal length for the depth of field effect
  53166. */
  53167. depthOfFieldDistance: number;
  53168. /**
  53169. * Represents the blur intensity for the blurred part of the depth of field effect
  53170. */
  53171. depthOfFieldBlurWidth: number;
  53172. /**
  53173. * For motion blur, defines how much the image is blurred by the movement
  53174. */
  53175. motionStrength: number;
  53176. /**
  53177. * List of animations for the pipeline (IAnimatable implementation)
  53178. */
  53179. animations: Animation[];
  53180. /**
  53181. * Private members
  53182. */
  53183. private _scene;
  53184. private _currentDepthOfFieldSource;
  53185. private _basePostProcess;
  53186. private _hdrCurrentLuminance;
  53187. private _floatTextureType;
  53188. private _ratio;
  53189. private _bloomEnabled;
  53190. private _depthOfFieldEnabled;
  53191. private _vlsEnabled;
  53192. private _lensFlareEnabled;
  53193. private _hdrEnabled;
  53194. private _motionBlurEnabled;
  53195. private _fxaaEnabled;
  53196. private _motionBlurSamples;
  53197. private _volumetricLightStepsCount;
  53198. private _samples;
  53199. /**
  53200. * @ignore
  53201. * Specifies if the bloom pipeline is enabled
  53202. */
  53203. BloomEnabled: boolean;
  53204. /**
  53205. * @ignore
  53206. * Specifies if the depth of field pipeline is enabed
  53207. */
  53208. DepthOfFieldEnabled: boolean;
  53209. /**
  53210. * @ignore
  53211. * Specifies if the lens flare pipeline is enabed
  53212. */
  53213. LensFlareEnabled: boolean;
  53214. /**
  53215. * @ignore
  53216. * Specifies if the HDR pipeline is enabled
  53217. */
  53218. HDREnabled: boolean;
  53219. /**
  53220. * @ignore
  53221. * Specifies if the volumetric lights scattering effect is enabled
  53222. */
  53223. VLSEnabled: boolean;
  53224. /**
  53225. * @ignore
  53226. * Specifies if the motion blur effect is enabled
  53227. */
  53228. MotionBlurEnabled: boolean;
  53229. /**
  53230. * Specifies if anti-aliasing is enabled
  53231. */
  53232. fxaaEnabled: boolean;
  53233. /**
  53234. * Specifies the number of steps used to calculate the volumetric lights
  53235. * Typically in interval [50, 200]
  53236. */
  53237. volumetricLightStepsCount: number;
  53238. /**
  53239. * Specifies the number of samples used for the motion blur effect
  53240. * Typically in interval [16, 64]
  53241. */
  53242. motionBlurSamples: number;
  53243. /**
  53244. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53245. */
  53246. samples: number;
  53247. /**
  53248. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53249. * @constructor
  53250. * @param name The rendering pipeline name
  53251. * @param scene The scene linked to this pipeline
  53252. * @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)
  53253. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53254. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53255. */
  53256. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53257. private _buildPipeline;
  53258. private _createDownSampleX4PostProcess;
  53259. private _createBrightPassPostProcess;
  53260. private _createBlurPostProcesses;
  53261. private _createTextureAdderPostProcess;
  53262. private _createVolumetricLightPostProcess;
  53263. private _createLuminancePostProcesses;
  53264. private _createHdrPostProcess;
  53265. private _createLensFlarePostProcess;
  53266. private _createDepthOfFieldPostProcess;
  53267. private _createMotionBlurPostProcess;
  53268. private _getDepthTexture;
  53269. private _disposePostProcesses;
  53270. /**
  53271. * Dispose of the pipeline and stop all post processes
  53272. */
  53273. dispose(): void;
  53274. /**
  53275. * Serialize the rendering pipeline (Used when exporting)
  53276. * @returns the serialized object
  53277. */
  53278. serialize(): any;
  53279. /**
  53280. * Parse the serialized pipeline
  53281. * @param source Source pipeline.
  53282. * @param scene The scene to load the pipeline to.
  53283. * @param rootUrl The URL of the serialized pipeline.
  53284. * @returns An instantiated pipeline from the serialized object.
  53285. */
  53286. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53287. /**
  53288. * Luminance steps
  53289. */
  53290. static LuminanceSteps: number;
  53291. }
  53292. }
  53293. declare module BABYLON {
  53294. /** @hidden */
  53295. export var tonemapPixelShader: {
  53296. name: string;
  53297. shader: string;
  53298. };
  53299. }
  53300. declare module BABYLON {
  53301. /** Defines operator used for tonemapping */
  53302. export enum TonemappingOperator {
  53303. /** Hable */
  53304. Hable = 0,
  53305. /** Reinhard */
  53306. Reinhard = 1,
  53307. /** HejiDawson */
  53308. HejiDawson = 2,
  53309. /** Photographic */
  53310. Photographic = 3
  53311. }
  53312. /**
  53313. * Defines a post process to apply tone mapping
  53314. */
  53315. export class TonemapPostProcess extends PostProcess {
  53316. private _operator;
  53317. /** Defines the required exposure adjustement */
  53318. exposureAdjustment: number;
  53319. /**
  53320. * Creates a new TonemapPostProcess
  53321. * @param name defines the name of the postprocess
  53322. * @param _operator defines the operator to use
  53323. * @param exposureAdjustment defines the required exposure adjustement
  53324. * @param camera defines the camera to use (can be null)
  53325. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53326. * @param engine defines the hosting engine (can be ignore if camera is set)
  53327. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53328. */
  53329. constructor(name: string, _operator: TonemappingOperator,
  53330. /** Defines the required exposure adjustement */
  53331. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53332. }
  53333. }
  53334. declare module BABYLON {
  53335. /** @hidden */
  53336. export var depthVertexShader: {
  53337. name: string;
  53338. shader: string;
  53339. };
  53340. }
  53341. declare module BABYLON {
  53342. /** @hidden */
  53343. export var volumetricLightScatteringPixelShader: {
  53344. name: string;
  53345. shader: string;
  53346. };
  53347. }
  53348. declare module BABYLON {
  53349. /** @hidden */
  53350. export var volumetricLightScatteringPassPixelShader: {
  53351. name: string;
  53352. shader: string;
  53353. };
  53354. }
  53355. declare module BABYLON {
  53356. /**
  53357. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53358. */
  53359. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53360. private _volumetricLightScatteringPass;
  53361. private _volumetricLightScatteringRTT;
  53362. private _viewPort;
  53363. private _screenCoordinates;
  53364. private _cachedDefines;
  53365. /**
  53366. * If not undefined, the mesh position is computed from the attached node position
  53367. */
  53368. attachedNode: {
  53369. position: Vector3;
  53370. };
  53371. /**
  53372. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53373. */
  53374. customMeshPosition: Vector3;
  53375. /**
  53376. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53377. */
  53378. useCustomMeshPosition: boolean;
  53379. /**
  53380. * If the post-process should inverse the light scattering direction
  53381. */
  53382. invert: boolean;
  53383. /**
  53384. * The internal mesh used by the post-process
  53385. */
  53386. mesh: Mesh;
  53387. /**
  53388. * @hidden
  53389. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53390. */
  53391. useDiffuseColor: boolean;
  53392. /**
  53393. * Array containing the excluded meshes not rendered in the internal pass
  53394. */
  53395. excludedMeshes: AbstractMesh[];
  53396. /**
  53397. * Controls the overall intensity of the post-process
  53398. */
  53399. exposure: number;
  53400. /**
  53401. * Dissipates each sample's contribution in range [0, 1]
  53402. */
  53403. decay: number;
  53404. /**
  53405. * Controls the overall intensity of each sample
  53406. */
  53407. weight: number;
  53408. /**
  53409. * Controls the density of each sample
  53410. */
  53411. density: number;
  53412. /**
  53413. * @constructor
  53414. * @param name The post-process name
  53415. * @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)
  53416. * @param camera The camera that the post-process will be attached to
  53417. * @param mesh The mesh used to create the light scattering
  53418. * @param samples The post-process quality, default 100
  53419. * @param samplingModeThe post-process filtering mode
  53420. * @param engine The babylon engine
  53421. * @param reusable If the post-process is reusable
  53422. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53423. */
  53424. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53425. /**
  53426. * Returns the string "VolumetricLightScatteringPostProcess"
  53427. * @returns "VolumetricLightScatteringPostProcess"
  53428. */
  53429. getClassName(): string;
  53430. private _isReady;
  53431. /**
  53432. * Sets the new light position for light scattering effect
  53433. * @param position The new custom light position
  53434. */
  53435. setCustomMeshPosition(position: Vector3): void;
  53436. /**
  53437. * Returns the light position for light scattering effect
  53438. * @return Vector3 The custom light position
  53439. */
  53440. getCustomMeshPosition(): Vector3;
  53441. /**
  53442. * Disposes the internal assets and detaches the post-process from the camera
  53443. */
  53444. dispose(camera: Camera): void;
  53445. /**
  53446. * Returns the render target texture used by the post-process
  53447. * @return the render target texture used by the post-process
  53448. */
  53449. getPass(): RenderTargetTexture;
  53450. private _meshExcluded;
  53451. private _createPass;
  53452. private _updateMeshScreenCoordinates;
  53453. /**
  53454. * Creates a default mesh for the Volumeric Light Scattering post-process
  53455. * @param name The mesh name
  53456. * @param scene The scene where to create the mesh
  53457. * @return the default mesh
  53458. */
  53459. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. interface Scene {
  53464. /** @hidden (Backing field) */
  53465. _boundingBoxRenderer: BoundingBoxRenderer;
  53466. /** @hidden (Backing field) */
  53467. _forceShowBoundingBoxes: boolean;
  53468. /**
  53469. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53470. */
  53471. forceShowBoundingBoxes: boolean;
  53472. /**
  53473. * Gets the bounding box renderer associated with the scene
  53474. * @returns a BoundingBoxRenderer
  53475. */
  53476. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53477. }
  53478. interface AbstractMesh {
  53479. /** @hidden (Backing field) */
  53480. _showBoundingBox: boolean;
  53481. /**
  53482. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53483. */
  53484. showBoundingBox: boolean;
  53485. }
  53486. /**
  53487. * Component responsible of rendering the bounding box of the meshes in a scene.
  53488. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53489. */
  53490. export class BoundingBoxRenderer implements ISceneComponent {
  53491. /**
  53492. * The component name helpfull to identify the component in the list of scene components.
  53493. */
  53494. readonly name: string;
  53495. /**
  53496. * The scene the component belongs to.
  53497. */
  53498. scene: Scene;
  53499. /**
  53500. * Color of the bounding box lines placed in front of an object
  53501. */
  53502. frontColor: Color3;
  53503. /**
  53504. * Color of the bounding box lines placed behind an object
  53505. */
  53506. backColor: Color3;
  53507. /**
  53508. * Defines if the renderer should show the back lines or not
  53509. */
  53510. showBackLines: boolean;
  53511. /**
  53512. * @hidden
  53513. */
  53514. renderList: SmartArray<BoundingBox>;
  53515. private _colorShader;
  53516. private _vertexBuffers;
  53517. private _indexBuffer;
  53518. /**
  53519. * Instantiates a new bounding box renderer in a scene.
  53520. * @param scene the scene the renderer renders in
  53521. */
  53522. constructor(scene: Scene);
  53523. /**
  53524. * Registers the component in a given scene
  53525. */
  53526. register(): void;
  53527. private _evaluateSubMesh;
  53528. private _activeMesh;
  53529. private _prepareRessources;
  53530. private _createIndexBuffer;
  53531. /**
  53532. * Rebuilds the elements related to this component in case of
  53533. * context lost for instance.
  53534. */
  53535. rebuild(): void;
  53536. /**
  53537. * @hidden
  53538. */
  53539. reset(): void;
  53540. /**
  53541. * Render the bounding boxes of a specific rendering group
  53542. * @param renderingGroupId defines the rendering group to render
  53543. */
  53544. render(renderingGroupId: number): void;
  53545. /**
  53546. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53547. * @param mesh Define the mesh to render the occlusion bounding box for
  53548. */
  53549. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53550. /**
  53551. * Dispose and release the resources attached to this renderer.
  53552. */
  53553. dispose(): void;
  53554. }
  53555. }
  53556. declare module BABYLON {
  53557. /** @hidden */
  53558. export var depthPixelShader: {
  53559. name: string;
  53560. shader: string;
  53561. };
  53562. }
  53563. declare module BABYLON {
  53564. /**
  53565. * This represents a depth renderer in Babylon.
  53566. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53567. */
  53568. export class DepthRenderer {
  53569. private _scene;
  53570. private _depthMap;
  53571. private _effect;
  53572. private _cachedDefines;
  53573. private _camera;
  53574. /**
  53575. * Specifiess that the depth renderer will only be used within
  53576. * the camera it is created for.
  53577. * This can help forcing its rendering during the camera processing.
  53578. */
  53579. useOnlyInActiveCamera: boolean;
  53580. /** @hidden */
  53581. static _SceneComponentInitialization: (scene: Scene) => void;
  53582. /**
  53583. * Instantiates a depth renderer
  53584. * @param scene The scene the renderer belongs to
  53585. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53586. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53587. */
  53588. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53589. /**
  53590. * Creates the depth rendering effect and checks if the effect is ready.
  53591. * @param subMesh The submesh to be used to render the depth map of
  53592. * @param useInstances If multiple world instances should be used
  53593. * @returns if the depth renderer is ready to render the depth map
  53594. */
  53595. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53596. /**
  53597. * Gets the texture which the depth map will be written to.
  53598. * @returns The depth map texture
  53599. */
  53600. getDepthMap(): RenderTargetTexture;
  53601. /**
  53602. * Disposes of the depth renderer.
  53603. */
  53604. dispose(): void;
  53605. }
  53606. }
  53607. declare module BABYLON {
  53608. interface Scene {
  53609. /** @hidden (Backing field) */
  53610. _depthRenderer: {
  53611. [id: string]: DepthRenderer;
  53612. };
  53613. /**
  53614. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53615. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53616. * @returns the created depth renderer
  53617. */
  53618. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53619. /**
  53620. * Disables a depth renderer for a given camera
  53621. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53622. */
  53623. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53624. }
  53625. /**
  53626. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53627. * in several rendering techniques.
  53628. */
  53629. export class DepthRendererSceneComponent implements ISceneComponent {
  53630. /**
  53631. * The component name helpfull to identify the component in the list of scene components.
  53632. */
  53633. readonly name: string;
  53634. /**
  53635. * The scene the component belongs to.
  53636. */
  53637. scene: Scene;
  53638. /**
  53639. * Creates a new instance of the component for the given scene
  53640. * @param scene Defines the scene to register the component in
  53641. */
  53642. constructor(scene: Scene);
  53643. /**
  53644. * Registers the component in a given scene
  53645. */
  53646. register(): void;
  53647. /**
  53648. * Rebuilds the elements related to this component in case of
  53649. * context lost for instance.
  53650. */
  53651. rebuild(): void;
  53652. /**
  53653. * Disposes the component and the associated ressources
  53654. */
  53655. dispose(): void;
  53656. private _gatherRenderTargets;
  53657. private _gatherActiveCameraRenderTargets;
  53658. }
  53659. }
  53660. declare module BABYLON {
  53661. /** @hidden */
  53662. export var outlinePixelShader: {
  53663. name: string;
  53664. shader: string;
  53665. };
  53666. }
  53667. declare module BABYLON {
  53668. /** @hidden */
  53669. export var outlineVertexShader: {
  53670. name: string;
  53671. shader: string;
  53672. };
  53673. }
  53674. declare module BABYLON {
  53675. interface Scene {
  53676. /** @hidden */
  53677. _outlineRenderer: OutlineRenderer;
  53678. /**
  53679. * Gets the outline renderer associated with the scene
  53680. * @returns a OutlineRenderer
  53681. */
  53682. getOutlineRenderer(): OutlineRenderer;
  53683. }
  53684. interface AbstractMesh {
  53685. /** @hidden (Backing field) */
  53686. _renderOutline: boolean;
  53687. /**
  53688. * Gets or sets a boolean indicating if the outline must be rendered as well
  53689. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53690. */
  53691. renderOutline: boolean;
  53692. /** @hidden (Backing field) */
  53693. _renderOverlay: boolean;
  53694. /**
  53695. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53696. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53697. */
  53698. renderOverlay: boolean;
  53699. }
  53700. /**
  53701. * This class is responsible to draw bothe outline/overlay of meshes.
  53702. * It should not be used directly but through the available method on mesh.
  53703. */
  53704. export class OutlineRenderer implements ISceneComponent {
  53705. /**
  53706. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53707. */
  53708. private static _StencilReference;
  53709. /**
  53710. * The name of the component. Each component must have a unique name.
  53711. */
  53712. name: string;
  53713. /**
  53714. * The scene the component belongs to.
  53715. */
  53716. scene: Scene;
  53717. /**
  53718. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53719. */
  53720. zOffset: number;
  53721. private _engine;
  53722. private _effect;
  53723. private _cachedDefines;
  53724. private _savedDepthWrite;
  53725. /**
  53726. * Instantiates a new outline renderer. (There could be only one per scene).
  53727. * @param scene Defines the scene it belongs to
  53728. */
  53729. constructor(scene: Scene);
  53730. /**
  53731. * Register the component to one instance of a scene.
  53732. */
  53733. register(): void;
  53734. /**
  53735. * Rebuilds the elements related to this component in case of
  53736. * context lost for instance.
  53737. */
  53738. rebuild(): void;
  53739. /**
  53740. * Disposes the component and the associated ressources.
  53741. */
  53742. dispose(): void;
  53743. /**
  53744. * Renders the outline in the canvas.
  53745. * @param subMesh Defines the sumesh to render
  53746. * @param batch Defines the batch of meshes in case of instances
  53747. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53748. */
  53749. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53750. /**
  53751. * Returns whether or not the outline renderer is ready for a given submesh.
  53752. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53753. * @param subMesh Defines the submesh to check readyness for
  53754. * @param useInstances Defines wheter wee are trying to render instances or not
  53755. * @returns true if ready otherwise false
  53756. */
  53757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53758. private _beforeRenderingMesh;
  53759. private _afterRenderingMesh;
  53760. }
  53761. }
  53762. declare module BABYLON {
  53763. /**
  53764. * Defines the list of states available for a task inside a AssetsManager
  53765. */
  53766. export enum AssetTaskState {
  53767. /**
  53768. * Initialization
  53769. */
  53770. INIT = 0,
  53771. /**
  53772. * Running
  53773. */
  53774. RUNNING = 1,
  53775. /**
  53776. * Done
  53777. */
  53778. DONE = 2,
  53779. /**
  53780. * Error
  53781. */
  53782. ERROR = 3
  53783. }
  53784. /**
  53785. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53786. */
  53787. export abstract class AbstractAssetTask {
  53788. /**
  53789. * Task name
  53790. */ name: string;
  53791. /**
  53792. * Callback called when the task is successful
  53793. */
  53794. onSuccess: (task: any) => void;
  53795. /**
  53796. * Callback called when the task is not successful
  53797. */
  53798. onError: (task: any, message?: string, exception?: any) => void;
  53799. /**
  53800. * Creates a new AssetsManager
  53801. * @param name defines the name of the task
  53802. */
  53803. constructor(
  53804. /**
  53805. * Task name
  53806. */ name: string);
  53807. private _isCompleted;
  53808. private _taskState;
  53809. private _errorObject;
  53810. /**
  53811. * Get if the task is completed
  53812. */
  53813. readonly isCompleted: boolean;
  53814. /**
  53815. * Gets the current state of the task
  53816. */
  53817. readonly taskState: AssetTaskState;
  53818. /**
  53819. * Gets the current error object (if task is in error)
  53820. */
  53821. readonly errorObject: {
  53822. message?: string;
  53823. exception?: any;
  53824. };
  53825. /**
  53826. * Internal only
  53827. * @hidden
  53828. */
  53829. _setErrorObject(message?: string, exception?: any): void;
  53830. /**
  53831. * Execute the current task
  53832. * @param scene defines the scene where you want your assets to be loaded
  53833. * @param onSuccess is a callback called when the task is successfully executed
  53834. * @param onError is a callback called if an error occurs
  53835. */
  53836. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53837. /**
  53838. * Execute the current task
  53839. * @param scene defines the scene where you want your assets to be loaded
  53840. * @param onSuccess is a callback called when the task is successfully executed
  53841. * @param onError is a callback called if an error occurs
  53842. */
  53843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53844. /**
  53845. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53846. * This can be used with failed tasks that have the reason for failure fixed.
  53847. */
  53848. reset(): void;
  53849. private onErrorCallback;
  53850. private onDoneCallback;
  53851. }
  53852. /**
  53853. * Define the interface used by progress events raised during assets loading
  53854. */
  53855. export interface IAssetsProgressEvent {
  53856. /**
  53857. * Defines the number of remaining tasks to process
  53858. */
  53859. remainingCount: number;
  53860. /**
  53861. * Defines the total number of tasks
  53862. */
  53863. totalCount: number;
  53864. /**
  53865. * Defines the task that was just processed
  53866. */
  53867. task: AbstractAssetTask;
  53868. }
  53869. /**
  53870. * Class used to share progress information about assets loading
  53871. */
  53872. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53873. /**
  53874. * Defines the number of remaining tasks to process
  53875. */
  53876. remainingCount: number;
  53877. /**
  53878. * Defines the total number of tasks
  53879. */
  53880. totalCount: number;
  53881. /**
  53882. * Defines the task that was just processed
  53883. */
  53884. task: AbstractAssetTask;
  53885. /**
  53886. * Creates a AssetsProgressEvent
  53887. * @param remainingCount defines the number of remaining tasks to process
  53888. * @param totalCount defines the total number of tasks
  53889. * @param task defines the task that was just processed
  53890. */
  53891. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53892. }
  53893. /**
  53894. * Define a task used by AssetsManager to load meshes
  53895. */
  53896. export class MeshAssetTask extends AbstractAssetTask {
  53897. /**
  53898. * Defines the name of the task
  53899. */
  53900. name: string;
  53901. /**
  53902. * Defines the list of mesh's names you want to load
  53903. */
  53904. meshesNames: any;
  53905. /**
  53906. * Defines the root url to use as a base to load your meshes and associated resources
  53907. */
  53908. rootUrl: string;
  53909. /**
  53910. * Defines the filename of the scene to load from
  53911. */
  53912. sceneFilename: string;
  53913. /**
  53914. * Gets the list of loaded meshes
  53915. */
  53916. loadedMeshes: Array<AbstractMesh>;
  53917. /**
  53918. * Gets the list of loaded particle systems
  53919. */
  53920. loadedParticleSystems: Array<IParticleSystem>;
  53921. /**
  53922. * Gets the list of loaded skeletons
  53923. */
  53924. loadedSkeletons: Array<Skeleton>;
  53925. /**
  53926. * Gets the list of loaded animation groups
  53927. */
  53928. loadedAnimationGroups: Array<AnimationGroup>;
  53929. /**
  53930. * Callback called when the task is successful
  53931. */
  53932. onSuccess: (task: MeshAssetTask) => void;
  53933. /**
  53934. * Callback called when the task is successful
  53935. */
  53936. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53937. /**
  53938. * Creates a new MeshAssetTask
  53939. * @param name defines the name of the task
  53940. * @param meshesNames defines the list of mesh's names you want to load
  53941. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53942. * @param sceneFilename defines the filename of the scene to load from
  53943. */
  53944. constructor(
  53945. /**
  53946. * Defines the name of the task
  53947. */
  53948. name: string,
  53949. /**
  53950. * Defines the list of mesh's names you want to load
  53951. */
  53952. meshesNames: any,
  53953. /**
  53954. * Defines the root url to use as a base to load your meshes and associated resources
  53955. */
  53956. rootUrl: string,
  53957. /**
  53958. * Defines the filename of the scene to load from
  53959. */
  53960. sceneFilename: string);
  53961. /**
  53962. * Execute the current task
  53963. * @param scene defines the scene where you want your assets to be loaded
  53964. * @param onSuccess is a callback called when the task is successfully executed
  53965. * @param onError is a callback called if an error occurs
  53966. */
  53967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53968. }
  53969. /**
  53970. * Define a task used by AssetsManager to load text content
  53971. */
  53972. export class TextFileAssetTask extends AbstractAssetTask {
  53973. /**
  53974. * Defines the name of the task
  53975. */
  53976. name: string;
  53977. /**
  53978. * Defines the location of the file to load
  53979. */
  53980. url: string;
  53981. /**
  53982. * Gets the loaded text string
  53983. */
  53984. text: string;
  53985. /**
  53986. * Callback called when the task is successful
  53987. */
  53988. onSuccess: (task: TextFileAssetTask) => void;
  53989. /**
  53990. * Callback called when the task is successful
  53991. */
  53992. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  53993. /**
  53994. * Creates a new TextFileAssetTask object
  53995. * @param name defines the name of the task
  53996. * @param url defines the location of the file to load
  53997. */
  53998. constructor(
  53999. /**
  54000. * Defines the name of the task
  54001. */
  54002. name: string,
  54003. /**
  54004. * Defines the location of the file to load
  54005. */
  54006. url: string);
  54007. /**
  54008. * Execute the current task
  54009. * @param scene defines the scene where you want your assets to be loaded
  54010. * @param onSuccess is a callback called when the task is successfully executed
  54011. * @param onError is a callback called if an error occurs
  54012. */
  54013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54014. }
  54015. /**
  54016. * Define a task used by AssetsManager to load binary data
  54017. */
  54018. export class BinaryFileAssetTask extends AbstractAssetTask {
  54019. /**
  54020. * Defines the name of the task
  54021. */
  54022. name: string;
  54023. /**
  54024. * Defines the location of the file to load
  54025. */
  54026. url: string;
  54027. /**
  54028. * Gets the lodaded data (as an array buffer)
  54029. */
  54030. data: ArrayBuffer;
  54031. /**
  54032. * Callback called when the task is successful
  54033. */
  54034. onSuccess: (task: BinaryFileAssetTask) => void;
  54035. /**
  54036. * Callback called when the task is successful
  54037. */
  54038. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54039. /**
  54040. * Creates a new BinaryFileAssetTask object
  54041. * @param name defines the name of the new task
  54042. * @param url defines the location of the file to load
  54043. */
  54044. constructor(
  54045. /**
  54046. * Defines the name of the task
  54047. */
  54048. name: string,
  54049. /**
  54050. * Defines the location of the file to load
  54051. */
  54052. url: string);
  54053. /**
  54054. * Execute the current task
  54055. * @param scene defines the scene where you want your assets to be loaded
  54056. * @param onSuccess is a callback called when the task is successfully executed
  54057. * @param onError is a callback called if an error occurs
  54058. */
  54059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54060. }
  54061. /**
  54062. * Define a task used by AssetsManager to load images
  54063. */
  54064. export class ImageAssetTask extends AbstractAssetTask {
  54065. /**
  54066. * Defines the name of the task
  54067. */
  54068. name: string;
  54069. /**
  54070. * Defines the location of the image to load
  54071. */
  54072. url: string;
  54073. /**
  54074. * Gets the loaded images
  54075. */
  54076. image: HTMLImageElement;
  54077. /**
  54078. * Callback called when the task is successful
  54079. */
  54080. onSuccess: (task: ImageAssetTask) => void;
  54081. /**
  54082. * Callback called when the task is successful
  54083. */
  54084. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54085. /**
  54086. * Creates a new ImageAssetTask
  54087. * @param name defines the name of the task
  54088. * @param url defines the location of the image to load
  54089. */
  54090. constructor(
  54091. /**
  54092. * Defines the name of the task
  54093. */
  54094. name: string,
  54095. /**
  54096. * Defines the location of the image to load
  54097. */
  54098. url: string);
  54099. /**
  54100. * Execute the current task
  54101. * @param scene defines the scene where you want your assets to be loaded
  54102. * @param onSuccess is a callback called when the task is successfully executed
  54103. * @param onError is a callback called if an error occurs
  54104. */
  54105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54106. }
  54107. /**
  54108. * Defines the interface used by texture loading tasks
  54109. */
  54110. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54111. /**
  54112. * Gets the loaded texture
  54113. */
  54114. texture: TEX;
  54115. }
  54116. /**
  54117. * Define a task used by AssetsManager to load 2D textures
  54118. */
  54119. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54120. /**
  54121. * Defines the name of the task
  54122. */
  54123. name: string;
  54124. /**
  54125. * Defines the location of the file to load
  54126. */
  54127. url: string;
  54128. /**
  54129. * Defines if mipmap should not be generated (default is false)
  54130. */
  54131. noMipmap?: boolean | undefined;
  54132. /**
  54133. * Defines if texture must be inverted on Y axis (default is false)
  54134. */
  54135. invertY?: boolean | undefined;
  54136. /**
  54137. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54138. */
  54139. samplingMode: number;
  54140. /**
  54141. * Gets the loaded texture
  54142. */
  54143. texture: Texture;
  54144. /**
  54145. * Callback called when the task is successful
  54146. */
  54147. onSuccess: (task: TextureAssetTask) => void;
  54148. /**
  54149. * Callback called when the task is successful
  54150. */
  54151. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54152. /**
  54153. * Creates a new TextureAssetTask object
  54154. * @param name defines the name of the task
  54155. * @param url defines the location of the file to load
  54156. * @param noMipmap defines if mipmap should not be generated (default is false)
  54157. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54158. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54159. */
  54160. constructor(
  54161. /**
  54162. * Defines the name of the task
  54163. */
  54164. name: string,
  54165. /**
  54166. * Defines the location of the file to load
  54167. */
  54168. url: string,
  54169. /**
  54170. * Defines if mipmap should not be generated (default is false)
  54171. */
  54172. noMipmap?: boolean | undefined,
  54173. /**
  54174. * Defines if texture must be inverted on Y axis (default is false)
  54175. */
  54176. invertY?: boolean | undefined,
  54177. /**
  54178. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54179. */
  54180. samplingMode?: number);
  54181. /**
  54182. * Execute the current task
  54183. * @param scene defines the scene where you want your assets to be loaded
  54184. * @param onSuccess is a callback called when the task is successfully executed
  54185. * @param onError is a callback called if an error occurs
  54186. */
  54187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54188. }
  54189. /**
  54190. * Define a task used by AssetsManager to load cube textures
  54191. */
  54192. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54193. /**
  54194. * Defines the name of the task
  54195. */
  54196. name: string;
  54197. /**
  54198. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54199. */
  54200. url: string;
  54201. /**
  54202. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54203. */
  54204. extensions?: string[] | undefined;
  54205. /**
  54206. * Defines if mipmaps should not be generated (default is false)
  54207. */
  54208. noMipmap?: boolean | undefined;
  54209. /**
  54210. * Defines the explicit list of files (undefined by default)
  54211. */
  54212. files?: string[] | undefined;
  54213. /**
  54214. * Gets the loaded texture
  54215. */
  54216. texture: CubeTexture;
  54217. /**
  54218. * Callback called when the task is successful
  54219. */
  54220. onSuccess: (task: CubeTextureAssetTask) => void;
  54221. /**
  54222. * Callback called when the task is successful
  54223. */
  54224. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54225. /**
  54226. * Creates a new CubeTextureAssetTask
  54227. * @param name defines the name of the task
  54228. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54229. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54230. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54231. * @param files defines the explicit list of files (undefined by default)
  54232. */
  54233. constructor(
  54234. /**
  54235. * Defines the name of the task
  54236. */
  54237. name: string,
  54238. /**
  54239. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54240. */
  54241. url: string,
  54242. /**
  54243. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54244. */
  54245. extensions?: string[] | undefined,
  54246. /**
  54247. * Defines if mipmaps should not be generated (default is false)
  54248. */
  54249. noMipmap?: boolean | undefined,
  54250. /**
  54251. * Defines the explicit list of files (undefined by default)
  54252. */
  54253. files?: string[] | undefined);
  54254. /**
  54255. * Execute the current task
  54256. * @param scene defines the scene where you want your assets to be loaded
  54257. * @param onSuccess is a callback called when the task is successfully executed
  54258. * @param onError is a callback called if an error occurs
  54259. */
  54260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54261. }
  54262. /**
  54263. * Define a task used by AssetsManager to load HDR cube textures
  54264. */
  54265. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54266. /**
  54267. * Defines the name of the task
  54268. */
  54269. name: string;
  54270. /**
  54271. * Defines the location of the file to load
  54272. */
  54273. url: string;
  54274. /**
  54275. * Defines the desired size (the more it increases the longer the generation will be)
  54276. */
  54277. size: number;
  54278. /**
  54279. * Defines if mipmaps should not be generated (default is false)
  54280. */
  54281. noMipmap: boolean;
  54282. /**
  54283. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54284. */
  54285. generateHarmonics: boolean;
  54286. /**
  54287. * 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)
  54288. */
  54289. gammaSpace: boolean;
  54290. /**
  54291. * Internal Use Only
  54292. */
  54293. reserved: boolean;
  54294. /**
  54295. * Gets the loaded texture
  54296. */
  54297. texture: HDRCubeTexture;
  54298. /**
  54299. * Callback called when the task is successful
  54300. */
  54301. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54302. /**
  54303. * Callback called when the task is successful
  54304. */
  54305. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54306. /**
  54307. * Creates a new HDRCubeTextureAssetTask object
  54308. * @param name defines the name of the task
  54309. * @param url defines the location of the file to load
  54310. * @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.
  54311. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54312. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54313. * @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)
  54314. * @param reserved Internal use only
  54315. */
  54316. constructor(
  54317. /**
  54318. * Defines the name of the task
  54319. */
  54320. name: string,
  54321. /**
  54322. * Defines the location of the file to load
  54323. */
  54324. url: string,
  54325. /**
  54326. * Defines the desired size (the more it increases the longer the generation will be)
  54327. */
  54328. size: number,
  54329. /**
  54330. * Defines if mipmaps should not be generated (default is false)
  54331. */
  54332. noMipmap?: boolean,
  54333. /**
  54334. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54335. */
  54336. generateHarmonics?: boolean,
  54337. /**
  54338. * 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)
  54339. */
  54340. gammaSpace?: boolean,
  54341. /**
  54342. * Internal Use Only
  54343. */
  54344. reserved?: boolean);
  54345. /**
  54346. * Execute the current task
  54347. * @param scene defines the scene where you want your assets to be loaded
  54348. * @param onSuccess is a callback called when the task is successfully executed
  54349. * @param onError is a callback called if an error occurs
  54350. */
  54351. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54352. }
  54353. /**
  54354. * This class can be used to easily import assets into a scene
  54355. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54356. */
  54357. export class AssetsManager {
  54358. private _scene;
  54359. private _isLoading;
  54360. protected _tasks: AbstractAssetTask[];
  54361. protected _waitingTasksCount: number;
  54362. protected _totalTasksCount: number;
  54363. /**
  54364. * Callback called when all tasks are processed
  54365. */
  54366. onFinish: (tasks: AbstractAssetTask[]) => void;
  54367. /**
  54368. * Callback called when a task is successful
  54369. */
  54370. onTaskSuccess: (task: AbstractAssetTask) => void;
  54371. /**
  54372. * Callback called when a task had an error
  54373. */
  54374. onTaskError: (task: AbstractAssetTask) => void;
  54375. /**
  54376. * Callback called when a task is done (whatever the result is)
  54377. */
  54378. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54379. /**
  54380. * Observable called when all tasks are processed
  54381. */
  54382. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54383. /**
  54384. * Observable called when a task had an error
  54385. */
  54386. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54387. /**
  54388. * Observable called when all tasks were executed
  54389. */
  54390. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54391. /**
  54392. * Observable called when a task is done (whatever the result is)
  54393. */
  54394. onProgressObservable: Observable<IAssetsProgressEvent>;
  54395. /**
  54396. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54398. */
  54399. useDefaultLoadingScreen: boolean;
  54400. /**
  54401. * Creates a new AssetsManager
  54402. * @param scene defines the scene to work on
  54403. */
  54404. constructor(scene: Scene);
  54405. /**
  54406. * Add a MeshAssetTask to the list of active tasks
  54407. * @param taskName defines the name of the new task
  54408. * @param meshesNames defines the name of meshes to load
  54409. * @param rootUrl defines the root url to use to locate files
  54410. * @param sceneFilename defines the filename of the scene file
  54411. * @returns a new MeshAssetTask object
  54412. */
  54413. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54414. /**
  54415. * Add a TextFileAssetTask to the list of active tasks
  54416. * @param taskName defines the name of the new task
  54417. * @param url defines the url of the file to load
  54418. * @returns a new TextFileAssetTask object
  54419. */
  54420. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54421. /**
  54422. * Add a BinaryFileAssetTask to the list of active tasks
  54423. * @param taskName defines the name of the new task
  54424. * @param url defines the url of the file to load
  54425. * @returns a new BinaryFileAssetTask object
  54426. */
  54427. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54428. /**
  54429. * Add a ImageAssetTask to the list of active tasks
  54430. * @param taskName defines the name of the new task
  54431. * @param url defines the url of the file to load
  54432. * @returns a new ImageAssetTask object
  54433. */
  54434. addImageTask(taskName: string, url: string): ImageAssetTask;
  54435. /**
  54436. * Add a TextureAssetTask to the list of active tasks
  54437. * @param taskName defines the name of the new task
  54438. * @param url defines the url of the file to load
  54439. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54440. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54441. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54442. * @returns a new TextureAssetTask object
  54443. */
  54444. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54445. /**
  54446. * Add a CubeTextureAssetTask to the list of active tasks
  54447. * @param taskName defines the name of the new task
  54448. * @param url defines the url of the file to load
  54449. * @param extensions defines the extension to use to load the cube map (can be null)
  54450. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54451. * @param files defines the list of files to load (can be null)
  54452. * @returns a new CubeTextureAssetTask object
  54453. */
  54454. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54455. /**
  54456. *
  54457. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54458. * @param taskName defines the name of the new task
  54459. * @param url defines the url of the file to load
  54460. * @param size defines the size you want for the cubemap (can be null)
  54461. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54462. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54463. * @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)
  54464. * @param reserved Internal use only
  54465. * @returns a new HDRCubeTextureAssetTask object
  54466. */
  54467. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54468. /**
  54469. * Remove a task from the assets manager.
  54470. * @param task the task to remove
  54471. */
  54472. removeTask(task: AbstractAssetTask): void;
  54473. private _decreaseWaitingTasksCount;
  54474. private _runTask;
  54475. /**
  54476. * Reset the AssetsManager and remove all tasks
  54477. * @return the current instance of the AssetsManager
  54478. */
  54479. reset(): AssetsManager;
  54480. /**
  54481. * Start the loading process
  54482. * @return the current instance of the AssetsManager
  54483. */
  54484. load(): AssetsManager;
  54485. /**
  54486. * Start the loading process as an async operation
  54487. * @return a promise returning the list of failed tasks
  54488. */
  54489. loadAsync(): Promise<void>;
  54490. }
  54491. }
  54492. declare module BABYLON {
  54493. /**
  54494. * Wrapper class for promise with external resolve and reject.
  54495. */
  54496. export class Deferred<T> {
  54497. /**
  54498. * The promise associated with this deferred object.
  54499. */
  54500. readonly promise: Promise<T>;
  54501. private _resolve;
  54502. private _reject;
  54503. /**
  54504. * The resolve method of the promise associated with this deferred object.
  54505. */
  54506. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54507. /**
  54508. * The reject method of the promise associated with this deferred object.
  54509. */
  54510. readonly reject: (reason?: any) => void;
  54511. /**
  54512. * Constructor for this deferred object.
  54513. */
  54514. constructor();
  54515. }
  54516. }
  54517. declare module BABYLON {
  54518. /**
  54519. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54520. */
  54521. export class MeshExploder {
  54522. private _centerMesh;
  54523. private _meshes;
  54524. private _meshesOrigins;
  54525. private _toCenterVectors;
  54526. private _scaledDirection;
  54527. private _newPosition;
  54528. private _centerPosition;
  54529. /**
  54530. * Explodes meshes from a center mesh.
  54531. * @param meshes The meshes to explode.
  54532. * @param centerMesh The mesh to be center of explosion.
  54533. */
  54534. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54535. private _setCenterMesh;
  54536. /**
  54537. * Get class name
  54538. * @returns "MeshExploder"
  54539. */
  54540. getClassName(): string;
  54541. /**
  54542. * "Exploded meshes"
  54543. * @returns Array of meshes with the centerMesh at index 0.
  54544. */
  54545. getMeshes(): Array<Mesh>;
  54546. /**
  54547. * Explodes meshes giving a specific direction
  54548. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54549. */
  54550. explode(direction?: number): void;
  54551. }
  54552. }
  54553. declare module BABYLON {
  54554. /**
  54555. * Class used to help managing file picking and drag'n'drop
  54556. */
  54557. export class FilesInput {
  54558. /**
  54559. * List of files ready to be loaded
  54560. */
  54561. static readonly FilesToLoad: {
  54562. [key: string]: File;
  54563. };
  54564. /**
  54565. * Callback called when a file is processed
  54566. */
  54567. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54568. private _engine;
  54569. private _currentScene;
  54570. private _sceneLoadedCallback;
  54571. private _progressCallback;
  54572. private _additionalRenderLoopLogicCallback;
  54573. private _textureLoadingCallback;
  54574. private _startingProcessingFilesCallback;
  54575. private _onReloadCallback;
  54576. private _errorCallback;
  54577. private _elementToMonitor;
  54578. private _sceneFileToLoad;
  54579. private _filesToLoad;
  54580. /**
  54581. * Creates a new FilesInput
  54582. * @param engine defines the rendering engine
  54583. * @param scene defines the hosting scene
  54584. * @param sceneLoadedCallback callback called when scene is loaded
  54585. * @param progressCallback callback called to track progress
  54586. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54587. * @param textureLoadingCallback callback called when a texture is loading
  54588. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54589. * @param onReloadCallback callback called when a reload is requested
  54590. * @param errorCallback callback call if an error occurs
  54591. */
  54592. 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);
  54593. private _dragEnterHandler;
  54594. private _dragOverHandler;
  54595. private _dropHandler;
  54596. /**
  54597. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54598. * @param elementToMonitor defines the DOM element to track
  54599. */
  54600. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54601. /**
  54602. * Release all associated resources
  54603. */
  54604. dispose(): void;
  54605. private renderFunction;
  54606. private drag;
  54607. private drop;
  54608. private _traverseFolder;
  54609. private _processFiles;
  54610. /**
  54611. * Load files from a drop event
  54612. * @param event defines the drop event to use as source
  54613. */
  54614. loadFiles(event: any): void;
  54615. private _processReload;
  54616. /**
  54617. * Reload the current scene from the loaded files
  54618. */
  54619. reload(): void;
  54620. }
  54621. }
  54622. declare module BABYLON {
  54623. /**
  54624. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54626. */
  54627. export class SceneOptimization {
  54628. /**
  54629. * Defines the priority of this optimization (0 by default which means first in the list)
  54630. */
  54631. priority: number;
  54632. /**
  54633. * Gets a string describing the action executed by the current optimization
  54634. * @returns description string
  54635. */
  54636. getDescription(): string;
  54637. /**
  54638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54639. * @param scene defines the current scene where to apply this optimization
  54640. * @param optimizer defines the current optimizer
  54641. * @returns true if everything that can be done was applied
  54642. */
  54643. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54644. /**
  54645. * Creates the SceneOptimization object
  54646. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54647. * @param desc defines the description associated with the optimization
  54648. */
  54649. constructor(
  54650. /**
  54651. * Defines the priority of this optimization (0 by default which means first in the list)
  54652. */
  54653. priority?: number);
  54654. }
  54655. /**
  54656. * Defines an optimization used to reduce the size of render target textures
  54657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54658. */
  54659. export class TextureOptimization extends SceneOptimization {
  54660. /**
  54661. * Defines the priority of this optimization (0 by default which means first in the list)
  54662. */
  54663. priority: number;
  54664. /**
  54665. * 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
  54666. */
  54667. maximumSize: number;
  54668. /**
  54669. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54670. */
  54671. step: number;
  54672. /**
  54673. * Gets a string describing the action executed by the current optimization
  54674. * @returns description string
  54675. */
  54676. getDescription(): string;
  54677. /**
  54678. * Creates the TextureOptimization object
  54679. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54680. * @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
  54681. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54682. */
  54683. constructor(
  54684. /**
  54685. * Defines the priority of this optimization (0 by default which means first in the list)
  54686. */
  54687. priority?: number,
  54688. /**
  54689. * 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
  54690. */
  54691. maximumSize?: number,
  54692. /**
  54693. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54694. */
  54695. step?: number);
  54696. /**
  54697. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54698. * @param scene defines the current scene where to apply this optimization
  54699. * @param optimizer defines the current optimizer
  54700. * @returns true if everything that can be done was applied
  54701. */
  54702. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54703. }
  54704. /**
  54705. * Defines an optimization used to increase or decrease the rendering resolution
  54706. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54707. */
  54708. export class HardwareScalingOptimization extends SceneOptimization {
  54709. /**
  54710. * Defines the priority of this optimization (0 by default which means first in the list)
  54711. */
  54712. priority: number;
  54713. /**
  54714. * Defines the maximum scale to use (2 by default)
  54715. */
  54716. maximumScale: number;
  54717. /**
  54718. * Defines the step to use between two passes (0.5 by default)
  54719. */
  54720. step: number;
  54721. private _currentScale;
  54722. private _directionOffset;
  54723. /**
  54724. * Gets a string describing the action executed by the current optimization
  54725. * @return description string
  54726. */
  54727. getDescription(): string;
  54728. /**
  54729. * Creates the HardwareScalingOptimization object
  54730. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54731. * @param maximumScale defines the maximum scale to use (2 by default)
  54732. * @param step defines the step to use between two passes (0.5 by default)
  54733. */
  54734. constructor(
  54735. /**
  54736. * Defines the priority of this optimization (0 by default which means first in the list)
  54737. */
  54738. priority?: number,
  54739. /**
  54740. * Defines the maximum scale to use (2 by default)
  54741. */
  54742. maximumScale?: number,
  54743. /**
  54744. * Defines the step to use between two passes (0.5 by default)
  54745. */
  54746. step?: number);
  54747. /**
  54748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54749. * @param scene defines the current scene where to apply this optimization
  54750. * @param optimizer defines the current optimizer
  54751. * @returns true if everything that can be done was applied
  54752. */
  54753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54754. }
  54755. /**
  54756. * Defines an optimization used to remove shadows
  54757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54758. */
  54759. export class ShadowsOptimization extends SceneOptimization {
  54760. /**
  54761. * Gets a string describing the action executed by the current optimization
  54762. * @return description string
  54763. */
  54764. getDescription(): string;
  54765. /**
  54766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54767. * @param scene defines the current scene where to apply this optimization
  54768. * @param optimizer defines the current optimizer
  54769. * @returns true if everything that can be done was applied
  54770. */
  54771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54772. }
  54773. /**
  54774. * Defines an optimization used to turn post-processes off
  54775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54776. */
  54777. export class PostProcessesOptimization extends SceneOptimization {
  54778. /**
  54779. * Gets a string describing the action executed by the current optimization
  54780. * @return description string
  54781. */
  54782. getDescription(): string;
  54783. /**
  54784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54785. * @param scene defines the current scene where to apply this optimization
  54786. * @param optimizer defines the current optimizer
  54787. * @returns true if everything that can be done was applied
  54788. */
  54789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54790. }
  54791. /**
  54792. * Defines an optimization used to turn lens flares off
  54793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54794. */
  54795. export class LensFlaresOptimization extends SceneOptimization {
  54796. /**
  54797. * Gets a string describing the action executed by the current optimization
  54798. * @return description string
  54799. */
  54800. getDescription(): string;
  54801. /**
  54802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54803. * @param scene defines the current scene where to apply this optimization
  54804. * @param optimizer defines the current optimizer
  54805. * @returns true if everything that can be done was applied
  54806. */
  54807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54808. }
  54809. /**
  54810. * Defines an optimization based on user defined callback.
  54811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54812. */
  54813. export class CustomOptimization extends SceneOptimization {
  54814. /**
  54815. * Callback called to apply the custom optimization.
  54816. */
  54817. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54818. /**
  54819. * Callback called to get custom description
  54820. */
  54821. onGetDescription: () => string;
  54822. /**
  54823. * Gets a string describing the action executed by the current optimization
  54824. * @returns description string
  54825. */
  54826. getDescription(): string;
  54827. /**
  54828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54829. * @param scene defines the current scene where to apply this optimization
  54830. * @param optimizer defines the current optimizer
  54831. * @returns true if everything that can be done was applied
  54832. */
  54833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54834. }
  54835. /**
  54836. * Defines an optimization used to turn particles off
  54837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54838. */
  54839. export class ParticlesOptimization extends SceneOptimization {
  54840. /**
  54841. * Gets a string describing the action executed by the current optimization
  54842. * @return description string
  54843. */
  54844. getDescription(): string;
  54845. /**
  54846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54847. * @param scene defines the current scene where to apply this optimization
  54848. * @param optimizer defines the current optimizer
  54849. * @returns true if everything that can be done was applied
  54850. */
  54851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54852. }
  54853. /**
  54854. * Defines an optimization used to turn render targets off
  54855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54856. */
  54857. export class RenderTargetsOptimization extends SceneOptimization {
  54858. /**
  54859. * Gets a string describing the action executed by the current optimization
  54860. * @return description string
  54861. */
  54862. getDescription(): string;
  54863. /**
  54864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54865. * @param scene defines the current scene where to apply this optimization
  54866. * @param optimizer defines the current optimizer
  54867. * @returns true if everything that can be done was applied
  54868. */
  54869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54870. }
  54871. /**
  54872. * Defines an optimization used to merge meshes with compatible materials
  54873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54874. */
  54875. export class MergeMeshesOptimization extends SceneOptimization {
  54876. private static _UpdateSelectionTree;
  54877. /**
  54878. * Gets or sets a boolean which defines if optimization octree has to be updated
  54879. */
  54880. /**
  54881. * Gets or sets a boolean which defines if optimization octree has to be updated
  54882. */
  54883. static UpdateSelectionTree: boolean;
  54884. /**
  54885. * Gets a string describing the action executed by the current optimization
  54886. * @return description string
  54887. */
  54888. getDescription(): string;
  54889. private _canBeMerged;
  54890. /**
  54891. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54892. * @param scene defines the current scene where to apply this optimization
  54893. * @param optimizer defines the current optimizer
  54894. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54895. * @returns true if everything that can be done was applied
  54896. */
  54897. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54898. }
  54899. /**
  54900. * Defines a list of options used by SceneOptimizer
  54901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54902. */
  54903. export class SceneOptimizerOptions {
  54904. /**
  54905. * Defines the target frame rate to reach (60 by default)
  54906. */
  54907. targetFrameRate: number;
  54908. /**
  54909. * Defines the interval between two checkes (2000ms by default)
  54910. */
  54911. trackerDuration: number;
  54912. /**
  54913. * Gets the list of optimizations to apply
  54914. */
  54915. optimizations: SceneOptimization[];
  54916. /**
  54917. * Creates a new list of options used by SceneOptimizer
  54918. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  54919. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  54920. */
  54921. constructor(
  54922. /**
  54923. * Defines the target frame rate to reach (60 by default)
  54924. */
  54925. targetFrameRate?: number,
  54926. /**
  54927. * Defines the interval between two checkes (2000ms by default)
  54928. */
  54929. trackerDuration?: number);
  54930. /**
  54931. * Add a new optimization
  54932. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  54933. * @returns the current SceneOptimizerOptions
  54934. */
  54935. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  54936. /**
  54937. * Add a new custom optimization
  54938. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  54939. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  54940. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54941. * @returns the current SceneOptimizerOptions
  54942. */
  54943. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  54944. /**
  54945. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  54946. * @param targetFrameRate defines the target frame rate (60 by default)
  54947. * @returns a SceneOptimizerOptions object
  54948. */
  54949. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54950. /**
  54951. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  54952. * @param targetFrameRate defines the target frame rate (60 by default)
  54953. * @returns a SceneOptimizerOptions object
  54954. */
  54955. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54956. /**
  54957. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  54958. * @param targetFrameRate defines the target frame rate (60 by default)
  54959. * @returns a SceneOptimizerOptions object
  54960. */
  54961. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54962. }
  54963. /**
  54964. * Class used to run optimizations in order to reach a target frame rate
  54965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54966. */
  54967. export class SceneOptimizer implements IDisposable {
  54968. private _isRunning;
  54969. private _options;
  54970. private _scene;
  54971. private _currentPriorityLevel;
  54972. private _targetFrameRate;
  54973. private _trackerDuration;
  54974. private _currentFrameRate;
  54975. private _sceneDisposeObserver;
  54976. private _improvementMode;
  54977. /**
  54978. * Defines an observable called when the optimizer reaches the target frame rate
  54979. */
  54980. onSuccessObservable: Observable<SceneOptimizer>;
  54981. /**
  54982. * Defines an observable called when the optimizer enables an optimization
  54983. */
  54984. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  54985. /**
  54986. * Defines an observable called when the optimizer is not able to reach the target frame rate
  54987. */
  54988. onFailureObservable: Observable<SceneOptimizer>;
  54989. /**
  54990. * Gets a boolean indicating if the optimizer is in improvement mode
  54991. */
  54992. readonly isInImprovementMode: boolean;
  54993. /**
  54994. * Gets the current priority level (0 at start)
  54995. */
  54996. readonly currentPriorityLevel: number;
  54997. /**
  54998. * Gets the current frame rate checked by the SceneOptimizer
  54999. */
  55000. readonly currentFrameRate: number;
  55001. /**
  55002. * Gets or sets the current target frame rate (60 by default)
  55003. */
  55004. /**
  55005. * Gets or sets the current target frame rate (60 by default)
  55006. */
  55007. targetFrameRate: number;
  55008. /**
  55009. * Gets or sets the current interval between two checks (every 2000ms by default)
  55010. */
  55011. /**
  55012. * Gets or sets the current interval between two checks (every 2000ms by default)
  55013. */
  55014. trackerDuration: number;
  55015. /**
  55016. * Gets the list of active optimizations
  55017. */
  55018. readonly optimizations: SceneOptimization[];
  55019. /**
  55020. * Creates a new SceneOptimizer
  55021. * @param scene defines the scene to work on
  55022. * @param options defines the options to use with the SceneOptimizer
  55023. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55024. * @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)
  55025. */
  55026. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55027. /**
  55028. * Stops the current optimizer
  55029. */
  55030. stop(): void;
  55031. /**
  55032. * Reset the optimizer to initial step (current priority level = 0)
  55033. */
  55034. reset(): void;
  55035. /**
  55036. * Start the optimizer. By default it will try to reach a specific framerate
  55037. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55038. */
  55039. start(): void;
  55040. private _checkCurrentState;
  55041. /**
  55042. * Release all resources
  55043. */
  55044. dispose(): void;
  55045. /**
  55046. * Helper function to create a SceneOptimizer with one single line of code
  55047. * @param scene defines the scene to work on
  55048. * @param options defines the options to use with the SceneOptimizer
  55049. * @param onSuccess defines a callback to call on success
  55050. * @param onFailure defines a callback to call on failure
  55051. * @returns the new SceneOptimizer object
  55052. */
  55053. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55054. }
  55055. }
  55056. declare module BABYLON {
  55057. /**
  55058. * Class used to serialize a scene into a string
  55059. */
  55060. export class SceneSerializer {
  55061. /**
  55062. * Clear cache used by a previous serialization
  55063. */
  55064. static ClearCache(): void;
  55065. /**
  55066. * Serialize a scene into a JSON compatible object
  55067. * @param scene defines the scene to serialize
  55068. * @returns a JSON compatible object
  55069. */
  55070. static Serialize(scene: Scene): any;
  55071. /**
  55072. * Serialize a mesh into a JSON compatible object
  55073. * @param toSerialize defines the mesh to serialize
  55074. * @param withParents defines if parents must be serialized as well
  55075. * @param withChildren defines if children must be serialized as well
  55076. * @returns a JSON compatible object
  55077. */
  55078. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55079. }
  55080. }
  55081. declare module BABYLON {
  55082. /**
  55083. * This represents the different options avilable for the video capture.
  55084. */
  55085. export interface VideoRecorderOptions {
  55086. /** Defines the mime type of the video */
  55087. mimeType: string;
  55088. /** Defines the video the video should be recorded at */
  55089. fps: number;
  55090. /** Defines the chunk size for the recording data */
  55091. recordChunckSize: number;
  55092. /** The audio tracks to attach to the record */
  55093. audioTracks?: MediaStreamTrack[];
  55094. }
  55095. /**
  55096. * This can helps recording videos from BabylonJS.
  55097. * This is based on the available WebRTC functionalities of the browser.
  55098. *
  55099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55100. */
  55101. export class VideoRecorder {
  55102. private static readonly _defaultOptions;
  55103. /**
  55104. * Returns wehther or not the VideoRecorder is available in your browser.
  55105. * @param engine Defines the Babylon Engine to check the support for
  55106. * @returns true if supported otherwise false
  55107. */
  55108. static IsSupported(engine: Engine): boolean;
  55109. private readonly _options;
  55110. private _canvas;
  55111. private _mediaRecorder;
  55112. private _recordedChunks;
  55113. private _fileName;
  55114. private _resolve;
  55115. private _reject;
  55116. /**
  55117. * True wether a recording is already in progress.
  55118. */
  55119. readonly isRecording: boolean;
  55120. /**
  55121. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55122. * a video file.
  55123. * @param engine Defines the BabylonJS Engine you wish to record
  55124. * @param options Defines options that can be used to customized the capture
  55125. */
  55126. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55127. /**
  55128. * Stops the current recording before the default capture timeout passed in the startRecording
  55129. * functions.
  55130. */
  55131. stopRecording(): void;
  55132. /**
  55133. * Starts recording the canvas for a max duration specified in parameters.
  55134. * @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.
  55135. * @param maxDuration Defines the maximum recording time in seconds.
  55136. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55137. * @return a promise callback at the end of the recording with the video data in Blob.
  55138. */
  55139. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55140. /**
  55141. * Releases internal resources used during the recording.
  55142. */
  55143. dispose(): void;
  55144. private _handleDataAvailable;
  55145. private _handleError;
  55146. private _handleStop;
  55147. }
  55148. }
  55149. declare module BABYLON {
  55150. /**
  55151. * Helper class to push actions to a pool of workers.
  55152. */
  55153. export class WorkerPool implements IDisposable {
  55154. private _workerInfos;
  55155. private _pendingActions;
  55156. /**
  55157. * Constructor
  55158. * @param workers Array of workers to use for actions
  55159. */
  55160. constructor(workers: Array<Worker>);
  55161. /**
  55162. * Terminates all workers and clears any pending actions.
  55163. */
  55164. dispose(): void;
  55165. /**
  55166. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55167. * pended until a worker has completed its action.
  55168. * @param action The action to perform. Call onComplete when the action is complete.
  55169. */
  55170. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55171. private _execute;
  55172. }
  55173. }
  55174. declare module BABYLON {
  55175. /**
  55176. * Class containing a set of static utilities functions for screenshots
  55177. */
  55178. export class ScreenshotTools {
  55179. /**
  55180. * Captures a screenshot of the current rendering
  55181. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55182. * @param engine defines the rendering engine
  55183. * @param camera defines the source camera
  55184. * @param size This parameter can be set to a single number or to an object with the
  55185. * following (optional) properties: precision, width, height. If a single number is passed,
  55186. * it will be used for both width and height. If an object is passed, the screenshot size
  55187. * will be derived from the parameters. The precision property is a multiplier allowing
  55188. * rendering at a higher or lower resolution
  55189. * @param successCallback defines the callback receives a single parameter which contains the
  55190. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55191. * src parameter of an <img> to display it
  55192. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55193. * Check your browser for supported MIME types
  55194. */
  55195. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55196. /**
  55197. * Generates an image screenshot from the specified camera.
  55198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55199. * @param engine The engine to use for rendering
  55200. * @param camera The camera to use for rendering
  55201. * @param size This parameter can be set to a single number or to an object with the
  55202. * following (optional) properties: precision, width, height. If a single number is passed,
  55203. * it will be used for both width and height. If an object is passed, the screenshot size
  55204. * will be derived from the parameters. The precision property is a multiplier allowing
  55205. * rendering at a higher or lower resolution
  55206. * @param successCallback The callback receives a single parameter which contains the
  55207. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55208. * src parameter of an <img> to display it
  55209. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55210. * Check your browser for supported MIME types
  55211. * @param samples Texture samples (default: 1)
  55212. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55213. * @param fileName A name for for the downloaded file.
  55214. */
  55215. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * A cursor which tracks a point on a path
  55221. */
  55222. export class PathCursor {
  55223. private path;
  55224. /**
  55225. * Stores path cursor callbacks for when an onchange event is triggered
  55226. */
  55227. private _onchange;
  55228. /**
  55229. * The value of the path cursor
  55230. */
  55231. value: number;
  55232. /**
  55233. * The animation array of the path cursor
  55234. */
  55235. animations: Animation[];
  55236. /**
  55237. * Initializes the path cursor
  55238. * @param path The path to track
  55239. */
  55240. constructor(path: Path2);
  55241. /**
  55242. * Gets the cursor point on the path
  55243. * @returns A point on the path cursor at the cursor location
  55244. */
  55245. getPoint(): Vector3;
  55246. /**
  55247. * Moves the cursor ahead by the step amount
  55248. * @param step The amount to move the cursor forward
  55249. * @returns This path cursor
  55250. */
  55251. moveAhead(step?: number): PathCursor;
  55252. /**
  55253. * Moves the cursor behind by the step amount
  55254. * @param step The amount to move the cursor back
  55255. * @returns This path cursor
  55256. */
  55257. moveBack(step?: number): PathCursor;
  55258. /**
  55259. * Moves the cursor by the step amount
  55260. * If the step amount is greater than one, an exception is thrown
  55261. * @param step The amount to move the cursor
  55262. * @returns This path cursor
  55263. */
  55264. move(step: number): PathCursor;
  55265. /**
  55266. * Ensures that the value is limited between zero and one
  55267. * @returns This path cursor
  55268. */
  55269. private ensureLimits;
  55270. /**
  55271. * Runs onchange callbacks on change (used by the animation engine)
  55272. * @returns This path cursor
  55273. */
  55274. private raiseOnChange;
  55275. /**
  55276. * Executes a function on change
  55277. * @param f A path cursor onchange callback
  55278. * @returns This path cursor
  55279. */
  55280. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55281. }
  55282. }
  55283. declare module BABYLON {
  55284. /** @hidden */
  55285. export var blurPixelShader: {
  55286. name: string;
  55287. shader: string;
  55288. };
  55289. }
  55290. declare module BABYLON {
  55291. /** @hidden */
  55292. export var bones300Declaration: {
  55293. name: string;
  55294. shader: string;
  55295. };
  55296. }
  55297. declare module BABYLON {
  55298. /** @hidden */
  55299. export var instances300Declaration: {
  55300. name: string;
  55301. shader: string;
  55302. };
  55303. }
  55304. declare module BABYLON {
  55305. /** @hidden */
  55306. export var pointCloudVertexDeclaration: {
  55307. name: string;
  55308. shader: string;
  55309. };
  55310. }
  55311. // Mixins
  55312. interface Window {
  55313. mozIndexedDB: IDBFactory;
  55314. webkitIndexedDB: IDBFactory;
  55315. msIndexedDB: IDBFactory;
  55316. webkitURL: typeof URL;
  55317. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55318. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55319. WebGLRenderingContext: WebGLRenderingContext;
  55320. MSGesture: MSGesture;
  55321. CANNON: any;
  55322. AudioContext: AudioContext;
  55323. webkitAudioContext: AudioContext;
  55324. PointerEvent: any;
  55325. Math: Math;
  55326. Uint8Array: Uint8ArrayConstructor;
  55327. Float32Array: Float32ArrayConstructor;
  55328. mozURL: typeof URL;
  55329. msURL: typeof URL;
  55330. VRFrameData: any; // WebVR, from specs 1.1
  55331. DracoDecoderModule: any;
  55332. setImmediate(handler: (...args: any[]) => void): number;
  55333. }
  55334. interface HTMLCanvasElement {
  55335. requestPointerLock(): void;
  55336. msRequestPointerLock?(): void;
  55337. mozRequestPointerLock?(): void;
  55338. webkitRequestPointerLock?(): void;
  55339. /** Track wether a record is in progress */
  55340. isRecording: boolean;
  55341. /** Capture Stream method defined by some browsers */
  55342. captureStream(fps?: number): MediaStream;
  55343. }
  55344. interface CanvasRenderingContext2D {
  55345. msImageSmoothingEnabled: boolean;
  55346. }
  55347. interface MouseEvent {
  55348. mozMovementX: number;
  55349. mozMovementY: number;
  55350. webkitMovementX: number;
  55351. webkitMovementY: number;
  55352. msMovementX: number;
  55353. msMovementY: number;
  55354. }
  55355. interface Navigator {
  55356. mozGetVRDevices: (any: any) => any;
  55357. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55358. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55359. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55360. webkitGetGamepads(): Gamepad[];
  55361. msGetGamepads(): Gamepad[];
  55362. webkitGamepads(): Gamepad[];
  55363. }
  55364. interface HTMLVideoElement {
  55365. mozSrcObject: any;
  55366. }
  55367. interface Math {
  55368. fround(x: number): number;
  55369. imul(a: number, b: number): number;
  55370. }
  55371. interface WebGLProgram {
  55372. context?: WebGLRenderingContext;
  55373. vertexShader?: WebGLShader;
  55374. fragmentShader?: WebGLShader;
  55375. isParallelCompiled: boolean;
  55376. onCompiled?: () => void;
  55377. }
  55378. interface WebGLRenderingContext {
  55379. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55380. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55381. vertexAttribDivisor(index: number, divisor: number): void;
  55382. createVertexArray(): any;
  55383. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55384. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55385. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55386. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55387. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55388. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55389. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55390. // Queries
  55391. createQuery(): WebGLQuery;
  55392. deleteQuery(query: WebGLQuery): void;
  55393. beginQuery(target: number, query: WebGLQuery): void;
  55394. endQuery(target: number): void;
  55395. getQueryParameter(query: WebGLQuery, pname: number): any;
  55396. getQuery(target: number, pname: number): any;
  55397. MAX_SAMPLES: number;
  55398. RGBA8: number;
  55399. READ_FRAMEBUFFER: number;
  55400. DRAW_FRAMEBUFFER: number;
  55401. UNIFORM_BUFFER: number;
  55402. HALF_FLOAT_OES: number;
  55403. RGBA16F: number;
  55404. RGBA32F: number;
  55405. R32F: number;
  55406. RG32F: number;
  55407. RGB32F: number;
  55408. R16F: number;
  55409. RG16F: number;
  55410. RGB16F: number;
  55411. RED: number;
  55412. RG: number;
  55413. R8: number;
  55414. RG8: number;
  55415. UNSIGNED_INT_24_8: number;
  55416. DEPTH24_STENCIL8: number;
  55417. /* Multiple Render Targets */
  55418. drawBuffers(buffers: number[]): void;
  55419. readBuffer(src: number): void;
  55420. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55421. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55422. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55423. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55424. // Occlusion Query
  55425. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55426. ANY_SAMPLES_PASSED: number;
  55427. QUERY_RESULT_AVAILABLE: number;
  55428. QUERY_RESULT: number;
  55429. }
  55430. interface WebGLBuffer {
  55431. references: number;
  55432. capacity: number;
  55433. is32Bits: boolean;
  55434. }
  55435. interface WebGLProgram {
  55436. transformFeedback?: WebGLTransformFeedback | null;
  55437. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55438. }
  55439. interface EXT_disjoint_timer_query {
  55440. QUERY_COUNTER_BITS_EXT: number;
  55441. TIME_ELAPSED_EXT: number;
  55442. TIMESTAMP_EXT: number;
  55443. GPU_DISJOINT_EXT: number;
  55444. QUERY_RESULT_EXT: number;
  55445. QUERY_RESULT_AVAILABLE_EXT: number;
  55446. queryCounterEXT(query: WebGLQuery, target: number): void;
  55447. createQueryEXT(): WebGLQuery;
  55448. beginQueryEXT(target: number, query: WebGLQuery): void;
  55449. endQueryEXT(target: number): void;
  55450. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55451. deleteQueryEXT(query: WebGLQuery): void;
  55452. }
  55453. interface WebGLUniformLocation {
  55454. _currentState: any;
  55455. }
  55456. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55457. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55458. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55459. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55460. interface WebGLRenderingContext {
  55461. readonly RASTERIZER_DISCARD: number;
  55462. readonly DEPTH_COMPONENT24: number;
  55463. readonly TEXTURE_3D: number;
  55464. readonly TEXTURE_2D_ARRAY: number;
  55465. readonly TEXTURE_COMPARE_FUNC: number;
  55466. readonly TEXTURE_COMPARE_MODE: number;
  55467. readonly COMPARE_REF_TO_TEXTURE: number;
  55468. readonly TEXTURE_WRAP_R: number;
  55469. readonly HALF_FLOAT: number;
  55470. readonly RGB8: number;
  55471. readonly RED_INTEGER: number;
  55472. readonly RG_INTEGER: number;
  55473. readonly RGB_INTEGER: number;
  55474. readonly RGBA_INTEGER: number;
  55475. readonly R8_SNORM: number;
  55476. readonly RG8_SNORM: number;
  55477. readonly RGB8_SNORM: number;
  55478. readonly RGBA8_SNORM: number;
  55479. readonly R8I: number;
  55480. readonly RG8I: number;
  55481. readonly RGB8I: number;
  55482. readonly RGBA8I: number;
  55483. readonly R8UI: number;
  55484. readonly RG8UI: number;
  55485. readonly RGB8UI: number;
  55486. readonly RGBA8UI: number;
  55487. readonly R16I: number;
  55488. readonly RG16I: number;
  55489. readonly RGB16I: number;
  55490. readonly RGBA16I: number;
  55491. readonly R16UI: number;
  55492. readonly RG16UI: number;
  55493. readonly RGB16UI: number;
  55494. readonly RGBA16UI: number;
  55495. readonly R32I: number;
  55496. readonly RG32I: number;
  55497. readonly RGB32I: number;
  55498. readonly RGBA32I: number;
  55499. readonly R32UI: number;
  55500. readonly RG32UI: number;
  55501. readonly RGB32UI: number;
  55502. readonly RGBA32UI: number;
  55503. readonly RGB10_A2UI: number;
  55504. readonly R11F_G11F_B10F: number;
  55505. readonly RGB9_E5: number;
  55506. readonly RGB10_A2: number;
  55507. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55508. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55509. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55510. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55511. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55512. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55513. 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;
  55514. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55515. readonly TRANSFORM_FEEDBACK: number;
  55516. readonly INTERLEAVED_ATTRIBS: number;
  55517. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55518. createTransformFeedback(): WebGLTransformFeedback;
  55519. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55520. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55521. beginTransformFeedback(primitiveMode: number): void;
  55522. endTransformFeedback(): void;
  55523. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55524. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55525. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55526. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55527. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55528. }
  55529. interface ImageBitmap {
  55530. readonly width: number;
  55531. readonly height: number;
  55532. close(): void;
  55533. }
  55534. interface WebGLQuery extends WebGLObject {
  55535. }
  55536. declare var WebGLQuery: {
  55537. prototype: WebGLQuery;
  55538. new(): WebGLQuery;
  55539. };
  55540. interface WebGLSampler extends WebGLObject {
  55541. }
  55542. declare var WebGLSampler: {
  55543. prototype: WebGLSampler;
  55544. new(): WebGLSampler;
  55545. };
  55546. interface WebGLSync extends WebGLObject {
  55547. }
  55548. declare var WebGLSync: {
  55549. prototype: WebGLSync;
  55550. new(): WebGLSync;
  55551. };
  55552. interface WebGLTransformFeedback extends WebGLObject {
  55553. }
  55554. declare var WebGLTransformFeedback: {
  55555. prototype: WebGLTransformFeedback;
  55556. new(): WebGLTransformFeedback;
  55557. };
  55558. interface WebGLVertexArrayObject extends WebGLObject {
  55559. }
  55560. declare var WebGLVertexArrayObject: {
  55561. prototype: WebGLVertexArrayObject;
  55562. new(): WebGLVertexArrayObject;
  55563. };
  55564. // Type definitions for WebVR API
  55565. // Project: https://w3c.github.io/webvr/
  55566. // Definitions by: six a <https://github.com/lostfictions>
  55567. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55568. interface VRDisplay extends EventTarget {
  55569. /**
  55570. * Dictionary of capabilities describing the VRDisplay.
  55571. */
  55572. readonly capabilities: VRDisplayCapabilities;
  55573. /**
  55574. * z-depth defining the far plane of the eye view frustum
  55575. * enables mapping of values in the render target depth
  55576. * attachment to scene coordinates. Initially set to 10000.0.
  55577. */
  55578. depthFar: number;
  55579. /**
  55580. * z-depth defining the near plane of the eye view frustum
  55581. * enables mapping of values in the render target depth
  55582. * attachment to scene coordinates. Initially set to 0.01.
  55583. */
  55584. depthNear: number;
  55585. /**
  55586. * An identifier for this distinct VRDisplay. Used as an
  55587. * association point in the Gamepad API.
  55588. */
  55589. readonly displayId: number;
  55590. /**
  55591. * A display name, a user-readable name identifying it.
  55592. */
  55593. readonly displayName: string;
  55594. readonly isConnected: boolean;
  55595. readonly isPresenting: boolean;
  55596. /**
  55597. * If this VRDisplay supports room-scale experiences, the optional
  55598. * stage attribute contains details on the room-scale parameters.
  55599. */
  55600. readonly stageParameters: VRStageParameters | null;
  55601. /**
  55602. * Passing the value returned by `requestAnimationFrame` to
  55603. * `cancelAnimationFrame` will unregister the callback.
  55604. * @param handle Define the hanle of the request to cancel
  55605. */
  55606. cancelAnimationFrame(handle: number): void;
  55607. /**
  55608. * Stops presenting to the VRDisplay.
  55609. * @returns a promise to know when it stopped
  55610. */
  55611. exitPresent(): Promise<void>;
  55612. /**
  55613. * Return the current VREyeParameters for the given eye.
  55614. * @param whichEye Define the eye we want the parameter for
  55615. * @returns the eye parameters
  55616. */
  55617. getEyeParameters(whichEye: string): VREyeParameters;
  55618. /**
  55619. * Populates the passed VRFrameData with the information required to render
  55620. * the current frame.
  55621. * @param frameData Define the data structure to populate
  55622. * @returns true if ok otherwise false
  55623. */
  55624. getFrameData(frameData: VRFrameData): boolean;
  55625. /**
  55626. * Get the layers currently being presented.
  55627. * @returns the list of VR layers
  55628. */
  55629. getLayers(): VRLayer[];
  55630. /**
  55631. * Return a VRPose containing the future predicted pose of the VRDisplay
  55632. * when the current frame will be presented. The value returned will not
  55633. * change until JavaScript has returned control to the browser.
  55634. *
  55635. * The VRPose will contain the position, orientation, velocity,
  55636. * and acceleration of each of these properties.
  55637. * @returns the pose object
  55638. */
  55639. getPose(): VRPose;
  55640. /**
  55641. * Return the current instantaneous pose of the VRDisplay, with no
  55642. * prediction applied.
  55643. * @returns the current instantaneous pose
  55644. */
  55645. getImmediatePose(): VRPose;
  55646. /**
  55647. * The callback passed to `requestAnimationFrame` will be called
  55648. * any time a new frame should be rendered. When the VRDisplay is
  55649. * presenting the callback will be called at the native refresh
  55650. * rate of the HMD. When not presenting this function acts
  55651. * identically to how window.requestAnimationFrame acts. Content should
  55652. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55653. * asynchronously from other displays and at differing refresh rates.
  55654. * @param callback Define the eaction to run next frame
  55655. * @returns the request handle it
  55656. */
  55657. requestAnimationFrame(callback: FrameRequestCallback): number;
  55658. /**
  55659. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55660. * Repeat calls while already presenting will update the VRLayers being displayed.
  55661. * @param layers Define the list of layer to present
  55662. * @returns a promise to know when the request has been fulfilled
  55663. */
  55664. requestPresent(layers: VRLayer[]): Promise<void>;
  55665. /**
  55666. * Reset the pose for this display, treating its current position and
  55667. * orientation as the "origin/zero" values. VRPose.position,
  55668. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55669. * updated when calling resetPose(). This should be called in only
  55670. * sitting-space experiences.
  55671. */
  55672. resetPose(): void;
  55673. /**
  55674. * The VRLayer provided to the VRDisplay will be captured and presented
  55675. * in the HMD. Calling this function has the same effect on the source
  55676. * canvas as any other operation that uses its source image, and canvases
  55677. * created without preserveDrawingBuffer set to true will be cleared.
  55678. * @param pose Define the pose to submit
  55679. */
  55680. submitFrame(pose?: VRPose): void;
  55681. }
  55682. declare var VRDisplay: {
  55683. prototype: VRDisplay;
  55684. new(): VRDisplay;
  55685. };
  55686. interface VRLayer {
  55687. leftBounds?: number[] | Float32Array | null;
  55688. rightBounds?: number[] | Float32Array | null;
  55689. source?: HTMLCanvasElement | null;
  55690. }
  55691. interface VRDisplayCapabilities {
  55692. readonly canPresent: boolean;
  55693. readonly hasExternalDisplay: boolean;
  55694. readonly hasOrientation: boolean;
  55695. readonly hasPosition: boolean;
  55696. readonly maxLayers: number;
  55697. }
  55698. interface VREyeParameters {
  55699. /** @deprecated */
  55700. readonly fieldOfView: VRFieldOfView;
  55701. readonly offset: Float32Array;
  55702. readonly renderHeight: number;
  55703. readonly renderWidth: number;
  55704. }
  55705. interface VRFieldOfView {
  55706. readonly downDegrees: number;
  55707. readonly leftDegrees: number;
  55708. readonly rightDegrees: number;
  55709. readonly upDegrees: number;
  55710. }
  55711. interface VRFrameData {
  55712. readonly leftProjectionMatrix: Float32Array;
  55713. readonly leftViewMatrix: Float32Array;
  55714. readonly pose: VRPose;
  55715. readonly rightProjectionMatrix: Float32Array;
  55716. readonly rightViewMatrix: Float32Array;
  55717. readonly timestamp: number;
  55718. }
  55719. interface VRPose {
  55720. readonly angularAcceleration: Float32Array | null;
  55721. readonly angularVelocity: Float32Array | null;
  55722. readonly linearAcceleration: Float32Array | null;
  55723. readonly linearVelocity: Float32Array | null;
  55724. readonly orientation: Float32Array | null;
  55725. readonly position: Float32Array | null;
  55726. readonly timestamp: number;
  55727. }
  55728. interface VRStageParameters {
  55729. sittingToStandingTransform?: Float32Array;
  55730. sizeX?: number;
  55731. sizeY?: number;
  55732. }
  55733. interface Navigator {
  55734. getVRDisplays(): Promise<VRDisplay[]>;
  55735. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55736. }
  55737. interface Window {
  55738. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55739. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55740. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55741. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55742. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55743. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55744. }
  55745. interface Gamepad {
  55746. readonly displayId: number;
  55747. }
  55748. interface XRDevice {
  55749. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55750. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55751. }
  55752. interface XRSession {
  55753. getInputSources(): Array<any>;
  55754. baseLayer: XRWebGLLayer;
  55755. requestFrameOfReference(type: string): Promise<void>;
  55756. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55757. end(): Promise<void>;
  55758. requestAnimationFrame: Function;
  55759. addEventListener: Function;
  55760. }
  55761. interface XRSessionCreationOptions {
  55762. outputContext?: WebGLRenderingContext | null;
  55763. immersive?: boolean;
  55764. environmentIntegration?: boolean;
  55765. }
  55766. interface XRLayer {
  55767. getViewport: Function;
  55768. framebufferWidth: number;
  55769. framebufferHeight: number;
  55770. }
  55771. interface XRView {
  55772. projectionMatrix: Float32Array;
  55773. }
  55774. interface XRFrame {
  55775. getDevicePose: Function;
  55776. getInputPose: Function;
  55777. views: Array<XRView>;
  55778. baseLayer: XRLayer;
  55779. }
  55780. interface XRFrameOfReference {
  55781. }
  55782. interface XRWebGLLayer extends XRLayer {
  55783. framebuffer: WebGLFramebuffer;
  55784. }
  55785. declare var XRWebGLLayer: {
  55786. prototype: XRWebGLLayer;
  55787. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55788. };